From bb18c5df9551b85a9dc47eb351172a05d7ed2306 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 18:42:37 +0200 Subject: [PATCH 1/2] [perf] Skip RemoveNullTagValueNodeRector for nodes without a docblock The rule subscribes to ClassMethod, Function_, Expression and Property and built a PhpDocInfo for every node to look for null param/return/var tags. Those tags only exist inside a docblock, so guard all branches with a single getDocComment() check. Each branch already no-ops when the tag is absent, so behaviour is unchanged. --- .../Rector/ClassMethod/RemoveNullTagValueNodeRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php index f5f465482b9..7452879b407 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php @@ -80,6 +80,11 @@ public function getNodeTypes(): array */ public function refactor(Node $node): ?Node { + // null param/return/var tags can only live in a docblock; skip nodes without one + if ($node->getDocComment() === null) { + return null; + } + if ($node instanceof Expression || $node instanceof Property) { return $this->processVarTagNull($node); } From afb320549bf64c9335cb58fe10815963b9946e87 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 16:43:57 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../Rector/ClassMethod/RemoveNullTagValueNodeRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php index 7452879b407..8d5dcc5a974 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php @@ -4,6 +4,7 @@ namespace Rector\DeadCode\Rector\ClassMethod; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\Stmt\ClassMethod; use PhpParser\Node\Stmt\Expression; @@ -81,7 +82,7 @@ public function getNodeTypes(): array public function refactor(Node $node): ?Node { // null param/return/var tags can only live in a docblock; skip nodes without one - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }