diff --git a/.github/dependabot.yml b/.github/dependabot.yml index ddafb34..473f3fb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,6 +5,8 @@ updates: - package-ecosystem: composer directory: "/" target-branch: develop + labels: + - "area: dependencies" schedule: interval: weekly groups: @@ -14,6 +16,8 @@ updates: - package-ecosystem: github-actions directory: "/" target-branch: develop + labels: + - "area: dependencies" schedule: interval: weekly groups: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 588fc83..ab40615 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,56 +1,203 @@ name: Build - -on: +'on': push: branches: - - develop - - "8.*.x" + - develop + - 8.*.x pull_request: branches: - - develop - - "8.*.x" - workflow_dispatch: - + - develop + - 8.*.x + workflow_dispatch: null concurrency: - group: "build-${{ github.workflow }}-${{ github.ref }}" + group: build-${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true - permissions: contents: read - jobs: + matrix: + runs-on: ubuntu-latest + outputs: + php: ${{ steps.php.outputs.versions }} + lowest: ${{ steps.php.outputs.lowest }} + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Read supported PHP minors + id: php + shell: bash + run: | + constraint="$(jq -r '.require.php' composer.json)" + if [[ ! "$constraint" =~ ^\>=8\.([0-9]+)\ \<8\.([0-9]+)$ ]] || (( BASH_REMATCH[2] != BASH_REMATCH[1] + 1 )); then + echo "require.php must declare exactly one PHP minor as >=8.N <8.N+1, got: $constraint" >&2 + exit 1 + fi + version="8.${BASH_REMATCH[1]}" + echo "versions=$(jq -cn --arg php "$version" '[$php]')" >> "$GITHUB_OUTPUT" + echo "lowest=$version" >> "$GITHUB_OUTPUT" + validate: + needs: + - matrix + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: fileinfo, pdo_sqlite, sqlite3 + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Validate + run: composer validate --strict + style: + needs: + - matrix + - validate + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: fileinfo, pdo_sqlite, sqlite3 + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Style + run: composer format:check + analyse: + needs: + - matrix + - style + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: fileinfo, pdo_sqlite, sqlite3 + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Analyse + run: composer analyse + tests: + name: Tests - PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependencies }} + needs: + - matrix + - analyse + strategy: + fail-fast: true + matrix: + php: ${{ fromJSON(needs.matrix.outputs.php) }} + dependencies: + - lowest + - highest + os: + - ubuntu-latest + - windows-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ matrix.php }} + extensions: fileinfo, pdo_sqlite, sqlite3 + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: ${{ matrix.dependencies }} + - name: Run tests + run: composer test + security: + needs: + - matrix + - tests + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: fileinfo, pdo_sqlite, sqlite3 + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Security audit + run: composer security + archive: + needs: + - matrix + - security + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v7 + - name: Setup PHP + uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 + with: + php-version: ${{ needs.matrix.outputs.lowest }} + extensions: fileinfo, pdo_sqlite, sqlite3 + coverage: none + tools: composer:v2 + - name: Install dependencies + uses: ramsey/composer-install@65e4f84970763564f46a70b8a54b90d033b3bdda # 4.0.0 + with: + dependency-versions: highest + - name: Verify Composer archive + shell: bash + run: | + mkdir -p /tmp/pharaonic-ci-archive + composer archive --format=zip --dir=/tmp/pharaonic-ci-archive --file=package + unzip -t /tmp/pharaonic-ci-archive/package.zip quality: + name: Quality gate + if: ${{ always() }} + needs: + - matrix + - validate + - style + - analyse + - tests + - security + - archive runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v7 - - # Every branch declares exactly one PHP minor (">=8.N <8.N+1"), so the - # version comes from composer.json. This works on develop and feature - # branches as well as on the 8.N.x lines. - - name: Detect target PHP version - id: php - shell: bash - run: | - constraint="$(jq -r '.require.php' composer.json)" - - if [[ ! "$constraint" =~ ^\>=(8\.[0-9]+) ]]; then - echo "Cannot read the target PHP minor from require.php: $constraint" >&2 - exit 1 - fi - - echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT" - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: "${{ steps.php.outputs.version }}" - coverage: none - tools: composer:v2 - - - name: Install dependencies - run: composer update --prefer-dist --no-interaction --no-progress - - - name: Check - run: composer check + steps: + - name: Require every stage to succeed + env: + NEEDS_JSON: ${{ toJSON(needs) }} + run: | + python3 - <<'PY_CHECK' + import json, os, sys + results = json.loads(os.environ['NEEDS_JSON']) + failed = {name: job['result'] for name, job in results.items() if job['result'] != 'success'} + if failed: + print('Required stages did not succeed:', failed) + sys.exit(1) + print('Every required stage succeeded.') + PY_CHECK diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 137d163..d96990d 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -22,7 +22,7 @@ jobs: # Creates and updates the labels in .github/labels.yml. Labels that are # not listed are left alone. - name: Sync labels - uses: crazy-max/ghaction-github-labeler@v6 + uses: crazy-max/ghaction-github-labeler@548a7c3603594ec17c819e1239f281a3b801ab4d # v6.0.0 with: yaml-file: .github/labels.yml skip-delete: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b81a51..781fc0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,17 @@ All notable changes to this project are documented here. +## 8.4.1 - Unreleased + +### Fixed + +- Hunk grouping is written so PHPStan 2.3.7 analyses it without errors; hunks are unchanged. + +### Changed + +- Internal classes moved out of `Support\` into `Engine\` and `Paths\`, and the unused `Support\Missing` was removed. All of them are `@internal`, so the public API is unchanged. +- The build runs staged checks (validate, style, analysis, tests on lowest and highest dependencies on Ubuntu and Windows, security, archive) behind one Quality gate, and requires PHPUnit 12.5.8 or later for development. + ## 8.4.0 - 2026-10-16 The `8.4.x` line targets PHP 8.4. Its public API and its output are identical to `8.3.0`. diff --git a/MAINTAINING.md b/MAINTAINING.md index b92e200..88ec51b 100644 --- a/MAINTAINING.md +++ b/MAINTAINING.md @@ -24,6 +24,8 @@ One branch per PHP minor, each requiring exactly that minor (`"php": ">=8.0 <8.1 - Options are immutable. Redaction happens before a value is stored in a result, including inside aggregate and subtree values. - Text diffs keep the low-level `added`/`removed`/`unchanged` lines; modified-line pairing is a layer on top. Unified output must apply with `git apply` and `patch`. - Every exception implements `Exceptions\DiffException`. Everything marked `@internal` may change in any release. +- The public classes stay directly under `Pharaonic\Diff` and the catch-all `DiffException` interface stays in `Exceptions\`. Both are deliberate: they are published on every line, and moving them to `ValueObjects\` or `Contracts\` would only add aliases. +- Internal code lives with its responsibility: `Engine\` (structured and text diffing and their value handling), `Paths\` (dot notation and path patterns), `Text\`, `Algorithm\` and `Renderer\`. ## Package-specific constraints diff --git a/README.md b/README.md index a29eda5..187ccd2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

