Skip to content

Commit

Permalink
Revert "processAssignVar optimization for arrays"
Browse files Browse the repository at this point in the history
This reverts commit 5d2b6244dd2e17fb078037b56a91cf3982e974ea.
  • Loading branch information
ondrejmirtes committed Oct 26, 2024
1 parent 61c1c85 commit 34fb83d
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/Analyser/NodeScopeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5078,30 +5078,7 @@ private function processAssignVar(
$offsetNativeValueType = $varNativeType;

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

$nativeValueToWrite = $valueToWrite;
if (!$offsetValueType->equals($offsetNativeValueType) || !$valueToWrite->equals($nativeValueToWrite)) {
$nativeValueToWrite = $this->produceArrayDimFetchAssignValueToWrite($offsetNativeTypes, $offsetNativeValueType, $nativeValueToWrite);
} else {
foreach ($offsetTypes as $i => $offsetType) {
$offsetNativeType = $offsetNativeTypes[$i];
if ($offsetType === null) {
if ($offsetNativeType !== null) {
throw new ShouldNotHappenException();
}

continue;
} elseif ($offsetNativeType === null) {
throw new ShouldNotHappenException();
}
if ($offsetType->equals($offsetNativeType)) {
continue;
}

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

if ($varType->isArray()->yes() || !(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->yes()) {
if ($var instanceof Variable && is_string($var->name)) {
Expand Down

0 comments on commit 34fb83d

Please sign in to comment.