From d7cb055faea503b41cbddc1c9cfb77880d853d51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Wed, 29 Nov 2023 00:54:18 +0100 Subject: [PATCH] style: Apply PHP-CS-Fixer --- src/DBAL/Type/Grant.php | 3 --- src/DBAL/Type/ImplodedArray.php | 10 ---------- src/DBAL/Type/RedirectUri.php | 3 --- src/DBAL/Type/Scope.php | 3 --- src/DependencyInjection/Configuration.php | 3 --- .../LeagueOAuth2ServerExtension.php | 9 --------- src/Entity/Scope.php | 5 ----- src/LeagueOAuth2ServerBundle.php | 5 ----- src/Model/RefreshToken.php | 2 +- src/Repository/AccessTokenRepository.php | 6 ------ src/Repository/AuthCodeRepository.php | 11 ----------- src/Repository/ClientRepository.php | 6 ------ src/Repository/NullAccessTokenRepository.php | 12 ------------ src/Repository/RefreshTokenRepository.php | 6 ------ src/Repository/ScopeRepository.php | 3 --- src/Repository/UserRepository.php | 3 --- .../Authenticator/OAuth2Authenticator.php | 4 +--- .../Exception/InsufficientScopesException.php | 2 +- .../OAuth2AuthenticationException.php | 2 +- .../OAuth2AuthenticationFailedException.php | 2 +- .../DoctrineCredentialsRevokerTest.php | 4 ++-- tests/Fixtures/User.php | 18 ------------------ tests/Integration/AbstractIntegrationTest.php | 3 --- tests/TestKernel.php | 18 ------------------ 24 files changed, 7 insertions(+), 136 deletions(-) diff --git a/src/DBAL/Type/Grant.php b/src/DBAL/Type/Grant.php index 781cab48..56d3c4b1 100644 --- a/src/DBAL/Type/Grant.php +++ b/src/DBAL/Type/Grant.php @@ -16,9 +16,6 @@ final class Grant extends ImplodedArray */ private const NAME = 'oauth2_grant'; - /** - * {@inheritdoc} - */ public function getName(): string { return self::NAME; diff --git a/src/DBAL/Type/ImplodedArray.php b/src/DBAL/Type/ImplodedArray.php index 2f12f435..5044dade 100644 --- a/src/DBAL/Type/ImplodedArray.php +++ b/src/DBAL/Type/ImplodedArray.php @@ -39,10 +39,6 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform): ?str } /** - * {@inheritdoc} - * - * @param mixed $value - * * @psalm-return list */ public function convertToPHPValue($value, AbstractPlatform $platform): array @@ -58,9 +54,6 @@ public function convertToPHPValue($value, AbstractPlatform $platform): array return $this->convertDatabaseValues($values); } - /** - * {@inheritdoc} - */ public function getSQLDeclaration(array $column, AbstractPlatform $platform): string { $column['length'] = 65535; @@ -68,9 +61,6 @@ public function getSQLDeclaration(array $column, AbstractPlatform $platform): st return parent::getSQLDeclaration($column, $platform); } - /** - * {@inheritdoc} - */ public function requiresSQLCommentHint(AbstractPlatform $platform): bool { return true; diff --git a/src/DBAL/Type/RedirectUri.php b/src/DBAL/Type/RedirectUri.php index 840e6a49..b6baee9a 100644 --- a/src/DBAL/Type/RedirectUri.php +++ b/src/DBAL/Type/RedirectUri.php @@ -16,9 +16,6 @@ final class RedirectUri extends ImplodedArray */ private const NAME = 'oauth2_redirect_uri'; - /** - * {@inheritdoc} - */ public function getName(): string { return self::NAME; diff --git a/src/DBAL/Type/Scope.php b/src/DBAL/Type/Scope.php index c946815f..3d4b23ab 100644 --- a/src/DBAL/Type/Scope.php +++ b/src/DBAL/Type/Scope.php @@ -16,9 +16,6 @@ final class Scope extends ImplodedArray */ private const NAME = 'oauth2_scope'; - /** - * {@inheritdoc} - */ public function getName(): string { return self::NAME; diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index c61d6944..11861cfe 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -13,9 +13,6 @@ final class Configuration implements ConfigurationInterface { - /** - * {@inheritdoc} - */ public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('league_oauth2_server'); diff --git a/src/DependencyInjection/LeagueOAuth2ServerExtension.php b/src/DependencyInjection/LeagueOAuth2ServerExtension.php index dcff3006..81922ad0 100644 --- a/src/DependencyInjection/LeagueOAuth2ServerExtension.php +++ b/src/DependencyInjection/LeagueOAuth2ServerExtension.php @@ -42,8 +42,6 @@ final class LeagueOAuth2ServerExtension extends Extension implements PrependExtensionInterface, CompilerPassInterface { /** - * {@inheritdoc} - * * @return void * * @throws \Exception @@ -73,17 +71,12 @@ public function load(array $configs, ContainerBuilder $container) ; } - /** - * {@inheritdoc} - */ public function getAlias(): string { return 'league_oauth2_server'; } /** - * {@inheritdoc} - * * @return void */ public function prepend(ContainerBuilder $container) @@ -101,8 +94,6 @@ public function prepend(ContainerBuilder $container) } /** - * {@inheritdoc} - * * @return void */ public function process(ContainerBuilder $container) diff --git a/src/Entity/Scope.php b/src/Entity/Scope.php index 89395c0b..08a9c168 100644 --- a/src/Entity/Scope.php +++ b/src/Entity/Scope.php @@ -11,11 +11,6 @@ final class Scope implements ScopeEntityInterface { use EntityTrait; - /** - * {@inheritdoc} - * - * @return mixed - */ #[\ReturnTypeWillChange] public function jsonSerialize() { diff --git a/src/LeagueOAuth2ServerBundle.php b/src/LeagueOAuth2ServerBundle.php index 3b241a7c..1f9b06a1 100644 --- a/src/LeagueOAuth2ServerBundle.php +++ b/src/LeagueOAuth2ServerBundle.php @@ -18,8 +18,6 @@ final class LeagueOAuth2ServerBundle extends Bundle { /** - * {@inheritdoc} - * * @return void */ public function build(ContainerBuilder $container) @@ -30,9 +28,6 @@ public function build(ContainerBuilder $container) $this->configureSecurityExtension($container); } - /** - * {@inheritdoc} - */ public function getContainerExtension(): ExtensionInterface { return new LeagueOAuth2ServerExtension(); diff --git a/src/Model/RefreshToken.php b/src/Model/RefreshToken.php index a212b72e..9a15703e 100644 --- a/src/Model/RefreshToken.php +++ b/src/Model/RefreshToken.php @@ -29,7 +29,7 @@ class RefreshToken implements RefreshTokenInterface /** * @psalm-mutation-free */ - public function __construct(string $identifier, \DateTimeInterface $expiry, ?AccessTokenInterface $accessToken = null) + public function __construct(string $identifier, \DateTimeInterface $expiry, AccessTokenInterface $accessToken = null) { $this->identifier = $identifier; $this->expiry = $expiry; diff --git a/src/Repository/AccessTokenRepository.php b/src/Repository/AccessTokenRepository.php index b6a65971..ede92328 100644 --- a/src/Repository/AccessTokenRepository.php +++ b/src/Repository/AccessTokenRepository.php @@ -42,9 +42,6 @@ public function __construct( $this->scopeConverter = $scopeConverter; } - /** - * {@inheritdoc} - */ public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null) { /** @var int|string|null $userIdentifier */ @@ -59,9 +56,6 @@ public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, return $accessToken; } - /** - * {@inheritdoc} - */ public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void { $accessToken = $this->accessTokenManager->find($accessTokenEntity->getIdentifier()); diff --git a/src/Repository/AuthCodeRepository.php b/src/Repository/AuthCodeRepository.php index 313d55b1..ce6e1620 100644 --- a/src/Repository/AuthCodeRepository.php +++ b/src/Repository/AuthCodeRepository.php @@ -41,17 +41,12 @@ public function __construct( $this->scopeConverter = $scopeConverter; } - /** - * {@inheritdoc} - */ public function getNewAuthCode(): AuthCode { return new AuthCode(); } /** - * {@inheritdoc} - * * @return void */ public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity) @@ -67,9 +62,6 @@ public function persistNewAuthCode(AuthCodeEntityInterface $authCodeEntity) $this->authorizationCodeManager->save($authorizationCode); } - /** - * {@inheritdoc} - */ public function revokeAuthCode($codeId): void { $authorizationCode = $this->authorizationCodeManager->find($codeId); @@ -83,9 +75,6 @@ public function revokeAuthCode($codeId): void $this->authorizationCodeManager->save($authorizationCode); } - /** - * {@inheritdoc} - */ public function isAuthCodeRevoked($codeId): bool { $authorizationCode = $this->authorizationCodeManager->find($codeId); diff --git a/src/Repository/ClientRepository.php b/src/Repository/ClientRepository.php index d270d940..afb4867d 100644 --- a/src/Repository/ClientRepository.php +++ b/src/Repository/ClientRepository.php @@ -21,9 +21,6 @@ public function __construct(ClientManagerInterface $clientManager) $this->clientManager = $clientManager; } - /** - * {@inheritdoc} - */ public function getClientEntity($clientIdentifier) { $client = $this->clientManager->find($clientIdentifier); @@ -35,9 +32,6 @@ public function getClientEntity($clientIdentifier) return $this->buildClientEntity($client); } - /** - * {@inheritdoc} - */ public function validateClient($clientIdentifier, $clientSecret, $grantType): bool { $client = $this->clientManager->find($clientIdentifier); diff --git a/src/Repository/NullAccessTokenRepository.php b/src/Repository/NullAccessTokenRepository.php index 6061d1de..d315c924 100644 --- a/src/Repository/NullAccessTokenRepository.php +++ b/src/Repository/NullAccessTokenRepository.php @@ -11,9 +11,6 @@ final class NullAccessTokenRepository implements AccessTokenRepositoryInterface { - /** - * {@inheritdoc} - */ public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, $userIdentifier = null): AccessTokenEntityInterface { /** @var int|string|null $userIdentifier */ @@ -28,25 +25,16 @@ public function getNewToken(ClientEntityInterface $clientEntity, array $scopes, return $accessToken; } - /** - * {@inheritdoc} - */ public function persistNewAccessToken(AccessTokenEntityInterface $accessTokenEntity): void { // do nothing } - /** - * {@inheritdoc} - */ public function revokeAccessToken($tokenId): void { // do nothing } - /** - * {@inheritdoc} - */ public function isAccessTokenRevoked($tokenId): bool { return false; diff --git a/src/Repository/RefreshTokenRepository.php b/src/Repository/RefreshTokenRepository.php index 06aa93b3..a81527d2 100644 --- a/src/Repository/RefreshTokenRepository.php +++ b/src/Repository/RefreshTokenRepository.php @@ -32,17 +32,11 @@ public function __construct( $this->accessTokenManager = $accessTokenManager; } - /** - * {@inheritdoc} - */ public function getNewRefreshToken() { return new RefreshTokenEntity(); } - /** - * {@inheritdoc} - */ public function persistNewRefreshToken(RefreshTokenEntityInterface $refreshTokenEntity): void { $refreshToken = $this->refreshTokenManager->find($refreshTokenEntity->getIdentifier()); diff --git a/src/Repository/ScopeRepository.php b/src/Repository/ScopeRepository.php index c93680d2..e750b30b 100644 --- a/src/Repository/ScopeRepository.php +++ b/src/Repository/ScopeRepository.php @@ -52,9 +52,6 @@ public function __construct( $this->eventDispatcher = $eventDispatcher; } - /** - * {@inheritdoc} - */ public function getScopeEntityByIdentifier($identifier) { $scope = $this->scopeManager->find($identifier); diff --git a/src/Repository/UserRepository.php b/src/Repository/UserRepository.php index 48b8c385..7c1f604f 100644 --- a/src/Repository/UserRepository.php +++ b/src/Repository/UserRepository.php @@ -42,9 +42,6 @@ public function __construct( $this->userConverter = $userConverter; } - /** - * {@inheritdoc} - */ public function getUserEntityByUserCredentials( $username, $password, diff --git a/src/Security/Authenticator/OAuth2Authenticator.php b/src/Security/Authenticator/OAuth2Authenticator.php index 3187925b..68e4acfa 100644 --- a/src/Security/Authenticator/OAuth2Authenticator.php +++ b/src/Security/Authenticator/OAuth2Authenticator.php @@ -70,7 +70,7 @@ public function __construct( public function supports(Request $request): ?bool { - return 0 === strpos($request->headers->get('Authorization', ''), 'Bearer '); + return str_starts_with($request->headers->get('Authorization', ''), 'Bearer '); } public function start(Request $request, AuthenticationException $authException = null): Response @@ -79,8 +79,6 @@ public function start(Request $request, AuthenticationException $authException = } /** - * {@inheritdoc} - * * @return Passport */ public function doAuthenticate(Request $request) /* : Passport */ diff --git a/src/Security/Exception/InsufficientScopesException.php b/src/Security/Exception/InsufficientScopesException.php index f3167f31..e1bcf1e7 100644 --- a/src/Security/Exception/InsufficientScopesException.php +++ b/src/Security/Exception/InsufficientScopesException.php @@ -9,7 +9,7 @@ */ class InsufficientScopesException extends OAuth2AuthenticationException { - public static function create(?\Throwable $previous = null): self + public static function create(\Throwable $previous = null): self { return new self('Insufficient scopes.', 403, $previous); } diff --git a/src/Security/Exception/OAuth2AuthenticationException.php b/src/Security/Exception/OAuth2AuthenticationException.php index d7033934..2509fe92 100644 --- a/src/Security/Exception/OAuth2AuthenticationException.php +++ b/src/Security/Exception/OAuth2AuthenticationException.php @@ -17,7 +17,7 @@ class OAuth2AuthenticationException extends AuthenticationException implements H */ private $statusCode; - public function __construct(string $message, int $statusCode, ?\Throwable $previous = null) + public function __construct(string $message, int $statusCode, \Throwable $previous = null) { $this->statusCode = $statusCode; diff --git a/src/Security/Exception/OAuth2AuthenticationFailedException.php b/src/Security/Exception/OAuth2AuthenticationFailedException.php index 781575c6..73e457ca 100644 --- a/src/Security/Exception/OAuth2AuthenticationFailedException.php +++ b/src/Security/Exception/OAuth2AuthenticationFailedException.php @@ -9,7 +9,7 @@ */ class OAuth2AuthenticationFailedException extends OAuth2AuthenticationException { - public static function create(string $message, ?\Throwable $previous = null): self + public static function create(string $message, \Throwable $previous = null): self { return new self($message, 401, $previous); } diff --git a/tests/Acceptance/DoctrineCredentialsRevokerTest.php b/tests/Acceptance/DoctrineCredentialsRevokerTest.php index 4de2ebf1..e99baab5 100644 --- a/tests/Acceptance/DoctrineCredentialsRevokerTest.php +++ b/tests/Acceptance/DoctrineCredentialsRevokerTest.php @@ -90,7 +90,7 @@ private function buildRefreshToken(string $identifier, string $modify, AccessTok ); } - private function buildAccessToken(string $identifier, string $modify, Client $client, ?string $userIdentifier = null): AccessToken + private function buildAccessToken(string $identifier, string $modify, Client $client, string $userIdentifier = null): AccessToken { return new AccessToken( $identifier, @@ -101,7 +101,7 @@ private function buildAccessToken(string $identifier, string $modify, Client $cl ); } - private function buildAuthCode(string $identifier, string $modify, Client $client, ?string $userIdentifier = null): AuthorizationCode + private function buildAuthCode(string $identifier, string $modify, Client $client, string $userIdentifier = null): AuthorizationCode { return new AuthorizationCode( $identifier, diff --git a/tests/Fixtures/User.php b/tests/Fixtures/User.php index 42e07702..43702bf7 100644 --- a/tests/Fixtures/User.php +++ b/tests/Fixtures/User.php @@ -8,49 +8,31 @@ class User extends \ArrayObject implements UserInterface { - /** - * {@inheritdoc} - */ public function getRoles(): array { return $this['roles'] ?? []; } - /** - * {@inheritdoc} - */ public function getPassword(): ?string { return FixtureFactory::FIXTURE_PASSWORD; } - /** - * {@inheritdoc} - */ public function getSalt(): ?string { return null; } - /** - * {@inheritdoc} - */ public function getUsername(): string { return $this->getUserIdentifier(); } - /** - * {@inheritdoc} - */ public function getUserIdentifier(): string { return FixtureFactory::FIXTURE_USER; } - /** - * {@inheritdoc} - */ public function eraseCredentials() { } diff --git a/tests/Integration/AbstractIntegrationTest.php b/tests/Integration/AbstractIntegrationTest.php index 00d708f3..51acbb05 100644 --- a/tests/Integration/AbstractIntegrationTest.php +++ b/tests/Integration/AbstractIntegrationTest.php @@ -102,9 +102,6 @@ abstract class AbstractIntegrationTest extends TestCase */ private $requireCodeChallengeForPublicClients = true; - /** - * {@inheritdoc} - */ protected function setUp(): void { $this->eventDispatcher = new EventDispatcher(); diff --git a/tests/TestKernel.php b/tests/TestKernel.php index e275f1d7..12abdec2 100644 --- a/tests/TestKernel.php +++ b/tests/TestKernel.php @@ -20,9 +20,6 @@ final class TestKernel extends Kernel implements CompilerPassInterface { - /** - * {@inheritdoc} - */ public function boot() { $this->initializeEnvironmentVariables(); @@ -30,9 +27,6 @@ public function boot() parent::boot(); } - /** - * {@inheritdoc} - */ public function registerBundles(): iterable { return [ @@ -43,33 +37,21 @@ public function registerBundles(): iterable ]; } - /** - * {@inheritdoc} - */ public function getCacheDir(): string { return sprintf('%s/tests/.kernel/cache', $this->getProjectDir()); } - /** - * {@inheritdoc} - */ public function getLogDir(): string { return sprintf('%s/tests/.kernel/logs', $this->getProjectDir()); } - /** - * {@inheritdoc} - */ public function process(ContainerBuilder $container) { $this->exposeManagerServices($container); } - /** - * {@inheritdoc} - */ public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(function (ContainerBuilder $container) {