[skip] fix match class + path matching in reporting of unused skips#8073
Merged
Conversation
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.
Bug
UnusedSkipResolver::resolveUnusedRuleScopedSkips()matched used skips by path only, ignoring the rule class.Used skips live in one flat list (
UsedSkipCollector), mixing rule-scoped paths and global paths. The same path skipped under two rules collapsed to a single key, so a match under one rule silently marked the same path under every other rule as "used".Before (false negative)
src/Foo.phpmatched underSomeRector, landed in the used list as the bare pathsrc/Foo.php. The resolver then checkedin_array('src/Foo.php', $usedSkips)forAnotherRectortoo — found it — and reported the genuinely unused skip as used. It was never flagged for removal.After (fixed)
Used skips are now tracked scoped to their rule as
class|path:SkipSkipper::doesMatchSkip()marks$skippedClass . '|' . $matchedPathUnusedSkipResolverchecksin_array($rectorClass . '|' . $path, $usedSkips, true)SomeRector|src/Foo.phpandAnotherRector|src/Foo.phpare distinct keys, so the unmatched skip underAnotherRectoris correctly reported as unused.Global skips and skip-everywhere (
nullpath) rules are unchanged — they carry no rule scope.Tests
testSamePathUnderAnotherRuleDoesNotMarkSkipUsed— same path under two rules, only one matched; asserts the other still reports unused.UnusedSkipResolverTest+UsedSkipCollectorTestto theclass|pathkey shape.