From 1b3ee279f63d32213006a52287404e967812d9e9 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 18:42:09 +0200 Subject: [PATCH 1/2] [perf] Skip RemoveUselessVarTagRector for nodes without a docblock A useless @var tag can only live in a docblock. The rule subscribes to Property, ClassConst and Expression and built a PhpDocInfo for every one, including the many Expression nodes that carry no docblock. Guard with a cheap getDocComment() check so the phpdoc work runs only when a docblock exists; removeVarTagIfUseless already returns false without a @var tag, so behaviour is unchanged. --- rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php b/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php index c0aff29a41e..568dff8aee3 100644 --- a/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php +++ b/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php @@ -63,6 +63,11 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + // a @var tag can only live in a docblock; skip nodes without one + if ($node->getDocComment() === null) { + return null; + } + $phpDocInfo = $this->phpDocInfoFactory->createFromNodeOrEmpty($node); $hasChanged = $this->varTagRemover->removeVarTagIfUseless($phpDocInfo, $node); From 106ebc751d8b558bf823dbf2d3e78b08cf87fec9 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 16:45:01 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php b/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php index 568dff8aee3..7a1d54f10eb 100644 --- a/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php +++ b/rules/DeadCode/Rector/Property/RemoveUselessVarTagRector.php @@ -4,6 +4,7 @@ namespace Rector\DeadCode\Rector\Property; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\Stmt\ClassConst; use PhpParser\Node\Stmt\Expression; @@ -64,7 +65,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { // a @var tag can only live in a docblock; skip nodes without one - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }