Skip to content

[BUGFIX] Replace usage of UnifiedDiffOutputBuilder with StrictUnifiedDiffOutputBuilder#409

Draft
alexanderschnitzler wants to merge 1 commit into
andreaswolf:mainfrom
alexanderschnitzler:fix/diff-output-builder
Draft

[BUGFIX] Replace usage of UnifiedDiffOutputBuilder with StrictUnifiedDiffOutputBuilder#409
alexanderschnitzler wants to merge 1 commit into
andreaswolf:mainfrom
alexanderschnitzler:fix/diff-output-builder

Conversation

@alexanderschnitzler

Copy link
Copy Markdown
Contributor

Resolves: #408

@alexanderschnitzler

Copy link
Copy Markdown
Contributor Author

@andreaswolf @simonschaufi Maybe someone of you can take a deeper look sometime. I am not quite sure how fractor works in detail.

It seems that replacing the UnifiedDiffOutputBuilder with the StrictUnifiedDiffOutputBuilder is not the actual solution here as you strip the headers of unified diffs. I tried using the DiffOnlyOutputBuilder and without removing the first line of the diff, this works well actually. But the e2e-tests are something different to have a look at then.

@alexanderschnitzler alexanderschnitzler marked this pull request as draft June 18, 2026 10:14
@simonschaufi

Copy link
Copy Markdown
Collaborator

What I would do is to check how Rector fixed this issue as most of the Fractor code is almost a 1:1 copy of Rector

@magicsunday

Copy link
Copy Markdown

Re @simonschaufi's suggestion to check how Rector solved this: Rector's DefaultDiffer (src/Differ/DefaultDiffer.php) uses

new StrictUnifiedDiffOutputBuilder(['fromFile' => 'Original', 'toFile' => 'New'])

The header concern @alexanderschnitzler raised is handled by passing fromFile/toFile: with those options StrictUnifiedDiffOutputBuilder emits exactly the two lines --- Original and +++ New, which fractor's own ColorConsoleDiffFormatter already strips (=== '--- Original' / === '+++ New'). So no header lines leak into the console output.

For what it's worth, the console path was already handled this way in #416 (merged): ConsoleDiffer was replaced by DefaultDiffer using the same StrictUnifiedDiffOutputBuilder(['fromFile' => 'Original', 'toFile' => 'New']). This PR's remaining scope is then the doc-generator differ (DifferFactory / MarkdownDiffer), where the same fromFile/toFile approach applies.

One more note: the latest release v0.5.11 (2026-06-17) predates #416 (merged 2026-06-29), so consumers still hit the fatal under sebastian/diff 9 with no released fix. A tagged release including #416 would unblock them.

@simonschaufi

Copy link
Copy Markdown
Collaborator

Yeah, I too care of the sync with Rector but the doc generator needs to be maintained by us as there are no more external updates. Would you take care of a fix?

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.

[BUG] UnifiedDiffOutputBuilder Class not found with sebastian/diff:9.0

3 participants