From e48422079a83e20c9476507b2b72a6cb28078355 Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Sat, 6 Nov 2021 10:01:12 -0300 Subject: [PATCH] [9.0] Change some strpos to str_contains --- src/Illuminate/Auth/Middleware/Authorize.php | 2 +- src/Illuminate/Foundation/AliasLoader.php | 2 +- src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php | 2 +- src/Illuminate/Routing/RouteUri.php | 4 ++-- src/Illuminate/Support/NamespacedItemResolver.php | 2 +- src/Illuminate/View/ViewName.php | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Illuminate/Auth/Middleware/Authorize.php b/src/Illuminate/Auth/Middleware/Authorize.php index aea9801dd345..f173d9eb0139 100644 --- a/src/Illuminate/Auth/Middleware/Authorize.php +++ b/src/Illuminate/Auth/Middleware/Authorize.php @@ -88,6 +88,6 @@ protected function getModel($request, $model) */ protected function isClassName($value) { - return strpos($value, '\\') !== false; + return str_contains($value, '\\'); } } diff --git a/src/Illuminate/Foundation/AliasLoader.php b/src/Illuminate/Foundation/AliasLoader.php index 0f12b6c74421..5146e443be97 100755 --- a/src/Illuminate/Foundation/AliasLoader.php +++ b/src/Illuminate/Foundation/AliasLoader.php @@ -70,7 +70,7 @@ public static function getInstance(array $aliases = []) */ public function load($alias) { - if (static::$facadeNamespace && strpos($alias, static::$facadeNamespace) === 0) { + if (static::$facadeNamespace && str_starts_with($alias, static::$facadeNamespace)) { $this->loadFacade($alias); return true; diff --git a/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php b/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php index 85a9596f9c57..21623a7fbee8 100644 --- a/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php +++ b/src/Illuminate/Foundation/Auth/Access/AuthorizesRequests.php @@ -49,7 +49,7 @@ public function authorizeForUser($user, $ability, $arguments = []) */ protected function parseAbilityAndArguments($ability, $arguments) { - if (is_string($ability) && strpos($ability, '\\') === false) { + if (is_string($ability) && ! str_contains($ability, '\\')) { return [$ability, $arguments]; } diff --git a/src/Illuminate/Routing/RouteUri.php b/src/Illuminate/Routing/RouteUri.php index ad69527e0b1a..f34e752f19f9 100644 --- a/src/Illuminate/Routing/RouteUri.php +++ b/src/Illuminate/Routing/RouteUri.php @@ -44,7 +44,7 @@ public static function parse($uri) $bindingFields = []; foreach ($matches[0] as $match) { - if (strpos($match, ':') === false) { + if (! str_contains($match, ':')) { continue; } @@ -52,7 +52,7 @@ public static function parse($uri) $bindingFields[$segments[0]] = $segments[1]; - $uri = strpos($match, '?') !== false + $uri = str_contains($match, '?') ? str_replace($match, '{'.$segments[0].'?}', $uri) : str_replace($match, '{'.$segments[0].'}', $uri); } diff --git a/src/Illuminate/Support/NamespacedItemResolver.php b/src/Illuminate/Support/NamespacedItemResolver.php index e9251db60976..5997c154035f 100755 --- a/src/Illuminate/Support/NamespacedItemResolver.php +++ b/src/Illuminate/Support/NamespacedItemResolver.php @@ -29,7 +29,7 @@ public function parseKey($key) // If the key does not contain a double colon, it means the key is not in a // namespace, and is just a regular configuration item. Namespaces are a // tool for organizing configuration items for things such as modules. - if (strpos($key, '::') === false) { + if (! str_contains($key, '::')) { $segments = explode('.', $key); $parsed = $this->parseBasicSegments($segments); diff --git a/src/Illuminate/View/ViewName.php b/src/Illuminate/View/ViewName.php index 9b803332fbb3..2808b134f4fc 100644 --- a/src/Illuminate/View/ViewName.php +++ b/src/Illuminate/View/ViewName.php @@ -14,7 +14,7 @@ public static function normalize($name) { $delimiter = ViewFinderInterface::HINT_PATH_DELIMITER; - if (strpos($name, $delimiter) === false) { + if (! str_contains($name, $delimiter)) { return str_replace('/', '.', $name); }