Skip to content

Commit

Permalink
Prevent unnecessary isSuperTypeOf() calls
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Jan 30, 2024
1 parent e25e29e commit 142dc2f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Type/Constant/ConstantArrayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,12 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
return $result;
}

return $result->and(
$this->getKeyType()->isSuperTypeOf($type->getKeyType()),
$this->getItemType()->isSuperTypeOf($type->getItemType()),
);
$isKeySuperType = $this->getKeyType()->isSuperTypeOf($type->getKeyType());
if ($isKeySuperType->no()) {
return TrinaryLogic::createNo();
}

return $result->and($isKeySuperType, $this->getItemType()->isSuperTypeOf($type->getItemType()));
}

if ($type instanceof CompoundType) {
Expand Down

0 comments on commit 142dc2f

Please sign in to comment.