Skip to content

[BUGFIX] Replace usage of UnifiedDiffOutputBuilder with StrictUnifiedDiffOutputBuilder - #409

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

[BUGFIX] Replace usage of UnifiedDiffOutputBuilder with StrictUnifiedDiffOutputBuilder#409
alexanderschnitzler wants to merge 1 commit into
FriendsOfTYPO3: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

simonschaufi commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

Yeah, I took 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?

@alexanderschnitzler

Copy link
Copy Markdown
Contributor Author

@simonschaufi Do I understand correctly that fractor performs the changes but it doesn't show them? That's currently missing?

@simonschaufi

simonschaufi commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Fractor only hides pure whitespace changes (reformatting) but all the others are shown.

@alexanderschnitzler

Copy link
Copy Markdown
Contributor Author

@simonschaufi My question was in reference to your slack comment:

There is already a partial PR #409 to fix the issue but it is not yet complete. I'm still hoping that @aschnitzler will finalize the PR soon.

I am unsure what exactly is missing what you want me to do. I used fractor 1.0 yesterday and realized it doesn't print a diff of changes but it actually changes things. Is that the remaining issue?

@simonschaufi

Copy link
Copy Markdown
Collaborator

I am unsure what exactly is missing what you want me to do.

the doc generator still needs adjustments.

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