PHP Version : 8.4 License - Tests + Build
Source Packagist Version @@ -11,7 +11,6 @@

Know exactly what changed in PHP data and text.

-
Added, removed, modified and moved values at their exact paths, records matched by ID, redacted secrets, and GitHub-style line diffs.

## Installation diff --git a/composer.json b/composer.json index 55f96fb..ee760ca 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,12 @@ "description": "Semantic structured diffs and GitHub-style text diffs for PHP: added, removed, modified and moved values with paths, identity-aware lists, redaction, hunks, unified patches and HTML.", "type": "library", "license": "MIT", + "authors": [ + { + "name": "Moamen Eltouny (Raggi)", + "email": "raggigroup@gmail.com" + } + ], "keywords": [ "php", "diff", @@ -15,12 +21,6 @@ "change detection", "pharaonic" ], - "authors": [ - { - "name": "Moamen Eltouny (Raggi)", - "email": "raggigroup@gmail.com" - } - ], "homepage": "https://github.com/Pharaonic/php-diff", "support": { "docs": "https://pharaonic.dev/packages/php/diff", @@ -34,7 +34,8 @@ "require-dev": { "laravel/pint": "^1.20", "pestphp/pest": "^4.0", - "phpstan/phpstan": "^2.1" + "phpstan/phpstan": "^2.1", + "phpunit/phpunit": "^12.5.8" }, "autoload": { "psr-4": { diff --git a/docs/sections/17-upgrade-guide.md b/docs/sections/17-upgrade-guide.md new file mode 100644 index 0000000..6555cac --- /dev/null +++ b/docs/sections/17-upgrade-guide.md @@ -0,0 +1,23 @@ +## Upgrade Guide + +Diff has one release line per PHP version, and every line has the same classes, methods and output. This page covers the `8.4.x` line, for PHP 8.4. + +### Patch Releases + +Patch releases such as `8.4.0` to `8.4.1` never break your code. Update with: + +```bash no-line-numbers +composer update pharaonic/php-diff +``` + +Output changes only to fix a bug, and every such change is listed in the changelog. Classes marked `@internal` (the engines, renderers and text helpers) are not part of the public API and may move or change in any release; don't use them directly. + +### Moving To Another PHP Version + +No code changes are needed. Composer picks the line that matches your PHP version, so after upgrading PHP run `composer update pharaonic/php-diff`. + +The constraint that `composer require` writes (for example `^8.4`) already allows the newer lines. If you pinned a line with a tilde constraint such as `~8.4.0`, widen it first, or Composer stays on `8.4.x` and cannot install on the new PHP version. + +### Changelog + +Every release is listed in the [changelog](https://github.com/Pharaonic/php-diff/blob/8.4.x/CHANGELOG.md) and on the [GitHub releases](https://github.com/Pharaonic/php-diff/releases) page. diff --git a/docs/sidebar.md b/docs/sidebar.md index 37f590e..aec48ca 100644 --- a/docs/sidebar.md +++ b/docs/sidebar.md @@ -20,3 +20,5 @@ - [Troubleshooting](#troubleshooting) - Community - [Contributors](#contributors) +- Upgrades + - [Upgrade Guide](#upgrade-guide) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index da944d8..59102b5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,11 +1,8 @@ - - tests/Unit - - - tests/Feature + + tests diff --git a/src/DiffOptions.php b/src/DiffOptions.php index c0ca796..c532090 100644 --- a/src/DiffOptions.php +++ b/src/DiffOptions.php @@ -6,8 +6,8 @@ use Closure; use InvalidArgumentException; -use Pharaonic\Diff\Support\Arrays; -use Pharaonic\Diff\Support\DotNotation; +use Pharaonic\Diff\Engine\Arrays; +use Pharaonic\Diff\Paths\DotNotation; /** * Immutable options for Diff::between() diff --git a/src/Support/Arrays.php b/src/Engine/Arrays.php similarity index 93% rename from src/Support/Arrays.php rename to src/Engine/Arrays.php index f48e01b..8e2e16f 100644 --- a/src/Support/Arrays.php +++ b/src/Engine/Arrays.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Engine; /** * @internal diff --git a/src/Support/Canonical.php b/src/Engine/Canonical.php similarity index 98% rename from src/Support/Canonical.php rename to src/Engine/Canonical.php index 72ccd06..722929d 100644 --- a/src/Support/Canonical.php +++ b/src/Engine/Canonical.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Engine; use Closure; use DateTimeInterface; @@ -11,6 +11,8 @@ use Pharaonic\Diff\ListStrategy; use Pharaonic\Diff\Exceptions\UnsupportedValueException; use Pharaonic\Diff\Path; +use Pharaonic\Diff\Paths\PathFilter; +use Pharaonic\Diff\Paths\Pattern; /** * Encodes a value as a string that two values share exactly when no change would be reported diff --git a/src/Support/Objects.php b/src/Engine/Objects.php similarity index 99% rename from src/Support/Objects.php rename to src/Engine/Objects.php index c3c0e48..97c7f72 100644 --- a/src/Support/Objects.php +++ b/src/Engine/Objects.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Engine; use Closure; use DateTimeInterface; diff --git a/src/Support/Snapshot.php b/src/Engine/Snapshot.php similarity index 97% rename from src/Support/Snapshot.php rename to src/Engine/Snapshot.php index a25e137..fcb1660 100644 --- a/src/Support/Snapshot.php +++ b/src/Engine/Snapshot.php @@ -2,13 +2,15 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Engine; use Pharaonic\Diff\Change; use Pharaonic\Diff\DiffOptions; use Pharaonic\Diff\Exceptions\MaximumDepthExceededException; use Pharaonic\Diff\Exceptions\UnsupportedValueException; use Pharaonic\Diff\Path; +use Pharaonic\Diff\Paths\PathFilter; +use Pharaonic\Diff\Paths\Pattern; /** * Prepares a value before a change stores it: values at redacted paths are replaced with diff --git a/src/Engine/StructuredDiffer.php b/src/Engine/StructuredDiffer.php index c1f775a..2574cf4 100644 --- a/src/Engine/StructuredDiffer.php +++ b/src/Engine/StructuredDiffer.php @@ -13,12 +13,7 @@ use Pharaonic\Diff\Exceptions\UnsupportedValueException; use Pharaonic\Diff\ListStrategy; use Pharaonic\Diff\Path; -use Pharaonic\Diff\Support\Arrays; -use Pharaonic\Diff\Support\Canonical; -use Pharaonic\Diff\Support\Objects; -use Pharaonic\Diff\Support\PathFilter; -use Pharaonic\Diff\Support\Snapshot; -use Pharaonic\Diff\Support\Values; +use Pharaonic\Diff\Paths\PathFilter; /** * Compares two structured values and collects their changes in traversal order diff --git a/src/Support/Values.php b/src/Engine/Values.php similarity index 95% rename from src/Support/Values.php rename to src/Engine/Values.php index 91b5682..1e2f798 100644 --- a/src/Support/Values.php +++ b/src/Engine/Values.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Engine; use Closure; use Generator; diff --git a/src/Path.php b/src/Path.php index 712d36d..60490ad 100644 --- a/src/Path.php +++ b/src/Path.php @@ -5,7 +5,7 @@ namespace Pharaonic\Diff; use InvalidArgumentException; -use Pharaonic\Diff\Support\DotNotation; +use Pharaonic\Diff\Paths\DotNotation; /** * The location of a value inside the compared data, as a list of keys and list indexes diff --git a/src/Support/DotNotation.php b/src/Paths/DotNotation.php similarity index 98% rename from src/Support/DotNotation.php rename to src/Paths/DotNotation.php index 9aa92f6..d439c56 100644 --- a/src/Support/DotNotation.php +++ b/src/Paths/DotNotation.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Paths; use InvalidArgumentException; diff --git a/src/Support/PathFilter.php b/src/Paths/PathFilter.php similarity index 98% rename from src/Support/PathFilter.php rename to src/Paths/PathFilter.php index cf4bd0b..65c5e30 100644 --- a/src/Support/PathFilter.php +++ b/src/Paths/PathFilter.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Paths; use Pharaonic\Diff\DiffOptions; diff --git a/src/Support/Pattern.php b/src/Paths/Pattern.php similarity index 97% rename from src/Support/Pattern.php rename to src/Paths/Pattern.php index c06c66a..d419f4b 100644 --- a/src/Support/Pattern.php +++ b/src/Paths/Pattern.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Pharaonic\Diff\Support; +namespace Pharaonic\Diff\Paths; /** * Matching of parsed dot-notation patterns, where null stands for the "*" wildcard diff --git a/src/Support/Missing.php b/src/Support/Missing.php deleted file mode 100644 index ca4f54c..0000000 --- a/src/Support/Missing.php +++ /dev/null @@ -1,27 +0,0 @@ - $line) { if ($line->type() === ChangeType::UNCHANGED) { continue; } - $last = count($ranges) - 1; + if ($first !== null && $index - $last - 1 <= 2 * $context) { + $last = $index; - if ($last >= 0 && $index - $ranges[$last][1] - 1 <= 2 * $context) { - $ranges[$last][1] = $index; - } else { - $ranges[] = [$index, $index]; + continue; } - } - $hunks = []; - $count = count($lines); + if ($first !== null) { + $hunks[] = self::around($lines, $first, $last, $context); + } + + $first = $index; + $last = $index; + } - foreach ($ranges as [$first, $last]) { - $start = max(0, $first - $context); - $end = min($count - 1, $last + $context); - $hunks[] = self::hunk($lines, $start, $end); + if ($first !== null) { + $hunks[] = self::around($lines, $first, $last, $context); } return $hunks; } + /** + * The hunk for the changed lines $first to $last with their context + * + * @param list $lines + */ + private static function around(array $lines, int $first, int $last, int $context): Hunk + { + return self::hunk($lines, max(0, $first - $context), min(count($lines) - 1, $last + $context)); + } + /** * @param list $lines */ diff --git a/tests/Feature/ObjectsTest.php b/tests/Feature/ObjectsTest.php index 7ecadf6..f615c7b 100644 --- a/tests/Feature/ObjectsTest.php +++ b/tests/Feature/ObjectsTest.php @@ -107,9 +107,10 @@ it('treats dates at the same instant as equal whatever their time zone', function () { $utc = new DateTimeImmutable('2026-10-15 12:00:00.000000', new DateTimeZone('UTC')); - $cairo = new DateTime('2026-10-15 15:00:00.000000', new DateTimeZone('Africa/Cairo')); + // Tokyo has kept UTC+9 without daylight saving since 1951, so the result does not depend on the time zone database. + $tokyo = new DateTime('2026-10-15 21:00:00.000000', new DateTimeZone('Asia/Tokyo')); - expect(Diff::between(['at' => $utc], ['at' => $cairo])->hasChanges())->toBeFalse(); + expect(Diff::between(['at' => $utc], ['at' => $tokyo])->hasChanges())->toBeFalse(); }); it('compares dates to the microsecond', function () { diff --git a/tests/Feature/UnifiedRoundTripTest.php b/tests/Feature/UnifiedRoundTripTest.php index 6ef794e..a187253 100644 --- a/tests/Feature/UnifiedRoundTripTest.php +++ b/tests/Feature/UnifiedRoundTripTest.php @@ -24,6 +24,10 @@ function run(string $command, string $directory): array */ function applyWith(string $tool, string $old, string $new, int $context): string { + if ($tool === 'patch' && PHP_OS_FAMILY === 'Windows') { + PHPUnit\Framework\Assert::markTestSkipped('GNU patch is not reliably available on Windows; git apply covers the same patches there.'); + } + $directory = sys_get_temp_dir() . '/php-diff-' . bin2hex(random_bytes(6)); mkdir($directory); @@ -32,7 +36,7 @@ function applyWith(string $tool, string $old, string $new, int $context): string file_put_contents("{$directory}/change.patch", Diff::text($old, $new, TextDiffOptions::create()->context($context))->toUnified('a/file', 'b/file')); // git apply only accepts patches without context lines with --unidiff-zero. - $git = $context === 0 ? 'git apply --unidiff-zero -p1 change.patch' : 'git apply -p1 change.patch'; + $git = 'git -c core.autocrlf=false apply ' . ($context === 0 ? '--unidiff-zero ' : '') . '-p1 change.patch'; [$code, $output] = run($tool === 'git' ? $git : 'patch -s -p1 -i change.patch', $directory); expect($code)->toBe(0, "{$tool} rejected the patch: {$output}"); @@ -107,7 +111,7 @@ function generatedTexts(int $seed, int $count): array foreach (generatedTexts($seed, 40) as [$old, $new]) { file_put_contents("{$directory}/a", $old); file_put_contents("{$directory}/b", $new); - [, $output] = run('git diff --no-index --numstat a b', $directory); + [, $output] = run('git -c core.autocrlf=false diff --no-index --numstat a b', $directory); $stats = Diff::text($old, $new)->stats(); $expected = $output === '' ? '0 0' : implode(' ', array_slice(preg_split('/\s+/', $output) ?: [], 0, 2)); diff --git a/tests/Unit/SupportTest.php b/tests/Unit/Engine/ArraysTest.php similarity index 60% rename from tests/Unit/SupportTest.php rename to tests/Unit/Engine/ArraysTest.php index 4635d0f..0a4584d 100644 --- a/tests/Unit/SupportTest.php +++ b/tests/Unit/Engine/ArraysTest.php @@ -2,14 +2,7 @@ declare(strict_types=1); -use Pharaonic\Diff\Support\Arrays; -use Pharaonic\Diff\Support\Missing; - -it('has one missing value that differs from null', function () { - expect(Missing::value())->toBe(Missing::value()) - ->and(Missing::is(Missing::value()))->toBeTrue() - ->and(Missing::is(null))->toBeFalse(); -}); +use Pharaonic\Diff\Engine\Arrays; it('treats only arrays keyed 0 to n-1 in order as lists', function (array $value, bool $isList) { expect(Arrays::isList($value))->toBe($isList);