Skip to content

Commit cd2e033

Browse files
CS fixes
1 parent 04ab306 commit cd2e033

22 files changed

+96
-96
lines changed

Command/DebugCommand.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ protected function configure()
6868
->setDefinition([
6969
new InputArgument('name', InputArgument::OPTIONAL, 'The template name'),
7070
new InputOption('filter', null, InputOption::VALUE_REQUIRED, 'Show details for all entries matching this filter'),
71-
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'text'),
71+
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'text'),
7272
])
7373
->setHelp(<<<'EOF'
7474
The <info>%command.name%</info> command outputs a list of twig functions,
@@ -101,13 +101,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
101101
$filter = $input->getOption('filter');
102102

103103
if (null !== $name && [] === $this->getFilesystemLoaders()) {
104-
throw new InvalidArgumentException(sprintf('Argument "name" not supported, it requires the Twig loader "%s".', FilesystemLoader::class));
104+
throw new InvalidArgumentException(\sprintf('Argument "name" not supported, it requires the Twig loader "%s".', FilesystemLoader::class));
105105
}
106106

107107
match ($input->getOption('format')) {
108108
'text' => $name ? $this->displayPathsText($io, $name) : $this->displayGeneralText($io, $filter),
109109
'json' => $name ? $this->displayPathsJson($io, $name) : $this->displayGeneralJson($io, $filter),
110-
default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
110+
default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
111111
};
112112

113113
return 0;
@@ -132,7 +132,7 @@ private function displayPathsText(SymfonyStyle $io, string $name): void
132132
$io->section('Matched File');
133133
if ($file->valid()) {
134134
if ($fileLink = $this->getFileLink($file->key())) {
135-
$io->block($file->current(), 'OK', sprintf('fg=black;bg=green;href=%s', $fileLink), ' ', true);
135+
$io->block($file->current(), 'OK', \sprintf('fg=black;bg=green;href=%s', $fileLink), ' ', true);
136136
} else {
137137
$io->success($file->current());
138138
}
@@ -142,9 +142,9 @@ private function displayPathsText(SymfonyStyle $io, string $name): void
142142
$io->section('Overridden Files');
143143
do {
144144
if ($fileLink = $this->getFileLink($file->key())) {
145-
$io->text(sprintf('* <href=%s>%s</>', $fileLink, $file->current()));
145+
$io->text(\sprintf('* <href=%s>%s</>', $fileLink, $file->current()));
146146
} else {
147-
$io->text(sprintf('* %s', $file->current()));
147+
$io->text(\sprintf('* %s', $file->current()));
148148
}
149149
$file->next();
150150
} while ($file->valid());
@@ -169,7 +169,7 @@ private function displayPathsText(SymfonyStyle $io, string $name): void
169169
}
170170
}
171171

172-
$this->error($io, sprintf('Template name "%s" not found', $name), $alternatives);
172+
$this->error($io, \sprintf('Template name "%s" not found', $name), $alternatives);
173173
}
174174

175175
$io->section('Configured Paths');
@@ -182,7 +182,7 @@ private function displayPathsText(SymfonyStyle $io, string $name): void
182182
if (FilesystemLoader::MAIN_NAMESPACE === $namespace) {
183183
$message = 'No template paths configured for your application';
184184
} else {
185-
$message = sprintf('No template paths configured for "@%s" namespace', $namespace);
185+
$message = \sprintf('No template paths configured for "@%s" namespace', $namespace);
186186
foreach ($this->getFilesystemLoaders() as $loader) {
187187
$namespaces = $loader->getNamespaces();
188188
foreach ($this->findAlternatives($namespace, $namespaces) as $namespace) {
@@ -210,7 +210,7 @@ private function displayPathsJson(SymfonyStyle $io, string $name): void
210210
$data['overridden_files'] = $files;
211211
}
212212
} else {
213-
$data['matched_file'] = sprintf('Template name "%s" not found', $name);
213+
$data['matched_file'] = \sprintf('Template name "%s" not found', $name);
214214
}
215215
$data['loader_paths'] = $paths;
216216

@@ -375,7 +375,7 @@ private function getPrettyMetadata(string $type, mixed $entity, bool $decorated)
375375
return '(unknown?)';
376376
}
377377
} catch (\UnexpectedValueException $e) {
378-
return sprintf(' <error>%s</error>', $decorated ? OutputFormatter::escape($e->getMessage()) : $e->getMessage());
378+
return \sprintf(' <error>%s</error>', $decorated ? OutputFormatter::escape($e->getMessage()) : $e->getMessage());
379379
}
380380

