diff --git a/.github/patch-types.php b/.github/patch-types.php index b4878156fea42..9d26fa8e3e999 100644 --- a/.github/patch-types.php +++ b/.github/patch-types.php @@ -13,30 +13,30 @@ foreach ($loader->getClassMap() as $class => $file) { switch (true) { - case false !== strpos($file = realpath($file), '/vendor/'): - case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'): - case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'): - case false !== strpos($file, '/src/Symfony/Component/Cache/Tests/Fixtures/DriverWrapper.php'): - case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'): - case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'): - case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'): - case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'): - case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'): - case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php'): - case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php'): - case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/TraitUsage/DummyUsingTrait.php'): - case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'): - case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'): - case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'): - case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'): + case str_contains($file = realpath($file), '/vendor/'): + case str_contains($file, '/src/Symfony/Bridge/PhpUnit/'): + case str_contains($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'): + case str_contains($file, '/src/Symfony/Component/Cache/Tests/Fixtures/DriverWrapper.php'): + case str_contains($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'): + case str_contains($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'): + case str_contains($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'): + case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'): + case str_contains($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'): + case str_contains($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Dummy.php'): + case str_contains($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/ParentDummy.php'): + case str_contains($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/TraitUsage/DummyUsingTrait.php'): + case str_contains($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'): + case str_contains($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'): + case str_contains($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'): + case str_contains($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'): continue 2; } diff --git a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php index 34aba14e9f6ee..868042bc31e6f 100644 --- a/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php +++ b/src/Symfony/Bridge/Doctrine/DependencyInjection/AbstractDoctrineExtension.php @@ -221,7 +221,7 @@ protected function registerMappingDrivers(array $objectManager, ContainerBuilder ]); } $mappingDriverDef->setPublic(false); - if (false !== strpos($mappingDriverDef->getClass(), 'yml') || false !== strpos($mappingDriverDef->getClass(), 'xml')) { + if (str_contains($mappingDriverDef->getClass(), 'yml') || str_contains($mappingDriverDef->getClass(), 'xml')) { $mappingDriverDef->setArguments([array_flip($driverPaths)]); $mappingDriverDef->addMethodCall('setGlobalBasename', ['mapping']); } diff --git a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php index 4b5d795cbb0f7..72f0489c85008 100644 --- a/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php +++ b/src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php @@ -161,7 +161,7 @@ private function getClass(): string if (null === $this->class) { $class = $this->classOrAlias; - if (false !== strpos($class, ':')) { + if (str_contains($class, ':')) { $class = $this->getClassMetadata()->getName(); } diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index f9bd78619d6b5..74536e81793b6 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -122,7 +122,7 @@ public function __construct($message, array $trace, $file) return; } - if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) { + if (!isset($line['class'], $trace[$i - 2]['function']) || str_contains($line['class'], SymfonyTestsListenerFor::class)) { $this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class']; $this->originMethod = $line['function']; @@ -171,7 +171,7 @@ public function originatingClass() $class = $this->originClass; - return false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; + return str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; } /** @@ -225,7 +225,7 @@ public function isMuted() return 0 === strpos($this->trace[1]['class'], 'PHPUnit\\'); } - return false !== strpos($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR); + return str_contains($this->triggeringFile, \DIRECTORY_SEPARATOR.'vendor'.\DIRECTORY_SEPARATOR.'phpunit'.\DIRECTORY_SEPARATOR); } /** @@ -339,7 +339,7 @@ private static function getVendors() } foreach ($paths as $path) { foreach (self::$vendors as $vendor) { - if (0 !== strpos($path, $vendor)) { + if (str_contains($path, $vendor)) { self::$internalPaths[] = $path; } } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php index 4b80d96c9bc5d..a9e9a84e616ab 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/composer/autoload_real.php @@ -27,7 +27,7 @@ public function loadClass($className) public function findFile($class) { foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) { - if (0 !== strpos($class, $prefix)) { + if (str_contains($class, $prefix)) { continue; } diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php index aabb103e4d04c..d140c99b7c1b6 100644 --- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor_bis/composer/autoload_real.php @@ -17,7 +17,7 @@ public function getPrefixesPsr4() public function loadClass($className) { foreach ($this->getPrefixesPsr4() as $prefix => $baseDirs) { - if (0 !== strpos($className, $prefix)) { + if (str_contains($className, $prefix)) { continue; } diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index 40ae2d073a20c..bab168716d845 100644 --- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php +++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php @@ -212,7 +212,7 @@ private function displayGeneralText(SymfonyStyle $io, string $filter = null) foreach ($types as $index => $type) { $items = []; foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) { - if (!$filter || false !== strpos($name, $filter)) { + if (!$filter || str_contains($name, $filter)) { $items[$name] = $name.$this->getPrettyMetadata($type, $entity, $decorated); } } @@ -246,7 +246,7 @@ private function displayGeneralJson(SymfonyStyle $io, ?string $filter) $data = []; foreach ($types as $type) { foreach ($this->twig->{'get'.ucfirst($type)}() as $name => $entity) { - if (!$filter || false !== strpos($name, $filter)) { + if (!$filter || str_contains($name, $filter)) { $data[$type][$name] = $this->getMetadata($type, $entity); } } @@ -526,7 +526,7 @@ private function findAlternatives(string $name, array $collection): array $alternatives = []; foreach ($collection as $item) { $lev = levenshtein($name, $item); - if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) { + if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) { $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; } } diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index b57bb3de3871a..fff853a51f5ed 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -62,7 +62,7 @@ public function abbrClass(string $class): string public function abbrMethod(string $method): string { - if (false !== strpos($method, '::')) { + if (str_contains($method, '::')) { [$class, $method] = explode('::', $method, 2); $result = sprintf('%s::%s()', $this->abbrClass($class), $method); } elseif ('Closure' === $method) { @@ -206,7 +206,7 @@ public function formatFileFromText(string $text): string */ public function formatLogMessage(string $message, array $context): string { - if ($context && false !== strpos($message, '{')) { + if ($context && str_contains($message, '{')) { $replacements = []; foreach ($context as $key => $val) { if (is_scalar($val)) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php index 660bf3f96a65a..9181d6803572f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/ContainerDebugCommand.php @@ -264,7 +264,7 @@ public function filterToServiceTypes(string $serviceId): bool } // if the id has a \, assume it is a class - if (false !== strpos($serviceId, '\\')) { + if (str_contains($serviceId, '\\')) { return true; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php index a3c523ef5ef88..c45bc411dd069 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/DebugAutowiringCommand.php @@ -83,7 +83,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($search = $input->getArgument('search')) { $searchNormalized = preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', '', $search); $serviceIds = array_filter($serviceIds, function ($serviceId) use ($searchNormalized) { - return false !== stripos(str_replace('\\', '', $serviceId), $searchNormalized) && 0 !== strpos($serviceId, '.'); + return false !== stripos(str_replace('\\', '', $serviceId), $searchNormalized) && str_contains($serviceId, '.'); }); if (empty($serviceIds)) { @@ -107,7 +107,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int foreach ($serviceIds as $serviceId) { $text = []; $resolvedServiceId = $serviceId; - if (0 !== strpos($serviceId, $previousId)) { + if (str_contains($serviceId, $previousId)) { $text[] = ''; if ('' !== $description = Descriptor::getClassDescription($serviceId, $resolvedServiceId)) { if (isset($hasAlias[$serviceId])) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php index e1067f1fdab8b..6d937bf9c4e65 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/JsonDescriptor.php @@ -313,7 +313,7 @@ private function getCallableData(mixed $callable): array $data['name'] = $callable[1]; $data['class'] = \get_class($callable[0]); } else { - if (0 !== strpos($callable[1], 'parent::')) { + if (str_contains($callable[1], 'parent::')) { $data['name'] = $callable[1]; $data['class'] = $callable[0]; $data['static'] = true; @@ -348,7 +348,7 @@ private function getCallableData(mixed $callable): array $data['type'] = 'closure'; $r = new \ReflectionFunction($callable); - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return $data; } $data['name'] = $r->name; diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php index 84d420f47a9ca..9db42d7cc8ba2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/MarkdownDescriptor.php @@ -337,7 +337,7 @@ protected function describeCallable(mixed $callable, array $options = []) $string .= "\n".sprintf('- Name: `%s`', $callable[1]); $string .= "\n".sprintf('- Class: `%s`', \get_class($callable[0])); } else { - if (0 !== strpos($callable[1], 'parent::')) { + if (str_contains($callable[1], 'parent::')) { $string .= "\n".sprintf('- Name: `%s`', $callable[1]); $string .= "\n".sprintf('- Class: `%s`', $callable[0]); $string .= "\n- Static: yes"; @@ -372,7 +372,7 @@ protected function describeCallable(mixed $callable, array $options = []) $string .= "\n- Type: `closure`"; $r = new \ReflectionFunction($callable); - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return $this->write($string."\n"); } $string .= "\n".sprintf('- Name: `%s`', $r->name); diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php index 6a2faa04a3e1e..581395efd0035 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php @@ -556,7 +556,7 @@ private function formatControllerLink(mixed $controller, string $anchorText, cal $r = new \ReflectionMethod($controller, '__invoke'); } elseif (!\is_string($controller)) { return $anchorText; - } elseif (false !== strpos($controller, '::')) { + } elseif (str_contains($controller, '::')) { $r = new \ReflectionMethod($controller); } else { $r = new \ReflectionFunction($controller); @@ -609,7 +609,7 @@ private function formatCallable(mixed $callable): string if ($callable instanceof \Closure) { $r = new \ReflectionFunction($callable); - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return 'Closure()'; } if ($class = $r->getClosureScopeClass()) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php index 86ff4985b6cf3..5de3e67a99068 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php +++ b/src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/XmlDescriptor.php @@ -505,7 +505,7 @@ private function getCallableDocument(mixed $callable): \DOMDocument $callableXML->setAttribute('name', $callable[1]); $callableXML->setAttribute('class', \get_class($callable[0])); } else { - if (0 !== strpos($callable[1], 'parent::')) { + if (str_contains($callable[1], 'parent::')) { $callableXML->setAttribute('name', $callable[1]); $callableXML->setAttribute('class', $callable[0]); $callableXML->setAttribute('static', 'true'); @@ -540,7 +540,7 @@ private function getCallableDocument(mixed $callable): \DOMDocument $callableXML->setAttribute('type', 'closure'); $r = new \ReflectionFunction($callable); - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return $dom; } $callableXML->setAttribute('name', $r->name); diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php index b164bfc96ad99..392a95ce64b5f 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php @@ -111,7 +111,7 @@ public function process(ContainerBuilder $container) continue; } - if (false !== strpos($definedTag, $tag) || levenshtein($tag, $definedTag) <= \strlen($tag) / 3) { + if (str_contains($definedTag, $tag) || levenshtein($tag, $definedTag) <= \strlen($tag) / 3) { $candidates[] = $definedTag; } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php index 3a63471c6f630..272a8bf43739d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php +++ b/src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php @@ -109,7 +109,7 @@ public function registerContainerConfiguration(LoaderInterface $loader) ], ]); - $kernelClass = false !== strpos(static::class, "@anonymous\0") ? parent::class : static::class; + $kernelClass = str_contains(static::class, "@anonymous\0") ? parent::class : static::class; if (!$container->hasDefinition('kernel')) { $container->register('kernel', $kernelClass) diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index 91adfbf579917..7284d3f1db8c4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -82,7 +82,7 @@ public function load(mixed $resource, string $type = null): mixed continue; } - if (false !== strpos($controller, '::')) { + if (str_contains($controller, '::')) { continue; } diff --git a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php index 933091d19ce73..3338b973c1645 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php +++ b/src/Symfony/Bundle/FrameworkBundle/Secrets/DotenvVault.php @@ -54,7 +54,7 @@ public function reveal(string $name): ?string { $this->lastMessage = null; $this->validateName($name); - $v = \is_string($_SERVER[$name] ?? null) && 0 !== strpos($name, 'HTTP_') ? $_SERVER[$name] : ($_ENV[$name] ?? null); + $v = \is_string($_SERVER[$name] ?? null) && str_contains($name, 'HTTP_') ? $_SERVER[$name] : ($_ENV[$name] ?? null); if (null === $v) { $this->lastMessage = sprintf('Secret "%s" not found in "%s".', $name, $this->getPrettyPath($this->dotenvFile)); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php index 0e67c73ed8cc0..edd12b4487d32 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/CachePoolsTest.php @@ -35,12 +35,12 @@ public function testRedisCachePools() try { $this->doTestCachePools(['root_config' => 'redis_config.yml', 'environment' => 'redis_cache'], RedisAdapter::class); } catch (\PHPUnit\Framework\Error\Warning $e) { - if (0 !== strpos($e->getMessage(), 'unable to connect to')) { + if (str_contains($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); } catch (InvalidArgumentException $e) { - if (0 !== strpos($e->getMessage(), 'Redis connection ')) { + if (str_contains($e->getMessage(), 'Redis connection ')) { throw $e; } $this->markTestSkipped($e->getMessage()); @@ -58,7 +58,7 @@ public function testRedisCustomCachePools() try { $this->doTestCachePools(['root_config' => 'redis_custom_config.yml', 'environment' => 'custom_redis_cache'], RedisAdapter::class); } catch (\PHPUnit\Framework\Error\Warning $e) { - if (0 !== strpos($e->getMessage(), 'unable to connect to')) { + if (str_contains($e->getMessage(), 'unable to connect to')) { throw $e; } $this->markTestSkipped($e->getMessage()); diff --git a/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php index c16818cdb388a..33011662d2a6b 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php @@ -246,7 +246,7 @@ private function formatCallable(mixed $callable): string if ($callable instanceof \Closure) { $r = new \ReflectionFunction($callable); - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { return 'Closure()'; } if ($class = $r->getClosureScopeClass()) { diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php index a5dc679cda3f3..78f36cd16e878 100644 --- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php +++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php @@ -307,7 +307,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto continue; } - if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { + if (str_contains($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) { throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern'])); } } diff --git a/src/Symfony/Component/Asset/Package.php b/src/Symfony/Component/Asset/Package.php index 0d39958825f50..21148c2f25247 100644 --- a/src/Symfony/Component/Asset/Package.php +++ b/src/Symfony/Component/Asset/Package.php @@ -73,6 +73,6 @@ protected function getVersionStrategy() */ protected function isAbsoluteUrl(string $url) { - return false !== strpos($url, '://') || '//' === substr($url, 0, 2); + return str_contains($url, '://') || '//' === substr($url, 0, 2); } } diff --git a/src/Symfony/Component/BrowserKit/CookieJar.php b/src/Symfony/Component/BrowserKit/CookieJar.php index 3a585bed668f3..fba06ad9f9a82 100644 --- a/src/Symfony/Component/BrowserKit/CookieJar.php +++ b/src/Symfony/Component/BrowserKit/CookieJar.php @@ -48,7 +48,7 @@ public function get(string $name, string $path = '/', string $domain = null) } foreach ($pathCookies as $cookiePath => $namedCookies) { - if (0 !== strpos($path, $cookiePath)) { + if (str_contains($path, $cookiePath)) { continue; } if (isset($namedCookies[$name])) { diff --git a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php index 5cd25f422e541..217d2880d8a1e 100644 --- a/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/CouchbaseBucketAdapter.php @@ -79,7 +79,7 @@ public static function createConnection(array|string $servers, array $options = $password = $options['password']; foreach ($servers as $dsn) { - if (0 !== strpos($dsn, 'couchbase:')) { + if (str_contains($dsn, 'couchbase:')) { throw new InvalidArgumentException(sprintf('Invalid Couchbase DSN: "%s" does not start with "couchbase:".', $dsn)); } diff --git a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php index 0590af3c00461..3891b4b2fc55c 100644 --- a/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/MemcachedAdapter.php @@ -118,7 +118,7 @@ public static function createConnection(array|string $servers, array $options = if (\is_array($dsn)) { continue; } - if (0 !== strpos($dsn, 'memcached:')) { + if (str_contains($dsn, 'memcached:')) { throw new InvalidArgumentException(sprintf('Invalid Memcached DSN: "%s" does not start with "memcached:".', $dsn)); } $params = preg_replace_callback('#^memcached:(//)?(?:([^@]*+)@)?#', function ($m) use (&$username, &$password) { diff --git a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php index fe2ed34cbfa56..bae625130c285 100644 --- a/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/RedisTagAwareAdapter.php @@ -83,7 +83,7 @@ public function __construct(\Redis|\RedisArray|\RedisCluster|\Predis\ClientInter protected function doSave(array $values, int $lifetime, array $addTagData = [], array $delTagData = []): array { $eviction = $this->getRedisEvictionPolicy(); - if ('noeviction' !== $eviction && 0 !== strpos($eviction, 'volatile-')) { + if ('noeviction' !== $eviction && str_contains($eviction, 'volatile-')) { throw new LogicException(sprintf('Redis maxmemory-policy setting "%s" is *not* supported by RedisTagAwareAdapter, use "noeviction" or "volatile-*" eviction policies.', $eviction)); } diff --git a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php index 07d72313809d9..01a5332fb505c 100644 --- a/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php +++ b/src/Symfony/Component/Cache/Traits/FilesystemCommonTrait.php @@ -58,7 +58,7 @@ protected function doClear(string $namespace) $ok = true; foreach ($this->scanHashDir($this->directory) as $file) { - if ('' !== $namespace && 0 !== strpos($this->getFileKey($file), $namespace)) { + if ('' !== $namespace && str_contains($this->getFileKey($file), $namespace)) { continue; } diff --git a/src/Symfony/Component/Config/Definition/ArrayNode.php b/src/Symfony/Component/Config/Definition/ArrayNode.php index 7f4ffaabbe105..bf3f754f477b9 100644 --- a/src/Symfony/Component/Config/Definition/ArrayNode.php +++ b/src/Symfony/Component/Config/Definition/ArrayNode.php @@ -55,7 +55,7 @@ protected function preNormalize(mixed $value) $normalized = []; foreach ($value as $k => $v) { - if (false !== strpos($k, '-') && false === strpos($k, '_') && !\array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) { + if (str_contains($k, '-') && false === strpos($k, '_') && !\array_key_exists($normalizedKey = str_replace('-', '_', $k), $value)) { $normalized[$normalizedKey] = $v; } else { $normalized[$k] = $v; diff --git a/src/Symfony/Component/Config/Definition/BaseNode.php b/src/Symfony/Component/Config/Definition/BaseNode.php index f3ded874456de..e82e564f7b668 100644 --- a/src/Symfony/Component/Config/Definition/BaseNode.php +++ b/src/Symfony/Component/Config/Definition/BaseNode.php @@ -47,7 +47,7 @@ abstract class BaseNode implements NodeInterface */ public function __construct(?string $name, NodeInterface $parent = null, string $pathSeparator = self::DEFAULT_PATH_SEPARATOR) { - if (false !== strpos($name = (string) $name, $pathSeparator)) { + if (str_contains($name = (string) $name, $pathSeparator)) { throw new \InvalidArgumentException('The name must not contain ".'.$pathSeparator.'".'); } diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index b910027da0680..e09c928e71a1a 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -82,7 +82,7 @@ public function import(mixed $resource, string $type = null, bool $ignoreErrors } $ret = []; - $isSubpath = 0 !== $i && false !== strpos(substr($resource, 0, $i), '/'); + $isSubpath = 0 !== $i && str_contains(substr($resource, 0, $i), '/'); foreach ($this->glob($resource, false, $_, $ignoreErrors || !$isSubpath, false, $excluded) as $path => $info) { if (null !== $res = $this->doImport($path, 'glob' === $type ? null : $type, $ignoreErrors, $sourceResource)) { $ret[] = $res; diff --git a/src/Symfony/Component/Config/Resource/GlobResource.php b/src/Symfony/Component/Config/Resource/GlobResource.php index 0449bdc2a150d..cab445e39298c 100644 --- a/src/Symfony/Component/Config/Resource/GlobResource.php +++ b/src/Symfony/Component/Config/Resource/GlobResource.php @@ -104,7 +104,7 @@ public function getIterator(): \Traversable $prefix = str_replace('\\', '/', $this->prefix); $paths = null; - if (0 !== strpos($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/')) { + if (str_contains($this->prefix, 'phar://') && false === strpos($this->pattern, '/**/')) { if ($this->globBrace || false === strpos($this->pattern, '{')) { $paths = glob($this->prefix.$this->pattern, \GLOB_NOSORT | $this->globBrace); } elseif (false === strpos($this->pattern, '\\') || !preg_match('/\\\\[,{}]/', $this->pattern)) { @@ -220,7 +220,7 @@ private function expandGlob(string $pattern): array $j = 0; foreach ($patterns as $i => $p) { - if (false !== strpos($p, '{')) { + if (str_contains($p, '{')) { $p = $this->expandGlob($p); array_splice($paths, $i + $j, 1, $p); $j += \count($p) - 1; diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index f76c1f7052580..769c65d63e6bf 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -819,7 +819,7 @@ protected function doRenderThrowable(\Throwable $e, OutputInterface $output): vo $len = 0; } - if (false !== strpos($message, "@anonymous\0")) { + if (str_contains($message, "@anonymous\0")) { $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); @@ -1119,7 +1119,7 @@ private function findAlternatives(string $name, iterable $collection): array } $lev = levenshtein($subname, $parts[$i]); - if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) { + if ($lev <= \strlen($subname) / 3 || '' !== $subname && str_contains($parts[$i], $subname)) { $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; } elseif ($exists) { $alternatives[$collectionName] += $threshold; @@ -1129,7 +1129,7 @@ private function findAlternatives(string $name, iterable $collection): array foreach ($collection as $item) { $lev = levenshtein($name, $item); - if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) { + if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) { $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; } } diff --git a/src/Symfony/Component/Console/Command/Command.php b/src/Symfony/Component/Console/Command/Command.php index 8cb4aeb36c8eb..9ddaec8a7864b 100644 --- a/src/Symfony/Component/Console/Command/Command.php +++ b/src/Symfony/Component/Console/Command/Command.php @@ -647,7 +647,7 @@ public function getSynopsis(bool $short = false) */ public function addUsage(string $usage) { - if (0 !== strpos($usage, $this->name)) { + if (str_contains($usage, $this->name)) { $usage = sprintf('%s %s', $this->name, $usage); } diff --git a/src/Symfony/Component/Console/Formatter/OutputFormatter.php b/src/Symfony/Component/Console/Formatter/OutputFormatter.php index 52ca232730553..7f1d9e13e2a0f 100644 --- a/src/Symfony/Component/Console/Formatter/OutputFormatter.php +++ b/src/Symfony/Component/Console/Formatter/OutputFormatter.php @@ -178,7 +178,7 @@ public function formatAndWrap(?string $message, int $width) $output .= $this->applyCurrentStyle(substr($message, $offset), $output, $width, $currentLineLength); - if (false !== strpos($output, "\0")) { + if (str_contains($output, "\0")) { return strtr($output, ["\0" => '\\', '\\<' => '<']); } diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 771e8daec6ede..c73a43ba76753 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -133,7 +133,7 @@ private function parseLongOption(string $token) { $name = substr($token, 2); - if (false !== $pos = strpos($name, '=')) { + if ($pos = str_contains($name, '=')) { if (0 === \strlen($value = substr($name, $pos + 1))) { array_unshift($this->parsed, $value); } @@ -264,7 +264,7 @@ public function getFirstArgument() $isOption = false; foreach ($this->tokens as $i => $token) { if ($token && '-' === $token[0]) { - if (false !== strpos($token, '=') || !isset($this->tokens[$i + 1])) { + if (str_contains($token, '=') || !isset($this->tokens[$i + 1])) { continue; } diff --git a/src/Symfony/Component/CssSelector/XPath/Translator.php b/src/Symfony/Component/CssSelector/XPath/Translator.php index b0045bd4d4f45..2b87d51796402 100644 --- a/src/Symfony/Component/CssSelector/XPath/Translator.php +++ b/src/Symfony/Component/CssSelector/XPath/Translator.php @@ -74,7 +74,7 @@ public static function getXpathLiteral(string $element): string $string = $element; $parts = []; while (true) { - if (false !== $pos = strpos($string, "'")) { + if ($pos = str_contains($string, "'")) { $parts[] = sprintf("'%s'", substr($string, 0, $pos)); $parts[] = "\"'\""; $string = substr($string, $pos + 1); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php index eb4af610b165c..771df761bd6d8 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckExceptionOnInvalidReferenceBehaviorPass.php @@ -95,7 +95,7 @@ private function getAlternatives(string $id): array } $lev = levenshtein($id, $knownId); - if ($lev <= \strlen($id) / 3 || false !== strpos($knownId, $id)) { + if ($lev <= \strlen($id) / 3 || str_contains($knownId, $id)) { $alternatives[] = $knownId; } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php index 2be7b71622828..56c498d75daa4 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php @@ -231,7 +231,7 @@ private function checkType(Definition $checkedDefinition, mixed $value, \Reflect $value = $this->container->getParameter(substr($value, 1, -1)); } - if ($envPlaceholderUniquePrefix && \is_string($value) && false !== strpos($value, 'env_')) { + if ($envPlaceholderUniquePrefix && \is_string($value) && str_contains($value, 'env_')) { // If the value is an env placeholder that is either mixed with a string or with another env placeholder, then its resolved value will always be a string, so we don't need to resolve it. // We don't need to change the value because it is already a string. if ('' === preg_replace('/'.$envPlaceholderUniquePrefix.'_\w+_[a-f0-9]{32}/U', '', $value, -1, $c) && 1 === $c) { diff --git a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php index 36fdb65652e40..a26030e458ef6 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php @@ -64,7 +64,7 @@ public function addPass(CompilerPassInterface $pass, string $type = PassConfig:: */ public function log(CompilerPassInterface $pass, string $message) { - if (false !== strpos($message, "\n")) { + if (str_contains($message, "\n")) { $message = str_replace("\n", "\n".\get_class($pass).': ', trim($message)); } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php index b31b471ec1ddd..4db6765530ad4 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/RegisterServiceSubscribersPass.php @@ -96,9 +96,9 @@ protected function processValue(mixed $value, bool $isRoot = false) } if ($name) { - if (false !== $i = strpos($name, '::get')) { + if ($i = str_contains($name, '::get')) { $name = lcfirst(substr($name, 5 + $i)); - } elseif (false !== strpos($name, '::')) { + } elseif (str_contains($name, '::')) { $name = null; } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php index c0b236629234f..1fdff3cccc487 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveBindingsPass.php @@ -45,7 +45,7 @@ public function process(ContainerBuilder $container) foreach ($this->unusedBindings as [$key, $serviceId, $bindingType, $file]) { $argumentType = $argumentName = $message = null; - if (false !== strpos($key, ' ')) { + if (str_contains($key, ' ')) { [$argumentType, $argumentName] = explode(' ', $key, 2); } elseif ('$' === $key[0]) { $argumentName = $key; diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index f9f6a704936ee..90a0eb7fe3577 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -250,7 +250,7 @@ private function make(string $id, int $invalidBehavior) continue; } $lev = levenshtein($id, $knownId); - if ($lev <= \strlen($id) / 3 || false !== strpos($knownId, $id)) { + if ($lev <= \strlen($id) / 3 || str_contains($knownId, $id)) { $alternatives[] = $knownId; } } @@ -367,7 +367,7 @@ protected function getEnv(string $name) $this->getEnv ??= \Closure::fromCallable([$this, 'getEnv']); $processors = $this->get($id); - if (false !== $i = strpos($name, ':')) { + if ($i = str_contains($name, ':')) { $prefix = substr($name, 0, $i); $localName = substr($name, 1 + $i); } else { diff --git a/src/Symfony/Component/DependencyInjection/Definition.php b/src/Symfony/Component/DependencyInjection/Definition.php index f4300af3fd394..ad30e71f5fe07 100644 --- a/src/Symfony/Component/DependencyInjection/Definition.php +++ b/src/Symfony/Component/DependencyInjection/Definition.php @@ -104,7 +104,7 @@ public function setFactory(string|array|Reference|null $factory) { $this->changes['factory'] = true; - if (\is_string($factory) && false !== strpos($factory, '::')) { + if (\is_string($factory) && str_contains($factory, '::')) { $factory = explode('::', $factory, 2); } elseif ($factory instanceof Reference) { $factory = [$factory, '__invoke']; @@ -736,7 +736,7 @@ public function setConfigurator(string|array|Reference|null $configurator) { $this->changes['configurator'] = true; - if (\is_string($configurator) && false !== strpos($configurator, '::')) { + if (\is_string($configurator) && str_contains($configurator, '::')) { $configurator = explode('::', $configurator, 2); } elseif ($configurator instanceof Reference) { $configurator = [$configurator, '__invoke']; diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index fe57f2e29c6f6..d2aa2031d63cd 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -155,7 +155,7 @@ public function dump(array $options = []) $this->inlineRequires = $options['inline_class_loader_parameter'] && ($this->container->hasParameter($options['inline_class_loader_parameter']) ? $this->container->getParameter($options['inline_class_loader_parameter']) : $options['debug']); $this->serviceLocatorTag = $options['service_locator_tag']; - if (0 !== strpos($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) { + if (str_contains($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) { $baseClass = sprintf('%s\%s', $options['namespace'] ? '\\'.$options['namespace'] : '', $baseClass); $this->baseClass = $baseClass; } elseif ('Container' === $baseClass) { @@ -327,7 +327,7 @@ class %s extends {$options['class']} EOF; foreach ($this->preload as $class) { - if (!$class || false !== strpos($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], true)) { + if (!$class || str_contains($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], true)) { continue; } if (!(class_exists($class, false) || interface_exists($class, false) || trait_exists($class, false)) || (new \ReflectionClass($class))->isUserDefined()) { @@ -1864,10 +1864,10 @@ private function dumpValue(mixed $value, bool $interpolate = true): string */ private function dumpLiteralClass(string $class): string { - if (false !== strpos($class, '$')) { + if (str_contains($class, '$')) { return sprintf('${($_ = %s) && false ?: "_"}', $class); } - if (0 !== strpos($class, "'") || !preg_match('/^\'(?:\\\{2})?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) { + if (str_contains($class, "'") || !preg_match('/^\'(?:\\\{2})?[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*(?:\\\{2}[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)*\'$/', $class)) { throw new RuntimeException(sprintf('Cannot dump definition because of invalid class name (%s).', $class ?: 'n/a')); } @@ -2113,7 +2113,7 @@ private function doExport(mixed $value, bool $resolveEnv = false): mixed if ($shouldCacheValue && isset($this->exportedVariables[$value])) { return $this->exportedVariables[$value]; } - if (\is_string($value) && false !== strpos($value, "\n")) { + if (\is_string($value) && str_contains($value, "\n")) { $cleanParts = explode("\n", $value); $cleanParts = array_map(function ($part) { return var_export($part, true); }, $cleanParts); $export = implode('."\n".', $cleanParts); @@ -2121,10 +2121,10 @@ private function doExport(mixed $value, bool $resolveEnv = false): mixed $export = var_export($value, true); } if ($this->asFiles) { - if (false !== strpos($export, '$this')) { + if (str_contains($export, '$this')) { $export = str_replace('$this', "$'.'this", $export); } - if (false !== strpos($export, 'function () {')) { + if (str_contains($export, 'function () {')) { $export = str_replace('function () {', "function ('.') {", $export); } } diff --git a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php index 5e40c6ec6c7ad..39ddc607f60f8 100644 --- a/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php +++ b/src/Symfony/Component/DependencyInjection/EnvVarProcessor.php @@ -130,7 +130,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv) $env = $getEnv($name); } elseif (isset($_ENV[$name])) { $env = $_ENV[$name]; - } elseif (isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')) { + } elseif (isset($_SERVER[$name]) && str_contains($name, 'HTTP_')) { $env = $_SERVER[$name]; } elseif (false === ($env = getenv($name)) || null === $env) { // null is a possible value because of thread safety issues foreach ($this->loadedVars as $vars) { diff --git a/src/Symfony/Component/DependencyInjection/Extension/Extension.php b/src/Symfony/Component/DependencyInjection/Extension/Extension.php index 04910dea2eb1f..86898090138f0 100644 --- a/src/Symfony/Component/DependencyInjection/Extension/Extension.php +++ b/src/Symfony/Component/DependencyInjection/Extension/Extension.php @@ -82,7 +82,7 @@ public function getConfiguration(array $config, ContainerBuilder $container) { $class = static::class; - if (false !== strpos($class, "\0")) { + if (str_contains($class, "\0")) { return null; // ignore anonymous classes } diff --git a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php index b43b3b643cc4c..c2a57b5da355e 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/FileLoader.php @@ -193,7 +193,7 @@ private function findClasses(string $namespace, string $pattern, array $excludeP if (null === $prefixLen) { $prefixLen = \strlen($resource->getPrefix()); - if ($excludePrefix && 0 !== strpos($excludePrefix, $resource->getPrefix())) { + if ($excludePrefix && str_contains($excludePrefix, $resource->getPrefix())) { throw new InvalidArgumentException(sprintf('Invalid "exclude" pattern when importing classes for "%s": make sure your "exclude" pattern (%s) is a subset of the "resource" pattern (%s).', $namespace, $excludePattern, $pattern)); } } diff --git a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php index 72f85fa179222..7bc44acbf1608 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/PhpFileLoader.php @@ -178,7 +178,7 @@ private function configBuilder(string $namespace): ConfigBuilderInterface // Try to get the extension alias $alias = Container::underscore(substr($namespace, 15, -6)); - if (false !== strpos($alias, '\\')) { + if (str_contains($alias, '\\')) { throw new InvalidArgumentException('You can only use "root" ConfigBuilders from "Symfony\\Config\\" namespace. Nested classes like "Symfony\\Config\\Framework\\CacheConfig" cannot be used.'); } diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 4123af7e18ee0..a772703b58db0 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -342,7 +342,7 @@ private function parseDefinition(\DOMElement $service, string $file, Definition continue; } - if (false !== strpos($name, '-') && false === strpos($name, '_') && !\array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) { + if (str_contains($name, '-') && false === strpos($name, '_') && !\array_key_exists($normalizedName = str_replace('-', '_', $name), $parameters)) { $parameters[$normalizedName] = XmlUtils::phpize($node->nodeValue); } // keep not normalized key diff --git a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php index 6b1e9e4a4818f..7b30ff9156260 100644 --- a/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php +++ b/src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php @@ -69,13 +69,13 @@ public function get(string $name) $alternatives = []; foreach ($this->parameters as $key => $parameterValue) { $lev = levenshtein($name, $key); - if ($lev <= \strlen($name) / 3 || false !== strpos($key, $name)) { + if ($lev <= \strlen($name) / 3 || str_contains($key, $name)) { $alternatives[] = $key; } } $nonNestedAlternative = null; - if (!\count($alternatives) && false !== strpos($name, '.')) { + if (!\count($alternatives) && str_contains($name, '.')) { $namePartsLength = array_map('strlen', explode('.', $name)); $key = substr($name, 0, -1 * (1 + array_pop($namePartsLength))); while (\count($namePartsLength)) { diff --git a/src/Symfony/Component/DomCrawler/Crawler.php b/src/Symfony/Component/DomCrawler/Crawler.php index fd6ad538ff227..289a28eac59b9 100644 --- a/src/Symfony/Component/DomCrawler/Crawler.php +++ b/src/Symfony/Component/DomCrawler/Crawler.php @@ -147,7 +147,7 @@ public function addContent(string $content, string $type = null) $charset = null; if (false !== $pos = stripos($type, 'charset=')) { $charset = substr($type, $pos + 8); - if (false !== $pos = strpos($charset, ';')) { + if ($pos = str_contains($charset, ';')) { $charset = substr($charset, 0, $pos); } } @@ -939,7 +939,7 @@ public static function xpathLiteral(string $s) $string = $s; $parts = []; while (true) { - if (false !== $pos = strpos($string, "'")) { + if ($pos = str_contains($string, "'")) { $parts[] = sprintf("'%s'", substr($string, 0, $pos)); $parts[] = "\"'\""; $string = substr($string, $pos + 1); @@ -1049,7 +1049,7 @@ private function relativize(string $xpath): string } elseif (preg_match('/^(ancestor|ancestor-or-self|attribute|following|following-sibling|namespace|parent|preceding|preceding-sibling)::/', $expression)) { // the fake root has no parent, preceding or following nodes and also no attributes (even no namespace attributes) $expression = $nonMatchingExpression; - } elseif (0 !== strpos($expression, 'descendant-or-self::')) { + } elseif (str_contains($expression, 'descendant-or-self::')) { $expression = 'self::'.$expression; } $expressions[] = $parenthesis.$expression; diff --git a/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php b/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php index 17af3aa1fe19b..2697af02500fb 100644 --- a/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php +++ b/src/Symfony/Component/DomCrawler/Test/Constraint/CrawlerSelectorTextContains.php @@ -45,7 +45,7 @@ protected function matches($crawler): bool return false; } - return false !== mb_strpos($crawler->text(null, true), $this->expectedText); + return str_contains($crawler->text(null, true), $this->expectedText); } /** diff --git a/src/Symfony/Component/DomCrawler/UriResolver.php b/src/Symfony/Component/DomCrawler/UriResolver.php index be64f5257018d..2356163a94d45 100644 --- a/src/Symfony/Component/DomCrawler/UriResolver.php +++ b/src/Symfony/Component/DomCrawler/UriResolver.php @@ -115,7 +115,7 @@ private static function cleanupUri(string $uri): string */ private static function cleanupQuery(string $uri): string { - if (false !== $pos = strpos($uri, '?')) { + if ($pos = str_contains($uri, '?')) { return substr($uri, 0, $pos); } @@ -127,7 +127,7 @@ private static function cleanupQuery(string $uri): string */ private static function cleanupAnchor(string $uri): string { - if (false !== $pos = strpos($uri, '#')) { + if ($pos = str_contains($uri, '#')) { return substr($uri, 0, $pos); } diff --git a/src/Symfony/Component/Dotenv/Dotenv.php b/src/Symfony/Component/Dotenv/Dotenv.php index e1490af2bd93d..834c1f05ac2a8 100644 --- a/src/Symfony/Component/Dotenv/Dotenv.php +++ b/src/Symfony/Component/Dotenv/Dotenv.php @@ -181,7 +181,7 @@ public function populate(array $values, bool $overrideExistingVars = false): voi $loadedVars = array_flip(explode(',', $_SERVER['SYMFONY_DOTENV_VARS'] ?? $_ENV['SYMFONY_DOTENV_VARS'] ?? '')); foreach ($values as $name => $value) { - $notHttpName = 0 !== strpos($name, 'HTTP_'); + $notHttpName = str_contains($name, 'HTTP_'); // don't check existence with getenv() because of thread safety issues if (!isset($loadedVars[$name]) && (!$overrideExistingVars && (isset($_ENV[$name]) || (isset($_SERVER[$name]) && $notHttpName)))) { continue; @@ -453,7 +453,7 @@ private function resolveCommands(string $value, array $loadedVars): string $env = []; foreach ($this->values as $name => $value) { - if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')))) { + if (isset($loadedVars[$name]) || (!isset($_ENV[$name]) && !(isset($_SERVER[$name]) && str_contains($name, 'HTTP_')))) { $env[$name] = $value; } } @@ -506,7 +506,7 @@ private function resolveVariables(string $value, array $loadedVars): string $value = $this->values[$name]; } elseif (isset($_ENV[$name])) { $value = $_ENV[$name]; - } elseif (isset($_SERVER[$name]) && 0 !== strpos($name, 'HTTP_')) { + } elseif (isset($_SERVER[$name]) && str_contains($name, 'HTTP_')) { $value = $_SERVER[$name]; } elseif (isset($this->values[$name])) { $value = $this->values[$name]; diff --git a/src/Symfony/Component/ErrorHandler/BufferingLogger.php b/src/Symfony/Component/ErrorHandler/BufferingLogger.php index 72be64d1278a4..4c27685a845fb 100644 --- a/src/Symfony/Component/ErrorHandler/BufferingLogger.php +++ b/src/Symfony/Component/ErrorHandler/BufferingLogger.php @@ -48,7 +48,7 @@ public function __wakeup() public function __destruct() { foreach ($this->logs as [$level, $message, $context]) { - if (false !== strpos($message, '{')) { + if (str_contains($message, '{')) { foreach ($context as $key => $val) { if (null === $val || is_scalar($val) || (\is_object($val) && \is_callable([$val, '__toString']))) { $message = str_replace("{{$key}}", $val, $message); diff --git a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php index bf9b1d0455113..4117f4fc06dcf 100644 --- a/src/Symfony/Component/ErrorHandler/DebugClassLoader.php +++ b/src/Symfony/Component/ErrorHandler/DebugClassLoader.php @@ -391,7 +391,7 @@ private function checkClass(string $class, string $file = null): void } if (!$exists) { - if (false !== strpos($class, '/')) { + if (str_contains($class, '/')) { throw new \RuntimeException(sprintf('Trying to autoload a class with an invalid name "%s". Be careful that the namespace separator is "\" in PHP, not "/".', $class)); } @@ -413,7 +413,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array } $deprecations = []; - $className = false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; + $className = str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; // Don't trigger deprecations for classes in the same vendor if ($class !== $className) { @@ -429,12 +429,12 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array // Detect annotations on the class if (false !== $doc = $refl->getDocComment()) { foreach (['final', 'deprecated', 'internal'] as $annotation) { - if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { + if (str_contains($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { self::${$annotation}[$class] = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; } } - if ($refl->isInterface() && false !== strpos($doc, 'method') && preg_match_all('#\n \* @method\s+(static\s+)?+([\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#', $doc, $notice, \PREG_SET_ORDER)) { + if ($refl->isInterface() && str_contains($doc, 'method') && preg_match_all('#\n \* @method\s+(static\s+)?+([\w\|&\[\]\\\]+\s+)?(\w+(?:\s*\([^\)]*\))?)+(.+?([[:punct:]]\s*)?)?(?=\r?\n \*(?: @|/$|\r?\n))#', $doc, $notice, \PREG_SET_ORDER)) { foreach ($notice as $method) { $static = '' !== $method[1] && !empty($method[2]); $name = $method[3]; @@ -596,7 +596,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array $this->patchTypes['force'] = $forcePatchTypes ?: 'docblock'; } - $canAddReturnType = false !== strpos($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR) + $canAddReturnType = str_contains($refl->getFileName(), \DIRECTORY_SEPARATOR.'Tests'.\DIRECTORY_SEPARATOR) || $refl->isFinal() || $method->isFinal() || $method->isPrivate() @@ -634,7 +634,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array $matches = []; - if (!$method->hasReturnType() && ((false !== strpos($doc, '@return') && preg_match('/\n\s+\* @return +([^\s<(]+)/', $doc, $matches)) || 'void' !== (self::MAGIC_METHODS[$method->name] ?? 'void'))) { + if (!$method->hasReturnType() && ((str_contains($doc, '@return') && preg_match('/\n\s+\* @return +([^\s<(]+)/', $doc, $matches)) || 'void' !== (self::MAGIC_METHODS[$method->name] ?? 'void'))) { $matches = $matches ?: [1 => self::MAGIC_METHODS[$method->name]]; $this->setReturnType($matches[1], $method, $parent); @@ -656,7 +656,7 @@ public function checkAnnotations(\ReflectionClass $refl, string $class): array $finalOrInternal = false; foreach (['final', 'internal'] as $annotation) { - if (false !== strpos($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { + if (str_contains($doc, $annotation) && preg_match('#\n\s+\* @'.$annotation.'(?:( .+?)\.?)?\r?\n\s+\*(?: @|/$|\r?\n)#s', $doc, $notice)) { $message = isset($notice[1]) ? preg_replace('#\.?\r?\n( \*)? *(?= |\r?\n|$)#', '', $notice[1]) : ''; self::${$annotation.'Methods'}[$class][$method->name] = [$class, $message]; $finalOrInternal = true; @@ -844,7 +844,7 @@ private function setReturnType(string $types, \ReflectionMethod $method, ?string $iterable = $object = true; foreach ($typesMap as $n => $t) { if ('null' !== $n) { - $iterable = $iterable && (\in_array($n, ['array', 'iterable']) || false !== strpos($n, 'Iterator')); + $iterable = $iterable && (\in_array($n, ['array', 'iterable']) || str_contains($n, 'Iterator')); $object = $object && (\in_array($n, ['callable', 'object', '$this', 'static']) || !isset(self::SPECIAL_RETURN_TYPES[$n])); } } diff --git a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php index f4c49c2856c22..282f2f6331008 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedFunctionErrorEnhancer.php @@ -42,7 +42,7 @@ public function enhance(\Throwable $error): ?\Throwable $prefix = 'Call to undefined function '; $prefixLen = \strlen($prefix); - if (0 !== strpos($message, $prefix)) { + if (str_contains($message, $prefix)) { return null; } diff --git a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php index c4355f92ce089..d5eb6d6b1e4a6 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorEnhancer/UndefinedMethodErrorEnhancer.php @@ -47,7 +47,7 @@ public function enhance(\Throwable $error): ?\Throwable $candidates = []; foreach ($methods as $definedMethodName) { $lev = levenshtein($methodName, $definedMethodName); - if ($lev <= \strlen($methodName) / 3 || false !== strpos($definedMethodName, $methodName)) { + if ($lev <= \strlen($methodName) / 3 || str_contains($definedMethodName, $methodName)) { $candidates[] = $definedMethodName; } } diff --git a/src/Symfony/Component/ErrorHandler/ErrorHandler.php b/src/Symfony/Component/ErrorHandler/ErrorHandler.php index d1994f090180c..b97694ca5d8d7 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorHandler.php +++ b/src/Symfony/Component/ErrorHandler/ErrorHandler.php @@ -387,7 +387,7 @@ private function reRegister(int $prev): void */ public function handleError(int $type, string $message, string $file, int $line): bool { - if (\E_WARNING === $type && '"' === $message[0] && false !== strpos($message, '" targeting switch is equivalent to "break')) { + if (\E_WARNING === $type && '"' === $message[0] && str_contains($message, '" targeting switch is equivalent to "break')) { $type = \E_DEPRECATED; } @@ -438,7 +438,7 @@ public function handleError(int $type, string $message, string $file, int $line) return true; } } else { - if (false !== strpos($message, '@anonymous')) { + if (str_contains($message, '@anonymous')) { $backtrace = debug_backtrace(false, 5); for ($i = 1; isset($backtrace[$i]); ++$i) { @@ -504,7 +504,7 @@ public function handleException(\Throwable $exception) } if ($this->loggedErrors & $type) { - if (false !== strpos($message = $exception->getMessage(), "@anonymous\0")) { + if (str_contains($message = $exception->getMessage(), "@anonymous\0")) { $message = $this->parseAnonymousClass($message); } diff --git a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php index 88ec4ed566f0e..a11fe080b95d0 100644 --- a/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php +++ b/src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php @@ -313,7 +313,7 @@ private function formatFileFromText(string $text) private function formatLogMessage(string $message, array $context) { - if ($context && false !== strpos($message, '{')) { + if ($context && str_contains($message, '{')) { $replacements = []; foreach ($context as $key => $val) { if (is_scalar($val)) { diff --git a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php index f6f0f6fe408ee..4ffaacb9990ef 100644 --- a/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php +++ b/src/Symfony/Component/ErrorHandler/Exception/FlattenException.php @@ -165,7 +165,7 @@ public function getClass(): string */ public function setClass(string $class): self { - $this->class = false !== strpos($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; + $this->class = str_contains($class, "@anonymous\0") ? (get_parent_class($class) ?: key(class_implements($class)) ?: 'class').'@anonymous' : $class; return $this; } @@ -222,7 +222,7 @@ public function getMessage(): string */ public function setMessage(string $message): self { - if (false !== strpos($message, "@anonymous\0")) { + if (str_contains($message, "@anonymous\0")) { $message = preg_replace_callback('/[a-zA-Z_\x7f-\xff][\\\\a-zA-Z0-9_\x7f-\xff]*+@anonymous\x00.*?\.php(?:0x?|:[0-9]++\$)[0-9a-fA-F]++/', function ($m) { return class_exists($m[0], false) ? (get_parent_class($m[0]) ?: key(class_implements($m[0])) ?: 'class').'@anonymous' : $m[0]; }, $message); diff --git a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php index 7df21922aa38e..c2fe127dcf562 100644 --- a/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php +++ b/src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php @@ -45,7 +45,7 @@ public function __construct(callable|array $listener, ?string $name, Stopwatch $ $this->pretty = $this->name.'::'.$listener[1]; } elseif ($listener instanceof \Closure) { $r = new \ReflectionFunction($listener); - if (false !== strpos($r->name, '{closure}')) { + if (str_contains($r->name, '{closure}')) { $this->pretty = $this->name = 'closure'; } elseif ($class = $r->getClosureScopeClass()) { $this->name = $class->name; diff --git a/src/Symfony/Component/ExpressionLanguage/Lexer.php b/src/Symfony/Component/ExpressionLanguage/Lexer.php index 6e3cc488b1ee3..a8966f6fa52fb 100644 --- a/src/Symfony/Component/ExpressionLanguage/Lexer.php +++ b/src/Symfony/Component/ExpressionLanguage/Lexer.php @@ -48,13 +48,13 @@ public function tokenize(string $expression) } $tokens[] = new Token(Token::NUMBER_TYPE, $number, $cursor + 1); $cursor += \strlen($match[0]); - } elseif (false !== strpos('([{', $expression[$cursor])) { + } elseif (str_contains('([{', $expression[$cursor])) { // opening bracket $brackets[] = [$expression[$cursor], $cursor]; $tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1); ++$cursor; - } elseif (false !== strpos(')]}', $expression[$cursor])) { + } elseif (str_contains(')]}', $expression[$cursor])) { // closing bracket if (empty($brackets)) { throw new SyntaxError(sprintf('Unexpected "%s".', $expression[$cursor]), $cursor, $expression); @@ -75,7 +75,7 @@ public function tokenize(string $expression) // operators $tokens[] = new Token(Token::OPERATOR_TYPE, $match[0], $cursor + 1); $cursor += \strlen($match[0]); - } elseif (false !== strpos('.,?:', $expression[$cursor])) { + } elseif (str_contains('.,?:', $expression[$cursor])) { // punctuation $tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1); ++$cursor; diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 1c75347cbba42..7acf53073a6ab 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -192,7 +192,7 @@ private static function doRemove(array $files, bool $isRecursive): void throw new IOException(sprintf('Failed to remove directory "%s": ', $file).$lastError); } - } elseif (!self::box('unlink', $file) && (false !== strpos(self::$lastError, 'Permission denied') || file_exists($file))) { + } elseif (!self::box('unlink', $file) && (str_contains(self::$lastError, 'Permission denied') || file_exists($file))) { throw new IOException(sprintf('Failed to remove file "%s": ', $file).self::$lastError); } } @@ -382,7 +382,7 @@ public function hardlink(string $originFile, string|iterable $targetFiles) private function linkException(string $origin, string $target, string $linkType) { if (self::$lastError) { - if ('\\' === \DIRECTORY_SEPARATOR && false !== strpos(self::$lastError, 'error code(1314)')) { + if ('\\' === \DIRECTORY_SEPARATOR && str_contains(self::$lastError, 'error code(1314)')) { throw new IOException(sprintf('Unable to create "%s" link due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', $linkType), 0, null, $target); } } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php index 76cfb9f9ff8cb..725870c69857a 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php @@ -48,7 +48,7 @@ public static function setUpBeforeClass(): void $targetFile = tempnam(sys_get_temp_dir(), 'li'); if (true !== @link($originFile, $targetFile)) { $report = error_get_last(); - if (\is_array($report) && false !== strpos($report['message'], 'error code(1314)')) { + if (\is_array($report) && str_contains($report['message'], 'error code(1314)')) { self::$linkOnWindows = false; } } else { @@ -60,7 +60,7 @@ public static function setUpBeforeClass(): void $targetDir = tempnam(sys_get_temp_dir(), 'sl'); if (true !== @symlink($originDir, $targetDir)) { $report = error_get_last(); - if (\is_array($report) && false !== strpos($report['message'], 'error code(1314)')) { + if (\is_array($report) && str_contains($report['message'], 'error code(1314)')) { self::$symlinkOnWindows = false; } } else { diff --git a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php index 8e11b48864b8a..df8a9a05d73d3 100644 --- a/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php +++ b/src/Symfony/Component/Finder/Iterator/ExcludeDirectoryFilterIterator.php @@ -34,7 +34,7 @@ public function __construct(\Iterator $iterator, array $directories) $patterns = []; foreach ($directories as $directory) { $directory = rtrim($directory, '/'); - if (!$this->isRecursive || false !== strpos($directory, '/')) { + if (!$this->isRecursive || str_contains($directory, '/')) { $patterns[] = preg_quote($directory, '#'); } else { $this->excludedDirs[$directory] = true; diff --git a/src/Symfony/Component/Finder/Tests/FinderTest.php b/src/Symfony/Component/Finder/Tests/FinderTest.php index 83e3a01e3106a..f005433d94c42 100644 --- a/src/Symfony/Component/Finder/Tests/FinderTest.php +++ b/src/Symfony/Component/Finder/Tests/FinderTest.php @@ -869,7 +869,7 @@ public function testSortAcrossDirectories() public function testFilter() { $finder = $this->buildFinder(); - $this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return false !== strpos($f, 'test'); })); + $this->assertSame($finder, $finder->filter(function (\SplFileInfo $f) { return str_contains($f, 'test'); })); $this->assertIterator($this->toAbsolute(['test.php', 'test.py']), $finder->in(self::$tmpDir)->getIterator()); } diff --git a/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php b/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php index bc80ed2e1e856..028e35845251d 100644 --- a/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php +++ b/src/Symfony/Component/Finder/Tests/Iterator/MockSplFileInfo.php @@ -51,7 +51,7 @@ public function __construct($param) public function isFile(): bool { if (null === $this->type) { - return false !== strpos($this->getFilename(), 'file'); + return str_contains($this->getFilename(), 'file'); } return self::TYPE_FILE === $this->type; @@ -60,7 +60,7 @@ public function isFile(): bool public function isDir(): bool { if (null === $this->type) { - return false !== strpos($this->getFilename(), 'directory'); + return str_contains($this->getFilename(), 'directory'); } return self::TYPE_DIRECTORY === $this->type; diff --git a/src/Symfony/Component/Form/Command/DebugCommand.php b/src/Symfony/Component/Form/Command/DebugCommand.php index fa97d9d51e126..cc5f0dcca3b50 100644 --- a/src/Symfony/Component/Form/Command/DebugCommand.php +++ b/src/Symfony/Component/Form/Command/DebugCommand.php @@ -231,7 +231,7 @@ private function findAlternatives(string $name, array $collection): array $alternatives = []; foreach ($collection as $item) { $lev = levenshtein($name, $item); - if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) { + if ($lev <= \strlen($name) / 3 || str_contains($item, $name)) { $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; } } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php index 04c20b54eefa4..0ac2904f90793 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php @@ -40,7 +40,7 @@ public function reverseTransform(mixed $value) { $decimalSeparator = $this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); - if (\is_string($value) && false !== strpos($value, $decimalSeparator)) { + if (\is_string($value) && str_contains($value, $decimalSeparator)) { throw new TransformationFailedException(sprintf('The value "%s" is not a valid integer.', $value)); } diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php index 6885c11867eeb..28d7433c458fe 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php @@ -108,7 +108,7 @@ public function reverseTransform(mixed $value) $value = str_replace(',', $decSep, $value); } - if (false !== strpos($value, $decSep)) { + if (str_contains($value, $decSep)) { $type = \NumberFormatter::TYPE_DOUBLE; } else { $type = \PHP_INT_SIZE === 8 diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php index 0d80ee2f92399..aac6cff361bbd 100644 --- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php @@ -129,7 +129,7 @@ public function reverseTransform(mixed $value) $value = str_replace(',', $decSep, $value); } - if (false !== strpos($value, $decSep)) { + if (str_contains($value, $decSep)) { $type = \NumberFormatter::TYPE_DOUBLE; } else { $type = \PHP_INT_SIZE === 8 ? \NumberFormatter::TYPE_INT64 : \NumberFormatter::TYPE_INT32; diff --git a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php index 1982e85d8b656..b64d0dbaae655 100644 --- a/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php +++ b/src/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php @@ -153,7 +153,7 @@ public function mapViolation(ConstraintViolation $violation, FormInterface $form $message = $violation->getMessage(); $messageTemplate = $violation->getMessageTemplate(); - if (false !== strpos($message, '{{ label }}') || false !== strpos($messageTemplate, '{{ label }}')) { + if (str_contains($message, '{{ label }}') || str_contains($messageTemplate, '{{ label }}')) { $form = $scope; do { diff --git a/src/Symfony/Component/HttpClient/CurlHttpClient.php b/src/Symfony/Component/HttpClient/CurlHttpClient.php index 1c565e9f7a680..bc796d3f9551a 100644 --- a/src/Symfony/Component/HttpClient/CurlHttpClient.php +++ b/src/Symfony/Component/HttpClient/CurlHttpClient.php @@ -272,7 +272,7 @@ public function request(string $method, string $url, array $options = []): Respo if ($options['bindto']) { if (file_exists($options['bindto'])) { $curlopts[\CURLOPT_UNIX_SOCKET_PATH] = $options['bindto']; - } elseif (0 !== strpos($options['bindto'], 'if!') && preg_match('/^(.*):(\d+)$/', $options['bindto'], $matches)) { + } elseif (str_contains($options['bindto'], 'if!') && preg_match('/^(.*):(\d+)$/', $options['bindto'], $matches)) { $curlopts[\CURLOPT_INTERFACE] = $matches[1]; $curlopts[\CURLOPT_LOCALPORT] = $matches[2]; } else { @@ -382,7 +382,7 @@ private function handlePush($parent, $pushed, array $requestHeaders, int $maxPen // curl before 7.65 doesn't validate the pushed ":authority" header, // but this is a MUST in the HTTP/2 RFC; let's restrict pushes to the original host, // ignoring domains mentioned as alt-name in the certificate for now (same as curl). - if (0 !== strpos($origin, $url.'/')) { + if (str_contains($origin, $url.'/')) { $this->logger && $this->logger->debug(sprintf('Rejecting pushed response from "%s": server is not authoritative for "%s"', $origin, $url)); return \CURL_PUSH_DENY; diff --git a/src/Symfony/Component/HttpClient/HttpClientTrait.php b/src/Symfony/Component/HttpClient/HttpClientTrait.php index 4dc279d1e9713..cab67984d83c2 100644 --- a/src/Symfony/Component/HttpClient/HttpClientTrait.php +++ b/src/Symfony/Component/HttpClient/HttpClientTrait.php @@ -227,7 +227,7 @@ private static function mergeDefaultOptions(array $options, array $defaultOption $alternatives = []; foreach ($defaultOptions as $key => $v) { - if (levenshtein($name, $key) <= \strlen($name) / 3 || false !== strpos($key, $name)) { + if (levenshtein($name, $key) <= \strlen($name) / 3 || str_contains($key, $name)) { $alternatives[] = $key; } } @@ -486,7 +486,7 @@ private static function parseUrl(string $url, array $query = [], array $allowedS continue; } - if (false !== strpos($parts[$part], '%')) { + if (str_contains($parts[$part], '%')) { // https://tools.ietf.org/html/rfc3986#section-2.3 $parts[$part] = preg_replace_callback('/%(?:2[DE]|3[0-9]|[46][1-9A-F]|5F|[57][0-9A]|7E)++/i', function ($m) { return rawurldecode($m[0]); }, $parts[$part]); } diff --git a/src/Symfony/Component/HttpClient/Internal/AmpListener.php b/src/Symfony/Component/HttpClient/Internal/AmpListener.php index cb3235bca3ff6..70be7a26997f9 100644 --- a/src/Symfony/Component/HttpClient/Internal/AmpListener.php +++ b/src/Symfony/Component/HttpClient/Internal/AmpListener.php @@ -81,7 +81,7 @@ public function startSendingRequest(Request $request, Stream $stream): Promise { $host = $stream->getRemoteAddress()->getHost(); - if (false !== strpos($host, ':')) { + if (str_contains($host, ':')) { $host = '['.$host.']'; } diff --git a/src/Symfony/Component/HttpClient/Response/CurlResponse.php b/src/Symfony/Component/HttpClient/Response/CurlResponse.php index 585fdb933a286..7a00b1342a4cf 100644 --- a/src/Symfony/Component/HttpClient/Response/CurlResponse.php +++ b/src/Symfony/Component/HttpClient/Response/CurlResponse.php @@ -374,7 +374,7 @@ private static function parseHeaderLine($ch, string $data, array &$info, array & return \strlen($data); } - if (0 !== strpos($data, 'HTTP/')) { + if (str_contains($data, 'HTTP/')) { if (0 === stripos($data, 'Location:')) { $location = trim(substr($data, 9)); } diff --git a/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php b/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php index 1618b123c8cc9..01299e26f7eef 100644 --- a/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php +++ b/src/Symfony/Component/HttpClient/Tests/CurlHttpClientTest.php @@ -22,7 +22,7 @@ class CurlHttpClientTest extends HttpClientTestCase { protected function getHttpClient(string $testCase): HttpClientInterface { - if (false !== strpos($testCase, 'Push')) { + if (str_contains($testCase, 'Push')) { if (!\defined('CURLMOPT_PUSHFUNCTION') || 0x073d00 > ($v = curl_version())['version_number'] || !(\CURL_VERSION_HTTP2 & $v['features'])) { $this->markTestSkipped('curl <7.61 is used or it is not compiled with support for HTTP/2 PUSH'); } diff --git a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php index cea0463981e51..64b0940c6f19e 100644 --- a/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php +++ b/src/Symfony/Component/HttpFoundation/BinaryFileResponse.php @@ -138,7 +138,7 @@ public function setContentDisposition(string $disposition, string $filename = '' $filename = $this->file->getFilename(); } - if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) { + if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || str_contains($filename, '%'))) { $encoding = mb_detect_encoding($filename, null, true) ?: '8bit'; for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) { diff --git a/src/Symfony/Component/HttpFoundation/HeaderUtils.php b/src/Symfony/Component/HttpFoundation/HeaderUtils.php index 1824ac336d57b..8ef870284d5c5 100644 --- a/src/Symfony/Component/HttpFoundation/HeaderUtils.php +++ b/src/Symfony/Component/HttpFoundation/HeaderUtils.php @@ -176,12 +176,12 @@ public static function makeDisposition(string $disposition, string $filename, st } // percent characters aren't safe in fallback. - if (false !== strpos($filenameFallback, '%')) { + if (str_contains($filenameFallback, '%')) { throw new \InvalidArgumentException('The filename fallback cannot contain the "%" character.'); } // path separators aren't allowed in either. - if (false !== strpos($filename, '/') || false !== strpos($filename, '\\') || false !== strpos($filenameFallback, '/') || false !== strpos($filenameFallback, '\\')) { + if (str_contains($filename, '/') || str_contains($filename, '\\') || str_contains($filenameFallback, '/') || str_contains($filenameFallback, '\\')) { throw new \InvalidArgumentException('The filename and the fallback cannot contain the "/" and "\\" characters.'); } diff --git a/src/Symfony/Component/HttpFoundation/IpUtils.php b/src/Symfony/Component/HttpFoundation/IpUtils.php index 70738c8d5ed6e..8349867d80d72 100644 --- a/src/Symfony/Component/HttpFoundation/IpUtils.php +++ b/src/Symfony/Component/HttpFoundation/IpUtils.php @@ -70,7 +70,7 @@ public static function checkIp4(?string $requestIp, string $ip) return self::$checkedIps[$cacheKey] = false; } - if (false !== strpos($ip, '/')) { + if (str_contains($ip, '/')) { [$address, $netmask] = explode('/', $ip, 2); if ('0' === $netmask) { @@ -117,7 +117,7 @@ public static function checkIp6(?string $requestIp, string $ip) throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".'); } - if (false !== strpos($ip, '/')) { + if (str_contains($ip, '/')) { [$address, $netmask] = explode('/', $ip, 2); if ('0' === $netmask) { diff --git a/src/Symfony/Component/HttpFoundation/Request.php b/src/Symfony/Component/HttpFoundation/Request.php index 6324221fa3ee9..c66434271f84d 100644 --- a/src/Symfony/Component/HttpFoundation/Request.php +++ b/src/Symfony/Component/HttpFoundation/Request.php @@ -1666,7 +1666,7 @@ public function getLanguages() $languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all(); $this->languages = []; foreach ($languages as $lang => $acceptHeaderItem) { - if (false !== strpos($lang, '-')) { + if (str_contains($lang, '-')) { $codes = explode('-', $lang); if ('i' === $codes[0]) { // Language not listed in ISO 639 that are not variants @@ -1991,7 +1991,7 @@ private function setPhpDefaultLocale(string $locale): void */ private function getUrlencodedPrefix(string $string, string $prefix): ?string { - if (0 !== strpos(rawurldecode($string), $prefix)) { + if (str_contains(rawurldecode($string), $prefix)) { return null; } diff --git a/src/Symfony/Component/HttpFoundation/Response.php b/src/Symfony/Component/HttpFoundation/Response.php index 7c129f4f573ac..ee7462ff0ac59 100644 --- a/src/Symfony/Component/HttpFoundation/Response.php +++ b/src/Symfony/Component/HttpFoundation/Response.php @@ -303,7 +303,7 @@ public function prepare(Request $request) } // Check if we need to send extra expire info headers - if ('1.0' == $this->getProtocolVersion() && false !== strpos($headers->get('Cache-Control'), 'no-cache')) { + if ('1.0' == $this->getProtocolVersion() && str_contains($headers->get('Cache-Control'), 'no-cache')) { $headers->set('pragma', 'no-cache'); $headers->set('expires', -1); } @@ -905,7 +905,7 @@ public function setEtag(string $etag = null, bool $weak = false): object if (null === $etag) { $this->headers->remove('Etag'); } else { - if (0 !== strpos($etag, '"')) { + if (str_contains($etag, '"')) { $etag = '"'.$etag.'"'; } diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index f8be4462f86bb..23453259f7bb5 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -179,7 +179,7 @@ public function __construct(\PDO|string $pdoOrDsn = null, array $options = []) $this->pdo = $pdoOrDsn; $this->driver = $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME); - } elseif (\is_string($pdoOrDsn) && false !== strpos($pdoOrDsn, '://')) { + } elseif (\is_string($pdoOrDsn) && str_contains($pdoOrDsn, '://')) { $this->dsn = $this->buildDsnFromUrl($pdoOrDsn); } else { $this->dsn = $pdoOrDsn; diff --git a/src/Symfony/Component/HttpFoundation/UrlHelper.php b/src/Symfony/Component/HttpFoundation/UrlHelper.php index 0f417130afb0b..c15f101cdf80b 100644 --- a/src/Symfony/Component/HttpFoundation/UrlHelper.php +++ b/src/Symfony/Component/HttpFoundation/UrlHelper.php @@ -31,7 +31,7 @@ public function __construct(RequestStack $requestStack, RequestContext $requestC public function getAbsoluteUrl(string $path): string { - if (false !== strpos($path, '://') || '//' === substr($path, 0, 2)) { + if (str_contains($path, '://') || '//' === substr($path, 0, 2)) { return $path; } @@ -60,7 +60,7 @@ public function getAbsoluteUrl(string $path): string public function getRelativePath(string $path): string { - if (false !== strpos($path, '://') || '//' === substr($path, 0, 2)) { + if (str_contains($path, '://') || '//' === substr($path, 0, 2)) { return $path; } diff --git a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php index b0bf578759135..2a6180cb54b40 100644 --- a/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php +++ b/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php @@ -143,7 +143,7 @@ protected function instantiateController(string $class) private function getControllerError(mixed $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); @@ -184,7 +184,7 @@ private function getControllerError(mixed $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/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php index 09d3700eea088..3dd1ae84b171f 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/DumpDataCollector.php @@ -115,7 +115,7 @@ public function collect(Request $request, Response $response, \Throwable $except || '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/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index c075ed02f6ade..71fe765842461 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -433,7 +433,7 @@ public function collectSessionUsage(): void */ protected function parseController(array|object|string|null $controller) { - if (\is_string($controller) && false !== strpos($controller, '::')) { + if (\is_string($controller) && str_contains($controller, '::')) { $controller = explode('::', $controller); } @@ -470,7 +470,7 @@ protected function parseController(array|object|string|null $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/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php index 5eb833b51d074..7dc8b18283804 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/AddAnnotatedClassesToCachePass.php @@ -127,7 +127,7 @@ 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')) { diff --git a/src/Symfony/Component/HttpKernel/Exception/ControllerDoesNotReturnResponseException.php b/src/Symfony/Component/HttpKernel/Exception/ControllerDoesNotReturnResponseException.php index 1e87690ff1cc8..54c80be90fa50 100644 --- a/src/Symfony/Component/HttpKernel/Exception/ControllerDoesNotReturnResponseException.php +++ b/src/Symfony/Component/HttpKernel/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/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php b/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php index bcfa13446af72..54d0dc9163fba 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/AbstractSurrogate.php +++ b/src/Symfony/Component/HttpKernel/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/src/Symfony/Component/HttpKernel/HttpCache/Esi.php b/src/Symfony/Component/HttpKernel/HttpCache/Esi.php index 4a1626eca08a9..cd6a00a10d61f 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Esi.php +++ b/src/Symfony/Component/HttpKernel/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/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php b/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php index 0ba351dd129c2..f114e05cfb2f6 100644 --- a/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php +++ b/src/Symfony/Component/HttpKernel/HttpCache/Ssi.php @@ -34,7 +34,7 @@ public function getName() */ public function addSurrogateControl(Response $response) { - if (false !== strpos($response->getContent(), '