Skip to content

Commit 196e0e3

Browse files
committed
Try fixing generic static type issue
1 parent 3f83b46 commit 196e0e3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Reflection/Type/CalledOnTypeUnresolvedMethodPrototypeReflection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
use PHPStan\Reflection\Php\DummyParameterWithPhpDocs;
1212
use PHPStan\Reflection\ResolvedMethodReflection;
1313
use PHPStan\Type\Generic\GenericStaticType;
14+
use PHPStan\Type\ObjectType;
1415
use PHPStan\Type\StaticType;
1516
use PHPStan\Type\Type;
1617
use PHPStan\Type\TypeTraverser;
1718
use function array_map;
18-
use function count;
1919

2020
final class CalledOnTypeUnresolvedMethodPrototypeReflection implements UnresolvedMethodPrototypeReflection
2121
{
@@ -117,11 +117,11 @@ private function transformStaticType(Type $type): Type
117117
{
118118
return TypeTraverser::map($type, function (Type $type, callable $traverse): Type {
119119
if ($type instanceof GenericStaticType) {
120-
$calledOnTypeReflections = $this->calledOnType->getObjectClassReflections();
121-
if (count($calledOnTypeReflections) === 1) {
122-
$calledOnTypeReflection = $calledOnTypeReflections[0];
123-
124-
return $traverse($type->changeBaseClass($calledOnTypeReflection)->getStaticObjectType());
120+
if ($this->calledOnType instanceof ObjectType) {
121+
$calledOnTypeReflection = $this->calledOnType->getClassReflection();
122+
if ($calledOnTypeReflection !== null) {
123+
return $traverse($type->changeBaseClass($calledOnTypeReflection)->getStaticObjectType());
124+
}
125125
}
126126

127127
return $this->calledOnType;

0 commit comments

Comments
 (0)