From f2217ed923578663778922d2d5b0db4d1645f46a Mon Sep 17 00:00:00 2001 From: Shuvro Roy Date: Mon, 19 Jul 2021 22:58:11 +0600 Subject: [PATCH] update php8 string function --- src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php | 6 +++--- src/Illuminate/Support/Str.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php index af89e47e0a28..211cf5030984 100644 --- a/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php +++ b/src/Illuminate/Database/Eloquent/Concerns/HasAttributes.php @@ -669,8 +669,8 @@ protected function serializeClassCastableAttribute($key, $value) */ protected function isCustomDateTimeCast($cast) { - return strncmp($cast, 'date:', 5) === 0 || - strncmp($cast, 'datetime:', 9) === 0; + return str_starts_with($cast, 'date:') || + str_starts_with($cast, 'datetime:'); } /** @@ -681,7 +681,7 @@ protected function isCustomDateTimeCast($cast) */ protected function isDecimalCast($cast) { - return strncmp($cast, 'decimal:', 8) === 0; + return str_starts_with($cast, 'decimal:'); } /** diff --git a/src/Illuminate/Support/Str.php b/src/Illuminate/Support/Str.php index b5d8b2694a13..7739b78fe603 100644 --- a/src/Illuminate/Support/Str.php +++ b/src/Illuminate/Support/Str.php @@ -181,7 +181,7 @@ public static function camel($value) public static function contains($haystack, $needles) { foreach ((array) $needles as $needle) { - if ($needle !== '' && mb_strpos($haystack, $needle) !== false) { + if ($needle !== '' && str_contains($haystack, $needle)) { return true; } } @@ -699,7 +699,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; } }