@@ -153,7 +153,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
153153 $ scope = $ argsResult ->getScope ();
154154
155155 if ($ methodReflection !== null ) {
156- $ methodThrowPoint = $ this ->getMethodThrowPoint ($ methodReflection , $ parametersAcceptor , $ expr , $ scope );
156+ $ methodThrowPoint = $ this ->getMethodThrowPoint ($ methodReflection , $ parametersAcceptor , $ normalizedExpr , $ scope );
157157 if ($ methodThrowPoint !== null ) {
158158 $ throwPoints [] = $ methodThrowPoint ;
159159 }
@@ -235,29 +235,26 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
235235 return $ result ;
236236 }
237237
238- private function getMethodThrowPoint (MethodReflection $ methodReflection , ParametersAcceptor $ parametersAcceptor , MethodCall $ methodCall , MutatingScope $ scope ): ?InternalThrowPoint
238+ private function getMethodThrowPoint (MethodReflection $ methodReflection , ParametersAcceptor $ parametersAcceptor , MethodCall $ normalizedMethodCall , MutatingScope $ scope ): ?InternalThrowPoint
239239 {
240- $ normalizedMethodCall = ArgumentsNormalizer::reorderMethodArguments ($ parametersAcceptor , $ methodCall );
241- if ($ normalizedMethodCall !== null ) {
242- foreach ($ this ->dynamicThrowTypeExtensionProvider ->getDynamicMethodThrowTypeExtensions () as $ extension ) {
243- if (!$ extension ->isMethodSupported ($ methodReflection )) {
244- continue ;
245- }
246-
247- $ throwType = $ extension ->getThrowTypeFromMethodCall ($ methodReflection , $ normalizedMethodCall , $ scope );
248- if ($ throwType === null ) {
249- return null ;
250- }
240+ foreach ($ this ->dynamicThrowTypeExtensionProvider ->getDynamicMethodThrowTypeExtensions () as $ extension ) {
241+ if (!$ extension ->isMethodSupported ($ methodReflection )) {
242+ continue ;
243+ }
251244
252- return InternalThrowPoint::createExplicit ($ scope , $ throwType , $ methodCall , false );
245+ $ throwType = $ extension ->getThrowTypeFromMethodCall ($ methodReflection , $ normalizedMethodCall , $ scope );
246+ if ($ throwType === null ) {
247+ return null ;
253248 }
249+
250+ return InternalThrowPoint::createExplicit ($ scope , $ throwType , $ normalizedMethodCall , false );
254251 }
255252
256253 if (
257254 in_array ($ methodReflection ->getName (), ['invoke ' , 'invokeArgs ' ], true )
258255 && in_array ($ methodReflection ->getDeclaringClass ()->getName (), [ReflectionMethod::class, ReflectionFunction::class], true )
259256 ) {
260- return InternalThrowPoint::createImplicit ($ scope , $ methodCall );
257+ return InternalThrowPoint::createImplicit ($ scope , $ normalizedMethodCall );
261258 }
262259
263260 $ throwType = $ methodReflection ->getThrowType ();
@@ -270,12 +267,12 @@ private function getMethodThrowPoint(MethodReflection $methodReflection, Paramet
270267
271268 if ($ throwType !== null ) {
272269 if (!$ throwType ->isVoid ()->yes ()) {
273- return InternalThrowPoint::createExplicit ($ scope , $ throwType , $ methodCall , true );
270+ return InternalThrowPoint::createExplicit ($ scope , $ throwType , $ normalizedMethodCall , true );
274271 }
275272 } elseif ($ this ->implicitThrows ) {
276- $ methodReturnedType = $ scope ->getType ($ methodCall );
273+ $ methodReturnedType = $ scope ->getType ($ normalizedMethodCall );
277274 if (!(new ObjectType (Throwable::class))->isSuperTypeOf ($ methodReturnedType )->yes ()) {
278- return InternalThrowPoint::createImplicit ($ scope , $ methodCall );
275+ return InternalThrowPoint::createImplicit ($ scope , $ normalizedMethodCall );
279276 }
280277 }
281278
0 commit comments