Skip to content

Commit 76dd4ad

Browse files
authored
Merge pull request #81 from KartaviK/hotfix/is-valid-key-with-null
Fix validating key with null value
2 parents a8284c7 + 89efd4f commit 76dd4ad

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Enum.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public static function isValidKey($key)
150150
{
151151
$array = static::toArray();
152152

153-
return isset($array[$key]);
153+
return isset($array[$key]) || \array_key_exists($key, $array);
154154
}
155155

156156
/**

tests/EnumTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ public function testIsValidKey()
190190
{
191191
$this->assertTrue(EnumFixture::isValidKey('FOO'));
192192
$this->assertFalse(EnumFixture::isValidKey('BAZ'));
193+
$this->assertTrue(EnumFixture::isValidKey('PROBLEMATIC_NULL'));
193194
}
194195

195196
/**

0 commit comments

Comments
 (0)