Skip to content

fix(symfony): use StrictUnifiedDiffOutputBuilder in api:upgrade-filter - #8559

Merged
soyuka merged 1 commit into
api-platform:5.0from
mislavjakopovic:fix/symfony-use-strictunifieddiffoutputbuilder-in-api-upgrade-filter
Sep 22, 2026
Merged

soyuka merged 1 commit into
api-platform:5.0from
mislavjakopovic:fix/symfony-use-strictunifieddiffoutputbuilder-in-api-upgrade-filter

Conversation

@mislavjakopovic

@mislavjakopovic mislavjakopovic commented Sep 21, 2026

Copy link
Copy Markdown
Contributor
Q A
Branch? 5.0
Tickets none
PRs Preparation for #8537
License MIT
Doc PR n/a

Currently our UpgradeApiFilterCommand::diff() builds the dry-run diff with SebastianBergmann\Diff\Output\UnifiedDiffOutputBuilder, which no longer exists in sebastian/diff: "^9".

Why we need this for PHPUnit 13:

The proposed fix in this pull request is a replacement from UnifiedDiffOutputBuilder to StrictUnifiedDiffOutputBuilder with fromFile/toFile, which has existed since sebastian/diff 3.0.0, as it emits the same --- original / +++ upgraded header, and it produces identical output on 6.0.2, 7.0.1, 8.x and 9.0.1.

It is the builder php-cs-fixer uses 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) and sebastian/comparator 8 (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:patch while 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 --force on a fixture app with nothing to upgrade, so diff() 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.

@mislavjakopovic
mislavjakopovic marked this pull request as ready for review September 21, 2026 22:14
@mislavjakopovic
mislavjakopovic force-pushed the fix/symfony-use-strictunifieddiffoutputbuilder-in-api-upgrade-filter branch from 680f027 to a64298a Compare September 21, 2026 22:30
@soyuka
soyuka merged commit 1dc1637 into api-platform:5.0 Sep 22, 2026
116 of 117 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants