Repository navigation
[Utils] Add PHPStan rule to spot Rector rules not registered in any set - #8760
Merged
Merged
Conversation
TomasVotruba
force-pushed
the
tv-phpstan-register-rule-wt
branch
6 times, most recently
from
October 22, 2026 18:45
ff69001 to
82224f1
Compare
Flags any Rector rule whose ::class is in no set/level config - it can never run otherwise. Scans rector-src config + src/Config and sibling rector-* configs. Deprecated rules and Rector\Tests\ doubles are skipped. A short handful of rules registered only in third-party sets (rector-laravel, drupal-rector, which cannot be installed here due to the rector/rector replace) or shipped opt-in only are listed as rector.registerRector ignores.
TomasVotruba
force-pushed
the
tv-phpstan-register-rule-wt
branch
from
October 22, 2026 19:02
82224f1 to
f404e9f
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.
Adds
RegisterRectorRule, a PHPStan rule that flags a Rector rule class that can never run because it is registered in no set or level config.A non-configurable, non-deprecated Rector rule only runs when some set or level lists its
::class. If none does, the rule is dead code - it ships but nothing can trigger it. This rule enforces that invariant, the same wayRegisterRelatedPolyfillRectorRuleenforces polyfill-set membership.Skips:
ConfigurableRectorInterfacerules - shipped for downstream configs (e.g. rector-laravel) to register, so absence from a rector-src set is expectedDeprecatedInterfacerules - intentionally unregisteredRector\Tests\test doubles - wired directly in their testThe scan reads
config/andsrc/Config/once and checks for theShortName::classreference.Two existing standalone rules are opt-in via explicit
withRules()only and kept out of any set on purpose; they are listed as ignores inphpstan.neonwith a comment, next to the existingrector.upgradeDowngradeRegisteredInSetexceptions.Note: no non-configurable Transform rule turned out to be orphaned - the unregistered Transform rules are all
ConfigurableRectorInterface, so they are downstream opt-in, not dead.