Skip to content

Commit 4875a84

Browse files
committed
Prefix all sprintf() calls
1 parent 971a137 commit 4875a84

File tree

65 files changed

+295
-295
lines changed

Some content is hidden

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

65 files changed

+295
-295
lines changed

CacheWarmer/RouterCacheWarmer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function warmUp(string $cacheDir, ?string $buildDir = null): array
4646
return (array) $router->warmUp($cacheDir, $buildDir);
4747
}
4848

49-
throw new \LogicException(sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));
49+
throw new \LogicException(\sprintf('The router "%s" cannot be warmed up because it does not implement "%s".', get_debug_type($router), WarmableInterface::class));
5050
}
5151

5252
public function isOptional(): bool

Command/AbstractConfigCommand.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ protected function findExtension(string $name): ExtensionInterface
114114
foreach ($bundles as $bundle) {
115115
if ($name === $bundle->getName()) {
116116
if (!$bundle->getContainerExtension()) {
117-
throw new \LogicException(sprintf('Bundle "%s" does not have a container extension.', $name));
117+
throw new \LogicException(\sprintf('Bundle "%s" does not have a container extension.', $name));
118118
}
119119

120120
return $bundle->getContainerExtension();
@@ -144,13 +144,13 @@ protected function findExtension(string $name): ExtensionInterface
144144
}
145145

146146
if (!str_ends_with($name, 'Bundle')) {
147-
$message = sprintf('No extensions with configuration available for "%s".', $name);
147+
$message = \sprintf('No extensions with configuration available for "%s".', $name);
148148
} else {
149-
$message = sprintf('No extension with alias "%s" is enabled.', $name);
149+
$message = \sprintf('No extension with alias "%s" is enabled.', $name);
150150
}
151151

152152
if (isset($guess) && $minScore < 3) {
153-
$message .= sprintf("\n\nDid you mean \"%s\"?", $guess);
153+
$message .= \sprintf("\n\nDid you mean \"%s\"?", $guess);
154154
}
155155

156156
throw new LogicException($message);
@@ -159,11 +159,11 @@ protected function findExtension(string $name): ExtensionInterface
159159
public function validateConfiguration(ExtensionInterface $extension, mixed $configuration): void
160160
{
161161
if (!$configuration) {
162-
throw new \LogicException(sprintf('The extension with alias "%s" does not have its getConfiguration() method setup.', $extension->getAlias()));
162+
throw new \LogicException(\sprintf('The extension with alias "%s" does not have its getConfiguration() method setup.', $extension->getAlias()));
163163
}
164164

165165
if (!$configuration instanceof ConfigurationInterface) {
166-
throw new \LogicException(sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', get_debug_type($configuration)));
166+
throw new \LogicException(\sprintf('Configuration class "%s" should implement ConfigurationInterface in order to be dumpable.', get_debug_type($configuration)));
167167
}
168168
}
169169

Command/AssetsInstallCommand.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9393
$targetArg = $kernel->getProjectDir().'/'.$targetArg;
9494

9595
if (!is_dir($targetArg)) {
96-
throw new InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $targetArg));
96+
throw new InvalidArgumentException(\sprintf('The target directory "%s" does not exist.', $targetArg));
9797
}
9898
}
9999

@@ -130,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
130130
$validAssetDirs[] = $assetDir;
131131

132132
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
133-
$message = sprintf("%s\n-> %s", $bundle->getName(), $targetDir);
133+
$message = \sprintf("%s\n-> %s", $bundle->getName(), $targetDir);
134134
} else {
135135
$message = $bundle->getName();
136136
}
@@ -151,13 +151,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
151151
}
152152

