[ax] Allow --only to run several rules at once - #8451
Merged
Conversation
…earDown The new onlyRules test left the shared ConfigurationRuleFilter singleton holding onlyRules, which leaked into other tests in the same process and filtered out their rules. Reset to a neutral Configuration after each test. Claude-Session: https://claude.ai/code/session_01QDEtmow9psVbccgbgHDqgd
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.
Why
--onlyaccepted a single rule, so applying a curated subset of rules in one run was not possible - you had to run Rector once per rule. Agents and scripts that want to apply a specific set of rules (and nothing else) had no way to express it.What
--onlynow accepts multiple values by repeating the flag:A rule runs if it matches any of the given
--onlyvalues. A single--only=Foobehaves exactly as before, so this is backward compatible.Changes
--onlyoption is nowVALUE_REQUIRED | VALUE_IS_ARRAY.Configuration::getOnlyRule(): ?string->getOnlyRules(): string[]; each value is resolved through the existingOnlyRuleResolver(short names, ambiguity and not-found errors unchanged, per rule).ConfigurationRuleFilter::filterOnlyRule()->filterOnlyRules(), keeping any rule that matches one of the listed classes.ChangedFilesDetector::setActiveScope()takes the rule list and builds the per-selection cache key from it, so different--onlysets keep separate cache scopes.--onlyand fixes passing several rules to workers.Tests
ConfigurationRuleFilterTest::testOnlyRulesKeepsEveryListedRule- three rules in, two listed, only those two kept.--onlyscope/cache tests updated to the array shape; all green.composer check-cs,composer phpstanclean; verified on the CLI in both parallel and single-process runs (two rules -> both applied; one rule -> BC).