Skip to content

Commit 30e6d0f

Browse files
committed
Update NodeScopeResolver.php
1 parent fafbdf8 commit 30e6d0f

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

src/Analyser/NodeScopeResolver.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6142,7 +6142,7 @@ private function isImplicitArrayCreation(array $dimFetchStack, Scope $scope): Tr
61426142
/**
61436143
* @param list<ArrayDimFetch> $dimFetchStack
61446144
* @param list<Type|null> $offsetTypes
6145-
* @param-out list<array{Expr, Type}> $additionalExpressions
6145+
* @param list<array{Expr, Type}> $additionalExpressions
61466146
*/
61476147
private function produceArrayDimFetchAssignValueToWrite(array $dimFetchStack, array $offsetTypes, Type $offsetValueType, Type $valueToWrite, Scope $scope, array &$additionalExpressions = []): Type
61486148
{
@@ -6234,16 +6234,23 @@ private function produceArrayDimFetchAssignValueToWrite(array $dimFetchStack, ar
62346234
}
62356235
}
62366236

6237-
$iterableValueType = $valueToWrite->getIterableValueType();
6238-
foreach($dimFetchStack as $dimFetch) {
6239-
if ($dimFetch->dim === null || $dimFetch->dim instanceof Node\Scalar) {
6240-
$additionalExpressions = [];
6241-
break;
6242-
}
6237+
if (count($dimFetchStack) > 1) {
6238+
$offsetValueType = $valueToWrite;
6239+
foreach ($dimFetchStack as $dimFetch) {
6240+
if ($dimFetch->dim === null) {
6241+
$additionalExpressions = [];
6242+
break;
6243+
}
62436244

6244-
$additionalExpressions[] = [$dimFetch, $iterableValueType];
6245+
$offsetType = $scope->getType($dimFetch->dim);
6246+
if (!$offsetValueType->hasOffsetValueType($offsetType)->yes()) {
6247+
$additionalExpressions = [];
6248+
break;
6249+
}
62456250

6246-
$iterableValueType = $iterableValueType->getIterableValueType();
6251+
$offsetValueType = $offsetValueType->getOffsetValueType($offsetType);
6252+
$additionalExpressions[] = [$dimFetch, $offsetValueType];
6253+
}
62476254
}
62486255

62496256
return $valueToWrite;

0 commit comments

Comments
 (0)