Skip to content

Commit bbe96c7

Browse files
committed
Leverage str_starts_with(), str_ends_with() and str_contains()
1 parent 6ab662b commit bbe96c7

File tree

95 files changed

+194
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+194
-194
lines changed

.github/build-packages.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
'type' => 'composer',
3636
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
3737
]];
38-
if (false === strpos($json, "\n \"repositories\": [\n")) {
38+
if (!str_contains($json, "\n \"repositories\": [\n")) {
3939
$json = rtrim(json_encode(['repositories' => $package->repositories], $flags), "\n}").','.substr($json, 1);
4040
file_put_contents($dir.'/composer.json', $json);
4141
}

.github/get-modified-packages.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ function isComponentBridge(string $packageDir): bool
2626
$modifiedPackages = [];
2727
foreach ($modifiedFiles as $file) {
2828
foreach ($allPackages as $package) {
29-
if (0 === strpos($file, $package)) {
29+
if (str_starts_with($file, $package)) {
3030
$modifiedPackages[$package] = true;
31-
if ('LICENSE' === substr($file, -7)) {
31+
if (str_ends_with($file, 'LICENSE')) {
3232
/*
3333
* There is never a reason to modify the LICENSE file, this diff
3434
* must be adding a new package

.github/patch-types.php

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,36 @@
1313

1414
foreach ($loader->getClassMap() as $class => $file) {
1515
switch (true) {
16-
case false !== strpos($file = realpath($file), '/vendor/'):
17-
case false !== strpos($file, '/src/Symfony/Bridge/PhpUnit/'):
18-
case false !== strpos($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
19-
case false !== strpos($file, '/src/Symfony/Component/Cache/Tests/Fixtures/DriverWrapper.php'):
20-
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):
21-
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
22-
case false !== strpos($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'):
23-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php'):
24-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
25-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'):
26-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'):
27-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'):
28-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'):
29-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/NewInInitializer.php'):
30-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
31-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'):
32-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
33-
case false !== strpos($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
34-
case false !== strpos($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
35-
case false !== strpos($file, '/src/Symfony/Component/Form/Tests/Fixtures/Answer.php'):
36-
case false !== strpos($file, '/src/Symfony/Component/Form/Tests/Fixtures/Number.php'):
37-
case false !== strpos($file, '/src/Symfony/Component/Form/Tests/Fixtures/Suit.php'):
38-
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'):
39-
case false !== strpos($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php81Dummy.php'):
40-
case false !== strpos($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'):
41-
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Fixtures/'):
42-
case false !== strpos($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
43-
case false !== strpos($file, '/src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/Entity.php'):
44-
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
45-
case false !== strpos($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'):
16+
case str_contains($file = realpath($file), '/vendor/'):
17+
case str_contains($file, '/src/Symfony/Bridge/PhpUnit/'):
18+
case str_contains($file, '/src/Symfony/Bundle/FrameworkBundle/Tests/Fixtures/Validation/Article.php'):
19+
case str_contains($file, '/src/Symfony/Component/Cache/Tests/Fixtures/DriverWrapper.php'):
20+
case str_contains($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadFileName.php'):
21+
case str_contains($file, '/src/Symfony/Component/Config/Tests/Fixtures/BadParent.php'):
22+
case str_contains($file, '/src/Symfony/Component/Config/Tests/Fixtures/ParseError.php'):
23+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php'):
24+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Compiler/OptionalServiceClass.php'):
25+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/autowiring_classes.php'):
26+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/intersectiontype_classes.php'):
27+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/includes/MultipleArgumentsOptionalScalarNotReallyOptional.php'):
28+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/CheckTypeDeclarationsPass/IntersectionConstructor.php'):
29+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/NewInInitializer.php'):
30+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ParentNotExists.php'):
31+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Preload/'):
32+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/Prototype/BadClasses/MissingParent.php'):
33+
case str_contains($file, '/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/'):
34+
case str_contains($file, '/src/Symfony/Component/ErrorHandler/Tests/Fixtures/'):
35+
case str_contains($file, '/src/Symfony/Component/Form/Tests/Fixtures/Answer.php'):
36+
case str_contains($file, '/src/Symfony/Component/Form/Tests/Fixtures/Number.php'):
37+
case str_contains($file, '/src/Symfony/Component/Form/Tests/Fixtures/Suit.php'):
38+
case str_contains($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/'):
39+
case str_contains($file, '/src/Symfony/Component/PropertyInfo/Tests/Fixtures/Php81Dummy.php'):
40+
case str_contains($file, '/src/Symfony/Component/Runtime/Internal/ComposerPlugin.php'):
41+
case str_contains($file, '/src/Symfony/Component/Serializer/Tests/Fixtures/'):
42+
case str_contains($file, '/src/Symfony/Component/Serializer/Tests/Normalizer/Features/ObjectOuter.php'):
43+
case str_contains($file, '/src/Symfony/Component/Validator/Tests/Fixtures/NestedAttribute/Entity.php'):
44+
case str_contains($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/NotLoadableClass.php'):
45+
case str_contains($file, '/src/Symfony/Component/VarDumper/Tests/Fixtures/ReflectionIntersectionTypeFixture.php'):
4646
continue 2;
4747
}
4848

src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9090
}
9191

9292
$useBuildDir = $realBuildDir !== $realCacheDir;
93-
$oldBuildDir = substr($realBuildDir, 0, -1).('~' === substr($realBuildDir, -1) ? '+' : '~');
93+
$oldBuildDir = substr($realBuildDir, 0, -1).(str_ends_with($realBuildDir, '~') ? '+' : '~');
9494
if ($useBuildDir) {
9595
$fs->remove($oldBuildDir);
9696

@@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
120120

121121
// the warmup cache dir name must have the same length as the real one
122122
// to avoid the many problems in serialized resources files
123-
$warmupDir = substr($realBuildDir, 0, -1).('_' === substr($realBuildDir, -1) ? '-' : '_');
123+
$warmupDir = substr($realBuildDir, 0, -1).(str_ends_with($realBuildDir, '_') ? '-' : '_');
124124

125125
if ($output->isVerbose() && $fs->exists($warmupDir)) {
126126
$io->comment('Clearing outdated warmup directory...');
@@ -217,7 +217,7 @@ private function isNfs(string $dir): bool
217217
}
218218
}
219219
foreach ($mounts as $mount) {
220-
if (0 === strpos($dir, $mount)) {
220+
if (str_starts_with($dir, $mount)) {
221221
return true;
222222
}
223223
}

src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
146146
],
147147
]);
148148

149-
$kernelClass = false !== strpos(static::class, "@anonymous\0") ? parent::class : static::class;
149+
$kernelClass = str_contains(static::class, "@anonymous\0") ? parent::class : static::class;
150150

151151
if (!$container->hasDefinition('kernel')) {
152152
$container->register('kernel', $kernelClass)

src/Symfony/Bundle/FrameworkBundle/KernelBrowser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ protected function getScript(object $request): string
200200

201201
$requires = '';
202202
foreach (get_declared_classes() as $class) {
203-
if (0 === strpos($class, 'ComposerAutoloaderInit')) {
203+
if (str_starts_with($class, 'ComposerAutoloaderInit')) {
204204
$r = new \ReflectionClass($class);
205205
$file = \dirname($r->getFileName(), 2).'/autoload.php';
206206
if (is_file($file)) {

src/Symfony/Bundle/SecurityBundle/Command/DebugFirewallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ private function formatCallable(mixed $callable): string
242242

243243
if ($callable instanceof \Closure) {
244244
$r = new \ReflectionFunction($callable);
245-
if (false !== strpos($r->name, '{closure}')) {
245+
if (str_contains($r->name, '{closure}')) {
246246
return 'Closure()';
247247
}
248248
if ($class = $r->getClosureScopeClass()) {

src/Symfony/Bundle/SecurityBundle/DependencyInjection/MainConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
255255
return $requiredBadge;
256256
}
257257

258-
if (false === strpos($requiredBadge, '\\')) {
258+
if (!str_contains($requiredBadge, '\\')) {
259259
$fqcn = 'Symfony\Component\Security\Http\Authenticator\Passport\Badge\\'.$requiredBadge;
260260
if (class_exists($fqcn)) {
261261
return $fqcn;

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Security/Factory/RememberMeFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public function createAuthenticator(ContainerBuilder $container, string $firewal
112112

113113
foreach ($container->findTaggedServiceIds('security.remember_me_aware') as $serviceId => $attributes) {
114114
// register ContextListener
115-
if ('security.context_listener' === substr($serviceId, 0, 25)) {
115+
if (str_starts_with($serviceId, 'security.context_listener')) {
116116
continue;
117117
}
118118

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/AuthenticatorBundle/ApiAuthenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function supports(Request $request): ?bool
4040
public function authenticate(Request $request): Passport
4141
{
4242
$email = $request->headers->get('X-USER-EMAIL');
43-
if (false === strpos($email, '@')) {
43+
if (!str_contains($email, '@')) {
4444
throw new BadCredentialsException('Email is not a valid email address.');
4545
}
4646

0 commit comments

Comments
 (0)