From d67bf032134a740fa6d39c55c9f76327e4bf4429 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 29 Sep 2021 15:12:32 +0200 Subject: [PATCH 1/3] Fix casting to string on PHP 8.1 --- src/Illuminate/Support/Str.php | 3 +++ tests/Support/SupportStrTest.php | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index f1ab26d383f2..b1a69b5c27f4 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -252,12 +252,15 @@ public static function finish($value, $cap) 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 6d0801c1df63..5c656fbfd652 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -272,6 +272,8 @@ public function testIs() // empty patterns $this->assertFalse(Str::is([], 'test')); + $this->assertFalse(Str::is([null], 0)); + $this->assertTrue(Str::is([null], null)); } /** From 977d6928295403e17f2b42c980608e54ca517f48 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Wed, 29 Sep 2021 15:13:35 +0200 Subject: [PATCH 2/3] Update tests --- tests/Support/SupportStrTest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/Support/SupportStrTest.php b/tests/Support/SupportStrTest.php index 5c656fbfd652..610dfcc00b55 100755 --- a/tests/Support/SupportStrTest.php +++ b/tests/Support/SupportStrTest.php @@ -272,6 +272,8 @@ 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)); } From b9691415bb6c39645d4d634f16285a685a8e7d0e Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Wed, 29 Sep 2021 08:18:35 -0500 Subject: [PATCH 3/3] Update Str.php --- src/Illuminate/Support/Str.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index b1a69b5c27f4..b77cdfe3baeb 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -252,6 +252,7 @@ public static function finish($value, $cap) public static function is($pattern, $value) { $patterns = Arr::wrap($pattern); + $value = (string) $value; if (empty($patterns)) {