Skip to content

Commit 2da3b51

Browse files
committed
Prefix all sprintf() calls
1 parent e0071b0 commit 2da3b51

File tree

82 files changed

+504
-504
lines changed

Some content is hidden

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

82 files changed

+504
-504
lines changed

Argument/LazyClosure.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(
3636
public function __get(mixed $name): mixed
3737
{
3838
if ('service' !== $name) {
39-
throw new InvalidArgumentException(sprintf('Cannot read property "%s" from a lazy closure.', $name));
39+
throw new InvalidArgumentException(\sprintf('Cannot read property "%s" from a lazy closure.', $name));
4040
}
4141

4242
if (isset($this->initializer)) {
@@ -61,17 +61,17 @@ public static function getCode(string $initializer, array $callable, Definition
6161
$r = $container->getReflectionClass($class);
6262

6363
if (null !== $id) {
64-
$id = sprintf(' for service "%s"', $id);
64+
$id = \sprintf(' for service "%s"', $id);
6565
}
6666

6767
if (!$asClosure) {
6868
$id = str_replace('%', '%%', (string) $id);
6969

7070
if (!$r || !$r->isInterface()) {
71-
throw new RuntimeException(sprintf("Cannot create adapter{$id} because \"%s\" is not an interface.", $class));
71+
throw new RuntimeException(\sprintf("Cannot create adapter{$id} because \"%s\" is not an interface.", $class));
7272
}
7373
if (1 !== \count($method = $r->getMethods())) {
74-
throw new RuntimeException(sprintf("Cannot create adapter{$id} because interface \"%s\" doesn't have exactly one method.", $class));
74+
throw new RuntimeException(\sprintf("Cannot create adapter{$id} because interface \"%s\" doesn't have exactly one method.", $class));
7575
}
7676
$method = $method[0]->name;
7777
} elseif (!$r || !$r->hasMethod($method)) {

Attribute/AutowireLocator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ public function __construct(
6262
if ($type instanceof SubscribedService) {
6363
$key = $type->key ?? $key;
6464
$attributes = $type->attributes;
65-
$type = ($type->nullable ? '?' : '').($type->type ?? throw new InvalidArgumentException(sprintf('When "%s" is used, a type must be set.', SubscribedService::class)));
65+
$type = ($type->nullable ? '?' : '').($type->type ?? throw new InvalidArgumentException(\sprintf('When "%s" is used, a type must be set.', SubscribedService::class)));
6666
}
6767

6868
if (!\is_string($type) || !preg_match('/(?(DEFINE)(?<cn>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*+))(?(DEFINE)(?<fqcn>(?&cn)(?:\\\\(?&cn))*+))^\??(?&fqcn)(?:(?:\|(?&fqcn))*+|(?:&(?&fqcn))*+)$/', $type)) {
69-
throw new InvalidArgumentException(sprintf('"%s" is not a PHP type for key "%s".', \is_string($type) ? $type : get_debug_type($type), $key));
69+
throw new InvalidArgumentException(\sprintf('"%s" is not a PHP type for key "%s".', \is_string($type) ? $type : get_debug_type($type), $key));
7070
}
7171
$optionalBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
7272
if ('?' === $type[0]) {

Attribute/Target.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function __construct(public ?string $name = null)
3232
public function getParsedName(): string
3333
{
3434
if (null === $this->name) {
35-
throw new LogicException(sprintf('Cannot parse the name of a #[Target] attribute that has not been resolved. Did you forget to call "%s::parseName()"?', __CLASS__));
35+
throw new LogicException(\sprintf('Cannot parse the name of a #[Target] attribute that has not been resolved. Did you forget to call "%s::parseName()"?', __CLASS__));
3636
}
3737

3838
return lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->name))));
@@ -58,7 +58,7 @@ public static function parseName(\ReflectionParameter $parameter, ?self &$attrib
5858
$function = $function->name;
5959
}
6060

61-
throw new InvalidArgumentException(sprintf('Invalid #[Target] name "%s" on parameter "$%s" of "%s()": the first character must be a letter.', $name, $parameter->name, $function));
61+
throw new InvalidArgumentException(\sprintf('Invalid #[Target] name "%s" on parameter "$%s" of "%s()": the first character must be a letter.', $name, $parameter->name, $function));
6262
}
6363

6464
return preg_match('/^[a-zA-Z0-9_\x7f-\xff]++$/', $name) ? $name : $parsedName;

Compiler/AbstractRecursivePass.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
130130
}
131131

132132
if (!\function_exists($factory)) {
133-
throw new RuntimeException(sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory));
133+
throw new RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory));
134134
}
135135
$r = new \ReflectionFunction($factory);
136136
if (false !== $r->getFileName() && file_exists($r->getFileName())) {
@@ -144,7 +144,7 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
144144
[$class, $method] = $factory;
145145

146146
if ('__construct' === $method) {
147-
throw new RuntimeException(sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId));
147+
throw new RuntimeException(\sprintf('Invalid service "%s": "__construct()" cannot be used as a factory method.', $this->currentId));
148148
}
149149

