diff --git a/src/Illuminate/Support/helpers.php b/src/Illuminate/Support/helpers.php index 8ecb1eb3cffe..55cb69aa7990 100644 --- a/src/Illuminate/Support/helpers.php +++ b/src/Illuminate/Support/helpers.php @@ -50,6 +50,10 @@ function append_config(array $array) */ function blank($value) { + if ($value instanceof Closure) { + $value = value($value); + } + if (is_null($value)) { return true; } diff --git a/tests/Support/SupportHelpersTest.php b/tests/Support/SupportHelpersTest.php index ee67f818a3cd..8a382e597982 100644 --- a/tests/Support/SupportHelpersTest.php +++ b/tests/Support/SupportHelpersTest.php @@ -65,12 +65,16 @@ public function testBlank() $this->assertTrue(blank(' ')); $this->assertTrue(blank(new Stringable(''))); $this->assertTrue(blank(new Stringable(' '))); + $this->assertTrue(blank(fn () => null)); + $this->assertTrue(blank(fn () => '')); $this->assertFalse(blank(10)); $this->assertFalse(blank(true)); $this->assertFalse(blank(false)); $this->assertFalse(blank(0)); $this->assertFalse(blank(0.0)); $this->assertFalse(blank(new Stringable(' FooBar '))); + $this->assertFalse(blank(fn () => 0)); + $this->assertFalse(blank(fn () => 'FooBar')); $object = new SupportTestCountable(); $this->assertTrue(blank($object));