Skip to content

Run CommandMustHaveAsCommandAttributeRule only when composer.json requires symfony/console - #380

Merged
TomasVotruba merged 1 commit into
mainfrom
command-ascommand-composer-guard
Oct 23, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
command-ascommand-composer-guard

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

The rule flagged every Command subclass once the #[AsCommand] attribute class was reachable through reflection, even in projects that only pull symfony/console transitively and never opted into it.

Gate the rule on a direct symfony/console entry in the analysed project composer.json (require or require-dev), read once and memoized. Projects that do not depend on the package are left alone.

Added symfony/console to require-dev so the rule own test still reports, as the package tests Symfony commands directly.

@TomasVotruba
TomasVotruba merged commit 51391ef into main Oct 23, 2026
9 checks passed
@TomasVotruba
TomasVotruba deleted the command-ascommand-composer-guard branch October 23, 2026 08:00
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.

1 participant