Skip to content

Commit 1052e00

Browse files
committed
Prefix all sprintf() calls
1 parent 60c31ba commit 1052e00

26 files changed

+95
-95
lines changed

Exception/MissingMandatoryParametersException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function __construct(string $routeName = '', array $missingParameters = [
2929
{
3030
$this->routeName = $routeName;
3131
$this->missingParameters = $missingParameters;
32-
$message = sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".', implode('", "', $missingParameters), $routeName);
32+
$message = \sprintf('Some mandatory parameters are missing ("%s") to generate a URL for route "%s".', implode('", "', $missingParameters), $routeName);
3333

3434
parent::__construct($message, $code, $previous);
3535
}

Exception/RouteCircularReferenceException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ class RouteCircularReferenceException extends RuntimeException
1515
{
1616
public function __construct(string $routeId, array $path)
1717
{
18-
parent::__construct(sprintf('Circular reference detected for route "%s", path: "%s".', $routeId, implode(' -> ', $path)));
18+
parent::__construct(\sprintf('Circular reference detected for route "%s", path: "%s".', $routeId, implode(' -> ', $path)));
1919
}
2020
}

Generator/CompiledUrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function generate(string $name, array $parameters = [], int $referenceTyp
4949
}
5050

5151
if (!isset($this->compiledRoutes[$name])) {
52-
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
52+
throw new RouteNotFoundException(\sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
5353
}
5454

5555
[$variables, $defaults, $requirements, $tokens, $hostTokens, $requiredSchemes, $deprecations] = $this->compiledRoutes[$name] + [6 => []];

Generator/Dumper/CompiledUrlGeneratorDumper.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function getCompiledAliases(): array
6969
}
7070

7171
if (null === $target = $routes->get($currentId)) {
72-
throw new RouteNotFoundException(sprintf('Target route "%s" for alias "%s" does not exist.', $currentId, $name));
72+
throw new RouteNotFoundException(\sprintf('Target route "%s" for alias "%s" does not exist.', $currentId, $name));
7373
}
7474

7575
$compiledTarget = $target->compile();
@@ -109,11 +109,11 @@ private function generateDeclaredRoutes(): string
109109
{
110110
$routes = '';
111111
foreach ($this->getCompiledRoutes() as $name => $properties) {
112-
$routes .= sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
112+
$routes .= \sprintf("\n '%s' => %s,", $name, CompiledUrlMatcherDumper::export($properties));
113113
}
114114

115115
foreach ($this->getCompiledAliases() as $alias => $properties) {
116-
$routes .= sprintf("\n '%s' => %s,", $alias, CompiledUrlMatcherDumper::export($properties));
116+
$routes .= \sprintf("\n '%s' => %s,", $alias, CompiledUrlMatcherDumper::export($properties));
117117
}
118118

119119
return $routes;

Generator/UrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function generate(string $name, array $parameters = [], int $referenceTyp
115115
}
116116

117117
if (null === $route ??= $this->routes->get($name)) {
118-
throw new RouteNotFoundException(sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
118+
throw new RouteNotFoundException(\sprintf('Unable to generate a URL for the named route "%s" as such route does not exist.', $name));
119119
}
120120

121121
// the Route has a cache of its own and is not recompiled as long as it does not get modified

Loader/AttributeClassLoader.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ public function setRouteAnnotationClass(string $class): void
7575
public function load(mixed $class, ?string $type = null): RouteCollection
7676
{
7777
if (!class_exists($class)) {
78-
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
78+
throw new \InvalidArgumentException(\sprintf('Class "%s" does not exist.', $class));
7979
}
8080

8181
$class = new \ReflectionClass($class);
8282
if ($class->isAbstract()) {
83-
throw new \InvalidArgumentException(sprintf('Attributes from class "%s" cannot be read as it is abstract.', $class->getName()));
83+
throw new \InvalidArgumentException(\sprintf('Attributes from class "%s" cannot be read as it is abstract.', $class->getName()));
8484
}
8585

8686
$globals = $this->getGlobals($class);
@@ -102,7 +102,7 @@ public function load(mixed $class, ?string $type = null): RouteCollection
102102

103103
if (1 === $collection->count() - \count($routeNamesBefore)) {
104104
$newRouteName = current(array_diff(array_keys($collection->all()), $routeNamesBefore));
105-
if ($newRouteName !== $aliasName = sprintf('%s::%s', $class->name, $method->name)) {
105+
if ($newRouteName !== $aliasName = \sprintf('%s::%s', $class->name, $method->name)) {
106106
$collection->addAlias($aliasName, $newRouteName);
107107
}
108108
}
@@ -120,7 +120,7 @@ public function load(mixed $class, ?string $type = null): RouteCollection
120120
$collection->addAlias($class->name, $invokeRouteName);
121121
}
122122

123-
if ($invokeRouteName !== $aliasName = sprintf('%s::__invoke', $class->name)) {
123+
if ($invokeRouteName !== $aliasName = \sprintf('%s::__invoke', $class->name)) {
124124
$collection->addAlias($aliasName, $invokeRouteName);
125125
}
126126
}
@@ -144,7 +144,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g
144144

145145
foreach ($requirements as $placeholder => $requirement) {
146146
if (\is_int($placeholder)) {
147-
throw new \InvalidArgumentException(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s::%s()"?', $placeholder, $requirement, $name, $class->getName(), $method->getName()));
147+
throw new \InvalidArgumentException(\sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" of route "%s" in "%s::%s()"?', $placeholder, $requirement, $name, $class->getName(), $method->getName()));
148148
}
149149
}
150150

@@ -168,11 +168,11 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g
168168
$paths[$locale] = $prefix.$localePath;
169169
}
170170
} elseif ($missing = array_diff_key($prefix, $path)) {
171-
throw new \LogicException(sprintf('Route to "%s" is missing paths for locale(s) "%s".', $class->name.'::'.$method->name, implode('", "', array_keys($missing))));
171+
throw new \LogicException(\sprintf('Route to "%s" is missing paths for locale(s) "%s".', $class->name.'::'.$method->name, implode('", "', array_keys($missing))));
172172
} else {
173173
foreach ($path as $locale => $localePath) {
174174
if (!isset($prefix[$locale])) {
175-
throw new \LogicException(sprintf('Route to "%s" with locale "%s" is missing a corresponding prefix in class "%s".', $method->name, $locale, $class->name));
175+
throw new \LogicException(\sprintf('Route to "%s" with locale "%s" is missing a corresponding prefix in class "%s".', $method->name, $locale, $class->name));
176176
}
177177

178178
$paths[$locale] = $prefix[$locale].$localePath;
@@ -191,7 +191,7 @@ protected function addRoute(RouteCollection $collection, object $annot, array $g
191191
continue;
192192
}
193193
foreach ($paths as $locale => $path) {
194-
if (preg_match(sprintf('/\{%s(?:<.*?>)?\}/', preg_quote($param->name)), $path)) {
194+
if (preg_match(\sprintf('/\{%s(?:<.*?>)?\}/', preg_quote($param->name)), $path)) {
195195
if (\is_scalar($defaultValue = $param->getDefaultValue()) || null === $defaultValue) {
196196
$defaults[$param->name] = $defaultValue;
197197
} elseif ($defaultValue instanceof \BackedEnum) {
@@ -227,7 +227,7 @@ public function setResolver(LoaderResolverInterface $resolver): void
227227

228228
public function getResolver(): LoaderResolverInterface
229229
{
230-
throw new LogicException(sprintf('The "%s()" method must not be called.', __METHOD__));
230+
throw new LogicException(\sprintf('The "%s()" method must not be called.', __METHOD__));
231231
}
232232

233233
/**
@@ -300,7 +300,7 @@ protected function getGlobals(\ReflectionClass $class): array
300300

301301
foreach ($globals['requirements'] as $placeholder => $requirement) {
302302
if (\is_int($placeholder)) {
303-
throw new \InvalidArgumentException(sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" in "%s"?', $placeholder, $requirement, $class->getName()));
303+
throw new \InvalidArgumentException(\sprintf('A placeholder name must be a string (%d given). Did you forget to specify the placeholder key for the requirement "%s" in "%s"?', $placeholder, $requirement, $class->getName()));
304304
}
305305
}
306306
}

Loader/AttributeFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ protected function findClass(string $file): string|false
7676
$tokens = token_get_all(file_get_contents($file));
7777

7878
if (1 === \count($tokens) && \T_INLINE_HTML === $tokens[0][0]) {
79-
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?', $file));
79+
throw new \InvalidArgumentException(\sprintf('The file "%s" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?', $file));
8080
}
8181

8282
$nsTokens = [\T_NS_SEPARATOR => true, \T_STRING => true];

Loader/Configurator/CollectionConfigurator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ final public function prefix(string|array $prefix): static
7979
if (null === $this->parentPrefixes) {
8080
// no-op
8181
} elseif ($missing = array_diff_key($this->parentPrefixes, $prefix)) {
82-
throw new \LogicException(sprintf('Collection "%s" is missing prefixes for locale(s) "%s".', $this->name, implode('", "', array_keys($missing))));
82+
throw new \LogicException(\sprintf('Collection "%s" is missing prefixes for locale(s) "%s".', $this->name, implode('", "', array_keys($missing))));
8383
} else {
8484
foreach ($prefix as $locale => $localePrefix) {
8585
if (!isset($this->parentPrefixes[$locale])) {
86-
throw new \LogicException(sprintf('Collection "%s" with locale "%s" is missing a corresponding prefix in its parent collection.', $this->name, $locale));
86+
throw new \LogicException(\sprintf('Collection "%s" with locale "%s" is missing a corresponding prefix in its parent collection.', $this->name, $locale));
8787
}
8888

8989
$prefix[$locale] = $this->parentPrefixes[$locale].$localePrefix;

Loader/Configurator/Traits/HostTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final protected function addHost(RouteCollection $routes, string|array $hosts):
3838
$routes->add($name.'.'.$locale, $localizedRoute);
3939
}
4040
} elseif (!isset($hosts[$locale])) {
41-
throw new \InvalidArgumentException(sprintf('Route "%s" with locale "%s" is missing a corresponding host in its parent collection.', $name, $locale));
41+
throw new \InvalidArgumentException(\sprintf('Route "%s" with locale "%s" is missing a corresponding host in its parent collection.', $name, $locale));
4242
} else {
4343
$route->setHost($hosts[$locale]);
4444
$route->setRequirement('_locale', preg_quote($locale));

Loader/Configurator/Traits/LocalizedRouteTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ final protected function createLocalizedRoute(RouteCollection $collection, strin
3737
if (null === $prefixes) {
3838
$paths = $path;
3939
} elseif ($missing = array_diff_key($prefixes, $path)) {
40-
throw new \LogicException(sprintf('Route "%s" is missing routes for locale(s) "%s".', $name, implode('", "', array_keys($missing))));
40+
throw new \LogicException(\sprintf('Route "%s" is missing routes for locale(s) "%s".', $name, implode('", "', array_keys($missing))));
4141
} else {
4242
foreach ($path as $locale => $localePath) {
4343
if (!isset($prefixes[$locale])) {
44-
throw new \LogicException(sprintf('Route "%s" with locale "%s" is missing a corresponding prefix in its parent collection.', $name, $locale));
44+
throw new \LogicException(\sprintf('Route "%s" with locale "%s" is missing a corresponding prefix in its parent collection.', $name, $locale));
4545
}
4646

4747
$paths[$locale] = $prefixes[$locale].$localePath;

0 commit comments

Comments
 (0)