Skip to content

Commit b9c9994

Browse files
committed
fix
1 parent 58da676 commit b9c9994

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rules/TypeDeclaration/NodeFactory/JMSTypePropertyTypeFactory.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Identifier;
9+
use PhpParser\Node\Name\FullyQualified;
910
use PhpParser\Node\Stmt\Property;
11+
use PHPStan\Reflection\ReflectionProvider;
1012
use PHPStan\Type\FloatType;
1113
use PHPStan\Type\MixedType;
1214
use PHPStan\Type\ObjectType;
@@ -25,6 +27,7 @@ public function __construct(
2527
private StaticTypeMapper $staticTypeMapper,
2628
private PhpDocInfoFactory $phpDocInfoFactory,
2729
private VarTagRemover $varTagRemover,
30+
private ReflectionProvider $reflectionProvider,
2831
) {
2932
}
3033

@@ -41,7 +44,13 @@ public function createObjectTypeNode(string $typeValue): ?Node
4144
$type = new ObjectType($typeValue);
4245
}
4346

44-
return $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PROPERTY);
47+
$node = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PROPERTY);
48+
49+
if ($node instanceof FullyQualified && ! $this->reflectionProvider->hasClass($node->toString())) {
50+
return null;
51+
}
52+
53+
return $node;
4554
}
4655

4756
public function createScalarTypeNode(string $typeValue, Property $property): ?Node

0 commit comments

Comments
 (0)