Skip to content

Commit 6cd7c22

Browse files
committed
Prefix all sprintf() calls
1 parent 1e477ee commit 6cd7c22

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

Cache/CacheTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function delete(string $key): bool
3838
private function doGet(CacheItemPoolInterface $pool, string $key, callable $callback, ?float $beta, ?array &$metadata = null, ?LoggerInterface $logger = null): mixed
3939
{
4040
if (0 > $beta ??= 1.0) {
41-
throw new class(sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements InvalidArgumentException {};
41+
throw new class(\sprintf('Argument "$beta" provided to "%s::get()" must be a positive number, %f given.', static::class, $beta)) extends \InvalidArgumentException implements InvalidArgumentException {};
4242
}
4343

4444
$item = $pool->getItem($key);
@@ -54,7 +54,7 @@ private function doGet(CacheItemPoolInterface $pool, string $key, callable $call
5454
$item->expiresAt(null);
5555
$logger?->info('Item "{key}" elected for early recomputation {delta}s before its expiration', [
5656
'key' => $key,
57-
'delta' => sprintf('%.1f', $expiry - $now),
57+
'delta' => \sprintf('%.1f', $expiry - $now),
5858
]);
5959
}
6060
}

Service/ServiceLocatorTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ private function createNotFoundException(string $id): NotFoundExceptionInterface
9090
} else {
9191
$last = array_pop($alternatives);
9292
if ($alternatives) {
93-
$message = sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
93+
$message = \sprintf('only knows about the "%s" and "%s" services.', implode('", "', $alternatives), $last);
9494
} else {
95-
$message = sprintf('only knows about the "%s" service.', $last);
95+
$message = \sprintf('only knows about the "%s" service.', $last);
9696
}
9797
}
9898

9999
if ($this->loading) {
100-
$message = sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
100+
$message = \sprintf('The service "%s" has a dependency on a non-existent service "%s". This locator %s', end($this->loading), $id, $message);
101101
} else {
102-
$message = sprintf('Service "%s" not found: the current service locator %s', $id, $message);
102+
$message = \sprintf('Service "%s" not found: the current service locator %s', $id, $message);
103103
}
104104

105105
return new class($message) extends \InvalidArgumentException implements NotFoundExceptionInterface {
@@ -108,7 +108,7 @@ private function createNotFoundException(string $id): NotFoundExceptionInterface
108108

109109
private function createCircularReferenceException(string $id, array $path): ContainerExceptionInterface
110110
{
111-
return new class(sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
111+
return new class(\sprintf('Circular reference detected for service "%s", path: "%s".', $id, implode(' -> ', $path))) extends \RuntimeException implements ContainerExceptionInterface {
112112
};
113113
}
114114
}

Service/ServiceMethodsSubscriberTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ public static function getSubscribedServices(): array
4242
}
4343

4444
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
45-
throw new \LogicException(sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
45+
throw new \LogicException(\sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
4646
}
4747

4848
if (!$returnType = $method->getReturnType()) {
49-
throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
49+
throw new \LogicException(\sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
5050
}
5151

5252
/* @var SubscribedService $attribute */

Service/ServiceSubscriberTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ public static function getSubscribedServices(): array
4646
}
4747

4848
if ($method->isStatic() || $method->isAbstract() || $method->isGenerator() || $method->isInternal() || $method->getNumberOfRequiredParameters()) {
49-
throw new \LogicException(sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
49+
throw new \LogicException(\sprintf('Cannot use "%s" on method "%s::%s()" (can only be used on non-static, non-abstract methods with no parameters).', SubscribedService::class, self::class, $method->name));
5050
}
5151

5252
if (!$returnType = $method->getReturnType()) {
53-
throw new \LogicException(sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
53+
throw new \LogicException(\sprintf('Cannot use "%s" on methods without a return type in "%s::%s()".', SubscribedService::class, $method->name, self::class));
5454
}
5555

5656
/* @var SubscribedService $attribute */

Translation/TranslatorTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function trans(?string $id, array $parameters = [], ?string $domain = nul
111111
return strtr($standardRules[0], $parameters);
112112
}
113113

114-
$message = sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
114+
$message = \sprintf('Unable to choose a translation for "%s" with locale "%s" for value "%d". Double check that this translation has the correct plural options (e.g. "There is one apple|There are %%count%% apples").', $id, $locale, $number);
115115

116116
if (class_exists(InvalidArgumentException::class)) {
117117
throw new InvalidArgumentException($message);

0 commit comments

Comments
 (0)