33namespace PHPStan \Type \PHPUnit ;
44
55use PhpParser \Node \Expr \MethodCall ;
6+ use PhpParser \Node \Expr \StaticCall ;
67use PHPStan \Analyser \Scope ;
78use PHPStan \Reflection \MethodReflection ;
89use PHPStan \Type \DynamicMethodReturnTypeExtension ;
10+ use PHPStan \Type \DynamicStaticMethodReturnTypeExtension ;
911use PHPStan \Type \ObjectType ;
1012use PHPStan \Type \Type ;
1113use PHPStan \Type \TypeCombinator ;
1517use function count ;
1618use function in_array ;
1719
18- class MockForIntersectionDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension
20+ class MockForIntersectionDynamicReturnTypeExtension implements DynamicMethodReturnTypeExtension, DynamicStaticMethodReturnTypeExtension
1921{
2022
2123 public function getClass (): string
@@ -35,9 +37,18 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3537 );
3638 }
3739
40+ public function getTypeFromStaticMethodCall (MethodReflection $ methodReflection , StaticCall $ methodCall , Scope $ scope ): ?Type
41+ {
42+ return $ this ->getTypeFromCall ($ methodReflection , $ methodCall ->getArgs (), $ scope );
43+ }
44+
3845 public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): ?Type
3946 {
40- $ args = $ methodCall ->getArgs ();
47+ return $ this ->getTypeFromCall ($ methodReflection , $ methodCall ->getArgs (), $ scope );
48+ }
49+
50+ private function getTypeFromCall (MethodReflection $ methodReflection , array $ args , Scope $ scope ): ?Type
51+ {
4152 if (!isset ($ args [0 ])) {
4253 return null ;
4354 }
0 commit comments