diff --git a/Command/ClearInvalidRefreshTokensCommand.php b/Command/ClearInvalidRefreshTokensCommand.php index bbfb93ea..7f9a1ad7 100644 --- a/Command/ClearInvalidRefreshTokensCommand.php +++ b/Command/ClearInvalidRefreshTokensCommand.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Command; +use DateTime; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; use Symfony\Component\Console\Attribute\AsCommand; @@ -52,9 +53,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $datetime = $input->getArgument('datetime'); if (null === $datetime) { - $datetime = new \DateTime(); + $datetime = new DateTime(); } else { - $datetime = new \DateTime($datetime); + $datetime = new DateTime($datetime); } $revokedTokens = $this->refreshTokenManager->revokeAllInvalid($datetime); diff --git a/DependencyInjection/GesdinetJWTRefreshTokenExtension.php b/DependencyInjection/GesdinetJWTRefreshTokenExtension.php index df590d07..ba1446e6 100644 --- a/DependencyInjection/GesdinetJWTRefreshTokenExtension.php +++ b/DependencyInjection/GesdinetJWTRefreshTokenExtension.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\DependencyInjection; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Doctrine\ODM\MongoDB\DocumentManager; use Doctrine\ORM\EntityManager; use Gesdinet\JWTRefreshTokenBundle\Document\RefreshToken as RefreshTokenDocument; @@ -19,7 +20,6 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Extension\Extension; -use Symfony\Component\DependencyInjection\Loader; class GesdinetJWTRefreshTokenExtension extends Extension { @@ -27,7 +27,7 @@ public function load(array $configs, ContainerBuilder $container): void { $config = $this->processConfiguration($this->getConfiguration($configs, $container), $configs); - $loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); + $loader = new PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.php'); $container->registerForAutoconfiguration(ExtractorInterface::class)->addTag('gesdinet_jwt_refresh_token.request_extractor'); diff --git a/Doctrine/RefreshTokenManager.php b/Doctrine/RefreshTokenManager.php index 3bffaad6..6e602fdd 100644 --- a/Doctrine/RefreshTokenManager.php +++ b/Doctrine/RefreshTokenManager.php @@ -11,6 +11,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Doctrine; +use LogicException; +use DateTimeInterface; use Doctrine\Persistence\ObjectManager; use Gesdinet\JWTRefreshTokenBundle\Generator\RefreshTokenGeneratorInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; @@ -36,7 +38,7 @@ class RefreshTokenManager implements RefreshTokenManagerInterface /** * @param class-string $class * - * @throws \LogicException if the object repository does not implement `Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenRepositoryInterface` + * @throws LogicException if the object repository does not implement `Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenRepositoryInterface` */ public function __construct(ObjectManager $om, $class) { @@ -45,7 +47,7 @@ public function __construct(ObjectManager $om, $class) $repository = $om->getRepository($class); if (!$repository instanceof RefreshTokenRepositoryInterface) { - throw new \LogicException(sprintf('Repository mapped for "%s" should implement %s.', $class, RefreshTokenRepositoryInterface::class)); + throw new LogicException(sprintf('Repository mapped for "%s" should implement %s.', $class, RefreshTokenRepositoryInterface::class)); } $this->repository = $repository; @@ -119,8 +121,8 @@ public function delete(RefreshTokenInterface $refreshToken, $andFlush = true) } /** - * @param \DateTimeInterface|null $datetime - * @param bool $andFlush + * @param DateTimeInterface|null $datetime + * @param bool $andFlush * * @return RefreshTokenInterface[] */ diff --git a/Doctrine/RefreshTokenRepositoryInterface.php b/Doctrine/RefreshTokenRepositoryInterface.php index 649ba921..8a3819f0 100644 --- a/Doctrine/RefreshTokenRepositoryInterface.php +++ b/Doctrine/RefreshTokenRepositoryInterface.php @@ -2,6 +2,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Doctrine; +use DateTimeInterface; use Doctrine\Persistence\ObjectRepository; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; @@ -13,7 +14,7 @@ interface RefreshTokenRepositoryInterface extends ObjectRepository { /** - * @param \DateTimeInterface|null $datetime + * @param DateTimeInterface|null $datetime * * @return T[] */ diff --git a/Document/RefreshTokenRepository.php b/Document/RefreshTokenRepository.php index 0afcb4f5..c3b3c186 100644 --- a/Document/RefreshTokenRepository.php +++ b/Document/RefreshTokenRepository.php @@ -2,6 +2,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Document; +use DateTimeInterface; +use DateTime; use Doctrine\ODM\MongoDB\Repository\DocumentRepository; use Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenRepositoryInterface; @@ -13,13 +15,13 @@ class RefreshTokenRepository extends DocumentRepository implements RefreshTokenRepositoryInterface { /** - * @param \DateTimeInterface|null $datetime + * @param DateTimeInterface|null $datetime * * @return RefreshToken[] */ public function findInvalid($datetime = null) { - $datetime = (null === $datetime) ? new \DateTime() : $datetime; + $datetime = (null === $datetime) ? new DateTime() : $datetime; $queryBuilder = $this->createQueryBuilder() ->field('valid')->lt($datetime); diff --git a/Entity/RefreshTokenRepository.php b/Entity/RefreshTokenRepository.php index 852405b3..74f8312c 100644 --- a/Entity/RefreshTokenRepository.php +++ b/Entity/RefreshTokenRepository.php @@ -2,6 +2,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Entity; +use DateTimeInterface; +use DateTime; use Doctrine\ORM\EntityRepository; use Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenRepositoryInterface; @@ -13,13 +15,13 @@ class RefreshTokenRepository extends EntityRepository implements RefreshTokenRepositoryInterface { /** - * @param \DateTimeInterface|null $datetime + * @param DateTimeInterface|null $datetime * * @return RefreshToken[] */ public function findInvalid($datetime = null) { - $datetime = (null === $datetime) ? new \DateTime() : $datetime; + $datetime = (null === $datetime) ? new DateTime() : $datetime; return $this->createQueryBuilder('u') ->where('u.valid < :datetime') diff --git a/EventListener/AttachRefreshTokenOnSuccessListener.php b/EventListener/AttachRefreshTokenOnSuccessListener.php index 415022ba..3ba1dd72 100644 --- a/EventListener/AttachRefreshTokenOnSuccessListener.php +++ b/EventListener/AttachRefreshTokenOnSuccessListener.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\EventListener; +use LogicException; use Gesdinet\JWTRefreshTokenBundle\Generator\RefreshTokenGeneratorInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; @@ -102,7 +103,7 @@ public function __construct( $this->returnExpirationParameterName = $returnExpirationParameterName; if ($this->cookieSettings['partitioned'] && Kernel::VERSION < '6.4') { - throw new \LogicException(sprintf('The `partitioned` option for cookies is only available for Symfony 6.4 and above. You are currently on version %s', Kernel::VERSION)); + throw new LogicException(sprintf('The `partitioned` option for cookies is only available for Symfony 6.4 and above. You are currently on version %s', Kernel::VERSION)); } } diff --git a/Http/RefreshAuthenticationFailureResponse.php b/Http/RefreshAuthenticationFailureResponse.php index 58841442..be9913fb 100644 --- a/Http/RefreshAuthenticationFailureResponse.php +++ b/Http/RefreshAuthenticationFailureResponse.php @@ -11,10 +11,11 @@ namespace Gesdinet\JWTRefreshTokenBundle\Http; +use ReflectionMethod; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Response; -if (80000 <= \PHP_VERSION_ID && (new \ReflectionMethod(JsonResponse::class, 'setData'))->hasReturnType()) { +if (80000 <= \PHP_VERSION_ID && (new ReflectionMethod(JsonResponse::class, 'setData'))->hasReturnType()) { eval(' namespace Gesdinet\JWTRefreshTokenBundle\Http; diff --git a/Model/AbstractRefreshToken.php b/Model/AbstractRefreshToken.php index 5cfa3d4d..04cc0413 100644 --- a/Model/AbstractRefreshToken.php +++ b/Model/AbstractRefreshToken.php @@ -11,6 +11,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Model; +use DateTimeInterface; +use DateTime; use Symfony\Component\Security\Core\User\UserInterface; abstract class AbstractRefreshToken implements RefreshTokenInterface @@ -31,7 +33,7 @@ abstract class AbstractRefreshToken implements RefreshTokenInterface protected $username; /** - * @var \DateTimeInterface|null + * @var DateTimeInterface|null */ protected $valid; @@ -40,7 +42,7 @@ abstract class AbstractRefreshToken implements RefreshTokenInterface */ public static function createForUserWithTtl(string $refreshToken, UserInterface $user, int $ttl): RefreshTokenInterface { - $valid = new \DateTime(); + $valid = new DateTime(); // Explicitly check for a negative number based on a behavior change in PHP 8.2, see https://github.com/php/php-src/issues/9950 if ($ttl > 0) { @@ -138,6 +140,6 @@ public function getUsername() */ public function isValid() { - return null !== $this->valid && $this->valid >= new \DateTime(); + return null !== $this->valid && $this->valid >= new DateTime(); } } diff --git a/Model/RefreshTokenInterface.php b/Model/RefreshTokenInterface.php index 0b38c476..50dc850c 100644 --- a/Model/RefreshTokenInterface.php +++ b/Model/RefreshTokenInterface.php @@ -11,9 +11,11 @@ namespace Gesdinet\JWTRefreshTokenBundle\Model; +use Stringable; +use DateTimeInterface; use Symfony\Component\Security\Core\User\UserInterface; -interface RefreshTokenInterface extends \Stringable +interface RefreshTokenInterface extends Stringable { /** * Creates a new model instance based on the provided details. @@ -38,14 +40,14 @@ public function setRefreshToken($refreshToken = null); public function getRefreshToken(); /** - * @param \DateTimeInterface|null $valid + * @param DateTimeInterface|null $valid * * @return $this */ public function setValid($valid); /** - * @return \DateTimeInterface|null + * @return DateTimeInterface|null */ public function getValid(); diff --git a/Model/RefreshTokenManagerInterface.php b/Model/RefreshTokenManagerInterface.php index 89cfdcb6..4e1f0e91 100644 --- a/Model/RefreshTokenManagerInterface.php +++ b/Model/RefreshTokenManagerInterface.php @@ -11,6 +11,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Model; +use DateTimeInterface; + /** * Interface to be implemented by user managers. This adds an additional level * of abstraction between your application, and the actual repository. @@ -53,7 +55,7 @@ public function save(RefreshTokenInterface $refreshToken); public function delete(RefreshTokenInterface $refreshToken); /** - * @param \DateTimeInterface|null $datetime + * @param DateTimeInterface|null $datetime * * @return RefreshTokenInterface[] */ diff --git a/Security/Authenticator/RefreshTokenAuthenticator.php b/Security/Authenticator/RefreshTokenAuthenticator.php index fa9e128e..8cae6a57 100644 --- a/Security/Authenticator/RefreshTokenAuthenticator.php +++ b/Security/Authenticator/RefreshTokenAuthenticator.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Security\Authenticator; +use InvalidArgumentException; use Gesdinet\JWTRefreshTokenBundle\Request\Extractor\ExtractorInterface; use Gesdinet\JWTRefreshTokenBundle\Exception\UnknownRefreshTokenException; use Gesdinet\JWTRefreshTokenBundle\Exception\UnknownUserFromRefreshTokenException; @@ -83,7 +84,7 @@ public function getCredentials(Request $request) public function getUser($credentials, UserProviderInterface $userProvider) { if (!$userProvider instanceof RefreshTokenProvider) { - throw new \InvalidArgumentException(sprintf('The user provider must be an instance of RefreshTokenProvider (%s was given).', get_class($userProvider))); + throw new InvalidArgumentException(sprintf('The user provider must be an instance of RefreshTokenProvider (%s was given).', get_class($userProvider))); } $refreshToken = $credentials['token'] ?? null; diff --git a/Security/Http/Authenticator/RefreshTokenAuthenticator.php b/Security/Http/Authenticator/RefreshTokenAuthenticator.php index 6102ff71..a8ed10ec 100644 --- a/Security/Http/Authenticator/RefreshTokenAuthenticator.php +++ b/Security/Http/Authenticator/RefreshTokenAuthenticator.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Security\Http\Authenticator; +use DateTime; use Gesdinet\JWTRefreshTokenBundle\Event\RefreshTokenNotFoundEvent; use Gesdinet\JWTRefreshTokenBundle\Http\RefreshAuthenticationFailureResponse; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; @@ -115,7 +116,7 @@ public function authenticate(Request $request): Passport } if ($this->options['ttl_update']) { - $expirationDate = new \DateTime(); + $expirationDate = new DateTime(); // Explicitly check for a negative number based on a behavior change in PHP 8.2, see https://github.com/php/php-src/issues/9950 if ($this->options['ttl'] > 0) { diff --git a/Security/Provider/RefreshTokenProvider.php b/Security/Provider/RefreshTokenProvider.php index f6a1d106..bfe2bc2c 100644 --- a/Security/Provider/RefreshTokenProvider.php +++ b/Security/Provider/RefreshTokenProvider.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Security\Provider; +use ReflectionClass; use Symfony\Component\Security\Core\User\InMemoryUser; use Symfony\Component\Security\Core\User\UserProviderInterface; use Symfony\Component\Security\Core\User\User; @@ -21,7 +22,7 @@ trigger_deprecation('gesdinet/jwt-refresh-token-bundle', '1.0', 'The "%s" class is deprecated, configure the user provider for the `refresh_jwt` authenticator instead.', RefreshTokenProvider::class); -if ((new \ReflectionClass(UserProviderInterface::class))->getMethod('supportsClass')->hasReturnType()) { +if ((new ReflectionClass(UserProviderInterface::class))->getMethod('supportsClass')->hasReturnType()) { /** * Compatibility layer for Symfony 7.0 and later, where {@see UserProviderInterface::supportsClass()} has a return type. * diff --git a/Service/RefreshToken.php b/Service/RefreshToken.php index b6b5d974..6ad5549a 100644 --- a/Service/RefreshToken.php +++ b/Service/RefreshToken.php @@ -11,6 +11,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Service; +use DateTime; use Gesdinet\JWTRefreshTokenBundle\Event\RefreshEvent; use Gesdinet\JWTRefreshTokenBundle\Security\Authenticator\RefreshTokenAuthenticator; use Gesdinet\JWTRefreshTokenBundle\Exception\InvalidRefreshTokenException; @@ -106,7 +107,7 @@ public function refresh(Request $request) } if ($this->ttlUpdate) { - $expirationDate = new \DateTime(); + $expirationDate = new DateTime(); $expirationDate->modify(sprintf('+%d seconds', $this->ttl)); $refreshToken->setValid($expirationDate); diff --git a/Tests/Functional/Command/ClearInvalidRefreshTokensCommandTest.php b/Tests/Functional/Command/ClearInvalidRefreshTokensCommandTest.php index 8d0df405..90ee637b 100644 --- a/Tests/Functional/Command/ClearInvalidRefreshTokensCommandTest.php +++ b/Tests/Functional/Command/ClearInvalidRefreshTokensCommandTest.php @@ -2,6 +2,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Functional\Command; +use DateTimeInterface; use Gesdinet\JWTRefreshTokenBundle\Command\ClearInvalidRefreshTokensCommand; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; @@ -23,7 +24,7 @@ public function test_clears_tokens_without_timestamp(): void $refreshTokenManager = $this->createMock(RefreshTokenManagerInterface::class); $refreshTokenManager->expects($this->once()) ->method('revokeAllInvalid') - ->with($this->isInstanceOf(\DateTimeInterface::class)) + ->with($this->isInstanceOf(DateTimeInterface::class)) ->willReturn([$refreshToken]); $command = new ClearInvalidRefreshTokensCommand($refreshTokenManager); @@ -51,7 +52,7 @@ public function test_clears_tokens_with_timestamp(): void $refreshTokenManager = $this->createMock(RefreshTokenManagerInterface::class); $refreshTokenManager->expects($this->once()) ->method('revokeAllInvalid') - ->with($this->isInstanceOf(\DateTimeInterface::class)) + ->with($this->isInstanceOf(DateTimeInterface::class)) ->willReturn([$refreshToken]); $command = new ClearInvalidRefreshTokensCommand($refreshTokenManager); diff --git a/Tests/Functional/Document/RefreshTokenRepositoryTest.php b/Tests/Functional/Document/RefreshTokenRepositoryTest.php index a9e9cc0b..f307c2fa 100644 --- a/Tests/Functional/Document/RefreshTokenRepositoryTest.php +++ b/Tests/Functional/Document/RefreshTokenRepositoryTest.php @@ -2,6 +2,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Functional\Document; +use DateTime; use Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenManager; use Gesdinet\JWTRefreshTokenBundle\Document\RefreshTokenRepository; use Gesdinet\JWTRefreshTokenBundle\Generator\RefreshTokenGenerator; @@ -93,7 +94,7 @@ public function test_retrieves_all_tokens_older_than_the_specified_time(): void /** @var RefreshTokenRepository $repo */ $repo = $this->documentManager->getRepository(RefreshToken::class); - $time = new \DateTime(); + $time = new DateTime(); $time->modify('+1200 seconds'); $this->assertCount(5, $repo->findInvalid($time)); diff --git a/Tests/Functional/Entity/RefreshTokenRepositoryTest.php b/Tests/Functional/Entity/RefreshTokenRepositoryTest.php index 2262f35a..b56a4c26 100644 --- a/Tests/Functional/Entity/RefreshTokenRepositoryTest.php +++ b/Tests/Functional/Entity/RefreshTokenRepositoryTest.php @@ -2,6 +2,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Functional\Entity; +use DateTime; use Doctrine\ORM\Tools\SchemaTool; use Gesdinet\JWTRefreshTokenBundle\Doctrine\RefreshTokenManager; use Gesdinet\JWTRefreshTokenBundle\Entity\RefreshTokenRepository; @@ -89,7 +90,7 @@ public function test_retrieves_all_tokens_older_than_the_specified_time(): void /** @var RefreshTokenRepository $repo */ $repo = $this->entityManager->getRepository(RefreshToken::class); - $time = new \DateTime(); + $time = new DateTime(); $time->modify('+1200 seconds'); $this->assertCount(5, $repo->findInvalid($time)); diff --git a/Tests/Unit/AbstractRefreshTokenTest.php b/Tests/Unit/AbstractRefreshTokenTest.php index aaf8076b..4bc7cac4 100644 --- a/Tests/Unit/AbstractRefreshTokenTest.php +++ b/Tests/Unit/AbstractRefreshTokenTest.php @@ -2,6 +2,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Unit; +use DateTimeInterface; +use DateTime; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; use Gesdinet\JWTRefreshTokenBundle\Tests\Services\UserCreator; use PHPUnit\Framework\TestCase; @@ -51,12 +53,12 @@ public function testHasUsername() public function testHasAValidTimestamp() { - $this->assertInstanceOf(\DateTimeInterface::class, $this->refreshToken->getValid()); + $this->assertInstanceOf(DateTimeInterface::class, $this->refreshToken->getValid()); } public function testValid() { - $date = new \DateTime(); + $date = new DateTime(); $date->modify('+1 day'); $this->refreshToken->setValid($date); $this->assertTrue($this->refreshToken->isValid()); @@ -64,7 +66,7 @@ public function testValid() public function testNotValid() { - $date = new \DateTime(); + $date = new DateTime(); $date->modify('-1 day'); $this->refreshToken->setValid($date); $this->assertFalse($this->refreshToken->isValid()); diff --git a/Tests/Unit/EventListener/AttachRefreshTokenOnSuccessListenerTest.php b/Tests/Unit/EventListener/AttachRefreshTokenOnSuccessListenerTest.php index 7b8e898d..4f3048b5 100644 --- a/Tests/Unit/EventListener/AttachRefreshTokenOnSuccessListenerTest.php +++ b/Tests/Unit/EventListener/AttachRefreshTokenOnSuccessListenerTest.php @@ -2,6 +2,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Unit\EventListener; +use ReflectionClass; use Gesdinet\JWTRefreshTokenBundle\EventListener\AttachRefreshTokenOnSuccessListener; use Gesdinet\JWTRefreshTokenBundle\Generator\RefreshTokenGeneratorInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; @@ -298,7 +299,7 @@ public function testAttachesTheTokenToTheResponseBodyOnCredentialsAuth() public function testDoesNothingWhenThereIsNotAUser() { - if ((new \ReflectionClass(AuthenticationSuccessEvent::class))->getMethod('getUser')->hasReturnType()) { + if ((new ReflectionClass(AuthenticationSuccessEvent::class))->getMethod('getUser')->hasReturnType()) { $this->markTestSkipped(sprintf('%s::getUser() has a non-nullable return type in LexikJWTAuthenticationBundle 3.x', AuthenticationSuccessEvent::class)); } @@ -315,7 +316,7 @@ public function testDoesNothingWhenThereIsNotAUser() private function setSingleUseOnEventListener(bool $singleUse): void { - $reflector = new \ReflectionClass(AttachRefreshTokenOnSuccessListener::class); + $reflector = new ReflectionClass(AttachRefreshTokenOnSuccessListener::class); $property = $reflector->getProperty('singleUse'); $property->setAccessible(true); $property->setValue($this->attachRefreshTokenOnSuccessListener, $singleUse); diff --git a/Tests/Unit/Security/Http/Authenticator/RefreshTokenAuthenticatorTest.php b/Tests/Unit/Security/Http/Authenticator/RefreshTokenAuthenticatorTest.php index 2939f370..574237df 100644 --- a/Tests/Unit/Security/Http/Authenticator/RefreshTokenAuthenticatorTest.php +++ b/Tests/Unit/Security/Http/Authenticator/RefreshTokenAuthenticatorTest.php @@ -2,6 +2,8 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Unit\Security\Http\Authenticator; +use DateTimeInterface; +use ReflectionClass; use Gesdinet\JWTRefreshTokenBundle\Http\RefreshAuthenticationFailureResponse; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; @@ -190,7 +192,7 @@ public function testAuthenticatesTheRequestWhenTtlUpdateIsEnabled(): void $refreshToken ->expects($this->atLeastOnce()) ->method('setValid') - ->with($this->isInstanceOf(\DateTimeInterface::class)); + ->with($this->isInstanceOf(DateTimeInterface::class)); $this->refreshTokenManager ->expects($this->atLeastOnce()) @@ -408,7 +410,7 @@ private function createRefreshTokenGetUsernameExpectation(MockObject $refreshTok private function appendOptionsOnRefreshTokenAuthenticator(array $options): void { - $reflector = new \ReflectionClass(RefreshTokenAuthenticator::class); + $reflector = new ReflectionClass(RefreshTokenAuthenticator::class); $property = $reflector->getProperty('options'); $property->setAccessible(true); diff --git a/Tests/Unit/Service/RefreshTokenTest.php b/Tests/Unit/Service/RefreshTokenTest.php index ebf8dabd..6915acd0 100644 --- a/Tests/Unit/Service/RefreshTokenTest.php +++ b/Tests/Unit/Service/RefreshTokenTest.php @@ -2,6 +2,7 @@ namespace Gesdinet\JWTRefreshTokenBundle\Tests\Unit\Service; +use ReflectionClass; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenInterface; use Gesdinet\JWTRefreshTokenBundle\Model\RefreshTokenManagerInterface; use Gesdinet\JWTRefreshTokenBundle\Security\Authenticator\RefreshTokenAuthenticator; @@ -131,7 +132,7 @@ public function testItThrowsAnAuthenticationException() private function setTtlUpdateOnRefreshToken(bool $ttlUpdate): void { - $reflector = new \ReflectionClass(RefreshToken::class); + $reflector = new ReflectionClass(RefreshToken::class); $property = $reflector->getProperty('ttlUpdate'); $property->setAccessible(true); $property->setValue($this->refreshToken, $ttlUpdate);