Skip to content

Commit

Permalink
Enum-case comparison: cheap checks first
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm committed May 10, 2024
1 parent 73521c3 commit 3ad6515
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Type/Enum/EnumCaseObjectType.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public function equals(Type $type): bool
return false;
}

return $this->getClassName() === $type->getClassName()
&& $this->enumCaseName === $type->enumCaseName;
return $this->enumCaseName === $type->enumCaseName &&
$this->getClassName() === $type->getClassName();
}

public function accepts(Type $type, bool $strictTypes): TrinaryLogic
Expand All @@ -71,8 +71,7 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
{
if ($type instanceof self) {
return TrinaryLogic::createFromBoolean(
$this->getClassName() === $type->getClassName()
&& $this->enumCaseName === $type->enumCaseName,
$this->enumCaseName === $type->enumCaseName && $this->getClassName() === $type->getClassName(),
);
}

Expand Down

0 comments on commit 3ad6515

Please sign in to comment.