diff --git a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php index 6f2b3ee69d5..d0909b09f19 100644 --- a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php @@ -4,6 +4,7 @@ namespace Rector\Php80\Rector\Class_; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\AttributeGroup; use PhpParser\Node\Expr\ArrowFunction; @@ -137,6 +138,11 @@ public function refactor(Node $node): ?Node throw new InvalidConfigurationException(sprintf('The "%s" rule requires configuration.', self::class)); } + // annotations converted to attributes only come from a docblock; skip nodes without one + if (!$node->getDocComment() instanceof Doc) { + return null; + } + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); if (! $phpDocInfo instanceof PhpDocInfo) { return null;