[composer-based] Register each rule only once, add --composer-based process filter - #8248
Merged
Merged
Conversation
…rocess filter A rule registered by multiple sets was tagged repeatedly, so the same singleton was handed out N times: run N times per node, and listed N times in reports. Also adds the --composer-based process option and the composer-bound rule configuration report.
TomasVotruba
force-pushed
the
composer-based-dedupe-rules
branch
from
July 31, 2026 20:21
00549b3 to
5fe8e35
Compare
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.
1. Each rule is registered only once
RectorConfig::rule()tagged the class on every call. A rule registered by more than one set got one tag entry per set, andgiveTagged(RectorInterface::class)handed the same singleton back once per entry.That means the rule was run repeatedly on every node, and listed repeatedly in
list-rules/composer-based:Reproduced with 3
rule()calls for the same class -$container->tagged(RectorInterface::class)returned 3 instances before, 1 after.Same for composer bound rule configurations - the same rule class + package + constraint + configuration is reported once, no matter how many sets register it.
2.
--composer-basedprocess optionRuns only the rules that are bound to an installed composer package version - rules implementing
ComposerPackageConstraintInterface, and rules whose configuration was registered throughruleWithConfigurationComposerVersionBound().Complements the
composer-basedcommand from #8247, which reports the same set of rules and configurations without running them.