We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents ca4a819 + 0f87634 commit 8c5649eCopy full SHA for 8c5649e
src/Enum.php
@@ -80,9 +80,9 @@ public function __toString()
80
*
81
* @return bool True if Enums are equal, false if not equal
82
*/
83
- final public function equals(Enum $enum)
+ final public function equals(Enum $enum = null)
84
{
85
- return $this->getValue() === $enum->getValue() && get_called_class() == get_class($enum);
+ return $enum !== null && $this->getValue() === $enum->getValue() && get_called_class() == get_class($enum);
86
}
87
88
/**
tests/EnumTest.php
@@ -223,6 +223,7 @@ public function testEquals()
223
$this->assertTrue($foo->equals($foo));
224
$this->assertFalse($foo->equals($number));
225
$this->assertTrue($foo->equals($anotherFoo));
226
+ $this->assertFalse($foo->equals(null));
227
228
229
0 commit comments