Skip to content

Register conditionally enabled rules with attributes - #6276

Open
calebdw wants to merge 1 commit into
phpstan:2.2.xfrom
calebdw:calebdw/push-rtxpvmukqlok
Open

Register conditionally enabled rules with attributes#6276
calebdw wants to merge 1 commit into
phpstan:2.2.xfrom
calebdw:calebdw/push-rtxpvmukqlok

Conversation

@calebdw

@calebdw calebdw commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Adds the optional enabledBy parameter to RegisteredRule and RegisteredCollector. It accepts a boolean parameter reference and only adds the rule or collector tag when that parameter is enabled.

This moves PHPStan's 18 conditionally registered rules out of conditionalTags and service definitions and onto the rule classes. The five conditional restricted-usage extension tags remain in NEON because they are not rules or collectors.

Closes phpstan/phpstan#15115

Adds the optional enabledBy parameter to RegisteredRule and
RegisteredCollector. It accepts a boolean parameter reference and only
adds the rule or collector tag when that parameter is enabled.

This moves PHPStan's 18 conditionally registered rules out of
conditionalTags and service definitions and onto the rule classes. The
five conditional restricted-usage extension tags remain in NEON because
they are not rules or collectors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Conditional rule/collector registration via #[RegisteredRule(enabledBy:)]

1 participant