@@ -4774,8 +4774,7 @@ private function exactInstantiation(New_ $node, string $className): ?Type
4774
4774
);
4775
4775
}
4776
4776
4777
- /** @api */
4778
- public function getMethodReflection (Type $ typeWithMethod , string $ methodName ): ?ExtendedMethodReflection
4777
+ private function filterTypeWithMethod (Type $ typeWithMethod , string $ methodName ): ?Type
4779
4778
{
4780
4779
if ($ typeWithMethod instanceof UnionType) {
4781
4780
$ newTypes = [];
@@ -4796,19 +4795,31 @@ public function getMethodReflection(Type $typeWithMethod, string $methodName): ?
4796
4795
return null ;
4797
4796
}
4798
4797
4799
- return $ typeWithMethod ->getMethod ($ methodName , $ this );
4798
+ return $ typeWithMethod ;
4799
+ }
4800
+
4801
+ /** @api */
4802
+ public function getMethodReflection (Type $ typeWithMethod , string $ methodName ): ?ExtendedMethodReflection
4803
+ {
4804
+ $ type = $ this ->filterTypeWithMethod ($ typeWithMethod , $ methodName );
4805
+ if ($ type === null ) {
4806
+ return null ;
4807
+ }
4808
+
4809
+ return $ type ->getMethod ($ methodName , $ this );
4800
4810
}
4801
4811
4802
4812
/**
4803
4813
* @param MethodCall|Node\Expr\StaticCall $methodCall
4804
4814
*/
4805
4815
private function methodCallReturnType (Type $ typeWithMethod , string $ methodName , Expr $ methodCall ): ?Type
4806
4816
{
4807
- $ methodReflection = $ this ->getMethodReflection ($ typeWithMethod , $ methodName );
4808
- if ($ methodReflection === null ) {
4817
+ $ typeWithMethod = $ this ->filterTypeWithMethod ($ typeWithMethod , $ methodName );
4818
+ if ($ typeWithMethod === null ) {
4809
4819
return null ;
4810
4820
}
4811
4821
4822
+ $ methodReflection = $ typeWithMethod ->getMethod ($ methodName , $ this );
4812
4823
$ parametersAcceptor = ParametersAcceptorSelector::selectFromArgs (
4813
4824
$ this ,
4814
4825
$ methodCall ->getArgs (),
0 commit comments