From e372f40f6eae9c083aa125387fbba5f07faa5f01 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 18:43:55 +0200 Subject: [PATCH 1/2] [perf] Skip NestedAnnotationToAttributeRector for nodes without a docblock The rule subscribes to Property, Class_ and Param and built a PhpDocInfo for every node. The attribute groups come only from docblock doctrine annotations and it reprints an existing docblock, so a node without one always returns null. Guard the phpdoc path behind getDocComment(). Behaviour unchanged. --- .../Rector/Property/NestedAnnotationToAttributeRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php b/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php index 78ac6a21d70..cab60d6a70f 100644 --- a/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php @@ -106,6 +106,11 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + // nested 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 e2270d736aa9d5153576abe67b83e561ef72ffb6 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 16:45:25 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../Rector/Property/NestedAnnotationToAttributeRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php b/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php index cab60d6a70f..c5f4434b06f 100644 --- a/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php +++ b/rules/Php80/Rector/Property/NestedAnnotationToAttributeRector.php @@ -4,6 +4,7 @@ namespace Rector\Php80\Rector\Property; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\AttributeGroup; use PhpParser\Node\Param; @@ -107,7 +108,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { // nested annotations converted to attributes only come from a docblock; skip nodes without one - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }