131131use stdClass ;
132132use Throwable ;
133133use function abs ;
134+ use function array_filter ;
134135use function array_key_exists ;
135136use function array_key_first ;
136137use function array_keys ;
@@ -186,7 +187,7 @@ class MutatingScope implements Scope
186187 * @param array<string, true> $currentlyAssignedExpressions
187188 * @param array<string, true> $currentlyAllowedUndefinedExpressions
188189 * @param array<string, ExpressionTypeHolder> $nativeExpressionTypes
189- * @param list<array{MethodReflection|FunctionReflection, ParameterReflection|null}> $inFunctionCallsStack
190+ * @param list<array{MethodReflection|FunctionReflection|null , ParameterReflection|null}> $inFunctionCallsStack
190191 */
191192 public function __construct (
192193 private InternalScopeFactory $ scopeFactory ,
@@ -1233,6 +1234,14 @@ private function resolveType(string $exprString, Expr $node): Type
12331234 foreach ($ arrayMapArgs as $ funcCallArg ) {
12341235 $ callableParameters [] = new DummyParameter ('item ' , $ this ->getType ($ funcCallArg ->value )->getIterableValueType (), false , PassedByReference::createNo (), false , null );
12351236 }
1237+ } else {
1238+ $ inFunctionCallsStackCount = count ($ this ->inFunctionCallsStack );
1239+ if ($ inFunctionCallsStackCount > 0 ) {
1240+ [, $ inParameter ] = $ this ->inFunctionCallsStack [$ inFunctionCallsStackCount - 1 ];
1241+ if ($ inParameter !== null ) {
1242+ $ callableParameters = $ this ->nodeScopeResolver ->createCallableParameters ($ this , $ node , null , $ inParameter ->getType ());
1243+ }
1244+ }
12361245 }
12371246
12381247 if ($ node instanceof Expr \ArrowFunction) {
@@ -2590,14 +2599,14 @@ public function hasExpressionType(Expr $node): TrinaryLogic
25902599 }
25912600
25922601 /**
2593- * @param MethodReflection|FunctionReflection $reflection
2602+ * @param MethodReflection|FunctionReflection|null $reflection
25942603 */
25952604 public function pushInFunctionCall ($ reflection , ?ParameterReflection $ parameter ): self
25962605 {
25972606 $ stack = $ this ->inFunctionCallsStack ;
25982607 $ stack [] = [$ reflection , $ parameter ];
25992608
2600- $ scope = $ this ->scopeFactory ->create (
2609+ return $ this ->scopeFactory ->create (
26012610 $ this ->context ,
26022611 $ this ->isDeclareStrictTypes (),
26032612 $ this ->getFunction (),
@@ -2615,19 +2624,14 @@ public function pushInFunctionCall($reflection, ?ParameterReflection $parameter)
26152624 $ this ->parentScope ,
26162625 $ this ->nativeTypesPromoted ,
26172626 );
2618- $ scope ->resolvedTypes = $ this ->resolvedTypes ;
2619- $ scope ->truthyScopes = $ this ->truthyScopes ;
2620- $ scope ->falseyScopes = $ this ->falseyScopes ;
2621-
2622- return $ scope ;
26232627 }
26242628
26252629 public function popInFunctionCall (): self
26262630 {
26272631 $ stack = $ this ->inFunctionCallsStack ;
26282632 array_pop ($ stack );
26292633
2630- $ scope = $ this ->scopeFactory ->create (
2634+ return $ this ->scopeFactory ->create (
26312635 $ this ->context ,
26322636 $ this ->isDeclareStrictTypes (),
26332637 $ this ->getFunction (),
@@ -2645,11 +2649,6 @@ public function popInFunctionCall(): self
26452649 $ this ->parentScope ,
26462650 $ this ->nativeTypesPromoted ,
26472651 );
2648- $ scope ->resolvedTypes = $ this ->resolvedTypes ;
2649- $ scope ->truthyScopes = $ this ->truthyScopes ;
2650- $ scope ->falseyScopes = $ this ->falseyScopes ;
2651-
2652- return $ scope ;
26532652 }
26542653
26552654 /** @api */
@@ -2677,12 +2676,18 @@ public function isInClassExists(string $className): bool
26772676
26782677 public function getFunctionCallStack (): array
26792678 {
2680- return array_map (static fn ($ values ) => $ values [0 ], $ this ->inFunctionCallsStack );
2679+ return array_values (array_filter (
2680+ array_map (static fn ($ values ) => $ values [0 ], $ this ->inFunctionCallsStack ),
2681+ static fn (FunctionReflection |MethodReflection |null $ reflection ) => $ reflection !== null ,
2682+ ));
26812683 }
26822684
26832685 public function getFunctionCallStackWithParameters (): array
26842686 {
2685- return $ this ->inFunctionCallsStack ;
2687+ return array_values (array_filter (
2688+ $ this ->inFunctionCallsStack ,
2689+ static fn ($ item ) => $ item [0 ] !== null ,
2690+ ));
26862691 }
26872692
26882693 /** @api */
0 commit comments