Skip to content

Commit efb3a2a

Browse files
fix error
1 parent 211f0dc commit efb3a2a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

rules/TypeDeclaration/Rector/ClassMethod/NarrowObjectReturnTypeRector.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode;
1919
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
2020
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
21+
use Rector\PhpParser\AstResolver;
2122
use Rector\PhpParser\Node\BetterNodeFinder;
2223
use Rector\Rector\AbstractRector;
2324
use Rector\Reflection\ReflectionResolver;
@@ -35,6 +36,7 @@ final class NarrowObjectReturnTypeRector extends AbstractRector
3536
public function __construct(
3637
private readonly BetterNodeFinder $betterNodeFinder,
3738
private readonly ReflectionResolver $reflectionResolver,
39+
private readonly AstResolver $astResolver,
3840
private readonly StaticTypeMapper $staticTypeMapper,
3941
private readonly TypeComparator $typeComparator,
4042
private readonly PhpDocInfoFactory $phpDocInfoFactory,
@@ -275,7 +277,7 @@ private function isNarrowingValidFromParent(ClassMethod $classMethod, string $ac
275277

276278
$parentReturnType = $parentClassMethod->returnType;
277279

278-
if (! $parentReturnType instanceof Node) {
280+
if (! $parentReturnType instanceof Identifier && ! $parentReturnType instanceof FullyQualified) {
279281
continue;
280282
}
281283

0 commit comments

Comments
 (0)