Support sebastian/diff 9 - #93
Merged
Merged
Conversation
UnifiedDiffOutputBuilder was removed in sebastian/diff 9.0.0, while the constraint here already allows ^9. Installing that version makes --ensure-sync fatal with "Class UnifiedDiffOutputBuilder not found" before it compares a single file. StrictUnifiedDiffOutputBuilder renders the same header through fromFile and toFile, and both options exist in ^7, ^8 and ^9, so the constraint can stay as it is.
Orest-Divintari
force-pushed
the
fix-sebastian-diff-9-compat
branch
from
August 4, 2026 05:18
aa75a31 to
1550d9c
Compare
Owner
|
Could you also provide a PR that bumps the minimum for diff to v9? |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UnifiedDiffOutputBuilderwas removed in sebastian/diff 9.0.0 (#157), butcomposer.jsonalready allows^7 || ^8 || ^9. With 9.x installed,--ensure-syncdies before comparing a single file:The builder is constructed unconditionally in the
$ensureSyncbranch, so every--ensure-syncrun fails, in sync or not.We hit this while upgrading to PHPUnit 13.2, which requires
sebastian/diff ^9.0— so any consumer on PHPUnit 13.2+ can no longer run the sync guard.Fix
StrictUnifiedDiffOutputBuilderwithfromFile/toFilerenders a byte-identical header (--- Actual\n+++ Expected\n). Those two options exist in 7.x, 8.x and 9.x alike, so the constraint needs no change and nothing drops out of support.Note that
headerwould not work here — that option only arrived in 8.3.0, and on older versions the constructor then throws becausefromFile/toFileare still null. That would break the^7 || ^8.0end of the range.One deliberate output change
Hunk headers now carry line numbers, because
StrictUnifiedDiffOutputBuilderdefaultsaddLineNumberstotruewhereUnifiedDiffOutputBuilderdefaulted it tofalse:Everything else — header, context lines,
+/-markers — is unchanged, andformatDiff()colours the new header fine since it still matchesstr_starts_with($line, '@@').This seemed worth keeping: the diff is console output for a human chasing drift in a long generated file, so knowing it is around line 641 beats searching for the snippet, and the output becomes a valid unified diff that
patchaccepts. Happy to pass'addLineNumbers' => falseinstead if you would rather the output stay byte-identical.Verified
vendor/bin/phpunit— 185 tests, 667 assertions, OKvendor/bin/php-cs-fixer check— cleanvendor/bin/phpstan analyse— no errors--ensure-syncagainst a real project withsebastian/diff9.0.0 installed, both in sync ("Generated code is in sync ✅") and with deliberate drift in a 1113-line generated file