diff --git a/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php b/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php index 037f0fc841..b31b59e43d 100644 --- a/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php +++ b/rules/TypeDeclaration/Rector/FunctionLike/ReturnTypeDeclarationRector.php @@ -21,6 +21,7 @@ use Rector\Core\ValueObject\PhpVersionFeature; use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\PHPStanStaticTypeMapper\Enum\TypeKind; +use Rector\StaticTypeMapper\ValueObject\Type\NonExistingObjectType; use Rector\TypeDeclaration\PhpDocParser\NonInformativeReturnTagRemover; use Rector\TypeDeclaration\PhpParserTypeAnalyzer; use Rector\TypeDeclaration\TypeAlreadyAddedChecker\ReturnTypeAlreadyAddedChecker; @@ -109,7 +110,7 @@ public function refactor(Node $node): ?Node [ReturnTypeDeclarationReturnTypeInfererTypeInferer::class] ); - if ($inferedReturnType instanceof MixedType) { + if ($inferedReturnType instanceof MixedType || $inferedReturnType instanceof NonExistingObjectType) { return null; }