Skip to content

Commit 142dc2f

Browse files
staabmondrejmirtes
authored andcommitted
Prevent unnecessary isSuperTypeOf() calls
1 parent e25e29e commit 142dc2f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Type/Constant/ConstantArrayType.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -405,10 +405,12 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
405405
return $result;
406406
}
407407

408-
return $result->and(
409-
$this->getKeyType()->isSuperTypeOf($type->getKeyType()),
410-
$this->getItemType()->isSuperTypeOf($type->getItemType()),
411-
);
408+
$isKeySuperType = $this->getKeyType()->isSuperTypeOf($type->getKeyType());
409+
if ($isKeySuperType->no()) {
410+
return TrinaryLogic::createNo();
411+
}
412+
413+
return $result->and($isKeySuperType, $this->getItemType()->isSuperTypeOf($type->getItemType()));
412414
}
413415

414416
if ($type instanceof CompoundType) {

0 commit comments

Comments
 (0)