Skip to content

Commit 7960b1a

Browse files
committed
minor #44506 Leverage str_starts_with(), str_ends_with() and str_contains() (fancyweb)
This PR was merged into the 6.1 branch. Discussion ---------- Leverage str_starts_with(), str_ends_with() and str_contains() | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Continuation of the previous ones. Let's see if the CI is green first. Commits ------- bbe96c7d72 Leverage str_starts_with(), str_ends_with() and str_contains()
2 parents d1e1723 + aaae265 commit 7960b1a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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
}

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)

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)) {

0 commit comments

Comments
 (0)