Skip to content

Commit

Permalink
[11.x] Handle empty values passed to enum_value() function instead of
Browse files Browse the repository at this point in the history
only empty string

fixes #53180

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
  • Loading branch information
crynobone committed Oct 16, 2024
1 parent 935cea4 commit 0be2671
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function defer(?callable $callback = null, ?string $name = null, bool $always =
*/
function enum_value($value, $default = null)
{
if (is_string($value) && empty($value)) {
if (empty($value)) {
return $value;
}

Expand Down
8 changes: 8 additions & 0 deletions tests/Support/SupportEnumValueFunctionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public function test_it_can_handle_enum_value($given, $expected)

public static function scalarDataProvider()
{
yield [null, null];
yield [0, 0];
yield ['0', '0'];
yield [false, false];
yield [1, 1];
yield ['1', '1'];
yield [true, true];
yield [[], []];
yield ['', ''];
yield ['laravel', 'laravel'];
yield [true, true];
Expand Down

0 comments on commit 0be2671

Please sign in to comment.