Skip to content

Commit 703ec31

Browse files
committed
Revert "Try fixing generic static type issue"
This reverts commit 196e0e3.
1 parent 196e0e3 commit 703ec31

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;
1514
use PHPStan\Type\StaticType;
1615
use PHPStan\Type\Type;
1716
use PHPStan\Type\TypeTraverser;
1817
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-
if ($this->calledOnType instanceof ObjectType) {
121-
$calledOnTypeReflection = $this->calledOnType->getClassReflection();
122-
if ($calledOnTypeReflection !== null) {
123-
return $traverse($type->changeBaseClass($calledOnTypeReflection)->getStaticObjectType());
124-
}
120+
$calledOnTypeReflections = $this->calledOnType->getObjectClassReflections();
121+
if (count($calledOnTypeReflections) === 1) {
122+
$calledOnTypeReflection = $calledOnTypeReflections[0];
123+
124+
return $traverse($type->changeBaseClass($calledOnTypeReflection)->getStaticObjectType());
125125
}
126126

127127
return $this->calledOnType;

0 commit comments

Comments
 (0)