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

Diff for: AbstractExtension.php

+1-1
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];

Diff for: Command/DebugCommand.php

+5-5
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

Diff for: Console/Descriptor/Descriptor.php

+1-1
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

Diff for: Console/Descriptor/TextDescriptor.php

+4-4
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

Diff for: DependencyInjection/FormPass.php

+1-1
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
}

Diff for: Exception/UnexpectedTypeException.php

+1-1
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
}

Diff for: Extension/Core/DataTransformer/ArrayToPartsTransformer.php

+1-1
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;

Diff for: Extension/Core/DataTransformer/BaseDateTimeTransformer.php

+2-2
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
}

Diff for: Extension/Core/DataTransformer/ChoiceToValueTransformer.php

+1-1
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);

Diff for: Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php

+4-4
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'],

Diff for: Extension/Core/DataTransformer/DateIntervalToStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function reverseTransform(mixed $value): ?\DateInterval
7979
}
8080
$valuePattern = '/^'.preg_replace('/%([yYmMdDhHiIsSwW])(\w)/', '(?P<$1>\d+)$2', $this->format).'$/';
8181
if (!preg_match($valuePattern, $value)) {
82-
throw new TransformationFailedException(sprintf('Value "%s" contains intervals not accepted by format "%s".', $value, $this->format));
82+
throw new TransformationFailedException(\sprintf('Value "%s" contains intervals not accepted by format "%s".', $value, $this->format));
8383
}
8484
try {
8585
$dateInterval = new \DateInterval($value);

Diff for: Extension/Core/DataTransformer/DateTimeToArrayTransformer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function reverseTransform(mixed $value): ?\DateTime
126126
}
127127

128128
if (\count($emptyFields) > 0) {
129-
throw new TransformationFailedException(sprintf('The fields "%s" should not be empty.', implode('", "', $emptyFields)));
129+
throw new TransformationFailedException(\sprintf('The fields "%s" should not be empty.', implode('", "', $emptyFields)));
130130
}
131131

132132
if (isset($value['month']) && !ctype_digit((string) $value['month'])) {
@@ -158,7 +158,7 @@ public function reverseTransform(mixed $value): ?\DateTime
158158
}
159159

160160
try {
161-
$dateTime = new \DateTime(sprintf(
161+
$dateTime = new \DateTime(\sprintf(
162162
'%s-%s-%s %s:%s:%s',
163163
empty($value['year']) ? $this->referenceDate->format('Y') : $value['year'],
164164
empty($value['month']) ? $this->referenceDate->format('m') : $value['month'],

Diff for: Extension/Core/DataTransformer/DateTimeToHtml5LocalDateTimeTransformer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function reverseTransform(mixed $dateTimeLocal): ?\DateTime
8585
// to maintain backwards compatibility we do not strictly validate the submitted date
8686
// see https://github.com/symfony/symfony/issues/28699
8787
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})[T ]\d{2}:\d{2}(?::\d{2})?/', $dateTimeLocal, $matches)) {
88-
throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $dateTimeLocal));
88+
throw new TransformationFailedException(\sprintf('The date "%s" is not a valid date.', $dateTimeLocal));
8989
}
9090

9191
try {
@@ -99,7 +99,7 @@ public function reverseTransform(mixed $dateTimeLocal): ?\DateTime
9999
}
100100

101101
if (!checkdate($matches[2], $matches[3], $matches[1])) {
102-
throw new TransformationFailedException(sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3]));
102+
throw new TransformationFailedException(\sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3]));
103103
}
104104

105105
return $dateTime;

Diff for: Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function reverseTransform(mixed $value): ?\DateTime
128128
} elseif (false === $timestamp) {
129129
// the value couldn't be parsed but the Intl extension didn't report an error code, this
130130
// could be the case when the Intl polyfill is used which always returns 0 as the error code
131-
throw new TransformationFailedException(sprintf('"%s" could not be parsed as a date.', $value));
131+
throw new TransformationFailedException(\sprintf('"%s" could not be parsed as a date.', $value));
132132
}
133133

134134
try {
@@ -137,7 +137,7 @@ public function reverseTransform(mixed $value): ?\DateTime
137137
$dateTime = new \DateTime(gmdate('Y-m-d', $timestamp), new \DateTimeZone($this->outputTimezone));
138138
} else {
139139
// read timestamp into DateTime object - the formatter delivers a timestamp
140-
$dateTime = new \DateTime(sprintf('@%s', $timestamp));
140+
$dateTime = new \DateTime(\sprintf('@%s', $timestamp));
141141
}
142142
// set timezone separately, as it would be ignored if set via the constructor,
143143
// see https://php.net/datetime.construct

Diff for: Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function reverseTransform(mixed $rfc3339): ?\DateTime
6464
}
6565

