diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveNullTagValueNodeRector.php index f5f465482b9..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; @@ -80,6 +81,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() instanceof Doc) { + return null; + } + if ($node instanceof Expression || $node instanceof Property) { return $this->processVarTagNull($node); }