Skip to content

Commit ab2b764

Browse files
[perf] Skip reflection in RemoveDuplicatedReturnSelfDocblockRector without a docblock (#8631)
Co-authored-by: GitHub Action <actions@github.com>
1 parent a8ad07c commit ab2b764

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎rules/DeadCode/Rector/ClassMethod/RemoveDuplicatedReturnSelfDocblockRector.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Rector\DeadCode\Rector\ClassMethod;
66

7+
use PhpParser\Comment\Doc;
78
use PhpParser\Node;
89
use PhpParser\Node\Identifier;
910
use PhpParser\Node\Name;
@@ -92,6 +93,11 @@ public function refactor(Node $node): ?Node
9293
return null;
9394
}
9495

96+
// a duplicated @return tag can only live in a docblock; skip before resolving reflection
97+
if (!$node->getDocComment() instanceof Doc) {
98+
return null;
99+
}
100+
95101
$classReflection = $this->reflectionResolver->resolveClassReflection($node);
96102
if (! $classReflection instanceof ClassReflection) {
97103
return null;

0 commit comments

Comments
 (0)