Skip to content

Commit ed9fb80

Browse files
CS fixes
1 parent 0d9f24f commit ed9fb80

File tree

96 files changed

+562
-563
lines changed

Some content is hidden

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

96 files changed

+562
-563
lines changed

Argument/LazyClosure.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Component\DependencyInjection\Argument;
1313

1414
use Symfony\Component\DependencyInjection\ContainerBuilder;
15-
use Symfony\Component\DependencyInjection\Definition;
1615
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
1716
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1817
use Symfony\Component\DependencyInjection\Reference;
@@ -36,7 +35,7 @@ public function __construct(
3635
public function __get(mixed $name): mixed
3736
{
3837
if ('service' !== $name) {
39-
throw new InvalidArgumentException(sprintf('Cannot read property "%s" from a lazy closure.', $name));
38+
throw new InvalidArgumentException(\sprintf('Cannot read property "%s" from a lazy closure.', $name));
4039
}
4140

4241
if (isset($this->initializer)) {
@@ -61,17 +60,17 @@ public static function getCode(string $initializer, array $callable, string $cla
6160
$r = $container->getReflectionClass($class);
6261

6362
if (null !== $id) {
64-
$id = sprintf(' for service "%s"', $id);
63+
$id = \sprintf(' for service "%s"', $id);
6564
}
6665

6766
if (!$asClosure) {
6867
$id = str_replace('%', '%%', (string) $id);
6968

7069
if (!$r || !$r->isInterface()) {
71-
throw new RuntimeException(sprintf("Cannot create adapter{$id} because \"%s\" is not an interface.", $class));
70+
throw new RuntimeException(\sprintf("Cannot create adapter{$id} because \"%s\" is not an interface.", $class));
7271
}
7372
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));
73+
throw new RuntimeException(\sprintf("Cannot create adapter{$id} because interface \"%s\" doesn't have exactly one method.", $class));
7574
}
7675
$method = $method[0]->name;
7776
} elseif (!$r || !$r->hasMethod($method)) {

Argument/ReferenceSetArgumentTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function setValues(array $values)
5151
{
5252
foreach ($values as $k => $v) {
5353
if (null !== $v && !$v instanceof Reference) {
54-
throw new InvalidArgumentException(sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, get_debug_type($v)));
54+
throw new InvalidArgumentException(\sprintf('A "%s" must hold only Reference instances, "%s" given.', __CLASS__, get_debug_type($v)));
5555
}
5656
}
5757

Attribute/AutowireLocator.php

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

6464
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)) {
65-
throw new InvalidArgumentException(sprintf('"%s" is not a PHP type for key "%s".', \is_string($type) ? $type : get_debug_type($type), $key));
65+
throw new InvalidArgumentException(\sprintf('"%s" is not a PHP type for key "%s".', \is_string($type) ? $type : get_debug_type($type), $key));
6666
}
6767
$optionalBehavior = ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE;
6868
if ('?' === $type[0]) {

Attribute/Target.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct(
3030
public function getParsedName(): string
3131
{
3232
if (null === $this->name) {
33-
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__));
33+
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__));
3434
}
3535

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

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

6262
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
@@ -136,7 +136,7 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
136136
}
137137

138138
if (!\function_exists($factory)) {
139-
throw new RuntimeException(sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory));
139+
throw new RuntimeException(\sprintf('Invalid service "%s": function "%s" does not exist.', $this->currentId, $factory));
140140
}
141141
$r = new \ReflectionFunction($factory);
142142
if (false !== $r->getFileName() && file_exists($r->getFileName())) {
@@ -150,7 +150,7 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
150150
[$class, $method] = $factory;
151151

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

156156
if ($class instanceof Reference) {
@@ -174,20 +174,20 @@ protected function getConstructor(Definition $definition, bool $required): ?\Ref
174174
try {
175175
if (!$r = $this->container->getReflectionClass($class)) {
176176
if (null === $class) {
177-
throw new RuntimeException(sprintf('Invalid service "%s": the class is not set.', $this->currentId));
177+
throw new RuntimeException(\sprintf('Invalid service "%s": the class is not set.', $this->currentId));
178178
}
179179

180-
throw new RuntimeException(sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
180+
throw new RuntimeException(\sprintf('Invalid service "%s": class "%s" does not exist.', $this->currentId, $class));
181181
}
182182
} catch (\ReflectionException $e) {
183-
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
183+
throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).lcfirst($e->getMessage()));
184184
}
185185
if (!$r = $r->getConstructor()) {
186186
if ($required) {
187-
throw new RuntimeException(sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
187+
throw new RuntimeException(\sprintf('Invalid service "%s": class%s has no constructor.', $this->currentId, \sprintf($class !== $this->currentId ? ' "%s"' : '', $class)));
188188
}
189189
} elseif (!$r->isPublic()) {
190-
throw new RuntimeException(sprintf('Invalid service "%s": ', $this->currentId).sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
190+
throw new RuntimeException(\sprintf('Invalid service "%s": ', $this->currentId).\sprintf($class !== $this->currentId ? 'constructor of class "%s"' : 'its constructor', $class).' must be public.');
191191
}
192192

193193
return $r;
@@ -207,11 +207,11 @@ protected function getReflectionMethod(Definition $definition, string $method):
207207
}
208208

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

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

217217
if (!$r->hasMethod($method)) {
@@ -223,12 +223,12 @@ protected function getReflectionMethod(Definition $definition, string $method):
223223
return new \ReflectionMethod(static function (...$arguments) {}, '__invoke');
224224
}
225225

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

229229
$r = $r->getMethod($method);
230230
if (!$r->isPublic()) {
231-
throw new RuntimeException(sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
231+
throw new RuntimeException(\sprintf('Invalid service "%s": method "%s()" must be public.', $this->currentId, $class !== $this->currentId ? $class.'::'.$method : $method));
232232
}
233233

234234
return $r;
@@ -249,12 +249,12 @@ private function getExpressionLanguage(): ExpressionLanguage
249249
$arg = $this->processValue(new Reference($id));
250250
$this->inExpression = false;
251251
if (!$arg instanceof Reference) {
252-
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));
252+
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));
253253
}
254-
$arg = sprintf('"%s"', $arg);
254+
$arg = \sprintf('"%s"', $arg);
255255
}
256256

257-
return sprintf('$this->get(%s)', $arg);
257+
return \sprintf('$this->get(%s)', $arg);
258258
});
259259
}
260260

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
@@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)
2828
foreach ($container->findTaggedServiceIds('auto_alias') as $serviceId => $tags) {
2929
foreach ($tags as $tag) {
3030
if (!isset($tag['format'])) {
31-
throw new InvalidArgumentException(sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
31+
throw new InvalidArgumentException(\sprintf('Missing tag information "format" on auto_alias service "%s".', $serviceId));
3232
}
3333

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

0 commit comments

Comments
 (0)