diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index f1ab26d383f..b77cdfe3bae 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -253,11 +253,15 @@ public static function is($pattern, $value) { $patterns = Arr::wrap($pattern); + $value = (string) $value; + if (empty($patterns)) { return false; } foreach ($patterns as $pattern) { + $pattern = (string) $pattern; + // If the given value is an exact match we can of course return true right // from the beginning. Otherwise, we will translate asterisks and do an // actual pattern match against the two strings to see if they match. diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index 6d0801c1df6..610dfcc00b5 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -272,6 +272,10 @@ public function testIs() // empty patterns $this->assertFalse(Str::is([], 'test')); + + $this->assertFalse(Str::is('', 0)); + $this->assertFalse(Str::is([null], 0)); + $this->assertTrue(Str::is([null], null)); } /**