Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Aug 12, 2024
1 parent 01ebde6 commit ec2c2d3
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 51 deletions.
6 changes: 3 additions & 3 deletions src/Command/ClearExpiredTokensCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function clearExpiredAccessTokens(SymfonyStyle $io): void
{
$numOfClearedAccessTokens = $this->accessTokenManager->clearExpired();
$io->success(sprintf(
$io->success(\sprintf(
'Cleared %d expired access token%s.',
$numOfClearedAccessTokens,
1 === $numOfClearedAccessTokens ? '' : 's'
Expand All @@ -113,7 +113,7 @@ private function clearExpiredAccessTokens(SymfonyStyle $io): void
private function clearExpiredRefreshTokens(SymfonyStyle $io): void
{
$numOfClearedRefreshTokens = $this->refreshTokenManager->clearExpired();
$io->success(sprintf(
$io->success(\sprintf(
'Cleared %d expired refresh token%s.',
$numOfClearedRefreshTokens,
1 === $numOfClearedRefreshTokens ? '' : 's'
Expand All @@ -123,7 +123,7 @@ private function clearExpiredRefreshTokens(SymfonyStyle $io): void
private function clearExpiredAuthCodes(SymfonyStyle $io): void
{
$numOfClearedAuthCodes = $this->authorizationCodeManager->clearExpired();
$io->success(sprintf(
$io->success(\sprintf(
'Cleared %d expired auth code%s.',
$numOfClearedAuthCodes,
1 === $numOfClearedAuthCodes ? '' : 's'
Expand Down
2 changes: 1 addition & 1 deletion src/Command/DeleteClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);

if (null === $client = $this->clientManager->find($input->getArgument('identifier'))) {
$io->error(sprintf('OAuth2 client identified as "%s" does not exist.', $input->getArgument('identifier')));
$io->error(\sprintf('OAuth2 client identified as "%s" does not exist.', $input->getArgument('identifier')));

return 1;
}
Expand Down
6 changes: 3 additions & 3 deletions src/Command/GenerateKeyPairCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);

if (!\in_array($this->algorithm, self::ACCEPTED_ALGORITHMS, true)) {
$io->error(sprintf('Cannot generate key pair with the provided algorithm `%s`.', $this->algorithm));
$io->error(\sprintf('Cannot generate key pair with the provided algorithm `%s`.', $this->algorithm));

return Command::FAILURE;
}
Expand All @@ -78,10 +78,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($input->getOption('dry-run')) {
$io->success('Your keys have been generated!');
$io->newLine();
$io->writeln(sprintf('Update your private key in <info>%s</info>:', $this->secretKey));
$io->writeln(\sprintf('Update your private key in <info>%s</info>:', $this->secretKey));
$io->writeln($secretKey);
$io->newLine();
$io->writeln(sprintf('Update your public key in <info>%s</info>:', $this->publicKey));
$io->writeln(\sprintf('Update your public key in <info>%s</info>:', $this->publicKey));
$io->writeln($publicKey);

return Command::SUCCESS;
Expand Down
8 changes: 4 additions & 4 deletions src/Command/UpdateClientCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$io = new SymfonyStyle($input, $output);

if (null === $client = $this->clientManager->find($input->getArgument('identifier'))) {
$io->error(sprintf('OAuth2 client identified as "%s" does not exist.', $input->getArgument('identifier')));
$io->error(\sprintf('OAuth2 client identified as "%s" does not exist.', $input->getArgument('identifier')));

return 1;
}
Expand Down Expand Up @@ -107,13 +107,13 @@ private function getClientActiveFromInput(InputInterface $input, bool $actual):
private function getClientRelatedModelsFromInput(InputInterface $input, string $modelFqcn, array $actual, string $argument): array
{
/** @var list<string> $toAdd */
$toAdd = $input->getOption($addArgument = sprintf('add-%s', $argument));
$toAdd = $input->getOption($addArgument = \sprintf('add-%s', $argument));

/** @var list<string> $toRemove */
$toRemove = $input->getOption($removeArgument = sprintf('remove-%s', $argument));
$toRemove = $input->getOption($removeArgument = \sprintf('remove-%s', $argument));

if ([] !== $colliding = array_intersect($toAdd, $toRemove)) {
throw new \RuntimeException(sprintf('Cannot specify "%s" in either "--%s" and "--%s".', implode('", "', $colliding), $addArgument, $removeArgument));
throw new \RuntimeException(\sprintf('Cannot specify "%s" in either "--%s" and "--%s".', implode('", "', $colliding), $addArgument, $removeArgument));
}

$filtered = array_filter($actual, static function ($model) use ($toRemove): bool {
Expand Down
2 changes: 1 addition & 1 deletion src/DBAL/Type/ImplodedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private function assertValueCanBeImploded($value): void
return;
}

throw new \InvalidArgumentException(sprintf('The value of \'%s\' type cannot be imploded.', \gettype($value)));
throw new \InvalidArgumentException(\sprintf('The value of \'%s\' type cannot be imploded.', \gettype($value)));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/CompilerPass/EncryptionKeyPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public function process(ContainerBuilder $container): void
return;
}

throw new \RuntimeException(sprintf('The value "%s" is not allowed for path "league_oauth2_server.authorization_server.encryption_key_type". Permissible values: "plain", "defuse"', $encryptionKeyType));
throw new \RuntimeException(\sprintf('The value "%s" is not allowed for path "league_oauth2_server.authorization_server.encryption_key_type". Permissible values: "plain", "defuse"', $encryptionKeyType));
}
}
6 changes: 3 additions & 3 deletions src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private function createAuthorizationServerNode(): NodeDefinition
->defaultValue(null)
->end()
->scalarNode('encryption_key')
->info(sprintf("The plain string or the ascii safe string used to create a %s to be used as an encryption key.\nHow to generate an encryption key: https://oauth2.thephpleague.com/installation/#string-password", Key::class))
->info(\sprintf("The plain string or the ascii safe string used to create a %s to be used as an encryption key.\nHow to generate an encryption key: https://oauth2.thephpleague.com/installation/#string-password", Key::class))
->isRequired()
->cannotBeEmpty()
->end()
Expand Down Expand Up @@ -240,13 +240,13 @@ private function createClientNode(): NodeDefinition
->addDefaultsIfNotSet()
->children()
->scalarNode('classname')
->info(sprintf('Set a custom client class. Must be a %s', AbstractClient::class))
->info(\sprintf('Set a custom client class. Must be a %s', AbstractClient::class))
->defaultValue(Client::class)
->validate()
->ifTrue(function ($v) {
return !is_a($v, AbstractClient::class, true);
})
->thenInvalid(sprintf('%%s must be a %s', AbstractClient::class))
->thenInvalid(\sprintf('%%s must be a %s', AbstractClient::class))
->end()
->end()
->end()
Expand Down
6 changes: 3 additions & 3 deletions src/DependencyInjection/LeagueOAuth2ServerExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private function assertRequiredBundlesAreEnabled(ContainerBuilder $container): v

foreach ($requiredBundles as $bundleAlias => $requiredBundle) {
if (!$container->hasExtension($bundleAlias)) {
throw new \LogicException(sprintf('Bundle \'%s\' needs to be enabled in your application kernel.', $requiredBundle));
throw new \LogicException(\sprintf('Bundle \'%s\' needs to be enabled in your application kernel.', $requiredBundle));
}
}
}
Expand Down Expand Up @@ -260,7 +260,7 @@ private function configureDoctrinePersistence(ContainerBuilder $container, array
$entityManagerName = $persistenceConfig['entity_manager'];

$entityManager = new Reference(
sprintf('doctrine.orm.%s_entity_manager', $entityManagerName)
\sprintf('doctrine.orm.%s_entity_manager', $entityManagerName)
);

$container
Expand Down Expand Up @@ -339,7 +339,7 @@ private function configureScopes(ContainerBuilder $container, array $scopes): vo
$defaultScopes = $scopes['default'];

if ([] !== $invalidDefaultScopes = array_diff($defaultScopes, $availableScopes)) {
throw new \LogicException(sprintf('Invalid default scopes "%s" for path "league_oauth2_server.scopes.default". Permissible values: "%s"', implode('", "', $invalidDefaultScopes), implode('", "', $availableScopes)));
throw new \LogicException(\sprintf('Invalid default scopes "%s" for path "league_oauth2_server.scopes.default". Permissible values: "%s"', implode('", "', $invalidDefaultScopes), implode('", "', $availableScopes)));
}

$container->setParameter('league.oauth2_server.scopes.default', $defaultScopes);
Expand Down
2 changes: 1 addition & 1 deletion src/DependencyInjection/Security/OAuth2FactoryTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,

public function createAuthenticator(ContainerBuilder $container, string $firewallName, array $config, string $userProviderId): string
{
$authenticator = sprintf('security.authenticator.oauth2.%s', $firewallName);
$authenticator = \sprintf('security.authenticator.oauth2.%s', $firewallName);

$definition = new ChildDefinition(OAuth2Authenticator::class);
$definition->replaceArgument(2, new Reference($userProviderId));
Expand Down
2 changes: 1 addition & 1 deletion src/Event/AuthorizationRequestResolveEventFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function fromAuthorizationRequest(AuthorizationRequest $authorizationRequ
$client = $this->clientManager->find($authorizationRequest->getClient()->getIdentifier());

if (null === $client) {
throw new \RuntimeException(sprintf('No client found for the given identifier \'%s\'.', $authorizationRequest->getClient()->getIdentifier()));
throw new \RuntimeException(\sprintf('No client found for the given identifier \'%s\'.', $authorizationRequest->getClient()->getIdentifier()));
}

return new AuthorizationRequestResolveEvent($authorizationRequest, $scopes, $client);
Expand Down
2 changes: 1 addition & 1 deletion src/Persistence/Mapping/Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function loadMetadataForClass($className, ClassMetadata $metadata): void

break;
default:
throw new \RuntimeException(sprintf('%s cannot load metadata for class %s', __CLASS__, $className));
throw new \RuntimeException(\sprintf('%s cannot load metadata for class %s', __CLASS__, $className));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authentication/Token/OAuth2Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct(

// Build roles from scope
$roles = array_map(function (string $scope) use ($rolePrefix): string {
return strtoupper(trim(sprintf('%s%s', $rolePrefix, $scope)));
return strtoupper(trim(\sprintf('%s%s', $rolePrefix, $scope)));
}, $scopes);

if (null !== $user) {
Expand Down
2 changes: 1 addition & 1 deletion src/Security/Authenticator/OAuth2Authenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function doAuthenticate(Request $request) /* : Passport */
public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface
{
if (!$passport instanceof Passport) {
throw new \RuntimeException(sprintf('Cannot create a OAuth2 authenticated token. $passport should be a %s', Passport::class));
throw new \RuntimeException(\sprintf('Cannot create a OAuth2 authenticated token. $passport should be a %s', Passport::class));
}

$token = $this->createToken($passport, $firewallName);
Expand Down
2 changes: 1 addition & 1 deletion src/ValueObject/RedirectUri.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RedirectUri
public function __construct(string $redirectUri)
{
if (!filter_var($redirectUri, \FILTER_VALIDATE_URL)) {
throw new \RuntimeException(sprintf('The \'%s\' string is not a valid URI.', $redirectUri));
throw new \RuntimeException(\sprintf('The \'%s\' string is not a valid URI.', $redirectUri));
}

$this->redirectUri = $redirectUri;
Expand Down
2 changes: 1 addition & 1 deletion tests/Acceptance/DeleteClientCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function testDeleteNonExistentClient(): void
'identifier' => $identifierName,
]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString(sprintf('OAuth2 client identified as "%s" does not exist.', $identifierName), $output);
$this->assertStringContainsString(\sprintf('OAuth2 client identified as "%s" does not exist.', $identifierName), $output);
}

private function findClient(string $identifier): ?Client
Expand Down
18 changes: 9 additions & 9 deletions tests/Acceptance/SecurityLayerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testAuthenticatedGuestRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_PUBLIC);

$this->client->request('GET', '/security-test', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -52,7 +52,7 @@ public function testAuthenticatedGuestScopedRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_WITH_SCOPES);

$this->client->request('GET', '/security-test-scopes', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -69,7 +69,7 @@ public function testAuthenticatedUserRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_USER_BOUND);

$this->client->request('GET', '/security-test', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -86,7 +86,7 @@ public function testAuthenticatedUserRolesRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_USER_BOUND_WITH_SCOPES);

$this->client->request('GET', '/security-test-roles', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -103,7 +103,7 @@ public function testSuccessfulAuthorizationForAuthenticatedUserRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_USER_BOUND_WITH_SCOPES);

$this->client->request('GET', '/security-test-authorization', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -120,7 +120,7 @@ public function testUnsuccessfulAuthorizationForAuthenticatedUserRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_USER_BOUND);

$this->client->request('GET', '/security-test-authorization', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -137,7 +137,7 @@ public function testExpiredRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_EXPIRED);

$this->client->request('GET', '/security-test', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -153,7 +153,7 @@ public function testRevokedRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_REVOKED);

$this->client->request('GET', '/security-test', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand All @@ -169,7 +169,7 @@ public function testInsufficientScopeRequest(): void
->find(FixtureFactory::FIXTURE_ACCESS_TOKEN_PUBLIC);

$this->client->request('GET', '/security-test-scopes', [], [], [
'HTTP_AUTHORIZATION' => sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
'HTTP_AUTHORIZATION' => \sprintf('Bearer %s', TestHelper::generateJwtToken($accessToken)),
]);

$response = $this->client->getResponse();
Expand Down
10 changes: 5 additions & 5 deletions tests/Acceptance/UpdateClientCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ public function testUpdateRelatedModels(string $argument, array $initial, array
$commandTester->execute([
'command' => $command->getName(),
'identifier' => $client->getIdentifier(),
sprintf('--add-%s', $argument) => $toAdd,
sprintf('--remove-%s', $argument) => $toRemove,
\sprintf('--add-%s', $argument) => $toAdd,
\sprintf('--remove-%s', $argument) => $toRemove,
]);
$output = $commandTester->getDisplay();
$this->assertStringContainsString('OAuth2 client updated successfully.', $output);
$this->assertEquals($expected, $client->{$getter}());

$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage(sprintf('Cannot specify "%s" in either "--add-%2$s" and "--remove-%2$s".', $toAdd[0], $argument));
$this->expectExceptionMessage(\sprintf('Cannot specify "%s" in either "--add-%2$s" and "--remove-%2$s".', $toAdd[0], $argument));

$commandTester->execute([
'command' => $command->getName(),
'identifier' => $client->getIdentifier(),
sprintf('--add-%s', $argument) => [$toAdd[0]],
sprintf('--remove-%s', $argument) => [$toAdd[0]],
\sprintf('--add-%s', $argument) => [$toAdd[0]],
\sprintf('--remove-%s', $argument) => [$toAdd[0]],
]);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Fixtures/SecurityTestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function helloAction(): Response
$user = $this->getUser();

return new Response(
sprintf('Hello, %s', null === $user || $user instanceof NullUser ? 'guest' : (method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername()))
\sprintf('Hello, %s', null === $user || $user instanceof NullUser ? 'guest' : (method_exists($user, 'getUserIdentifier') ? $user->getUserIdentifier() : $user->getUsername()))
);
}

Expand All @@ -42,7 +42,7 @@ public function rolesAction(): Response
$roles = $this->tokenStorage->getToken()->getRoleNames();

return new Response(
sprintf(
\sprintf(
'These are the roles I have currently assigned: %s',
implode(', ', $roles)
)
Expand Down
Loading

0 comments on commit ec2c2d3

Please sign in to comment.