Skip to content

Commit 032f7fe

Browse files
[allow-dynamic-calls] Fix cases where we don't have a class name yet to fall back to default return type of enums
1 parent 0a20a9f commit 032f7fe

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/EnumDynamicReturnTypeExtension.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace MabeEnumPHPStan;
44

55
use MabeEnum\Enum;
6+
use PhpParser\Node\Expr;
67
use PhpParser\Node\Expr\MethodCall;
78
use PhpParser\Node\Expr\StaticCall;
89
use PHPStan\Analyser\Scope;
@@ -81,6 +82,9 @@ public function getTypeFromStaticMethodCall(
8182
StaticCall $staticCall,
8283
Scope $scope
8384
): Type {
85+
if ($staticCall->class instanceof Expr) {
86+
return ParametersAcceptorSelector::selectSingle($methodReflection->getVariants())->getReturnType();
87+
}
8488
$callClass = $staticCall->class->toString();
8589

8690
// Can't detect possible types on static::*()

0 commit comments

Comments
 (0)