Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 26, 2024
1 parent 5d2512a commit 7869053
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5079,10 +5079,10 @@ private function processAssignVar(

$valueToWrite = $this->produceArrayDimFetchAssignValueToWrite($offsetTypes, $offsetValueType, $valueToWrite);

$nativeValueToWrite = $valueToWrite;
if (!$offsetValueType->equals($offsetNativeValueType) || !$valueToWrite->equals($nativeValueToWrite)) {
$nativeValueToWrite = $this->produceArrayDimFetchAssignValueToWrite($offsetNativeTypes, $offsetNativeValueType, $nativeValueToWrite);
} else {
$rewritten = false;
foreach ($offsetTypes as $i => $offsetType) {
$offsetNativeType = $offsetNativeTypes[$i];
if ($offsetType === null) {
Expand All @@ -5099,8 +5099,13 @@ private function processAssignVar(
}

$nativeValueToWrite = $this->produceArrayDimFetchAssignValueToWrite($offsetNativeTypes, $offsetNativeValueType, $nativeValueToWrite);
$rewritten = true;
break;
}

if (!$rewritten) {
$nativeValueToWrite = $valueToWrite;
}
}

if ($varType->isArray()->yes() || !(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->yes()) {
Expand Down

0 comments on commit 7869053

Please sign in to comment.