Skip to content

Commit 0981f0b

Browse files
committed
Prefix all sprintf() calls
1 parent b23a44f commit 0981f0b

File tree

59 files changed

+114
-114
lines changed

Some content is hidden

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

59 files changed

+114
-114
lines changed

AbstractExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function getType(string $name): FormTypeInterface
5050
}
5151

5252
if (!isset($this->types[$name])) {
53-
throw new InvalidArgumentException(sprintf('The type "%s" cannot be loaded by this extension.', $name));
53+
throw new InvalidArgumentException(\sprintf('The type "%s" cannot be loaded by this extension.', $name));
5454
}
5555

5656
return $this->types[$name];

Command/DebugCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function configure(): void
5353
new InputArgument('class', InputArgument::OPTIONAL, 'The form type class'),
5454
new InputArgument('option', InputArgument::OPTIONAL, 'The form type option'),
5555
new InputOption('show-deprecated', null, InputOption::VALUE_NONE, 'Display deprecated options in form types'),
56-
new InputOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
56+
new InputOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())), 'txt'),
5757
])
5858
->setHelp(<<<'EOF'
5959
The <info>%command.name%</info> command displays information about form types.
@@ -114,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
114114
$object = $resolvedType->getOptionsResolver();
115115

116116
if (!$object->isDefined($option)) {
117-
$message = sprintf('Option "%s" is not defined in "%s".', $option, $resolvedType->getInnerType()::class);
117+
$message = \sprintf('Option "%s" is not defined in "%s".', $option, $resolvedType->getInnerType()::class);
118118

119119
if ($alternatives = $this->findAlternatives($option, $object->getDefinedOptions())) {
120120
if (1 === \count($alternatives)) {
@@ -148,7 +148,7 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, strin
148148
$classes = $this->getFqcnTypeClasses($shortClassName);
149149

150150
if (0 === $count = \count($classes)) {
151-
$message = sprintf("Could not find type \"%s\" into the following namespaces:\n %s", $shortClassName, implode("\n ", $this->namespaces));
151+
$message = \sprintf("Could not find type \"%s\" into the following namespaces:\n %s", $shortClassName, implode("\n ", $this->namespaces));
152152

153153
$allTypes = array_merge($this->getCoreTypes(), $this->types);
154154
if ($alternatives = $this->findAlternatives($shortClassName, $allTypes)) {
@@ -166,10 +166,10 @@ private function getFqcnTypeClass(InputInterface $input, SymfonyStyle $io, strin
166166
return $classes[0];
167167
}
168168
if (!$input->isInteractive()) {
169-
throw new InvalidArgumentException(sprintf("The type \"%s\" is ambiguous.\n\nDid you mean one of these?\n %s.", $shortClassName, implode("\n ", $classes)));
169+
throw new InvalidArgumentException(\sprintf("The type \"%s\" is ambiguous.\n\nDid you mean one of these?\n %s.", $shortClassName, implode("\n ", $classes)));
170170
}
171171

172-
return $io->choice(sprintf("The type \"%s\" is ambiguous.\n\nSelect one of the following form types to display its information:", $shortClassName), $classes, $classes[0]);
172+
return $io->choice(\sprintf("The type \"%s\" is ambiguous.\n\nSelect one of the following form types to display its information:", $shortClassName), $classes, $classes[0]);
173173
}
174174

175175
private function getFqcnTypeClasses(string $shortClassName): array

Console/Descriptor/Descriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function describe(OutputInterface $output, ?object $object, array $option
4646
null === $object => $this->describeDefaults($options),
4747
$object instanceof ResolvedFormTypeInterface => $this->describeResolvedFormType($object, $options),
4848
$object instanceof OptionsResolver => $this->describeOption($object, $options),
49-
default => throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))),
49+
default => throw new \InvalidArgumentException(\sprintf('Object of type "%s" is not describable.', get_debug_type($object))),
5050
};
5151
}
5252

Console/Descriptor/TextDescriptor.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedF
8080
'extension' => 'Extension options',
8181
], $formOptions);
8282

83-
$this->output->title(sprintf('%s (Block prefix: "%s")', $resolvedFormType->getInnerType()::class, $resolvedFormType->getInnerType()->getBlockPrefix()));
83+
$this->output->title(\sprintf('%s (Block prefix: "%s")', $resolvedFormType->getInnerType()::class, $resolvedFormType->getInnerType()->getBlockPrefix()));
8484

8585
if ($formOptions) {
8686
$this->output->table($tableHeaders, $this->buildTableRows($tableHeaders, $formOptions));
@@ -131,7 +131,7 @@ protected function describeOption(OptionsResolver $optionsResolver, array $optio
131131
}
132132
array_pop($rows);
133133

134-
$this->output->title(sprintf('%s (%s)', $options['type']::class, $options['option']));
134+
$this->output->title(\sprintf('%s (%s)', $options['type']::class, $options['option']));
135135
$this->output->table([], $rows);
136136
}
137137

