We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 91c7507 commit 5400b58Copy full SHA for 5400b58
src/Type/Constant/ConstantArrayType.php
@@ -458,14 +458,24 @@ public function getOffsetValueType(Type $offsetType): Type
458
{
459
$offsetType = ArrayType::castToArrayKeyType($offsetType);
460
$matchingValueTypes = [];
461
+ $all = true;
462
foreach ($this->keyTypes as $i => $keyType) {
463
if ($keyType->isSuperTypeOf($offsetType)->no()) {
464
+ $all = false;
465
continue;
466
}
467
468
$matchingValueTypes[] = $this->valueTypes[$i];
469
470
471
+ if ($all) {
472
+ if (count($this->keyTypes) === 0) {
473
+ return new ErrorType();
474
+ }
475
+
476
+ return $this->getIterableValueType();
477
478
479
if (count($matchingValueTypes) > 0) {
480
$type = TypeCombinator::union(...$matchingValueTypes);
481
if ($type instanceof ErrorType) {
0 commit comments