66use PHPStan \Analyser \Scope ;
77use PHPStan \DependencyInjection \AutowiredService ;
88use PHPStan \Reflection \MethodReflection ;
9- use PHPStan \Type \ArrayType ;
9+ use PHPStan \Reflection \ParametersAcceptorSelector ;
10+ use PHPStan \Type \Constant \ConstantBooleanType ;
1011use PHPStan \Type \DynamicMethodReturnTypeExtension ;
11- use PHPStan \Type \MixedType ;
1212use PHPStan \Type \NeverType ;
1313use PHPStan \Type \Type ;
1414use PHPStan \Type \TypeCombinator ;
@@ -31,11 +31,12 @@ public function isMethodSupported(MethodReflection $methodReflection): bool
3131
3232 public function getTypeFromMethodCall (MethodReflection $ methodReflection , MethodCall $ methodCall , Scope $ scope ): ?Type
3333 {
34- if (!isset ($ methodCall ->getArgs ()[0 ])) {
34+ $ args = $ methodCall ->getArgs ();
35+ if (!isset ($ args [0 ])) {
3536 return null ;
3637 }
3738
38- $ argType = $ scope ->getType ($ methodCall -> getArgs () [0 ]->value );
39+ $ argType = $ scope ->getType ($ args [0 ]->value );
3940
4041 $ xmlElement = new SimpleXMLElement ('<foo /> ' );
4142
@@ -53,7 +54,9 @@ public function getTypeFromMethodCall(MethodReflection $methodReflection, Method
5354 return null ;
5455 }
5556
56- return new ArrayType (new MixedType (), $ scope ->getType ($ methodCall ->var ));
57+ $ variant = ParametersAcceptorSelector::selectFromArgs ($ scope , $ args , $ methodReflection ->getVariants ());
58+
59+ return TypeCombinator::remove ($ variant ->getReturnType (), new ConstantBooleanType (false ));
5760 }
5861
5962}
0 commit comments