From aaa0e81751ae52d9b573b4cc9ec11f2c904158b5 Mon Sep 17 00:00:00 2001 From: yivi Date: Tue, 19 Dec 2023 09:07:17 +0000 Subject: [PATCH] Apply Code Style Fixes --- src/Console/PurgeExpiredTokensCommand.php | 1 - src/DependencyInjection/YivoffJwtRefreshExtension.php | 1 + src/Event/JwtRefreshTokenFailed.php | 4 +--- src/Event/JwtRefreshTokenSucceeded.php | 4 +--- src/EventListener/AttachRefreshToken.php | 3 +-- src/Model/RefreshToken.php | 4 +--- src/Security/Authenticator.php | 4 ++-- src/Shared/Hasher.php | 5 ++--- src/Shared/TokenIdGenerator.php | 1 + tests/DependencyInjection/BundleInitializationTest.php | 1 + tests/Resource/Autowired.php | 3 +-- tests/Resource/InMemoryRefreshTokenProvider.php | 1 + tests/Unit/AttachRefreshTokenTest.php | 1 + tests/Unit/EventDispatcherSpy.php | 1 + tests/Unit/MockerTrait.php | 5 ++--- tests/Unit/TokenIdGeneratorTest.php | 1 + 16 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/Console/PurgeExpiredTokensCommand.php b/src/Console/PurgeExpiredTokensCommand.php index cf73320..8758d32 100644 --- a/src/Console/PurgeExpiredTokensCommand.php +++ b/src/Console/PurgeExpiredTokensCommand.php @@ -12,7 +12,6 @@ use Yivoff\JwtRefreshBundle\Contracts\PurgableRefreshTokenProviderInterface; use Yivoff\JwtRefreshBundle\Contracts\RefreshTokenProviderInterface; - #[AsCommand('yivoff:jwt_refresh:purge_expired_tokens')] class PurgeExpiredTokensCommand extends Command { diff --git a/src/DependencyInjection/YivoffJwtRefreshExtension.php b/src/DependencyInjection/YivoffJwtRefreshExtension.php index 41fcfae..738080b 100644 --- a/src/DependencyInjection/YivoffJwtRefreshExtension.php +++ b/src/DependencyInjection/YivoffJwtRefreshExtension.php @@ -17,6 +17,7 @@ use Yivoff\JwtRefreshBundle\Shared\Hasher; use Yivoff\JwtRefreshBundle\Shared\TokenIdGenerator; use Yivoff\JwtRefreshBundle\YivoffJwtRefreshBundle; + use function class_exists; /** diff --git a/src/Event/JwtRefreshTokenFailed.php b/src/Event/JwtRefreshTokenFailed.php index 3ae9257..1ed4f04 100644 --- a/src/Event/JwtRefreshTokenFailed.php +++ b/src/Event/JwtRefreshTokenFailed.php @@ -8,7 +8,5 @@ class JwtRefreshTokenFailed { - public function __construct(public readonly FailType $failType, public readonly ?string $tokenId, public readonly ?string $userIdentifier) - { - } + public function __construct(public readonly FailType $failType, public readonly ?string $tokenId, public readonly ?string $userIdentifier) {} } diff --git a/src/Event/JwtRefreshTokenSucceeded.php b/src/Event/JwtRefreshTokenSucceeded.php index d053398..6488001 100644 --- a/src/Event/JwtRefreshTokenSucceeded.php +++ b/src/Event/JwtRefreshTokenSucceeded.php @@ -6,7 +6,5 @@ class JwtRefreshTokenSucceeded { - public function __construct(public readonly string $tokenId, public readonly string $userIdentifier) - { - } + public function __construct(public readonly string $tokenId, public readonly string $userIdentifier) {} } diff --git a/src/EventListener/AttachRefreshToken.php b/src/EventListener/AttachRefreshToken.php index 2504d17..71d2aa7 100644 --- a/src/EventListener/AttachRefreshToken.php +++ b/src/EventListener/AttachRefreshToken.php @@ -21,8 +21,7 @@ public function __construct( private string $parameterName, private int $tokenShelfLife, private RefreshTokenProviderInterface $refreshTokenProvider - ) { - } + ) {} public function __invoke(AuthenticationSuccessEvent $event): void { diff --git a/src/Model/RefreshToken.php b/src/Model/RefreshToken.php index c74345e..6ff52ec 100644 --- a/src/Model/RefreshToken.php +++ b/src/Model/RefreshToken.php @@ -12,9 +12,7 @@ */ class RefreshToken implements RefreshTokenInterface { - public function __construct(private string $username, private string $identifier, private string $verifier, private DateTimeImmutable $validUntil) - { - } + public function __construct(private string $username, private string $identifier, private string $verifier, private DateTimeImmutable $validUntil) {} public function getUsername(): string { diff --git a/src/Security/Authenticator.php b/src/Security/Authenticator.php index f6dba52..80698ad 100644 --- a/src/Security/Authenticator.php +++ b/src/Security/Authenticator.php @@ -23,6 +23,7 @@ use Yivoff\JwtRefreshBundle\Exception\TokenExpiredException; use Yivoff\JwtRefreshBundle\Exception\TokenInvalidException; use Yivoff\JwtRefreshBundle\Exception\TokenNotFoundException; + use function explode; use function str_contains; use function time; @@ -35,8 +36,7 @@ public function __construct( private RefreshTokenProviderInterface $tokenProvider, private EventDispatcherInterface $eventDispatcher, private string $parameterName - ) { - } + ) {} public function authenticate(HttpFoundation\Request $request): Passport { diff --git a/src/Shared/Hasher.php b/src/Shared/Hasher.php index c366da7..7c2ab8c 100644 --- a/src/Shared/Hasher.php +++ b/src/Shared/Hasher.php @@ -5,6 +5,7 @@ namespace Yivoff\JwtRefreshBundle\Shared; use Yivoff\JwtRefreshBundle\Contracts\HasherInterface; + use function hash_equals; use function hash_hmac; @@ -13,9 +14,7 @@ */ final class Hasher implements HasherInterface { - public function __construct(private string $hash_key) - { - } + public function __construct(private string $hash_key) {} public function verify(string $token, string $hash): bool { diff --git a/src/Shared/TokenIdGenerator.php b/src/Shared/TokenIdGenerator.php index 8d71782..588613b 100644 --- a/src/Shared/TokenIdGenerator.php +++ b/src/Shared/TokenIdGenerator.php @@ -5,6 +5,7 @@ namespace Yivoff\JwtRefreshBundle\Shared; use Yivoff\JwtRefreshBundle\Contracts\TokenIdGeneratorInterface; + use function str_repeat; use function str_shuffle; use function substr; diff --git a/tests/DependencyInjection/BundleInitializationTest.php b/tests/DependencyInjection/BundleInitializationTest.php index 28e59c6..906e2c8 100644 --- a/tests/DependencyInjection/BundleInitializationTest.php +++ b/tests/DependencyInjection/BundleInitializationTest.php @@ -16,6 +16,7 @@ /** * @internal + * * @coversNothing */ class BundleInitializationTest extends KernelTestCase diff --git a/tests/Resource/Autowired.php b/tests/Resource/Autowired.php index ff8d3e1..48d0037 100644 --- a/tests/Resource/Autowired.php +++ b/tests/Resource/Autowired.php @@ -16,8 +16,7 @@ public function __construct( private TokenIdGeneratorInterface $generator, private Authenticator $authenticator, private AttachRefreshToken $eventListener - ) { - } + ) {} public function getEncoder(): HasherInterface { diff --git a/tests/Resource/InMemoryRefreshTokenProvider.php b/tests/Resource/InMemoryRefreshTokenProvider.php index aaf162e..cdbe876 100644 --- a/tests/Resource/InMemoryRefreshTokenProvider.php +++ b/tests/Resource/InMemoryRefreshTokenProvider.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use Yivoff\JwtRefreshBundle\Contracts\RefreshTokenInterface; use Yivoff\JwtRefreshBundle\Contracts\RefreshTokenProviderInterface; + use function array_key_exists; class InMemoryRefreshTokenProvider implements RefreshTokenProviderInterface diff --git a/tests/Unit/AttachRefreshTokenTest.php b/tests/Unit/AttachRefreshTokenTest.php index 03e5ccf..71479fa 100644 --- a/tests/Unit/AttachRefreshTokenTest.php +++ b/tests/Unit/AttachRefreshTokenTest.php @@ -12,6 +12,7 @@ use Yivoff\JwtRefreshBundle\Contracts\RefreshTokenInterface; use Yivoff\JwtRefreshBundle\EventListener\AttachRefreshToken; use Yivoff\JwtRefreshBundle\Test\Resource\InMemoryRefreshTokenProvider; + use function explode; /** diff --git a/tests/Unit/EventDispatcherSpy.php b/tests/Unit/EventDispatcherSpy.php index 235d05c..87bce7b 100644 --- a/tests/Unit/EventDispatcherSpy.php +++ b/tests/Unit/EventDispatcherSpy.php @@ -6,6 +6,7 @@ use InvalidArgumentException; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; + use function array_key_exists; class EventDispatcherSpy implements EventDispatcherInterface diff --git a/tests/Unit/MockerTrait.php b/tests/Unit/MockerTrait.php index 30c4a8b..a371e15 100644 --- a/tests/Unit/MockerTrait.php +++ b/tests/Unit/MockerTrait.php @@ -6,6 +6,7 @@ use Yivoff\JwtRefreshBundle\Contracts\HasherInterface; use Yivoff\JwtRefreshBundle\Contracts\TokenIdGeneratorInterface; + use function random_int; use function str_repeat; @@ -14,9 +15,7 @@ trait MockerTrait private function createHasher(bool $success = true): HasherInterface { return new class($success) implements HasherInterface { - public function __construct(private bool $success) - { - } + public function __construct(private bool $success) {} public function hash(string $token): string { diff --git a/tests/Unit/TokenIdGeneratorTest.php b/tests/Unit/TokenIdGeneratorTest.php index 1a25c48..0bc0d78 100644 --- a/tests/Unit/TokenIdGeneratorTest.php +++ b/tests/Unit/TokenIdGeneratorTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase; use Yivoff\JwtRefreshBundle\Shared\TokenIdGenerator; + use function strlen; /**