From 9cf6fec9fdb838326cd97a81d45cd8f02fe918bc Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 19:22:24 +0200 Subject: [PATCH 1/2] [perf] Skip MergePhpstanDocTagIntoNativeRector for nodes without a docblock The rule subscribes to Property, Param, ClassConst, ClassMethod and Function_ and built a PhpDocInfo for every node to look for @phpstan-param/-var/-return tags. Those tags only exist in a docblock; guard with getDocComment(). Without a docblock there is nothing to merge, so behaviour is unchanged. --- .../Rector/Property/MergePhpstanDocTagIntoNativeRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php b/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php index bc5a5293114..2ee28d0ad40 100644 --- a/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php +++ b/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php @@ -87,6 +87,11 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + // @phpstan-* tags can only live in a docblock; skip nodes without one + if ($node->getDocComment() === null) { + return null; + } + $phpDocInfo = $this->phpDocInfoFactory->createFromNode($node); if (! $phpDocInfo instanceof PhpDocInfo) { return null; From e535d8f0f80634b5f29718a56d3816555c0648de Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 17:23:41 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../Rector/Property/MergePhpstanDocTagIntoNativeRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php b/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php index 2ee28d0ad40..7855dc2d6de 100644 --- a/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php +++ b/rules/TypeDeclarationDocblocks/Rector/Property/MergePhpstanDocTagIntoNativeRector.php @@ -4,6 +4,7 @@ namespace Rector\TypeDeclarationDocblocks\Rector\Property; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\Param; use PhpParser\Node\Stmt\ClassConst; @@ -88,7 +89,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { // @phpstan-* tags can only live in a docblock; skip nodes without one - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }