@@ -2664,11 +2664,29 @@ static function (): void {
26642664 $ arrayArgNativeType = $ scope ->getNativeType ($ arrayArg );
26652665
26662666 $ isArrayPop = $ functionReflection ->getName () === 'array_pop ' ;
2667+ $ newType = $ isArrayPop ? $ arrayArgType ->popArray () : $ arrayArgType ->shiftArray ();
26672668 $ scope = $ scope ->invalidateExpression ($ arrayArg )->assignExpression (
26682669 $ arrayArg ,
2669- $ isArrayPop ? $ arrayArgType -> popArray () : $ arrayArgType -> shiftArray () ,
2670+ $ newType ,
26702671 $ isArrayPop ? $ arrayArgNativeType ->popArray () : $ arrayArgNativeType ->shiftArray (),
26712672 );
2673+
2674+ $ scope = $ this ->processAssignVar (
2675+ $ scope ,
2676+ $ stmt ,
2677+ $ arrayArg ,
2678+ new TypeExpr ($ newType ),
2679+ static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
2680+ if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
2681+ return ;
2682+ }
2683+
2684+ $ nodeCallback ($ node , $ scope );
2685+ },
2686+ $ context ,
2687+ static fn (MutatingScope $ scope ): ExpressionResult => new ExpressionResult ($ scope , false , false , [], []),
2688+ true ,
2689+ )->getScope ();
26722690 }
26732691
26742692 if (
@@ -2681,6 +2699,23 @@ static function (): void {
26812699
26822700 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
26832701 $ scope = $ scope ->invalidateExpression ($ arrayArg )->assignExpression ($ arrayArg , $ arrayType , $ arrayNativeType );
2702+
2703+ $ scope = $ this ->processAssignVar (
2704+ $ scope ,
2705+ $ stmt ,
2706+ $ arrayArg ,
2707+ new TypeExpr ($ arrayType ),
2708+ static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
2709+ if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
2710+ return ;
2711+ }
2712+
2713+ $ nodeCallback ($ node , $ scope );
2714+ },
2715+ $ context ,
2716+ static fn (MutatingScope $ scope ): ExpressionResult => new ExpressionResult ($ scope , false , false , [], []),
2717+ true ,
2718+ )->getScope ();
26842719 }
26852720
26862721 if (
@@ -2695,11 +2730,29 @@ static function (): void {
26952730 && $ functionReflection ->getName () === 'shuffle '
26962731 ) {
26972732 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2733+ $ newType = $ scope ->getType ($ arrayArg )->shuffleArray ();
26982734 $ scope = $ scope ->assignExpression (
26992735 $ arrayArg ,
2700- $ scope -> getType ( $ arrayArg )-> shuffleArray () ,
2736+ $ newType ,
27012737 $ scope ->getNativeType ($ arrayArg )->shuffleArray (),
27022738 );
2739+
2740+ $ scope = $ this ->processAssignVar (
2741+ $ scope ,
2742+ $ stmt ,
2743+ $ arrayArg ,
2744+ new TypeExpr ($ newType ),
2745+ static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
2746+ if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
2747+ return ;
2748+ }
2749+
2750+ $ nodeCallback ($ node , $ scope );
2751+ },
2752+ $ context ,
2753+ static fn (MutatingScope $ scope ): ExpressionResult => new ExpressionResult ($ scope , false , false , [], []),
2754+ true ,
2755+ )->getScope ();
27032756 }
27042757
27052758 if (
@@ -2715,11 +2768,29 @@ static function (): void {
27152768 $ lengthType = isset ($ expr ->getArgs ()[2 ]) ? $ scope ->getType ($ expr ->getArgs ()[2 ]->value ) : new NullType ();
27162769 $ replacementType = isset ($ expr ->getArgs ()[3 ]) ? $ scope ->getType ($ expr ->getArgs ()[3 ]->value ) : new ConstantArrayType ([], []);
27172770
2771+ $ newType = $ arrayArgType ->spliceArray ($ offsetType , $ lengthType , $ replacementType );
27182772 $ scope = $ scope ->invalidateExpression ($ arrayArg )->assignExpression (
27192773 $ arrayArg ,
2720- $ arrayArgType -> spliceArray ( $ offsetType , $ lengthType , $ replacementType ) ,
2774+ $ newType ,
27212775 $ arrayArgNativeType ->spliceArray ($ offsetType , $ lengthType , $ replacementType ),
27222776 );
2777+
2778+ $ scope = $ this ->processAssignVar (
2779+ $ scope ,
2780+ $ stmt ,
2781+ $ arrayArg ,
2782+ new TypeExpr ($ newType ),
2783+ static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
2784+ if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
2785+ return ;
2786+ }
2787+
2788+ $ nodeCallback ($ node , $ scope );
2789+ },
2790+ $ context ,
2791+ static fn (MutatingScope $ scope ): ExpressionResult => new ExpressionResult ($ scope , false , false , [], []),
2792+ true ,
2793+ )->getScope ();
27232794 }
27242795
27252796 if (
@@ -2728,11 +2799,29 @@ static function (): void {
27282799 && count ($ expr ->getArgs ()) >= 1
27292800 ) {
27302801 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2802+ $ newType = $ this ->getArraySortPreserveListFunctionType ($ scope ->getType ($ arrayArg ));
27312803 $ scope = $ scope ->assignExpression (
27322804 $ arrayArg ,
2733- $ this -> getArraySortPreserveListFunctionType ( $ scope -> getType ( $ arrayArg )) ,
2805+ $ newType ,
27342806 $ this ->getArraySortPreserveListFunctionType ($ scope ->getNativeType ($ arrayArg )),
27352807 );
2808+
2809+ $ scope = $ this ->processAssignVar (
2810+ $ scope ,
2811+ $ stmt ,
2812+ $ arrayArg ,
2813+ new TypeExpr ($ newType ),
2814+ static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
2815+ if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
2816+ return ;
2817+ }
2818+
2819+ $ nodeCallback ($ node , $ scope );
2820+ },
2821+ $ context ,
2822+ static fn (MutatingScope $ scope ): ExpressionResult => new ExpressionResult ($ scope , false , false , [], []),
2823+ true ,
2824+ )->getScope ();
27362825 }
27372826
27382827 if (
@@ -2741,11 +2830,29 @@ static function (): void {
27412830 && count ($ expr ->getArgs ()) >= 1
27422831 ) {
27432832 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2833+ $ newType = $ this ->getArraySortDoNotPreserveListFunctionType ($ scope ->getType ($ arrayArg ));
27442834 $ scope = $ scope ->assignExpression (
27452835 $ arrayArg ,
2746- $ this -> getArraySortDoNotPreserveListFunctionType ( $ scope -> getType ( $ arrayArg )) ,
2836+ $ newType ,
27472837 $ this ->getArraySortDoNotPreserveListFunctionType ($ scope ->getNativeType ($ arrayArg )),
27482838 );
2839+
2840+ $ scope = $ this ->processAssignVar (
2841+ $ scope ,
2842+ $ stmt ,
2843+ $ arrayArg ,
2844+ new TypeExpr ($ newType ),
2845+ static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
2846+ if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
2847+ return ;
2848+ }
2849+
2850+ $ nodeCallback ($ node , $ scope );
2851+ },
2852+ $ context ,
2853+ static fn (MutatingScope $ scope ): ExpressionResult => new ExpressionResult ($ scope , false , false , [], []),
2854+ true ,
2855+ )->getScope ();
27492856 }
27502857
27512858 if (
0 commit comments