Skip to content

Commit 6c85acc

Browse files
staabmondrejmirtes
authored andcommitted
Enum-case comparison: cheap checks first
1 parent 0463255 commit 6c85acc

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/Type/Enum/EnumCaseObjectType.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public function equals(Type $type): bool
5353
return false;
5454
}
5555

56-
return $this->getClassName() === $type->getClassName()
57-
&& $this->enumCaseName === $type->enumCaseName;
56+
return $this->enumCaseName === $type->enumCaseName &&
57+
$this->getClassName() === $type->getClassName();
5858
}
5959

6060
public function accepts(Type $type, bool $strictTypes): TrinaryLogic
@@ -71,8 +71,7 @@ public function isSuperTypeOf(Type $type): TrinaryLogic
7171
{
7272
if ($type instanceof self) {
7373
return TrinaryLogic::createFromBoolean(
74-
$this->getClassName() === $type->getClassName()
75-
&& $this->enumCaseName === $type->enumCaseName,
74+
$this->enumCaseName === $type->enumCaseName && $this->getClassName() === $type->getClassName(),
7675
);
7776
}
7877

0 commit comments

Comments
 (0)