Skip to content

Commit dc6e2c0

Browse files
committed
Update ConstantArrayType.php
1 parent d6dab64 commit dc6e2c0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Type/Constant/ConstantArrayType.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,8 +582,11 @@ public function findTypeAndMethodNames(): array
582582

583583
public function hasOffsetValueType(Type $offsetType): TrinaryLogic
584584
{
585-
$allowedArrayKeys = AllowedArrayKeysTypes::getType();
586-
$offsetArrayKeyType = TypeCombinator::intersect($allowedArrayKeys, $offsetType)->toArrayKey();
585+
$offsetArrayKeyType = $offsetType->toArrayKey();
586+
if ($offsetArrayKeyType instanceof ErrorType) {
587+
$allowedArrayKeys = AllowedArrayKeysTypes::getType();
588+
$offsetArrayKeyType = TypeCombinator::intersect($allowedArrayKeys, $offsetType)->toArrayKey();
589+
}
587590

588591
return $this->recursiveHasOffsetValueType($offsetArrayKeyType);
589592
}

0 commit comments

Comments
 (0)