Skip to content

Commit a8ad07c

Browse files
[perf] Skip NarrowArrayCollectionUnionReturnDocblockRector for nodes without a docblock (#8630)
Co-authored-by: GitHub Action <actions@github.com>
1 parent ceab323 commit a8ad07c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎rules/TypeDeclarationDocblocks/Rector/ClassMethod/NarrowArrayCollectionUnionReturnDocblockRector.php‎

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

55
namespace Rector\TypeDeclarationDocblocks\Rector\ClassMethod;
66

7+
use PhpParser\Comment\Doc;
78
use PhpParser\Node;
89
use PhpParser\Node\Stmt\ClassMethod;
910
use PhpParser\Node\Stmt\Function_;
@@ -85,6 +86,11 @@ public function getNodeTypes(): array
8586
*/
8687
public function refactor(Node $node): null|ClassMethod|Function_
8788
{
89+
// a @return tag can only live in a docblock; skip nodes without one
90+
if (!$node->getDocComment() instanceof Doc) {
91+
return null;
92+
}
93+
8894
$phpDocInfo = $this->phpDocInfoFactory->createFromNode($node);
8995
if (! $phpDocInfo instanceof PhpDocInfo) {
9096
return null;

0 commit comments

Comments
 (0)