Skip to content

Commit e70f73a

Browse files
committed
Prefix all sprintf() calls
1 parent 8acc2fb commit e70f73a

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

Authentication/Token/AbstractToken.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function hasAttribute(string $name): bool
125125
public function getAttribute(string $name): mixed
126126
{
127127
if (!\array_key_exists($name, $this->attributes)) {
128-
throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name));
128+
throw new \InvalidArgumentException(\sprintf('This token has no "%s" attribute.', $name));
129129
}
130130

131131
return $this->attributes[$name];
@@ -146,7 +146,7 @@ public function __toString(): string
146146
$roles[] = $role;
147147
}
148148

149-
return sprintf('%s(user="%s", roles="%s")', $class, $this->getUserIdentifier(), implode(', ', $roles));
149+
return \sprintf('%s(user="%s", roles="%s")', $class, $this->getUserIdentifier(), implode(', ', $roles));
150150
}
151151

152152
/**

Authorization/AccessDecisionManager.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public function decide(TokenInterface $token, array $attributes, mixed $object =
5353
{
5454
// Special case for AccessListener, do not remove the right side of the condition before 6.0
5555
if (\count($attributes) > 1 && !$allowMultipleAttributes) {
56-
throw new InvalidArgumentException(sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
56+
throw new InvalidArgumentException(\sprintf('Passing more than one Security attribute to "%s()" is not supported.', __METHOD__));
5757
}
5858

5959
return $this->strategy->decide(
@@ -69,7 +69,7 @@ private function collectResults(TokenInterface $token, array $attributes, mixed
6969
foreach ($this->getVoters($attributes, $object) as $voter) {
7070
$result = $voter->vote($token, $object, $attributes);
7171
if (!\is_int($result) || !(self::VALID_VOTES[$result] ?? false)) {
72-
throw new \LogicException(sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
72+
throw new \LogicException(\sprintf('"%s::vote()" must return one of "%s" constants ("ACCESS_GRANTED", "ACCESS_DENIED" or "ACCESS_ABSTAIN"), "%s" returned.', get_debug_type($voter), VoterInterface::class, var_export($result, true)));
7373
}
7474

7575
yield $result;

Authorization/ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Symfony\Component\ExpressionLanguage\ExpressionLanguage as BaseExpressionLanguage;
1616

1717
if (!class_exists(BaseExpressionLanguage::class)) {
18-
throw new \LogicException(sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
18+
throw new \LogicException(\sprintf('The "%s" class requires the "ExpressionLanguage" component. Try running "composer require symfony/expression-language".', ExpressionLanguage::class));
1919
} else {
2020
// Help opcache.preload discover always-needed symbols
2121
class_exists(ExpressionLanguageProvider::class);

Authorization/ExpressionLanguageProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function getFunctions(): array
2828

2929
new ExpressionFunction('is_fully_authenticated', fn () => '$token && $auth_checker->isGranted("IS_AUTHENTICATED_FULLY")', fn (array $variables) => $variables['token'] && $variables['auth_checker']->isGranted('IS_AUTHENTICATED_FULLY')),
3030

31-
new ExpressionFunction('is_granted', fn ($attributes, $object = 'null') => sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)),
31+
new ExpressionFunction('is_granted', fn ($attributes, $object = 'null') => \sprintf('$auth_checker->isGranted(%s, %s)', $attributes, $object), fn (array $variables, $attributes, $object = null) => $variables['auth_checker']->isGranted($attributes, $object)),
3232

3333
new ExpressionFunction('is_remember_me', fn () => '$token && $auth_checker->isGranted("IS_REMEMBERED")', fn (array $variables) => $variables['token'] && $variables['auth_checker']->isGranted('IS_REMEMBERED')),
3434
];

Signature/SignatureHasher.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function verifySignatureHash(UserInterface $user, int $expires, string $h
8787

8888
if ($this->expiredSignaturesStorage && $this->maxUses) {
8989
if ($this->expiredSignaturesStorage->countUsages($hash) >= $this->maxUses) {
90-
throw new ExpiredSignatureException(sprintf('Signature can only be used "%d" times.', $this->maxUses));
90+
throw new ExpiredSignatureException(\sprintf('Signature can only be used "%d" times.', $this->maxUses));
9191
}
9292

9393
$this->expiredSignaturesStorage->incrementUsages($hash);
@@ -111,7 +111,7 @@ public function computeSignatureHash(UserInterface $user, int $expires): string
111111
}
112112

113113
if (!\is_scalar($value) && !$value instanceof \Stringable) {
114-
throw new \InvalidArgumentException(sprintf('The property path "%s" on the user object "%s" must return a value that can be cast to a string, but "%s" was returned.', $property, $user::class, get_debug_type($value)));
114+
throw new \InvalidArgumentException(\sprintf('The property path "%s" on the user object "%s" must return a value that can be cast to a string, but "%s" was returned.', $property, $user::class, get_debug_type($value)));
115115
}
116116
hash_update($fieldsHash, ':'.base64_encode($value));
117117
}

Tests/Resources/TranslationFilesTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function testTranslationFileIsValid($filePath)
2626

2727
$errors = XliffUtils::validateSchema($document);
2828

29-
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
29+
$this->assertCount(0, $errors, \sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
3030
}
3131

3232
/**
@@ -39,7 +39,7 @@ public function testTranslationFileIsValidWithoutEntityLoader($filePath)
3939

4040
$errors = XliffUtils::validateSchema($document);
4141

42-
$this->assertCount(0, $errors, sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
42+
$this->assertCount(0, $errors, \sprintf('"%s" is invalid:%s', $filePath, \PHP_EOL.implode(\PHP_EOL, array_column($errors, 'message'))));
4343
}
4444

4545
public static function provideTranslationFiles()

User/ChainUserProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
5656
}
5757
}
5858

59-
$ex = new UserNotFoundException(sprintf('There is no user with identifier "%s".', $identifier));
59+
$ex = new UserNotFoundException(\sprintf('There is no user with identifier "%s".', $identifier));
6060
$ex->setUserIdentifier($identifier);
6161
throw $ex;
6262
}
@@ -82,11 +82,11 @@ public function refreshUser(UserInterface $user): UserInterface
8282

8383
if ($supportedUserFound) {
8484
$username = $user->getUserIdentifier();
85-
$e = new UserNotFoundException(sprintf('There is no user with name "%s".', $username));
85+
$e = new UserNotFoundException(\sprintf('There is no user with name "%s".', $username));
8686
$e->setUserIdentifier($username);
8787
throw $e;
8888
} else {
89-
throw new UnsupportedUserException(sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', get_debug_type($user)));
89+
throw new UnsupportedUserException(\sprintf('There is no user provider for user "%s". Shouldn\'t the "supportsClass()" method of your user provider return true for this classname?', get_debug_type($user)));
9090
}
9191
}
9292

User/InMemoryUserProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(array $users = [])
5555
public function createUser(UserInterface $user): void
5656
{
5757
if (!$user instanceof InMemoryUser) {
58-
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
58+
throw new UnsupportedUserException(\sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
5959
}
6060

6161
$userIdentifier = strtolower($user->getUserIdentifier());
@@ -76,7 +76,7 @@ public function loadUserByIdentifier(string $identifier): UserInterface
7676
public function refreshUser(UserInterface $user): UserInterface
7777
{
7878
if (!$user instanceof InMemoryUser) {
79-
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
79+
throw new UnsupportedUserException(\sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
8080
}
8181

8282
$storedUser = $this->getUser($user->getUserIdentifier());
@@ -98,7 +98,7 @@ public function supportsClass(string $class): bool
9898
private function getUser(string $username): InMemoryUser
9999
{
100100
if (!isset($this->users[strtolower($username)])) {
101-
$ex = new UserNotFoundException(sprintf('Username "%s" does not exist.', $username));
101+
$ex = new UserNotFoundException(\sprintf('Username "%s" does not exist.', $username));
102102
$ex->setUserIdentifier($username);
103103

104104
throw $ex;

User/MissingUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class MissingUserProvider implements UserProviderInterface
2828
*/
2929
public function __construct(string $firewall)
3030
{
31-
throw new InvalidConfigurationException(sprintf('"%s" firewall requires a user provider but none was defined.', $firewall));
31+
throw new InvalidConfigurationException(\sprintf('"%s" firewall requires a user provider but none was defined.', $firewall));
3232
}
3333

3434
public function loadUserByUsername(string $username): UserInterface

Validator/Constraints/UserPasswordValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function validate(mixed $password, Constraint $constraint): void
4949
$user = $this->tokenStorage->getToken()->getUser();
5050

5151
if (!$user instanceof PasswordAuthenticatedUserInterface) {
52-
throw new ConstraintDefinitionException(sprintf('The "%s" class must implement the "%s" interface.', PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
52+
throw new ConstraintDefinitionException(\sprintf('The "%s" class must implement the "%s" interface.', PasswordAuthenticatedUserInterface::class, get_debug_type($user)));
5353
}
5454

5555
$hasher = $this->hasherFactory->getPasswordHasher($user);

0 commit comments

Comments
 (0)