150150
if ($class instanceof Reference) {
@@ -168,20 +168,20 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
168168
try {
169169
if (!$r = $this->container->getReflectionClass($class)) {
170170
if (null === $class) {
171-
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
171+
throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId));
172172
}
173173

174-
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
174+
throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
175175
}
176176
} catch (\ReflectionException $e) {
177-
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
177+
throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
178178
}
179179
if (!$r = $r->getConstructor()) {
180180
if ($required) {
181-
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
181+
throw new RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
182182
}
183183
} elseif (!$r->isPublic()) {
184-
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
184+
throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).\sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
185185
}
186186

187187
return $r;
@@ -201,24 +201,24 @@ protected function getReflectionMethod(Definition $definition, string $method):
201201
}
202202

203203
if (null === $class) {
204-
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
204+
throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId));
205205
}
206206

207207
if (!$r = $this->container->getReflectionClass($class)) {
208-
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
208+
throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
209209
}
210210

211211
if (!$r->hasMethod($method)) {
212212
if ($r->hasMethod('__call') && ($r = $r->getMethod('__call')) && $r->isPublic()) {
213213
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
214214
}
215215

216-
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
216+
throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" does not exist.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
217217
}
218218

219219
$r = $r->getMethod($method);
220220
if (!$r->isPublic()) {
221-
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
221+
throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
222222
}
223223

224224
return $r;
@@ -239,12 +239,12 @@ private function getExpressionLanguage(): ExpressionLanguage
239239
$arg = $this->processValue(new Reference($id));
240240
$this->inExpression = false;
241241
if (!$arg instanceof Reference) {
242-
throw new RuntimeException(sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, get_debug_type($arg), $id));
242+
throw new RuntimeException(\sprintf('"%s::processValue()" must return a Reference when processing an expression, "%s" returned for service("%s").', static::class, get_debug_type($arg), $id));
243243
}
244-
$arg = sprintf('"%s"', $arg);
244+
$arg = \sprintf('"%s"', $arg);
245245
}
246246

247-
return sprintf('$this->get(%s)', $arg);
247+
return \sprintf('$this->get(%s)', $arg);
248248
});
249249
}
250250

Compiler/AliasDeprecatedPublicServicesPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public function process(ContainerBuilder $container): void
2525
{
2626
foreach ($container->findTaggedServiceIds('container.private') as $id => $tags) {
2727
if (null === $package = $tags[0]['package'] ?? null) {
28-
throw new InvalidArgumentException(sprintf('The "package" attribute is mandatory for the "container.private" tag on the "%s" service.', $id));
28+
throw new InvalidArgumentException(\sprintf('The "package" attribute is mandatory for the "container.private" tag on the "%s" service.', $id));
2929
}
3030

3131
if (null === $version = $tags[0]['version'] ?? null) {
32-
throw new InvalidArgumentException(sprintf('The "version" attribute is mandatory for the "container.private" tag on the "%s" service.', $id));
32+
throw new InvalidArgumentException(\sprintf('The "version" attribute is mandatory for the "container.private" tag on the "%s" service.', $id));
3333
}
3434

3535
$definition = $container->getDefinition($id);

Compiler/AttributeAutoconfigurationPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function process(ContainerBuilder $container): void
5252
} elseif ($parameterType instanceof \ReflectionNamedType) {
5353
$types[] = $parameterType->getName();
5454
} else {
55-
throw new LogicException(sprintf('Argument "$%s" of attribute autoconfigurator should have a type, use one or more of "\ReflectionClass|\ReflectionMethod|\ReflectionProperty|\ReflectionParameter|\Reflector" in "%s" on line "%d".', $reflectorParameter->getName(), $callableReflector->getFileName(), $callableReflector->getStartLine()));
55+
throw new LogicException(\sprintf('Argument "$%s" of attribute autoconfigurator should have a type, use one or more of "\ReflectionClass|\ReflectionMethod|\ReflectionProperty|\ReflectionParameter|\Reflector" in "%s" on line "%d".', $reflectorParameter->getName(), $callableReflector->getFileName(), $callableReflector->getStartLine()));
5656
}
5757

5858
try {
@@ -70,7 +70,7 @@ public function process(ContainerBuilder $container): void
7070
continue;
7171
}
7272
if (!($targets & \constant('Attribute::TARGET_'.strtoupper($symbol)))) {
73-
throw new LogicException(sprintf('Invalid type "Reflection%s" on argument "$%s": attribute "%s" cannot target a '.$symbol.' in "%s" on line "%d".', ucfirst($symbol), $reflectorParameter->getName(), $attributeName, $callableReflector->getFileName(), $callableReflector->getStartLine()));
73+
throw new LogicException(\sprintf('Invalid type "Reflection%s" on argument "$%s": attribute "%s" cannot target a '.$symbol.' in "%s" on line "%d".', ucfirst($symbol), $reflectorParameter->getName(), $attributeName, $callableReflector->getFileName(), $callableReflector->getStartLine()));
7474
}
7575
}
7676
$this->{$symbol.'AttributeConfigurators'}[$attributeName] = $callable;

Compiler/AutoAliasServicePass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function process(ContainerBuilder $container): void
2525
foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {
2626
foreach ($tags as $tag) {
2727
if (!isset($tag['format'])) {
28-
throw new InvalidArgumentException(sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
28+
throw new InvalidArgumentException(\sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
2929
}
3030

3131
$aliasId = $container->getParameterBag()->resolveValue($tag['format']);

0 commit comments

Comments
 (0)