Skip to content

Commit

Permalink
Merge branch refs/heads/1.12.x into 2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
phpstan-bot authored Oct 26, 2024
2 parents 3155acd + 7869053 commit 830b6d5
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 @@ -5073,10 +5073,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 @@ -5093,8 +5093,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 830b6d5

Please sign in to comment.