From 880bd4dd52b1803e6bf752477bfdbe0f63662db1 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 18:43:30 +0200 Subject: [PATCH 1/2] [perf] Skip AnnotationToAttributeRector for nodes without a docblock The rule subscribes to eight node types (Class_, Property, Param, ClassMethod, Function_, Closure, ArrowFunction, Interface_) and built a PhpDocInfo for every one. The attributes it produces come only from docblock annotations, and it reprints an existing docblock rather than adding a new one, so a node without a docblock always returns null. Guard the phpdoc path behind getDocComment() after the configuration check. Behaviour unchanged. --- rules/Php80/Rector/Class_/AnnotationToAttributeRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php index 6f2b3ee69d5..11ea4bc996b 100644 --- a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php @@ -137,6 +137,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() === null) { + return null; + } + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); if (! $phpDocInfo instanceof PhpDocInfo) { return null; From 8a5fd02dfe2d1adb98685dfc40a3217b0b97c81a Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 16:44:50 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- rules/Php80/Rector/Class_/AnnotationToAttributeRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php b/rules/Php80/Rector/Class_/AnnotationToAttributeRector.php index 11ea4bc996b..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; @@ -138,7 +139,7 @@ public function refactor(Node $node): ?Node } // annotations converted to attributes only come from a docblock; skip nodes without one - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }