Skip to content

Commit 0a8120d

Browse files
authored
Fix CS (#510)
1 parent 58e556c commit 0a8120d

19 files changed

+26
-26
lines changed

Command/CheckMissingCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9393
$io = new SymfonyStyle($input, $output);
9494

9595
if ($newMessages > 0) {
96-
$io->error(sprintf('%d new message(s) have been found, run bin/console translation:extract', $newMessages));
96+
$io->error(\sprintf('%d new message(s) have been found, run bin/console translation:extract', $newMessages));
9797

9898
return 1;
9999
}
@@ -102,7 +102,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
102102

103103
if ($emptyTranslations > 0) {
104104
$io->error(
105-
sprintf('%d messages have empty translations, please provide translations for them', $emptyTranslations)
105+
\sprintf('%d messages have empty translations, please provide translations for them', $emptyTranslations)
106106
);
107107

108108
return 1;

Command/DeleteEmptyCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
9999
if ($input->isInteractive()) {
100100
/** @var QuestionHelper $helper */
101101
$helper = $this->getHelper('question');
102-
$question = new ConfirmationQuestion(sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
102+
$question = new ConfirmationQuestion(\sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
103103
if (!$helper->ask($input, $output, $question)) {
104104
return 0;
105105
}
@@ -112,7 +112,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
112112
foreach ($messages as $message) {
113113
$storage->delete($message->getLocale(), $message->getDomain(), $message->getKey());
114114
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
115-
$output->writeln(sprintf(
115+
$output->writeln(\sprintf(
116116
'Deleted empty message "<info>%s</info>" from domain "<info>%s</info>" and locale "<info>%s</info>"',
117117
$message->getKey(),
118118
$message->getDomain(),

Command/DeleteObsoleteCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
100100
if ($input->isInteractive()) {
101101
/** @var QuestionHelper $helper */
102102
$helper = $this->getHelper('question');
103-
$question = new ConfirmationQuestion(sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
103+
$question = new ConfirmationQuestion(\sprintf('You are about to remove %d translations. Do you wish to continue? (y/N) ', $messageCount), false);
104104
if (!$helper->ask($input, $output, $question)) {
105105
return 0;
106106
}
@@ -113,7 +113,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
113113
foreach ($messages as $message) {
114114
$storage->delete($message->getLocale(), $message->getDomain(), $message->getKey());
115115
if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
116-
$output->writeln(sprintf(
116+
$output->writeln(\sprintf(
117117
'Deleted obsolete message "<info>%s</info>" from domain "<info>%s</info>" and locale "<info>%s</info>"',
118118
$message->getKey(),
119119
$message->getDomain(),

Command/ExtractCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
130130
/** @var Error $error */
131131
foreach ($errors as $error) {
132132
$io->error(
133-
sprintf("%s\nLine: %s\nMessage: %s", $error->getPath(), $error->getLine(), $error->getMessage())
133+
\sprintf("%s\nLine: %s\nMessage: %s", $error->getPath(), $error->getLine(), $error->getMessage())
134134
);
135135
}
136136
}

Command/StorageTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ private function getStorage($configName): StorageService
3131
if (null === $storage = $this->storageManager->getStorage($configName)) {
3232
$availableStorages = $this->storageManager->getNames();
3333

34-
throw new \InvalidArgumentException(sprintf('Unknown storage "%s". Available storages are "%s".', $configName, implode('", "', $availableStorages)));
34+
throw new \InvalidArgumentException(\sprintf('Unknown storage "%s". Available storages are "%s".', $configName, implode('", "', $availableStorages)));
3535
}
3636

3737
return $storage;

Command/SyncCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6060

6161
break;
6262
default:
63-
$output->writeln(sprintf('Direction must be either "up" or "down". Not "%s".', $input->getArgument('direction')));
63+
$output->writeln(\sprintf('Direction must be either "up" or "down". Not "%s".', $input->getArgument('direction')));
6464

6565
return 0;
6666
}

Controller/SymfonyProfilerController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function createAssetsAction(Request $request, string $token): Response
130130
$uploaded[] = $message;
131131
}
132132

133-
return new Response(sprintf('%s new assets created!', \count($uploaded)));
133+
return new Response(\sprintf('%s new assets created!', \count($uploaded)));
134134
}
135135

136136
private function getMessage(Request $request, string $token): SfProfilerMessage
@@ -142,7 +142,7 @@ private function getMessage(Request $request, string $token): SfProfilerMessage
142142
$collectorMessages = $this->getMessages($token);
143143

144144
if (!isset($collectorMessages[$messageId])) {
145-
throw new NotFoundHttpException(sprintf('No message with key "%s" was found.', $messageId));
145+
throw new NotFoundHttpException(\sprintf('No message with key "%s" was found.', $messageId));
146146
}
147147
$message = SfProfilerMessage::create($collectorMessages[$messageId]);
148148

@@ -152,7 +152,7 @@ private function getMessage(Request $request, string $token): SfProfilerMessage
152152

153153
$message
154154
->setLocale($requestCollector->getLocale())
155-
->setTranslation(sprintf('[%s]', $message->getTranslation()))
155+
->setTranslation(\sprintf('[%s]', $message->getTranslation()))
156156
;
157157
}
158158

Controller/WebUIController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ public function createAction(Request $request, string $configName, string $local
179179
try {
180180
$storage->create($message);
181181
} catch (StorageException $e) {
182-
throw new BadRequestHttpException(sprintf('Key "%s" does already exist for "%s" on domain "%s".', $message->getKey(), $locale, $domain), $e);
182+
throw new BadRequestHttpException(\sprintf('Key "%s" does already exist for "%s" on domain "%s".', $message->getKey(), $locale, $domain), $e);
183183
} catch (\Exception $e) {
184184
return new Response($e->getMessage(), Response::HTTP_BAD_REQUEST);
185185
}

DependencyInjection/CompilerPass/StoragePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function process(ContainerBuilder $container): void
5151

5252
break;
5353
default:
54-
throw new \LogicException(sprintf('The tag "php_translation.storage" must have a "type" of value "local" or "remote". Value "%s" was provided', $tag['type']));
54+
throw new \LogicException(\sprintf('The tag "php_translation.storage" must have a "type" of value "local" or "remote". Value "%s" was provided', $tag['type']));
5555
}
5656
}
5757
}

DependencyInjection/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,15 @@ private function configsNode(ArrayNodeDefinition $root): void
117117

118118
$bundles = $container->getParameter('kernel.bundles');
119119
if (!isset($bundles[$bundleName])) {
120-
throw new \Exception(sprintf('The bundle "%s" does not exist. Available bundles: %s', $bundleName, array_keys($bundles)));
120+
throw new \Exception(\sprintf('The bundle "%s" does not exist. Available bundles: %s', $bundleName, array_keys($bundles)));
121121
}
122122

123123
$ref = new \ReflectionClass($bundles[$bundleName]);
124124
$value = false === $pos ? \dirname($ref->getFileName()) : \dirname($ref->getFileName()).substr($value, $pos);
125125
}
126126

127127
if (!is_dir($value)) {
128-
throw new \Exception(sprintf('The directory "%s" does not exist.', $value));
128+
throw new \Exception(\sprintf('The directory "%s" does not exist.', $value));
129129
}
130130

131131
return $value;

DependencyInjection/TranslationExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ private function enableEditInPlace(ContainerBuilder $container, array $config):
182182
$name = $config['edit_in_place']['config_name'];
183183

184184
if ('default' !== $name && !isset($config['configs'][$name])) {
185-
throw new InvalidArgumentException(sprintf('There is no config named "%s".', $name));
185+
throw new InvalidArgumentException(\sprintf('There is no config named "%s".', $name));
186186
}
187187

188188
$activatorRef = new Reference($config['edit_in_place']['activator']);

EventListener/EditInPlaceResponseListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function onKernelResponse(ResponseEvent $event): void
104104
}
105105
$content = preg_replace($pattern, $replacement, $content);
106106

107-
$html = sprintf(
107+
$html = \sprintf(
108108
self::HTML,
109109
$this->packages->getUrl('bundles/translation/css/content-tools.min.css'),
110110
$this->packages->getUrl('bundles/translation/js/content-tools.min.js'),

Service/CacheClearer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(string $kernelCacheDir, $translator, Filesystem $fil
6060
*/
6161
public function clearAndWarmUp(?string $locale = null): void
6262
{
63-
$translationDir = sprintf('%s/translations', $this->kernelCacheDir);
63+
$translationDir = \sprintf('%s/translations', $this->kernelCacheDir);
6464

6565
$finder = new Finder();
6666

Service/ConfigurationManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getConfiguration($name = null): Configuration
5050
}
5151
}
5252

53-
throw new \InvalidArgumentException(sprintf('No configuration found for "%s"', $name));
53+
throw new \InvalidArgumentException(\sprintf('No configuration found for "%s"', $name));
5454
}
5555

5656
public function getFirstName(): ?string

Service/Importer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ private function convertSourceLocationsToMessages(
162162
$trimLength = 1 + \strlen($this->config['project_root']);
163163

164164
$meta = $this->getMetadata($catalogue, $key, $messageDomain);
165-
$meta->addCategory('file-source', sprintf('%s:%s', substr($sourceLocation->getPath(), $trimLength), $sourceLocation->getLine()));
165+
$meta->addCategory('file-source', \sprintf('%s:%s', substr($sourceLocation->getPath(), $trimLength), $sourceLocation->getLine()));
166166
if (isset($sourceLocation->getContext()['desc'])) {
167167
$meta->addCategory('desc', $sourceLocation->getContext()['desc']);
168168
}

Service/StorageService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function sync(string $direction = self::DIRECTION_DOWN, array $importOpti
8787

8888
break;
8989
default:
90-
throw new LogicException(sprintf('Direction must be either "up" or "down". Value "%s" was provided', $direction));
90+
throw new LogicException(\sprintf('Direction must be either "up" or "down". Value "%s" was provided', $direction));
9191
}
9292
}
9393

Translator/EditInPlaceTranslator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getCatalogue($locale = null): MessageCatalogueInterface
7676
public function getCatalogues(): array
7777
{
7878
if (!method_exists($this->translator, 'getCatalogues')) {
79-
throw new \Exception(sprintf('%s method is not available! Please, upgrade to Symfony 6 in order to to use it', __METHOD__));
79+
throw new \Exception(\sprintf('%s method is not available! Please, upgrade to Symfony 6 in order to to use it', __METHOD__));
8080
}
8181

8282
return $this->translator->getCatalogues();
@@ -103,7 +103,7 @@ public function trans($id, array $parameters = [], $domain = null, $locale = nul
103103
}
104104

105105
// Render all data in the translation tag required to allow in-line translation
106-
return sprintf('<x-trans data-key="%s|%s" data-value="%s" data-plain="%s" data-domain="%s" data-locale="%s">%s</x-trans>',
106+
return \sprintf('<x-trans data-key="%s|%s" data-value="%s" data-plain="%s" data-domain="%s" data-locale="%s">%s</x-trans>',
107107
$domain,
108108
$id,
109109
htmlspecialchars($original),

Translator/FallbackTranslator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function getCatalogue($locale = null): MessageCatalogueInterface
125125
public function getCatalogues(): array
126126
{
127127
if (!method_exists($this->symfonyTranslator, 'getCatalogues')) {
128-
throw new \Exception(sprintf('%s method is not available! Please, upgrade to Symfony 6 in order to to use it', __METHOD__));
128+
throw new \Exception(\sprintf('%s method is not available! Please, upgrade to Symfony 6 in order to to use it', __METHOD__));
129129
}
130130

131131
return $this->symfonyTranslator->getCatalogues();

Twig/Node/Transchoice.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function __construct(ArrayExpression $arguments, $lineno)
2525
public function compile(Compiler $compiler): void
2626
{
2727
$compiler->raw(
28-
sprintf(
28+
\sprintf(
2929
'$this->env->getExtension(\'%s\')->%s(',
3030
'Translation\Bundle\Twig\TranslationExtension',
3131
'transchoiceWithDefault'

0 commit comments

Comments
 (0)