381381
if ('globals' === $type) {
@@ -385,7 +385,7 @@ private function getPrettyMetadata(string $type, mixed $entity, bool $decorated)
385385

386386
$description = substr(@json_encode($meta), 0, 50);
387387

388-
return sprintf(' = %s', $decorated ? OutputFormatter::escape($description) : $description);
388+
return \sprintf(' = %s', $decorated ? OutputFormatter::escape($description) : $description);
389389
}
390390

391391
if ('functions' === $type) {
@@ -432,14 +432,14 @@ private function buildWarningMessages(array $wrongBundles): array
432432
{
433433
$messages = [];
434434
foreach ($wrongBundles as $path => $alternatives) {
435-
$message = sprintf('Path "%s" not matching any bundle found', $path);
435+
$message = \sprintf('Path "%s" not matching any bundle found', $path);
436436
if ($alternatives) {
437437
if (1 === \count($alternatives)) {
438-
$message .= sprintf(", did you mean \"%s\"?\n", $alternatives[0]);
438+
$message .= \sprintf(", did you mean \"%s\"?\n", $alternatives[0]);
439439
} else {
440440
$message .= ", did you mean one of these:\n";
441441
foreach ($alternatives as $bundle) {
442-
$message .= sprintf(" - %s\n", $bundle);
442+
$message .= \sprintf(" - %s\n", $bundle);
443443
}
444444
}
445445
}
@@ -492,7 +492,7 @@ private function parseTemplateName(string $name, string $default = FilesystemLoa
492492
{
493493
if (isset($name[0]) && '@' === $name[0]) {
494494
if (false === ($pos = strpos($name, '/')) || $pos === \strlen($name) - 1) {
495-
throw new InvalidArgumentException(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
495+
throw new InvalidArgumentException(\sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
496496
}
497497

498498
$namespace = substr($name, 1, $pos - 1);

Command/LintCommand.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function __construct(
5454
protected function configure()
5555
{
5656
$this
57-
->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))
57+
->addOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))
5858
->addOption('show-deprecations', null, InputOption::VALUE_NONE, 'Show deprecations as errors')
5959
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
6060
->setHelp(<<<'EOF'
@@ -151,7 +151,7 @@ protected function findFiles(string $filename): iterable
151151
return Finder::create()->files()->in($filename)->name($this->namePatterns);
152152
}
153153

154-
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
154+
throw new RuntimeException(\sprintf('File or directory "%s" is not readable.', $filename));
155155
}
156156

157157
private function validate(string $template, string $file): array
@@ -178,7 +178,7 @@ private function display(InputInterface $input, OutputInterface $output, Symfony
178178
'txt' => $this->displayTxt($output, $io, $files),
179179
'json' => $this->displayJson($output, $files),
180180
'github' => $this->displayTxt($output, $io, $files, true),
181-
default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
181+
default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
182182
};
183183
}
184184

@@ -189,17 +189,17 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, array $fi
189189

190190
foreach ($filesInfo as $info) {
191191
if ($info['valid'] && $output->isVerbose()) {
192-
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
192+
$io->comment('<info>OK</info>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
193193
} elseif (!$info['valid']) {
194194
++$errors;
195195
$this->renderException($io, $info['template'], $info['exception'], $info['file'], $githubReporter);
196196
}
197197
}
198198

199199
if (0 === $errors) {
200-
$io->success(sprintf('All %d Twig files contain valid syntax.', \count($filesInfo)));
200+
$io->success(\sprintf('All %d Twig files contain valid syntax.', \count($filesInfo)));
201201
} else {
202-
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
202+
$io->warning(\sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
203203
}
204204

205205
return min($errors, 1);
@@ -231,28 +231,28 @@ private function renderException(SymfonyStyle $output, string $template, Error $
231231
$githubReporter?->error($exception->getRawMessage(), $file, $line <= 0 ? null : $line);
232232

233233
if ($file) {
234-
$output->text(sprintf('<error> ERROR </error> in %s (line %s)', $file, $line));
234+
$output->text(\sprintf('<error> ERROR </error> in %s (line %s)', $file, $line));
235235
} else {
236-
$output->text(sprintf('<error> ERROR </error> (line %s)', $line));
236+
$output->text(\sprintf('<error> ERROR </error> (line %s)', $line));
237237
}
238238

239239
// If the line is not known (this might happen for deprecations if we fail at detecting the line for instance),
240240
// we render the message without context, to ensure the message is displayed.
241241
if ($line <= 0) {
242-
$output->text(sprintf('<error> >> %s</error> ', $exception->getRawMessage()));
242+
$output->text(\sprintf('<error> >> %s</error> ', $exception->getRawMessage()));
243243

244244
return;
245245
}
246246

247247
foreach ($this->getContext($template, $line) as $lineNumber => $code) {
248-
$output->text(sprintf(
248+
$output->text(\sprintf(
249249
'%s %-6s %s',
250250
$lineNumber === $line ? '<error> >> </error>' : ' ',
251251
$lineNumber,
252252
$code
253253
));
254254
if ($lineNumber === $line) {
255-
$output->text(sprintf('<error> >> %s</error> ', $exception->getRawMessage()));
255+
$output->text(\sprintf('<error> >> %s</error> ', $exception->getRawMessage()));
256256
}
257257
}
258258
}

ErrorRenderer/TwigErrorRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public static function isDebug(RequestStack $requestStack, bool $debug): \Closur
6868

6969
private function findTemplate(int $statusCode): ?string
7070
{
71-
$template = sprintf('@Twig/Exception/error%s.html.twig', $statusCode);
71+
$template = \sprintf('@Twig/Exception/error%s.html.twig', $statusCode);
7272
if ($this->twig->getLoader()->exists($template)) {
7373
return $template;
7474
}

Extension/CodeExtension.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,18 @@ public function abbrClass(string $class): string
5959
$parts = explode('\\', $class);
6060
$short = array_pop($parts);
6161

62-
return sprintf('<abbr title="%s">%s</abbr>', $class, $short);
62+
return \sprintf('<abbr title="%s">%s</abbr>', $class, $short);
6363
}
6464

6565
public function abbrMethod(string $method): string
6666
{
6767
if (str_contains($method, '::')) {
6868
[$class, $method] = explode('::', $method, 2);
69-
$result = sprintf('%s::%s()', $this->abbrClass($class), $method);
69+
$result = \sprintf('%s::%s()', $this->abbrClass($class), $method);
7070
} elseif ('Closure' === $method) {
71-
$result = sprintf('<abbr title="%s">%1$s</abbr>', $method);
71+
$result = \sprintf('<abbr title="%s">%1$s</abbr>', $method);
7272
} else {
73-
$result = sprintf('<abbr title="%s">%1$s</abbr>()', $method);
73+
$result = \sprintf('<abbr title="%s">%1$s</abbr>()', $method);
7474
}
7575

7676
return $result;
@@ -87,9 +87,9 @@ public function formatArgs(array $args): string
8787
$item[1] = htmlspecialchars($item[1], \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
8888
$parts = explode('\\', $item[1]);
8989
$short = array_pop($parts);
90-
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
90+
$formattedValue = \sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
9191
} elseif ('array' === $item[0]) {
92-
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
92+
$formattedValue = \sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
9393
} elseif ('null' === $item[0]) {
9494
$formattedValue = '<em>null</em>';
9595
} elseif ('boolean' === $item[0]) {
@@ -102,7 +102,7 @@ public function formatArgs(array $args): string
102102
$formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset));
103103
}
104104

105-
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", htmlspecialchars($key, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $formattedValue);
105+
$result[] = \is_int($key) ? $formattedValue : \sprintf("'%s' => %s", htmlspecialchars($key, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $formattedValue);
106106
}
107107

108108
return implode(', ', $result);
@@ -166,7 +166,7 @@ public function formatFile(string $file, int $line, ?string $text = null): strin
166166
if (null === $text) {
167167
if (null !== $rel = $this->getFileRelative($file)) {
168168
$rel = explode('/', htmlspecialchars($rel, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), 2);
169-
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', htmlspecialchars($this->projectDir, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $rel[0], '/'.($rel[1] ?? ''));
169+
$text = \sprintf('<abbr title="%s%2$s">%s</abbr>%s', htmlspecialchars($this->projectDir, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $rel[0], '/'.($rel[1] ?? ''));
170170
} else {
171171
$text = htmlspecialchars($file, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset);
172172
}
@@ -179,7 +179,7 @@ public function formatFile(string $file, int $line, ?string $text = null): strin
179179
}
180180

181181
if (false !== $link = $this->getFileLink($file, $line)) {
182-
return sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $text);
182+
return \sprintf('<a href="%s" title="Click to open this file" class="file_link">%s</a>', htmlspecialchars($link, \ENT_COMPAT | \ENT_SUBSTITUTE, $this->charset), $text);
183183
}
184184

185185
return $text;

Extension/HttpKernelRuntime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function renderFragmentStrategy(string $strategy, string|ControllerRefere
5757
public function generateFragmentUri(ControllerReference $controller, bool $absolute = false, bool $strict = true, bool $sign = true): string
5858
{
5959
if (null === $this->fragmentUriGenerator) {
60-
throw new \LogicException(sprintf('An instance of "%s" must be provided to use "%s()".', FragmentUriGeneratorInterface::class, __METHOD__));
60+
throw new \LogicException(\sprintf('An instance of "%s" must be provided to use "%s()".', FragmentUriGeneratorInterface::class, __METHOD__));
6161
}
6262

6363
return $this->fragmentUriGenerator->generate($controller, null, $absolute, $strict, $sign);

Extension/TranslationExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public function getTranslator(): TranslatorInterface
4747
{
4848
if (null === $this->translator) {
4949
if (!interface_exists(TranslatorInterface::class)) {
50-
throw new \LogicException(sprintf('You cannot use the "%s" if the Translation Contracts are not available. Try running "composer require symfony/translation".', __CLASS__));
50+
throw new \LogicException(\sprintf('You cannot use the "%s" if the Translation Contracts are not available. Try running "composer require symfony/translation".', __CLASS__));
5151
}
5252

53-
$this->translator = new class() implements TranslatorInterface {
53+
$this->translator = new class implements TranslatorInterface {
5454
use TranslatorTrait;
5555
};
5656
}
@@ -100,7 +100,7 @@ public function trans(string|\Stringable|TranslatableInterface|null $message, ar
100100
{
101101
if ($message instanceof TranslatableInterface) {
102102
if ([] !== $arguments && !\is_string($arguments)) {
103-
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be a locale passed as a string when the message is a "%s", "%s" given.', __METHOD__, TranslatableInterface::class, get_debug_type($arguments)));
103+
throw new \TypeError(\sprintf('Argument 2 passed to "%s()" must be a locale passed as a string when the message is a "%s", "%s" given.', __METHOD__, TranslatableInterface::class, get_debug_type($arguments)));
104104
}
105105

106106
if ($message instanceof TranslatableMessage && '' === $message->getMessage()) {
@@ -111,7 +111,7 @@ public function trans(string|\Stringable|TranslatableInterface|null $message, ar
111111
}
112112

113113
if (!\is_array($arguments)) {
114-
throw new \TypeError(sprintf('Unless the message is a "%s", argument 2 passed to "%s()" must be an array of parameters, "%s" given.', TranslatableInterface::class, __METHOD__, get_debug_type($arguments)));
114+
throw new \TypeError(\sprintf('Unless the message is a "%s", argument 2 passed to "%s()" must be an array of parameters, "%s" given.', TranslatableInterface::class, __METHOD__, get_debug_type($arguments)));
115115
}
116116

117117
if ('' === $message = (string) $message) {
@@ -128,7 +128,7 @@ public function trans(string|\Stringable|TranslatableInterface|null $message, ar
128128
public function createTranslatable(string $message, array $parameters = [], ?string $domain = null): TranslatableMessage
129129
{
130130
if (!class_exists(TranslatableMessage::class)) {
131-
throw new \LogicException(sprintf('You cannot use the "%s" as the Translation Component is not installed. Try running "composer require symfony/translation".', __CLASS__));
131+
throw new \LogicException(\sprintf('You cannot use the "%s" as the Translation Component is not installed. Try running "composer require symfony/translation".', __CLASS__));
132132
}
133133

134134
return new TranslatableMessage($message, $parameters, $domain);

0 commit comments

Comments
 (0)