Skip to content

Commit ea88244

Browse files
committed
fix
1 parent 4a54afc commit ea88244

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
@@ -367,15 +367,6 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
367367
return $type->isIterableAtLeastOnce()->negate();
368368
}
369369

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

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

0 commit comments

Comments
 (0)