diff --git a/Client.php b/Client.php index f0dd66ece8..5c9169ce4b 100644 --- a/Client.php +++ b/Client.php @@ -85,7 +85,7 @@ protected function getScript($request) $requires = ''; foreach (get_declared_classes() as $class) { - if (0 === strpos($class, 'ComposerAutoloaderInit')) { + if (str_starts_with($class, 'ComposerAutoloaderInit')) { $r = new \ReflectionClass($class); $file = \dirname($r->getFileName(), 2).'/autoload.php'; if (file_exists($file)) { diff --git a/Config/FileLocator.php b/Config/FileLocator.php index 5dc82b33dc..a302419701 100644 --- a/Config/FileLocator.php +++ b/Config/FileLocator.php @@ -70,11 +70,11 @@ public function locate($file, $currentPath = null, $first = true) // no need to trigger deprecations when the loaded file is given as absolute path foreach ($this->paths as $deprecatedPath) { foreach ((array) $locations as $location) { - if (null !== $currentPath && 0 === strpos($location, $currentPath)) { + if (null !== $currentPath && str_starts_with($location, $currentPath)) { return $locations; } - if (0 === strpos($location, $deprecatedPath) && (null === $currentPath || false === strpos($location, $currentPath))) { + if (str_starts_with($location, $deprecatedPath) && (null === $currentPath || !str_contains($location, $currentPath))) { $deprecation = sprintf('Loading the file "%s" from the global resource directory "%s" is deprecated since Symfony 4.4 and will be removed in 5.0.', $file, $deprecatedPath); } } diff --git a/Controller/ControllerResolver.php b/Controller/ControllerResolver.php index 9c2fdd9807..c3df8f9571 100644 --- a/Controller/ControllerResolver.php +++ b/Controller/ControllerResolver.php @@ -106,7 +106,7 @@ public function getController(Request $request) */ protected function createController($controller) { - if (false === strpos($controller, '::')) { + if (!str_contains($controller, '::')) { $controller = $this->instantiateController($controller); if (!\is_callable($controller)) { @@ -154,7 +154,7 @@ protected function instantiateController($class) private function getControllerError($callable): string { if (\is_string($callable)) { - if (false !== strpos($callable, '::')) { + if (str_contains($callable, '::')) { $callable = explode('::', $callable, 2); } else { return sprintf('Function "%s" does not exist.', $callable); @@ -195,7 +195,7 @@ private function getControllerError($callable): string foreach ($collection as $item) { $lev = levenshtein($method, $item); - if ($lev <= \strlen($method) / 3 || false !== strpos($item, $method)) { + if ($lev <= \strlen($method) / 3 || str_contains($item, $method)) { $alternatives[] = $item; } } diff --git a/DataCollector/DumpDataCollector.php b/DataCollector/DumpDataCollector.php index a3cf2147cb..a66224b6f4 100644 --- a/DataCollector/DumpDataCollector.php +++ b/DataCollector/DumpDataCollector.php @@ -120,11 +120,11 @@ public function collect(Request $request, Response $response/*, \Throwable $exce if (!$this->requestStack || !$response->headers->has('X-Debug-Token') || $response->isRedirection() - || ($response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html')) + || ($response->headers->has('Content-Type') && !str_contains($response->headers->get('Content-Type'), 'html')) || 'html' !== $request->getRequestFormat() || false === strripos($response->getContent(), '') ) { - if ($response->headers->has('Content-Type') && false !== strpos($response->headers->get('Content-Type'), 'html')) { + if ($response->headers->has('Content-Type') && str_contains($response->headers->get('Content-Type'), 'html')) { $dumper = new HtmlDumper('php://output', $this->charset); $dumper->setDisplayOptions(['fileLinkFormat' => $this->fileLinkFormat]); } else { diff --git a/DataCollector/MemoryDataCollector.php b/DataCollector/MemoryDataCollector.php index 7ffcdab41d..ff0ccd9fa9 100644 --- a/DataCollector/MemoryDataCollector.php +++ b/DataCollector/MemoryDataCollector.php @@ -104,9 +104,9 @@ private function convertToBytes(string $memoryLimit) $memoryLimit = strtolower($memoryLimit); $max = strtolower(ltrim($memoryLimit, '+')); - if (0 === strpos($max, '0x')) { + if (str_starts_with($max, '0x')) { $max = \intval($max, 16); - } elseif (0 === strpos($max, '0')) { + } elseif (str_starts_with($max, '0')) { $max = \intval($max, 8); } else { $max = (int) $max; diff --git a/DataCollector/RequestDataCollector.php b/DataCollector/RequestDataCollector.php index f40c2fb9f6..2a3f6ce514 100644 --- a/DataCollector/RequestDataCollector.php +++ b/DataCollector/RequestDataCollector.php @@ -394,7 +394,7 @@ public function getName() */ protected function parseController($controller) { - if (\is_string($controller) && false !== strpos($controller, '::')) { + if (\is_string($controller) && str_contains($controller, '::')) { $controller = explode('::', $controller); } @@ -431,7 +431,7 @@ protected function parseController($controller) 'line' => $r->getStartLine(), ]; - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return $controller; } $controller['method'] = $r->name; diff --git a/Debug/FileLinkFormatter.php b/Debug/FileLinkFormatter.php index 79755a8ad7..27c71708b2 100644 --- a/Debug/FileLinkFormatter.php +++ b/Debug/FileLinkFormatter.php @@ -50,7 +50,7 @@ public function format($file, $line) { if ($fmt = $this->getFileLinkFormat()) { for ($i = 1; isset($fmt[$i]); ++$i) { - if (0 === strpos($file, $k = $fmt[$i++])) { + if (str_starts_with($file, $k = $fmt[$i++])) { $file = substr_replace($file, $fmt[$i], 0, \strlen($k)); break; } diff --git a/DependencyInjection/AddAnnotatedClassesToCachePass.php b/DependencyInjection/AddAnnotatedClassesToCachePass.php index 17a5f7f02e..9825151ab0 100644 --- a/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -62,7 +62,7 @@ private function expandClasses(array $patterns, array $classes): array // Explicit classes declared in the patterns are returned directly foreach ($patterns as $key => $pattern) { - if (!str_ends_with($pattern, '\\') && false === strpos($pattern, '*')) { + if (!str_ends_with($pattern, '\\') && !str_contains($pattern, '*')) { unset($patterns[$key]); $expanded[] = ltrim($pattern, '\\'); } @@ -127,10 +127,10 @@ private function patternsToRegexps(array $patterns): array private function matchAnyRegexps(string $class, array $regexps): bool { - $isTest = false !== strpos($class, 'Test'); + $isTest = str_contains($class, 'Test'); foreach ($regexps as $regex) { - if ($isTest && false === strpos($regex, 'Test')) { + if ($isTest && !str_contains($regex, 'Test')) { continue; } diff --git a/EventListener/AbstractTestSessionListener.php b/EventListener/AbstractTestSessionListener.php index 86f179add7..25be3b3907 100644 --- a/EventListener/AbstractTestSessionListener.php +++ b/EventListener/AbstractTestSessionListener.php @@ -81,7 +81,7 @@ public function onKernelResponse(FilterResponseEvent $event) if ($session instanceof Session ? !$session->isEmpty() || (null !== $this->sessionId && $session->getId() !== $this->sessionId) : $wasStarted) { $params = session_get_cookie_params() + ['samesite' => null]; foreach ($this->sessionOptions as $k => $v) { - if (0 === strpos($k, 'cookie_')) { + if (str_starts_with($k, 'cookie_')) { $params[substr($k, 7)] = $v; } } diff --git a/Exception/ControllerDoesNotReturnResponseException.php b/Exception/ControllerDoesNotReturnResponseException.php index 1e87690ff1..54c80be90f 100644 --- a/Exception/ControllerDoesNotReturnResponseException.php +++ b/Exception/ControllerDoesNotReturnResponseException.php @@ -38,7 +38,7 @@ public function __construct(string $message, callable $controller, string $file, private function parseControllerDefinition(callable $controller): ?array { - if (\is_string($controller) && false !== strpos($controller, '::')) { + if (\is_string($controller) && str_contains($controller, '::')) { $controller = explode('::', $controller); } diff --git a/HttpCache/AbstractSurrogate.php b/HttpCache/AbstractSurrogate.php index 472d87e483..3385940243 100644 --- a/HttpCache/AbstractSurrogate.php +++ b/HttpCache/AbstractSurrogate.php @@ -57,7 +57,7 @@ public function hasSurrogateCapability(Request $request) return false; } - return false !== strpos($value, sprintf('%s/1.0', strtoupper($this->getName()))); + return str_contains($value, sprintf('%s/1.0', strtoupper($this->getName()))); } /** diff --git a/HttpCache/Esi.php b/HttpCache/Esi.php index 0bad63e748..829f4ac643 100644 --- a/HttpCache/Esi.php +++ b/HttpCache/Esi.php @@ -37,7 +37,7 @@ public function getName() */ public function addSurrogateControl(Response $response) { - if (false !== strpos($response->getContent(), 'getContent(), 'headers->set('Surrogate-Control', 'content="ESI/1.0"'); } } diff --git a/HttpCache/Ssi.php b/HttpCache/Ssi.php index 6dba4e11df..a2856f2760 100644 --- a/HttpCache/Ssi.php +++ b/HttpCache/Ssi.php @@ -34,7 +34,7 @@ public function getName() */ public function addSurrogateControl(Response $response) { - if (false !== strpos($response->getContent(), '