From 563cfb2669ca9e8ceaddb297f76f828222ba91b8 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Fri, 23 Oct 2026 12:20:00 +0200 Subject: [PATCH] Check #[AsCommand] attribute class is loadable first in CommandMustHaveAsCommandAttributeRule --- .../Symfony/CommandMustHaveAsCommandAttributeRule.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php b/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php index ee327a55..fa3c0a75 100644 --- a/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php +++ b/src/Rules/Symfony/CommandMustHaveAsCommandAttributeRule.php @@ -71,6 +71,11 @@ public function processNode(Node $node, Scope $scope): array return []; } + // do not require an attribute the project does not even have + if (! $this->reflectionProvider->hasClass(SymfonyAttribute::AS_COMMAND)) { + return []; + } + // symfony/console must be a direct production dependency, require-dev is skipped if (! $this->composerRequireResolver->hasRequiredPackage(self::SYMFONY_CONSOLE_PACKAGE)) { return []; @@ -95,11 +100,6 @@ public function processNode(Node $node, Scope $scope): array return []; } - // do not require an attribute the project does not even have - if (! $this->reflectionProvider->hasClass(SymfonyAttribute::AS_COMMAND)) { - return []; - } - foreach ($node->attrGroups as $attrGroup) { foreach ($attrGroup->attrs as $attr) { if ($attr->name->toString() === SymfonyAttribute::AS_COMMAND) {