@@ -267,6 +267,7 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
267267 }
268268 }
269269
270+ $ scopeBeforeArgs = $ scope ;
270271 $ argsResult = $ nodeScopeResolver ->processArgs ($ stmt , $ functionReflection , null , $ parametersAcceptor , $ normalizedExpr , $ scope , $ storage , $ nodeCallbackForArgs , $ context );
271272 $ scope = $ argsResult ->getScope ();
272273 $ hasYield = $ argsResult ->hasYield ();
@@ -395,8 +396,8 @@ public function processExpr(NodeScopeResolver $nodeScopeResolver, Stmt $stmt, Ex
395396 $ stmt ,
396397 $ arrayArg ,
397398 new NativeTypeExpr (
398- $ this ->getArrayFunctionAppendingType ($ functionReflection , $ scope , $ normalizedExpr ),
399- $ this ->getArrayFunctionAppendingType ($ functionReflection , $ scope ->doNotTreatPhpDocTypesAsCertain (), $ normalizedExpr ),
399+ $ this ->getArrayFunctionAppendingType ($ functionReflection , $ scope , $ scopeBeforeArgs , $ normalizedExpr ),
400+ $ this ->getArrayFunctionAppendingType ($ functionReflection , $ scope ->doNotTreatPhpDocTypesAsCertain (), $ scopeBeforeArgs -> doNotTreatPhpDocTypesAsCertain (), $ normalizedExpr ),
400401 ),
401402 $ nodeCallback ,
402403 )->getScope ();
@@ -621,7 +622,7 @@ private function getFunctionThrowPoint(
621622 return null ;
622623 }
623624
624- private function getArrayFunctionAppendingType (FunctionReflection $ functionReflection , Scope $ scope , FuncCall $ expr ): Type
625+ private function getArrayFunctionAppendingType (FunctionReflection $ functionReflection , Scope $ scope , Scope $ valuesScope , FuncCall $ expr ): Type
625626 {
626627 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
627628 $ arrayType = $ scope ->getType ($ arrayArg );
@@ -667,7 +668,7 @@ private function getArrayFunctionAppendingType(FunctionReflection $functionRefle
667668 $ arrayTypeBuilder = $ prepend ? ConstantArrayTypeBuilder::createEmpty () : ConstantArrayTypeBuilder::createFromConstantArray ($ constantArray );
668669
669670 $ setOffsetValueTypes (
670- $ scope ,
671+ $ valuesScope ,
671672 $ callArgs ,
672673 static function (?Type $ offsetType , Type $ valueType , bool $ optional ) use (&$ arrayTypeBuilder ): void {
673674 $ arrayTypeBuilder ->setOffsetValueType ($ offsetType , $ valueType , $ optional );
@@ -707,7 +708,7 @@ static function (?Type $offsetType, Type $valueType, bool $optional) use (&$arra
707708 }
708709
709710 $ setOffsetValueTypes (
710- $ scope ,
711+ $ valuesScope ,
711712 $ callArgs ,
712713 static function (?Type $ offsetType , Type $ valueType , bool $ optional ) use (&$ arrayType ): void {
713714 $ isIterableAtLeastOnce = $ arrayType ->isIterableAtLeastOnce ()->yes () || !$ optional ;
0 commit comments