@@ -5384,12 +5384,12 @@ private function processAssignVar(
5384
5384
}
5385
5385
5386
5386
if ($ dimExpr === null ) {
5387
- $ offsetTypes [] = null ;
5388
- $ offsetNativeTypes [] = null ;
5387
+ $ offsetTypes [] = [ null , TrinaryLogic:: createYes ()] ;
5388
+ $ offsetNativeTypes [] = [ null , TrinaryLogic:: createYes ()] ;
5389
5389
5390
5390
} else {
5391
- $ offsetTypes [] = $ scope ->getType ($ dimExpr );
5392
- $ offsetNativeTypes [] = $ scope ->getNativeType ($ dimExpr );
5391
+ $ offsetTypes [] = [ $ scope ->getType ($ dimExpr ), $ scope -> getType ( $ dimFetch -> var )-> hasOffsetValueType ( $ scope -> getType ( $ dimExpr ))-> or ( $ scope -> hasExpressionType ( $ dimFetch ))] ;
5392
+ $ offsetNativeTypes [] = [ $ scope ->getNativeType ($ dimExpr ), $ scope -> getNativeType ( $ dimFetch -> var )-> hasOffsetValueType ( $ scope -> getNativeType ( $ dimExpr ))-> or ( $ scope -> hasExpressionType ( $ dimFetch ))] ;
5393
5393
5394
5394
if ($ enterExpressionAssign ) {
5395
5395
$ scope ->enterExpressionAssign ($ dimExpr );
@@ -5436,8 +5436,8 @@ private function processAssignVar(
5436
5436
$ nativeValueToWrite = $ this ->produceArrayDimFetchAssignValueToWrite ($ offsetNativeTypes , $ offsetNativeValueType , $ nativeValueToWrite );
5437
5437
} else {
5438
5438
$ rewritten = false ;
5439
- foreach ($ offsetTypes as $ i => $ offsetType ) {
5440
- $ offsetNativeType = $ offsetNativeTypes [$ i ];
5439
+ foreach ($ offsetTypes as $ i => [ $ offsetType] ) {
5440
+ [ $ offsetNativeType] = $ offsetNativeTypes [$ i ];
5441
5441
if ($ offsetType === null ) {
5442
5442
if ($ offsetNativeType !== null ) {
5443
5443
throw new ShouldNotHappenException ();
@@ -5752,18 +5752,16 @@ static function (): void {
5752
5752
}
5753
5753
5754
5754
/**
5755
- * @param list<Type|null> $offsetTypes
5755
+ * @param list<array{ Type|null, TrinaryLogic} > $offsetTypes
5756
5756
*/
5757
5757
private function produceArrayDimFetchAssignValueToWrite (array $ offsetTypes , Type $ offsetValueType , Type $ valueToWrite ): Type
5758
5758
{
5759
5759
$ offsetValueTypeStack = [[$ offsetValueType , TrinaryLogic::createYes ()]];
5760
- foreach (array_slice ($ offsetTypes , 0 , -1 ) as $ offsetType ) {
5760
+ foreach (array_slice ($ offsetTypes , 0 , -1 ) as [ $ offsetType, $ has ] ) {
5761
5761
if ($ offsetType === null ) {
5762
- $ has = TrinaryLogic::createYes ();
5763
5762
$ offsetValueType = new ConstantArrayType ([], []);
5764
5763
5765
5764
} else {
5766
- $ has = $ offsetValueType ->hasOffsetValueType ($ offsetType );
5767
5765
$ offsetValueType = $ offsetValueType ->getOffsetValueType ($ offsetType );
5768
5766
if ($ offsetValueType instanceof ErrorType) {
5769
5767
$ offsetValueType = new ConstantArrayType ([], []);
@@ -5773,7 +5771,7 @@ private function produceArrayDimFetchAssignValueToWrite(array $offsetTypes, Type
5773
5771
$ offsetValueTypeStack [] = [$ offsetValueType , $ has ];
5774
5772
}
5775
5773
5776
- foreach (array_reverse ($ offsetTypes ) as $ i => $ offsetType ) {
5774
+ foreach (array_reverse ($ offsetTypes ) as $ i => [ $ offsetType] ) {
5777
5775
/** @var Type $offsetValueType */
5778
5776
[$ offsetValueType , $ has ] = array_pop ($ offsetValueTypeStack );
5779
5777
if (
0 commit comments