From 99278bd18d8b5cf7cb660e6687f59a01ca433fdf Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Wed, 14 Jul 2021 14:39:58 -0400 Subject: [PATCH 1/3] use str_contains over mb_strpos --- src/Illuminate/Support/Str.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 46d15353882f..8c833f4e7825 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -187,7 +187,7 @@ public static function contains($haystack, $needles, $ignoreCase = false) } foreach ((array) $needles as $needle) { - if ($needle !== '' && mb_strpos($haystack, $needle) !== false) { + if ($needle !== '' && str_contains($haystack, $needle)) { return true; } } From 0bb6453312aad0e81367142a2e1b8f63d1b3825a Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Wed, 14 Jul 2021 14:40:19 -0400 Subject: [PATCH 2/3] use str_ends_with over substr --- src/Illuminate/Support/Str.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 8c833f4e7825..8102b0542646 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -231,7 +231,7 @@ public static function endsWith($haystack, $needles) foreach ((array) $needles as $needle) { if ( $needle !== '' && $needle !== null - && substr($haystack, -strlen($needle)) === (string) $needle + && str_ends_with($haystack, $needle) ) { return true; } From 645fd0ea06030f450d84151ef40fc66f7dc15677 Mon Sep 17 00:00:00 2001 From: Tom Schlick Date: Wed, 14 Jul 2021 14:40:34 -0400 Subject: [PATCH 3/3] use str_starts_with over strncmp --- src/Illuminate/Support/Str.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index 8102b0542646..260b25a8ef6b 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -763,7 +763,7 @@ public static function snake($value, $delimiter = '_') public static function startsWith($haystack, $needles) { foreach ((array) $needles as $needle) { - if ((string) $needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0) { + if ((string) $needle !== '' && str_starts_with($haystack, $needle)) { return true; } }