From 5e3477d44bc561baa9128ac3769f5abf3659b5ee Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 19:23:25 +0200 Subject: [PATCH 1/2] [perf] Skip reflection in RemoveDuplicatedReturnSelfDocblockRector without a docblock The rule resolved a ClassReflection and built a PhpDocInfo for every self/static returning method. A duplicated @return tag can only live in a docblock, so add a getDocComment() guard before the reflection resolution. A method without a docblock is a no-op anyway, so this skips the reflection work for it. Behaviour unchanged. --- .../ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php index fba40a37222..5f758081ed7 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php @@ -92,6 +92,11 @@ public function refactor(Node $node): ?Node return null; } + // a duplicated @return tag can only live in a docblock; skip before resolving reflection + if ($node->getDocComment() === null) { + return null; + } + $classReflection = $this->reflectionResolver->resolveClassReflection($node); if (! $classReflection instanceof ClassReflection) { return null; From ba43a3b83f9a797838a72c99573f30c4bc1bb208 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 17:24:23 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php b/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php index 5f758081ed7..ce857108361 100644 --- a/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php +++ b/rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php @@ -4,6 +4,7 @@ namespace Rector\DeadCode\Rector\ClassMethod; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\Identifier; use PhpParser\Node\Name; @@ -93,7 +94,7 @@ public function refactor(Node $node): ?Node } // a duplicated @return tag can only live in a docblock; skip before resolving reflection - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }