Repository navigation
Conversation
A FileDiff also records a rule that printed identical code. With --no-diffs every diff is empty, so FileDiff carries the changed state.
Each file prints identical code but a name importing post rector records a change, so the list must not contain it.
Clintonrocha98
approved these changes
Nov 4, 2026
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.
With
--output-format=json, thechanged_fileslist can contain files that Rector did not change, whiletotals.changed_filescounts only the real changes. The e2eapplied-no-diffs-format-jsonof this PR, onmain:{ "totals": { "changed_files": 1, "errors": 0 }, "changed_files": [ "src/AliasedSameShortName.php", "src/AnonymousClassDocblock.php", "src/RemoveAlwaysElse.php", "src/global_class_constant_twice_without_namespace.php", "src/global_class_new_twice_without_namespace.php", "src/global_class_type_twice_without_namespace.php" ] }Only the file
src/RemoveAlwaysElse.phpshould be changed.A tool or a CI script that reads the list sees changes that do not exist. In a project I work on, a cold
--dry-runwithwithImportNames()lists 92 files withtotals.changed_files: 0. See rectorphp/rector#9911 for the same result on symfony/symfony and Sylius.Cause
A rule or a post rector can record a line change and print identical code.
FileProcessorthen creates aFileDiffwith an empty diff. This is on purpose (#6794):AbstractRectorTestCaseuses it to warn about a rule that changes nothing.JsonOutputFactorylists everyFileDiff, because with--no-diffsevery diff is empty and the real changes must stay in the list (#7821).The name importing post rectors cause it in different branches of their code, for example:
A fix for one branch (#8512) leaves the others. This PR fixes the output instead, for all of them.
Change
FileDiffgets ahasChangedflag, set fromFile::hasChanged(), the same source astotals.changed_files. The flag is serialized for the parallel workers.JsonOutputFactorylists a file only whenhasChanged()is true. This works with and without--no-diffs.FileDiffstays, so the [dx] add test to check that a rule is not applied if it does not change the code #6794 warning does not change.Tests
JsonOutputFactoryTest: an unchangedFileDiffis not listed with--no-diffs.FileDiffTest: the flag stays after the worker serialization.applied-no-diffs-format-json:importNames()plus one file for each case above (5 files). Without the fix, thechanged_fileslist also contains these 5 files, which Rector does not change.