@@ -4774,8 +4774,7 @@ private function exactInstantiation(New_ $node, string $className): ?Type
47744774 );
47754775 }
47764776
4777- /** @api */
4778- public function getMethodReflection (Type $ typeWithMethod , string $ methodName ): ?ExtendedMethodReflection
4777+ private function filterTypeWithMethod (Type $ typeWithMethod , string $ methodName ): ?Type
47794778 {
47804779 if ($ typeWithMethod instanceof UnionType) {
47814780 $ newTypes = [];
@@ -4796,19 +4795,31 @@ public function getMethodReflection(Type $typeWithMethod, string $methodName): ?
47964795 return null ;
47974796 }
47984797
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 );
48004810 }
48014811
48024812 /**
48034813 * @param MethodCall|Node\Expr\StaticCall $methodCall
48044814 */
48054815 private function methodCallReturnType (Type $ typeWithMethod , string $ methodName , Expr $ methodCall ): ?Type
48064816 {
4807- $ methodReflection = $ this ->getMethodReflection ($ typeWithMethod , $ methodName );
4808- if ($ methodReflection === null ) {
4817+ $ typeWithMethod = $ this ->filterTypeWithMethod ($ typeWithMethod , $ methodName );
4818+ if ($ typeWithMethod === null ) {
48094819 return null ;
48104820 }
48114821
4822+ $ methodReflection = $ typeWithMethod ->getMethod ($ methodName , $ this );
48124823 $ parametersAcceptor = ParametersAcceptorSelector::selectFromArgs (
48134824 $ this ,
48144825 $ methodCall ->getArgs (),
0 commit comments