Skip to content

Commit 17943df

Browse files
fix error
1 parent 40876ee commit 17943df

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
@@ -19,6 +19,7 @@
1919
use Rector\BetterPhpDocParser\ValueObject\Type\FullyQualifiedIdentifierTypeNode;
2020
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
2121
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
22+
use Rector\PhpParser\AstResolver;
2223
use Rector\PhpParser\Node\BetterNodeFinder;
2324
use Rector\Rector\AbstractRector;
2425
use Rector\Reflection\ReflectionResolver;
@@ -36,6 +37,7 @@ final class NarrowObjectReturnTypeRector extends AbstractRector
3637
public function __construct(
3738
private readonly BetterNodeFinder $betterNodeFinder,
3839
private readonly ReflectionResolver $reflectionResolver,
40+
private readonly AstResolver $astResolver,
3941
private readonly StaticTypeMapper $staticTypeMapper,
4042
private readonly TypeComparator $typeComparator,
4143
private readonly PhpDocInfoFactory $phpDocInfoFactory,
@@ -286,7 +288,7 @@ private function isNarrowingValidFromParent(ClassMethod $classMethod, string $ac
286288

287289
$parentReturnType = $parentClassMethod->returnType;
288290

289-
if (! $parentReturnType instanceof Node) {
291+
if (! $parentReturnType instanceof Identifier && ! $parentReturnType instanceof FullyQualified) {
290292
continue;
291293
}
292294

0 commit comments

Comments
 (0)