153153
if ($method === $expectedMethod) {
154-
$rows[] = [sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method];
154+
$rows[] = [\sprintf('<fg=green;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'OK' : "\xE2\x9C\x94" /* HEAVY CHECK MARK (U+2714) */), $message, $method];
155155
} else {
156-
$rows[] = [sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method];
156+
$rows[] = [\sprintf('<fg=yellow;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'WARNING' : '!'), $message, $method];
157157
}
158158
} catch (\Exception $e) {
159159
$exitCode = 1;
160-
$rows[] = [sprintf('<fg=red;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()];
160+
$rows[] = [\sprintf('<fg=red;options=bold>%s</>', '\\' === \DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage()];
161161
}
162162
}
163163
// remove the assets of the bundles that no longer exist
@@ -230,7 +230,7 @@ private function symlink(string $originDir, string $targetDir, bool $relative =
230230
}
231231
$this->filesystem->symlink($originDir, $targetDir);
232232
if (!file_exists($targetDir)) {
233-
throw new IOException(sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
233+
throw new IOException(\sprintf('Symbolic link "%s" was created but appears to be broken.', $targetDir), 0, null, $targetDir);
234234
}
235235
}
236236

Command/CacheClearCommand.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8080
$fs->remove($oldCacheDir);
8181

8282
if (!is_writable($realCacheDir)) {
83-
throw new RuntimeException(sprintf('Unable to write in the "%s" directory.', $realCacheDir));
83+
throw new RuntimeException(\sprintf('Unable to write in the "%s" directory.', $realCacheDir));
8484
}
8585

8686
$useBuildDir = $realBuildDir !== $realCacheDir;
@@ -89,7 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8989
$fs->remove($oldBuildDir);
9090

9191
if (!is_writable($realBuildDir)) {
92-
throw new RuntimeException(sprintf('Unable to write in the "%s" directory.', $realBuildDir));
92+
throw new RuntimeException(\sprintf('Unable to write in the "%s" directory.', $realBuildDir));
9393
}
9494

9595
if ($this->isNfs($realCacheDir)) {
@@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
100100
$fs->mkdir($realCacheDir);
101101
}
102102

103-
$io->comment(sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
103+
$io->comment(\sprintf('Clearing the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
104104
if ($useBuildDir) {
105105
$this->cacheClearer->clear($realBuildDir);
106106
}
@@ -189,7 +189,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
189189
$io->comment('Finished');
190190
}
191191

192-
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
192+
$io->success(\sprintf('Cache for the "%s" environment (debug=%s) was successfully cleared.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
193193

194194
return 0;
195195
}

Command/CachePoolClearCommand.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -95,28 +95,28 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9595
} elseif ($pool instanceof Psr6CacheClearer) {
9696
$clearers[$id] = $pool;
9797
} else {
98-
throw new InvalidArgumentException(sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
98+
throw new InvalidArgumentException(\sprintf('"%s" is not a cache pool nor a cache clearer.', $id));
9999
}
100100
}
101101
}
102102

103103
foreach ($clearers as $id => $clearer) {
104-
$io->comment(sprintf('Calling cache clearer: <info>%s</info>', $id));
104+
$io->comment(\sprintf('Calling cache clearer: <info>%s</info>', $id));
105105
$clearer->clear($kernel->getContainer()->getParameter('kernel.cache_dir'));
106106
}
107107

108108
$failure = false;
109109
foreach ($pools as $id => $pool) {
110-
$io->comment(sprintf('Clearing cache pool: <info>%s</info>', $id));
110+
$io->comment(\sprintf('Clearing cache pool: <info>%s</info>', $id));
111111

112112
if ($pool instanceof CacheItemPoolInterface) {
113113
if (!$pool->clear()) {
114-
$io->warning(sprintf('Cache pool "%s" could not be cleared.', $pool));
114+
$io->warning(\sprintf('Cache pool "%s" could not be cleared.', $pool));
115115
$failure = true;
116116
}
117117
} else {
118118
if (false === $this->poolClearer->clearPool($id)) {
119-
$io->warning(sprintf('Cache pool "%s" could not be cleared.', $pool));
119+
$io->warning(\sprintf('Cache pool "%s" could not be cleared.', $pool));
120120
$failure = true;
121121
}
122122
}

Command/CachePoolDeleteCommand.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,16 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6363
$cachePool = $this->poolClearer->getPool($pool);
6464

6565
if (!$cachePool->hasItem($key)) {
66-
$io->note(sprintf('Cache item "%s" does not exist in cache pool "%s".', $key, $pool));
66+
$io->note(\sprintf('Cache item "%s" does not exist in cache pool "%s".', $key, $pool));
6767

6868
return 0;
6969
}
7070

7171
if (!$cachePool->deleteItem($key)) {
72-
throw new \Exception(sprintf('Cache item "%s" could not be deleted.', $key));
72+
throw new \Exception(\sprintf('Cache item "%s" could not be deleted.', $key));
7373
}
7474

75-
$io->success(sprintf('Cache item "%s" was successfully deleted.', $key));
75+
$io->success(\sprintf('Cache item "%s" was successfully deleted.', $key));
7676

7777
return 0;
7878
}

Command/CachePoolInvalidateTagsCommand.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -64,26 +64,26 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6464
$errors = false;
6565

6666
foreach ($pools as $name) {
67-
$io->comment(sprintf('Invalidating tag(s): <info>%s</info> from pool <comment>%s</comment>.', $tagList, $name));
67+
$io->comment(\sprintf('Invalidating tag(s): <info>%s</info> from pool <comment>%s</comment>.', $tagList, $name));
6868

6969
try {
7070
$pool = $this->pools->get($name);
7171
} catch (ServiceNotFoundException) {
72-
$io->error(sprintf('Pool "%s" not found.', $name));
72+
$io->error(\sprintf('Pool "%s" not found.', $name));
7373
$errors = true;
7474

7575
continue;
7676
}
7777

7878
if (!$pool instanceof TagAwareCacheInterface) {
79-
$io->error(sprintf('Pool "%s" is not taggable.', $name));
79+
$io->error(\sprintf('Pool "%s" is not taggable.', $name));
8080
$errors = true;
8181

8282
continue;
8383
}
8484

8585
if (!$pool->invalidateTags($tags)) {
86-
$io->error(sprintf('Cache tag(s) "%s" could not be invalidated for pool "%s".', $tagList, $name));
86+
$io->error(\sprintf('Cache tag(s) "%s" could not be invalidated for pool "%s".', $tagList, $name));
8787
$errors = true;
8888
}
8989
}

Command/CachePoolPruneCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5252
$io = new SymfonyStyle($input, $output);
5353

5454
foreach ($this->pools as $name => $pool) {
55-
$io->comment(sprintf('Pruning cache pool: <info>%s</info>', $name));
55+
$io->comment(\sprintf('Pruning cache pool: <info>%s</info>', $name));
5656
$pool->prune();
5757
}
5858

Command/CacheWarmupCommand.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5858
$io = new SymfonyStyle($input, $output);
5959

6060
$kernel = $this->getApplication()->getKernel();
61-
$io->comment(sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
61+
$io->comment(\sprintf('Warming up the cache for the <info>%s</info> environment with debug <info>%s</info>', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
6262

6363
if (!$input->getOption('no-optional-warmers')) {
6464
$this->cacheWarmer->enableOptionalWarmers();
@@ -76,7 +76,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7676
Preloader::append($preloadFile, $preload);
7777
}
7878

79-
$io->success(sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
79+
$io->success(\sprintf('Cache for the "%s" environment (debug=%s) was successfully warmed.', $kernel->getEnvironment(), var_export($kernel->isDebug(), true)));
8080

8181
return 0;
8282
}

Command/ConfigDebugCommand.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class ConfigDebugCommand extends AbstractConfigCommand
4141
{
4242
protected function configure(): void
4343
{
44-
$commentedHelpFormats = array_map(fn ($format) => sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
44+
$commentedHelpFormats = array_map(fn ($format) => \sprintf('<comment>%s</comment>', $format), $this->getAvailableFormatOptions());
4545
$helpFormats = implode('", "', $commentedHelpFormats);
4646

4747
$this
4848
->setDefinition([
4949
new InputArgument('name', InputArgument::OPTIONAL, 'The bundle name or the extension alias'),
5050
new InputArgument('path', InputArgument::OPTIONAL, 'The configuration option path'),
5151
new InputOption('resolve-env', null, InputOption::VALUE_NONE, 'Display resolved environment variable values instead of placeholders'),
52-
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), class_exists(Yaml::class) ? 'txt' : 'json'),
52+
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), class_exists(Yaml::class) ? 'txt' : 'json'),
5353
])
5454
->setHelp(<<<EOF
5555
The <info>%command.name%</info> command dumps the current configuration for an
@@ -106,7 +106,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
106106
if (null === $path = $input->getArgument('path')) {
107107
if ('txt' === $input->getOption('format')) {
108108
$io->title(
109-
sprintf('Current configuration for %s', $name === $extensionAlias ? sprintf('extension with alias "%s"', $extensionAlias) : sprintf('"%s"', $name))
109+
\sprintf('Current configuration for %s', $name === $extensionAlias ? \sprintf('extension with alias "%s"', $extensionAlias) : \sprintf('"%s"', $name))
110110
);
111111
}
112112

@@ -123,7 +123,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
123123
return 1;
124124
}
125125

126-
$io->title(sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
126+
$io->title(\sprintf('Current configuration for "%s.%s"', $extensionAlias, $path));
127127

128128
$io->writeln($this->convertToFormat($config, $format));
129129

@@ -135,7 +135,7 @@ private function convertToFormat(mixed $config, string $format): string
135135
return match ($format) {
136136
'txt', 'yaml' => Yaml::dump($config, 10),
137137
'json' => json_encode($config, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE),
138-
default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
138+
default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
139139
};
140140
}
141141

@@ -162,7 +162,7 @@ private function getConfigForPath(array $config, string $path, string $alias): m
162162

163163
foreach ($steps as $step) {
164164
if (!\array_key_exists($step, $config)) {
165-
throw new LogicException(sprintf('Unable to find configuration for "%s.%s".', $alias, $path));
165+
throw new LogicException(\sprintf('Unable to find configuration for "%s.%s".', $alias, $path));
166166
}
167167

168168
$config = $config[$step];
@@ -190,7 +190,7 @@ private function getConfigForExtension(ExtensionInterface $extension, ContainerB
190190
// Fall back to default config if the extension has one
191191

192192
if (!$extension instanceof ConfigurationExtensionInterface && !$extension instanceof ConfigurationInterface) {
193-
throw new \LogicException(sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias));
193+
throw new \LogicException(\sprintf('The extension with alias "%s" does not have configuration.', $extensionAlias));
194194
}
195195

196196
$configs = $container->getExtensionConfig($extensionAlias);

0 commit comments

Comments
 (0)