Skip to content

Commit f894e7b

Browse files
committed
fix
1 parent 21d99b4 commit f894e7b

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/Type/Constant/ConstantArrayType.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,6 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
366366
return $type->isIterableAtLeastOnce()->negate();
367367
}
368368

369-
if (
370-
$this->isList->yes()
371-
&& $type->isList->yes()
372-
&& count($this->keyTypes) !== count($type->keyTypes)
373-
&& count($type->optionalKeys) === 0
374-
) {
375-
return TrinaryLogic::createNo();
376-
}
377-
378369
$results = [];
379370
foreach ($this->keyTypes as $i => $keyType) {
380371
$hasOffset = $type->hasOffsetValueType($keyType);
@@ -396,6 +387,25 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
396387
$results[] = $isValueSuperType;
397388
}
398389

390+
if (
391+
$this->isList->yes()
392+
&& $type->isList->yes()
393+
&& count($this->keyTypes) !== count($type->keyTypes)
394+
&& count($type->optionalKeys) === 0
395+
) {
396+
$keepSeparate = true;
397+
foreach ($this->valueTypes as $valueType) {
398+
if ($valueType->isConstantValue()->yes()) {
399+
$keepSeparate = false;
400+
break;
401+
}
402+
}
403+
404+
if ($keepSeparate) {
405+
return TrinaryLogic::createNo();
406+
}
407+
}
408+
399409
return TrinaryLogic::createYes()->and(...$results);
400410
}
401411

0 commit comments

Comments
 (0)