Skip to content

Commit b7e4706

Browse files
committed
Update AssignHandler.php
1 parent 03b1809 commit b7e4706

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

src/Analyser/ExprHandler/AssignHandler.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ private function produceArrayDimFetchAssignValueToWrite(array $dimFetchStack, ar
941941
}
942942

943943
$reversedOffsetTypes = array_reverse($offsetTypes);
944+
$lastOffsetIndex = count($reversedOffsetTypes) - 1;
944945
foreach ($reversedOffsetTypes as $i => [$offsetType]) {
945946
/** @var Type $offsetValueType */
946947
$offsetValueType = array_pop($offsetValueTypeStack);
@@ -984,7 +985,7 @@ private function produceArrayDimFetchAssignValueToWrite(array $dimFetchStack, ar
984985
} else {
985986
// we iterate the offset-types in reversed order.
986987
$isLastDimFetchInChain = $i === 0;
987-
$isFirstDimFetchInChain = $i === count($reversedOffsetTypes) - 1;
988+
$isFirstDimFetchInChain = $i === $lastOffsetIndex;
988989

989990
$unionValues = $isLastDimFetchInChain;
990991
if (
@@ -1089,14 +1090,6 @@ private function isSameVariable(Expr $a, Expr $b): bool
10891090
return false;
10901091
}
10911092

1092-
/**
1093-
* When modifying a nested array dimension with a non-constant key,
1094-
* check if the composed value has genuinely incompatible key values
1095-
* compared to the existing item type. Only union when the old and
1096-
* new values for a shared key are incompatible (neither is a supertype
1097-
* of the other), which means unmodified elements still have their
1098-
* original types that cannot be represented by the composed value alone.
1099-
*/
11001093
private function shouldUnionExistingItemType(Type $offsetValueType, Type $composedValue): bool
11011094
{
11021095
$existingItemType = $offsetValueType->getIterableValueType();

0 commit comments

Comments
 (0)