Skip to content

Commit 2c9273e

Browse files
herndlmondrejmirtes
authored andcommitted
Avoid calling describe on ConstantArrayTypes
1 parent 6b6f310 commit 2c9273e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Analyser/MutatingScope.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3088,7 +3088,7 @@ protected function getTypeFromArrayDimFetch(
30883088
throw new ShouldNotHappenException();
30893089
}
30903090

3091-
if ((new ObjectType(ArrayAccess::class))->isSuperTypeOf($offsetAccessibleType)->yes()) {
3091+
if (!$offsetAccessibleType->isArray()->yes() && (new ObjectType(ArrayAccess::class))->isSuperTypeOf($offsetAccessibleType)->yes()) {
30923092
return $this->getType(
30933093
new MethodCall(
30943094
$arrayDimFetch->var,

src/Analyser/NodeScopeResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,7 +3306,7 @@ private function processAssignVar(
33063306
$valueToWrite = $offsetValueType->setOffsetValueType($offsetType, $valueToWrite, $i === 0);
33073307
}
33083308

3309-
if (!(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->yes()) {
3309+
if ($varType->isArray()->yes() || !(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->yes()) {
33103310
if ($var instanceof Variable && is_string($var->name)) {
33113311
$scope = $scope->assignVariable($var->name, $valueToWrite);
33123312
} else {
@@ -3334,7 +3334,7 @@ private function processAssignVar(
33343334
}
33353335
}
33363336

3337-
if (!(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->no()) {
3337+
if (!$varType->isArray()->yes() && !(new ObjectType(ArrayAccess::class))->isSuperTypeOf($varType)->no()) {
33383338
$throwPoints = array_merge($throwPoints, $this->processExprNode(
33393339
new MethodCall($var, 'offsetSet'),
33403340
$scope,

0 commit comments

Comments
 (0)