@@ -2660,22 +2660,14 @@ static function (): void {
26602660 ) {
26612661 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
26622662
2663- $ arrayArgType = $ scope ->getType ($ arrayArg );
2664- $ arrayArgNativeType = $ scope ->getNativeType ($ arrayArg );
2665-
26662663 $ isArrayPop = $ functionReflection ->getName () === 'array_pop ' ;
2667- $ newType = $ isArrayPop ? $ arrayArgType ->popArray () : $ arrayArgType ->shiftArray ();
2668- $ scope = $ scope ->invalidateExpression ($ arrayArg )->assignExpression (
2669- $ arrayArg ,
2670- $ newType ,
2671- $ isArrayPop ? $ arrayArgNativeType ->popArray () : $ arrayArgNativeType ->shiftArray (),
2672- );
2664+ $ arrayArgType = $ scope ->getType ($ arrayArg );
26732665
26742666 $ scope = $ this ->processAssignVar (
26752667 $ scope ,
26762668 $ stmt ,
26772669 $ arrayArg ,
2678- new TypeExpr ($ newType ),
2670+ new TypeExpr ($ isArrayPop ? $ arrayArgType -> popArray () : $ arrayArgType -> shiftArray () ),
26792671 static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
26802672 if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
26812673 return ;
@@ -2694,17 +2686,13 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
26942686 && in_array ($ functionReflection ->getName (), ['array_push ' , 'array_unshift ' ], true )
26952687 && count ($ expr ->getArgs ()) >= 2
26962688 ) {
2697- $ arrayType = $ this ->getArrayFunctionAppendingType ($ functionReflection , $ scope , $ expr );
2698- $ arrayNativeType = $ this ->getArrayFunctionAppendingType ($ functionReflection , $ scope ->doNotTreatPhpDocTypesAsCertain (), $ expr );
2699-
27002689 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2701- $ scope = $ scope ->invalidateExpression ($ arrayArg )->assignExpression ($ arrayArg , $ arrayType , $ arrayNativeType );
27022690
27032691 $ scope = $ this ->processAssignVar (
27042692 $ scope ,
27052693 $ stmt ,
27062694 $ arrayArg ,
2707- new TypeExpr ($ arrayType ),
2695+ new TypeExpr ($ this -> getArrayFunctionAppendingType ( $ functionReflection , $ scope , $ expr ) ),
27082696 static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
27092697 if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
27102698 return ;
@@ -2730,18 +2718,12 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
27302718 && $ functionReflection ->getName () === 'shuffle '
27312719 ) {
27322720 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2733- $ newType = $ scope ->getType ($ arrayArg )->shuffleArray ();
2734- $ scope = $ scope ->assignExpression (
2735- $ arrayArg ,
2736- $ newType ,
2737- $ scope ->getNativeType ($ arrayArg )->shuffleArray (),
2738- );
27392721
27402722 $ scope = $ this ->processAssignVar (
27412723 $ scope ,
27422724 $ stmt ,
27432725 $ arrayArg ,
2744- new TypeExpr ($ newType ),
2726+ new TypeExpr ($ scope -> getType ( $ arrayArg )-> shuffleArray () ),
27452727 static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
27462728 if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
27472729 return ;
@@ -2762,24 +2744,16 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
27622744 ) {
27632745 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
27642746 $ arrayArgType = $ scope ->getType ($ arrayArg );
2765- $ arrayArgNativeType = $ scope ->getNativeType ($ arrayArg );
27662747
27672748 $ offsetType = $ scope ->getType ($ expr ->getArgs ()[1 ]->value );
27682749 $ lengthType = isset ($ expr ->getArgs ()[2 ]) ? $ scope ->getType ($ expr ->getArgs ()[2 ]->value ) : new NullType ();
27692750 $ replacementType = isset ($ expr ->getArgs ()[3 ]) ? $ scope ->getType ($ expr ->getArgs ()[3 ]->value ) : new ConstantArrayType ([], []);
27702751
2771- $ newType = $ arrayArgType ->spliceArray ($ offsetType , $ lengthType , $ replacementType );
2772- $ scope = $ scope ->invalidateExpression ($ arrayArg )->assignExpression (
2773- $ arrayArg ,
2774- $ newType ,
2775- $ arrayArgNativeType ->spliceArray ($ offsetType , $ lengthType , $ replacementType ),
2776- );
2777-
27782752 $ scope = $ this ->processAssignVar (
27792753 $ scope ,
27802754 $ stmt ,
27812755 $ arrayArg ,
2782- new TypeExpr ($ newType ),
2756+ new TypeExpr ($ arrayArgType -> spliceArray ( $ offsetType , $ lengthType , $ replacementType ) ),
27832757 static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
27842758 if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
27852759 return ;
@@ -2799,18 +2773,12 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
27992773 && count ($ expr ->getArgs ()) >= 1
28002774 ) {
28012775 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2802- $ newType = $ this ->getArraySortPreserveListFunctionType ($ scope ->getType ($ arrayArg ));
2803- $ scope = $ scope ->assignExpression (
2804- $ arrayArg ,
2805- $ newType ,
2806- $ this ->getArraySortPreserveListFunctionType ($ scope ->getNativeType ($ arrayArg )),
2807- );
28082776
28092777 $ scope = $ this ->processAssignVar (
28102778 $ scope ,
28112779 $ stmt ,
28122780 $ arrayArg ,
2813- new TypeExpr ($ newType ),
2781+ new TypeExpr ($ this -> getArraySortPreserveListFunctionType ( $ scope -> getType ( $ arrayArg )) ),
28142782 static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
28152783 if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
28162784 return ;
@@ -2830,18 +2798,12 @@ static function (Node $node, Scope $scope) use ($nodeCallback): void {
28302798 && count ($ expr ->getArgs ()) >= 1
28312799 ) {
28322800 $ arrayArg = $ expr ->getArgs ()[0 ]->value ;
2833- $ newType = $ this ->getArraySortDoNotPreserveListFunctionType ($ scope ->getType ($ arrayArg ));
2834- $ scope = $ scope ->assignExpression (
2835- $ arrayArg ,
2836- $ newType ,
2837- $ this ->getArraySortDoNotPreserveListFunctionType ($ scope ->getNativeType ($ arrayArg )),
2838- );
28392801
28402802 $ scope = $ this ->processAssignVar (
28412803 $ scope ,
28422804 $ stmt ,
28432805 $ arrayArg ,
2844- new TypeExpr ($ newType ),
2806+ new TypeExpr ($ this -> getArraySortDoNotPreserveListFunctionType ( $ scope -> getType ( $ arrayArg )) ),
28452807 static function (Node $ node , Scope $ scope ) use ($ nodeCallback ): void {
28462808 if (!$ node instanceof PropertyAssignNode && !$ node instanceof VariableAssignNode) {
28472809 return ;
0 commit comments