@@ -172,7 +172,7 @@ private function normalizeAndSortOptionsColumns(array $options): array
172172
} else {
173173
$options[$group][] = null;
174174
}
175-
$options[$group][] = sprintf('<info>%s</info>', (new \ReflectionClass($class))->getShortName());
175+
$options[$group][] = \sprintf('<info>%s</info>', (new \ReflectionClass($class))->getShortName());
176176
$options[$group][] = new TableSeparator();
177177

178178
sort($opt);
@@ -196,7 +196,7 @@ private function formatClassLink(string $class, ?string $text = null): string
196196
return $text;
197197
}
198198

199-
return sprintf('<href=%s>%s</>', $fileLink, $text);
199+
return \sprintf('<href=%s>%s</>', $fileLink, $text);
200200
}
201201

202202
private function getFileLink(string $class): string

DependencyInjection/FormPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function processFormTypeExtensions(ContainerBuilder $container): array
8989
}
9090

9191
if (!$extendsTypes) {
92-
throw new InvalidArgumentException(sprintf('The getExtendedTypes() method for service "%s" does not return any extended types.', $serviceId));
92+
throw new InvalidArgumentException(\sprintf('The getExtendedTypes() method for service "%s" does not return any extended types.', $serviceId));
9393
}
9494
}
9595
}

Exception/UnexpectedTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class UnexpectedTypeException extends InvalidArgumentException
1515
{
1616
public function __construct(mixed $value, string $expectedType)
1717
{
18-
parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value)));
18+
parent::__construct(\sprintf('Expected argument of type "%s", "%s" given', $expectedType, get_debug_type($value)));
1919
}
2020
}

Extension/Core/DataTransformer/ArrayToPartsTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function reverseTransform(mixed $array): mixed
7272
return null;
7373
}
7474

75-
throw new TransformationFailedException(sprintf('The keys "%s" should not be empty.', implode('", "', $emptyKeys)));
75+
throw new TransformationFailedException(\sprintf('The keys "%s" should not be empty.', implode('", "', $emptyKeys)));
7676
}
7777

7878
return $result;

Extension/Core/DataTransformer/BaseDateTimeTransformer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public function __construct(?string $inputTimezone = null, ?string $outputTimezo
4747
try {
4848
new \DateTimeZone($this->inputTimezone);
4949
} catch (\Exception $e) {
50-
throw new InvalidArgumentException(sprintf('Input timezone is invalid: "%s".', $this->inputTimezone), $e->getCode(), $e);
50+
throw new InvalidArgumentException(\sprintf('Input timezone is invalid: "%s".', $this->inputTimezone), $e->getCode(), $e);
5151
}
5252

5353
try {
5454
new \DateTimeZone($this->outputTimezone);
5555
} catch (\Exception $e) {
56-
throw new InvalidArgumentException(sprintf('Output timezone is invalid: "%s".', $this->outputTimezone), $e->getCode(), $e);
56+
throw new InvalidArgumentException(\sprintf('Output timezone is invalid: "%s".', $this->outputTimezone), $e->getCode(), $e);
5757
}
5858
}
5959
}

Extension/Core/DataTransformer/ChoiceToValueTransformer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function reverseTransform(mixed $value): mixed
4545
return null;
4646
}
4747

48-
throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique.', $value));
48+
throw new TransformationFailedException(\sprintf('The choice "%s" does not exist or is not unique.', $value));
4949
}
5050

5151
return current($choices);

Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,19 @@ public function reverseTransform(mixed $value): ?\DateInterval
124124
}
125125
}
126126
if (\count($emptyFields) > 0) {
127-
throw new TransformationFailedException(sprintf('The fields "%s" should not be empty.', implode('", "', $emptyFields)));
127+
throw new TransformationFailedException(\sprintf('The fields "%s" should not be empty.', implode('", "', $emptyFields)));
128128
}
129129
if (isset($value['invert']) && !\is_bool($value['invert'])) {
130130
throw new TransformationFailedException('The value of "invert" must be boolean.');
131131
}
132132
foreach (self::AVAILABLE_FIELDS as $field => $char) {
133133
if ('invert' !== $field && isset($value[$field]) && !ctype_digit((string) $value[$field])) {
134-
throw new TransformationFailedException(sprintf('This amount of "%s" is invalid.', $field));
134+
throw new TransformationFailedException(\sprintf('This amount of "%s" is invalid.', $field));
135135
}
136136
}
137137
try {
138138
if (!empty($value['weeks'])) {
139-
$interval = sprintf(
139+
$interval = \sprintf(
140140
'P%sY%sM%sWT%sH%sM%sS',
141141
empty($value['years']) ? '0' : $value['years'],
142142
empty($value['months']) ? '0' : $value['months'],
@@ -146,7 +146,7 @@ public function reverseTransform(mixed $value): ?\DateInterval
146146
empty($value['seconds']) ? '0' : $value['seconds']
147147
);
148148
} else {
149-
$interval = sprintf(
149+
$interval = \sprintf(
150150
'P%sY%sM%sDT%sH%sM%sS',
151151
empty($value['years']) ? '0' : $value['years'],
152152
empty($value['months']) ? '0' : $value['months'],

0 commit comments

Comments
 (0)