Repository navigation
Fix two blink false positives surfaced on rector-src - #197
Merged
Merged
Conversation
When one rule edits the stream and another reverts it (e.g. UnaryOperatorSpaces strips the space after "!" and NotOperatorWithSuccessorSpace adds it back), the rendered file equals the original. Those files were reported as fixable with an empty diff. Report a change only when the final content differs from the original, matching PHP-CS-Fixer.
The lexer tags a class name like "Enum" (in "Enum::MODE_ADD") as the "enum" keyword. ClassDefinition treated it as a declaration and, with single_line, flattened everything up to the next brace, mangling unrelated code. A real declaration is followed by the type-name identifier, so skip a class-like keyword not followed by one.
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.
Running
ecs check --blinkon rector-src reported 840 fixable files; the PHP engine reports the codebase clean. Two independent bugs caused this.1. Net-zero fixer runs reported with an empty diff (836 files)
UnaryOperatorSpacesFixer(full) strips the space after!(! $a->!$a) andNotOperatorWithSuccessorSpaceFixeradds it back. On files with! $x, the two fight to a draw: the rendered output is identical to the original, but both rules returnedchanged=true, so the file was listed as fixable with an empty diff.The runner now reports a change only when the final rendered content differs from the original, matching PHP-CS-Fixer (which reports real diffs only).
2. ClassDefinition mangled code after a keyword-named reference
The lexer tags a class name like
Enum(inEnum::MODE_ADD) as theenumkeyword.ClassDefinitionFixertreated it as a declaration and, withsingle_line: true, flattened every newline between it and the next{(a later method brace), collapsing a multi-line array and merging statements:A genuine declaration is always followed by the type-name identifier, so a class-like keyword not followed by one (
Enum::,Enum() is skipped.Verification
Regression tests added for both (
internal/runner,internal/fixer/rules). After the fix,ecs check --blinkon rector-src reports no errors, matching the PHP engine.