6666
if (!preg_match('/^(\d{4})-(\d{2})-(\d{2})T\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|(?:(?:\+|-)\d{2}:\d{2}))$/', $rfc3339, $matches)) {
67-
throw new TransformationFailedException(sprintf('The date "%s" is not a valid date.', $rfc3339));
67+
throw new TransformationFailedException(\sprintf('The date "%s" is not a valid date.', $rfc3339));
6868
}
6969

7070
try {
@@ -78,7 +78,7 @@ public function reverseTransform(mixed $rfc3339): ?\DateTime
7878
}
7979

8080
if (!checkdate($matches[2], $matches[3], $matches[1])) {
81-
throw new TransformationFailedException(sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3]));
81+
throw new TransformationFailedException(\sprintf('The date "%s-%s-%s" is not a valid date.', $matches[1], $matches[2], $matches[3]));
8282
}
8383

8484
return $dateTime;

Diff for: Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function reverseTransform(mixed $value): int|float|null
3838
$decimalSeparator = $this->getNumberFormatter()->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
3939

4040
if (\is_string($value) && str_contains($value, $decimalSeparator)) {
41-
throw new TransformationFailedException(sprintf('The value "%s" is not a valid integer.', $value));
41+
throw new TransformationFailedException(\sprintf('The value "%s" is not a valid integer.', $value));
4242
}
4343

4444
$result = parent::reverseTransform($value);

Diff for: Extension/Core/DataTransformer/IntlTimeZoneToStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function reverseTransform(mixed $value): mixed
7070
$intlTimeZone = \IntlTimeZone::createTimeZone($value);
7171

7272
if ('Etc/Unknown' === $intlTimeZone->getID()) {
73-
throw new TransformationFailedException(sprintf('Unknown timezone identifier "%s".', $value));
73+
throw new TransformationFailedException(\sprintf('Unknown timezone identifier "%s".', $value));
7474
}
7575

7676
return $intlTimeZone;

Diff for: Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public function reverseTransform(mixed $value): int|float|null
7575
}
7676

7777
if ($value > \PHP_INT_MAX || $value < \PHP_INT_MIN) {
78-
throw new TransformationFailedException(sprintf('Cannot cast "%s" to an integer. Try setting the input to "float" instead.', $value));
78+
throw new TransformationFailedException(\sprintf('Cannot cast "%s" to an integer. Try setting the input to "float" instead.', $value));
7979
}
8080

8181
$value = (int) $value;

Diff for: Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function reverseTransform(mixed $value): int|float|null
140140
$remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0");
141141

142142
if ('' !== $remainder) {
143-
throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s".', $remainder));
143+
throw new TransformationFailedException(\sprintf('The number contains unrecognized characters: "%s".', $remainder));
144144
}
145145
}
146146

Diff for: Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function reverseTransform(mixed $value): int|float|null
158158
$remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0");
159159

160160
if ('' !== $remainder) {
161-
throw new TransformationFailedException(sprintf('The number contains unrecognized characters: "%s".', $remainder));
161+
throw new TransformationFailedException(\sprintf('The number contains unrecognized characters: "%s".', $remainder));
162162
}
163163
}
164164

Diff for: Extension/Core/DataTransformer/UlidToStringTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function reverseTransform(mixed $value): ?Ulid
6565
try {
6666
$ulid = new Ulid($value);
6767
} catch (\InvalidArgumentException $e) {
68-
throw new TransformationFailedException(sprintf('The value "%s" is not a valid ULID.', $value), $e->getCode(), $e);
68+
throw new TransformationFailedException(\sprintf('The value "%s" is not a valid ULID.', $value), $e->getCode(), $e);
6969
}
7070

7171
return $ulid;

Diff for: Extension/Core/DataTransformer/UuidToStringTransformer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ public function reverseTransform(mixed $value): ?Uuid
6363
}
6464

6565
if (!Uuid::isValid($value)) {
66-
throw new TransformationFailedException(sprintf('The value "%s" is not a valid UUID.', $value));
66+
throw new TransformationFailedException(\sprintf('The value "%s" is not a valid UUID.', $value));
6767
}
6868

6969
try {
7070
return Uuid::fromString($value);
7171
} catch (\InvalidArgumentException $e) {
72-
throw new TransformationFailedException(sprintf('The value "%s" is not a valid UUID.', $value), $e->getCode(), $e);
72+
throw new TransformationFailedException(\sprintf('The value "%s" is not a valid UUID.', $value), $e->getCode(), $e);
7373
}
7474
}
7575
}

Diff for: Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function reverseTransform(mixed $array): mixed
7171
return null;
7272
}
7373

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

7777
return $result;

0 commit comments

Comments
 (0)