Skip to content

Commit 892d404

Browse files
[perf] Skip scope fetch in ReturnTypeFromGetRepositoryDocblockRector without a docblock (#8632)
Co-authored-by: GitHub Action <actions@github.com>
1 parent f66bf58 commit 892d404

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php‎

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

55
namespace Rector\TypeDeclaration\Rector\ClassMethod;
66

7+
use PhpParser\Comment\Doc;
78
use PhpParser\Node;
89
use PhpParser\Node\Expr\Assign;
910
use PhpParser\Node\Expr\MethodCall;
@@ -101,6 +102,11 @@ public function refactor(Node $node): ?Node
101102
return null;
102103
}
103104

105+
// the native type is read from the @return docblock; skip before scope fetch when there is none
106+
if (!$node->getDocComment() instanceof Doc) {
107+
return null;
108+
}
109+
104110
if (! $this->isGetRepositoryReturnOnly($node)) {
105111
return null;
106112
}

0 commit comments

Comments
 (0)