@@ -5549,6 +5549,8 @@ private function processArgs(
55495549 $ throwPoints = [];
55505550 $ impurePoints = [];
55515551 $ isAlwaysTerminating = false ;
5552+ /** @var list<array{InvalidateExprNode[], string[]}> $deferredInvalidateExpressions */
5553+ $ deferredInvalidateExpressions = [];
55525554 foreach ($ args as $ i => $ arg ) {
55535555 $ assignByReference = false ;
55545556 $ parameter = null ;
@@ -5676,7 +5678,7 @@ private function processArgs(
56765678 $ scope = $ scope ->restoreThis ($ restoreThisScope );
56775679 }
56785680
5679- $ scope = $ this -> processImmediatelyCalledCallable ( $ scope , $ invalidateExpressions , $ uses) ;
5681+ $ deferredInvalidateExpressions [] = [ $ invalidateExpressions , $ uses] ;
56805682 } elseif ($ arg ->value instanceof Expr \ArrowFunction) {
56815683 if (
56825684 $ closureBindScope === null
@@ -5717,7 +5719,7 @@ private function processArgs(
57175719 if ($ exprType ->isCallable ()->yes ()) {
57185720 $ acceptors = $ exprType ->getCallableParametersAcceptors ($ scope );
57195721 if (count ($ acceptors ) === 1 ) {
5720- $ scope = $ this -> processImmediatelyCalledCallable ( $ scope , $ acceptors [0 ]->getInvalidateExpressions (), $ acceptors [0 ]->getUsedVariables ()) ;
5722+ $ deferredInvalidateExpressions [] = [ $ acceptors [0 ]->getInvalidateExpressions (), $ acceptors [0 ]->getUsedVariables ()] ;
57215723 if ($ this ->callCallbackImmediately ($ parameter , $ parameterType , $ calleeReflection )) {
57225724 $ callableThrowPoints = array_map (static fn (SimpleThrowPoint $ throwPoint ) => $ throwPoint ->isExplicit () ? InternalThrowPoint::createExplicit ($ scope , $ throwPoint ->getType (), $ arg ->value , $ throwPoint ->canContainAnyThrowable ()) : InternalThrowPoint::createImplicit ($ scope , $ arg ->value ), $ acceptors [0 ]->getThrowPoints ());
57235725 if (!$ this ->implicitThrows ) {
@@ -5747,6 +5749,10 @@ private function processArgs(
57475749 $ scope = $ scope ->restoreOriginalScopeAfterClosureBind ($ originalScope );
57485750 }
57495751
5752+ foreach ($ deferredInvalidateExpressions as [$ invalidateExpressions , $ uses ]) {
5753+ $ scope = $ this ->processImmediatelyCalledCallable ($ scope , $ invalidateExpressions , $ uses );
5754+ }
5755+
57505756 if ($ parameters !== null ) {
57515757 foreach ($ args as $ i => $ arg ) {
57525758 $ assignByReference = false ;
0 commit comments