fix(symfony): use StrictUnifiedDiffOutputBuilder in api:upgrade-filter - #8559
Merged
Conversation
mislavjakopovic
marked this pull request as ready for review
September 21, 2026 22:14
mislavjakopovic
force-pushed
the
fix/symfony-use-strictunifieddiffoutputbuilder-in-api-upgrade-filter
branch
from
September 21, 2026 22:30
680f027 to
a64298a
Compare
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.
Currently our
UpgradeApiFilterCommand::diff()builds the dry-run diff withSebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder, which no longer exists insebastian/diff: "^9".Why we need this for PHPUnit 13:
sebastian/diff9.0.0 removedUnifiedDiffOutputBuilderandAbstractChunkOutputBuilder, and suggests to "useStrictUnifiedDiffOutputBuilderinstead" (RemoveUnifiedDiffOutputBuilderandAbstractChunkOutputBuildersebastianbergmann/diff#157).sebastian/diffmajor: 11.5 requires^6.0.2, 12.5^7.0.1, 13.1^8.3.0, and 13.2.0 switched to^9.0(13.3.4:^9.0.1), see thecomposer.jsonof those tags. So every install of PHPUnit 13.2 or newer comes withsebastian/diff9.Error: Class "SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder" not foundas soon as it finds a resource to upgrade, and PHPStan reports the two lines. That is what happened on the first run of chore: allow phpunit ^13.0 #8537 once the constraint allowed PHPUnit 13:https://github.com/api-platform/core/actions/runs/35087612230/job/104766045721 (
Instantiated class SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder not foundat
UpgradeApiFilterCommand.php:215).The proposed fix in this pull request is a replacement from
UnifiedDiffOutputBuildertoStrictUnifiedDiffOutputBuilderwithfromFile/toFile, which has existed sincesebastian/diff3.0.0, as it emits the same--- original/+++ upgradedheader, and it produces identical output on 6.0.2, 7.0.1, 8.x and 9.0.1.It is the builder
php-cs-fixeruses across^4.0.6 || ^5.1.1 || ^6.0.2 || ^7.0 || ^8.0 || ^9.0(src/Differ/UnifiedDiffer.php), and the one PHPUnit 13 (src/Util/DifferBuilder.php) andsebastian/comparator8 (ComparisonFailure) use themselves.The only visible change is that dry-run hunks carry real line ranges instead of
@@ @@.About added test:
I've had some problems with
codecov:patchwhile preparing this pull request. It failed on 0% change:https://app.codecov.io/gh/api-platform/core/pull/8559?dropdown=coverage&src=pr&el=h1
After exploring for several hours I'm still not 100% about what happened there but it looks like this dry-run path of the command had no test; the only CI job running the codemod (
upgrade-filter) runs with coverage disabled and exercises--forceon a fixture app with nothing to upgrade, sodiff()was never executed and the command had no coverage at all.codecov/patch"only measured lines adjusted in the pull request" against the base coverage (https://docs.codecov.com/docs/commit-status#patch-status), which is why I suspect the small two-lined fix alone scored 0% (https://github.com/api-platform/core/pull/8559/checks?check_run_id=106508255530).Again, these are just my speculations - after adding a test the issue was gone. I was not able to find any previous precedents in pull requests which would either confirm or deny above and given I don't have experience with
Codecovas service the only thing I could done to resolve this is a to write a test that should help us avoid issues with this exact problem and command in the future.If this looks weird to maintainers I would appreciate someone looking it and giving feedback on it.
This pull request is part of several fixes needed to enable PHPUnit 13 support in PR #8537.