From 56296077f3b5fb2b7e7b8d968f7b5cbf5e8a01d3 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 11 Oct 2026 19:23:57 +0200 Subject: [PATCH 1/2] [perf] Skip scope fetch in ReturnTypeFromGetRepositoryDocblockRector without a docblock The rule reads the native return type from the @return docblock, but fetched a scope and ran the getRepository check before touching the docblock. A method without a docblock has no @return to read, so it is a no-op. Add a getDocComment() guard before the scope fetch. Behaviour unchanged. --- .../ReturnTypeFromGetRepositoryDocblockRector.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php index b02fd6b2e4e..5f09088814a 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php @@ -101,6 +101,11 @@ public function refactor(Node $node): ?Node return null; } + // the native type is read from the @return docblock; skip before scope fetch when there is none + if ($node->getDocComment() === null) { + return null; + } + if (! $this->isGetRepositoryReturnOnly($node)) { return null; } From c4906aae91b421ee3d1566f6281e73281419348e Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sun, 11 Oct 2026 17:25:04 +0000 Subject: [PATCH 2/2] [ci-review] Rector Rectify --- .../ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php index 5f09088814a..cb0c6e85f25 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromGetRepositoryDocblockRector.php @@ -4,6 +4,7 @@ namespace Rector\TypeDeclaration\Rector\ClassMethod; +use PhpParser\Comment\Doc; use PhpParser\Node; use PhpParser\Node\Expr\Assign; use PhpParser\Node\Expr\MethodCall; @@ -102,7 +103,7 @@ public function refactor(Node $node): ?Node } // the native type is read from the @return docblock; skip before scope fetch when there is none - if ($node->getDocComment() === null) { + if (!$node->getDocComment() instanceof Doc) { return null; }