From c06922c689571b27760836d3a538a37da2b3b862 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 17 Sep 2022 23:53:33 +0700 Subject: [PATCH] Apply PHP 7.4 syntax and typed property Signed-off-by: Abdul Malik Ikhsan --- psalm-baseline.xml | 8 +++-- src/AuthorizationHandler.php | 10 ++---- src/AuthorizationMiddleware.php | 4 +-- src/OAuth2Adapter.php | 13 ++----- src/Repository/Pdo/AbstractRepository.php | 4 +-- src/TokenEndpointHandler.php | 4 +-- test/AuthorizationHandlerFactoryTest.php | 10 ++---- test/AuthorizationHandlerTest.php | 8 ++--- test/AuthorizationMiddlewareFactoryTest.php | 6 ++-- test/AuthorizationMiddlewareTest.php | 4 +-- test/AuthorizationServerFactoryTest.php | 2 +- test/Entity/UserEntityTest.php | 3 +- test/InMemoryContainer.php | 2 +- test/OAuth2AdapterFactoryTest.php | 12 ++----- test/OAuth2AdapterTest.php | 13 ++----- test/Pdo/OAuth2PdoMiddlewareTest.php | 34 ++++++------------- test/Psr17ResponseFactoryTraitTest.php | 16 +++------ .../Pdo/AccessTokenRepositoryFactoryTest.php | 4 +-- .../Pdo/AccessTokenRepositoryTest.php | 3 +- .../Pdo/AuthCodeRepositoryFactoryTest.php | 4 +-- .../Pdo/ClientRepositoryFactoryTest.php | 4 +-- test/Repository/Pdo/ClientRepositoryTest.php | 12 +++---- .../Pdo/RefreshTokenRepositoryFactoryTest.php | 4 +-- .../Pdo/ScopeRepositoryFactoryTest.php | 4 +-- test/Repository/Pdo/UserRepositoryTest.php | 4 +-- test/TokenEndpointHandlerFactoryTest.php | 5 ++- 26 files changed, 68 insertions(+), 129 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fdf1ea6c..778cbea6 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -848,8 +848,7 @@ - function ( - function () { + fn() testConstructor @@ -892,6 +891,11 @@ reveal reveal + + $identity + $roles + $details + diff --git a/src/AuthorizationHandler.php b/src/AuthorizationHandler.php index e96bda0e..3bdc6a41 100644 --- a/src/AuthorizationHandler.php +++ b/src/AuthorizationHandler.php @@ -25,11 +25,9 @@ */ class AuthorizationHandler implements RequestHandlerInterface { - /** @var AuthorizationServer */ - private $server; + private AuthorizationServer $server; - /** @var ResponseFactoryInterface */ - private $responseFactory; + private ResponseFactoryInterface $responseFactory; /** * @param (callable():ResponseInterface)|ResponseFactoryInterface $responseFactory @@ -39,9 +37,7 @@ public function __construct(AuthorizationServer $server, $responseFactory) $this->server = $server; if (is_callable($responseFactory)) { $responseFactory = new CallableResponseFactoryDecorator( - static function () use ($responseFactory): ResponseInterface { - return $responseFactory(); - } + static fn(): ResponseInterface => $responseFactory() ); } diff --git a/src/AuthorizationMiddleware.php b/src/AuthorizationMiddleware.php index 2b7c8b0b..a2e82dbd 100644 --- a/src/AuthorizationMiddleware.php +++ b/src/AuthorizationMiddleware.php @@ -47,9 +47,7 @@ public function __construct(AuthorizationServer $server, $responseFactory) $this->server = $server; if (is_callable($responseFactory)) { $responseFactory = new CallableResponseFactoryDecorator( - static function () use ($responseFactory): ResponseInterface { - return $responseFactory(); - } + static fn(): ResponseInterface => $responseFactory() ); } diff --git a/src/OAuth2Adapter.php b/src/OAuth2Adapter.php index 2341d9c8..a0dcb439 100644 --- a/src/OAuth2Adapter.php +++ b/src/OAuth2Adapter.php @@ -38,20 +38,13 @@ public function __construct( if (is_callable($responseFactory)) { $responseFactory = new CallableResponseFactoryDecorator( - static function () use ($responseFactory): ResponseInterface { - return $responseFactory(); - } + static fn(): ResponseInterface => $responseFactory() ); } $this->responseFactory = $responseFactory; - $this->userFactory = function ( - string $identity, - array $roles = [], - array $details = [] - ) use ($userFactory): UserInterface { - return $userFactory($identity, $roles, $details); - }; + $this->userFactory = static fn(string $identity, array $roles = [], array $details = []): UserInterface + => $userFactory($identity, $roles, $details); } /** diff --git a/src/Repository/Pdo/AbstractRepository.php b/src/Repository/Pdo/AbstractRepository.php index 75743c78..b4999597 100644 --- a/src/Repository/Pdo/AbstractRepository.php +++ b/src/Repository/Pdo/AbstractRepository.php @@ -35,8 +35,6 @@ protected function scopesToString(array $scopes): string return ''; } - return trim(array_reduce($scopes, function ($result, $item) { - return $result . ' ' . $item->getIdentifier(); - })); + return trim(array_reduce($scopes, static fn($result, $item): string => $result . ' ' . $item->getIdentifier())); } } diff --git a/src/TokenEndpointHandler.php b/src/TokenEndpointHandler.php index 9bc73eb5..beffc5f0 100644 --- a/src/TokenEndpointHandler.php +++ b/src/TokenEndpointHandler.php @@ -40,9 +40,7 @@ public function __construct(AuthorizationServer $server, $responseFactory) $this->server = $server; if (is_callable($responseFactory)) { $responseFactory = new CallableResponseFactoryDecorator( - static function () use ($responseFactory): ResponseInterface { - return $responseFactory(); - } + static fn(): ResponseInterface => $responseFactory() ); } $this->responseFactory = $responseFactory; diff --git a/test/AuthorizationHandlerFactoryTest.php b/test/AuthorizationHandlerFactoryTest.php index 607d31a6..0307b043 100644 --- a/test/AuthorizationHandlerFactoryTest.php +++ b/test/AuthorizationHandlerFactoryTest.php @@ -58,7 +58,7 @@ public function testRaisesTypeErrorForInvalidAuthorizationServer() ->willReturn(new stdClass()); $this->container ->get(ResponseInterface::class) - ->willReturn(function () { + ->willReturn(static function (): void { }); $factory = new AuthorizationHandlerFactory(); @@ -104,9 +104,7 @@ public function testFactoryReturnsInstanceWhenAppropriateDependenciesArePresentI ->willReturn($this->authServer->reveal()); $this->container ->get(ResponseInterface::class) - ->willReturn(function () { - return $this->response; - })->shouldBeCalled(); + ->willReturn(fn(): MockObject => $this->response)->shouldBeCalled(); $factory = new AuthorizationHandlerFactory(); $factory($this->container->reveal()); @@ -115,9 +113,7 @@ public function testFactoryReturnsInstanceWhenAppropriateDependenciesArePresentI public function testConfigProvider() { $authServer = $this->prophesize(AuthorizationServer::class)->reveal(); - $responseFactory = function () { - return $this->prophesize(ResponseInterface::class)->reveal(); - }; + $responseFactory = fn(): object => $this->prophesize(ResponseInterface::class)->reveal(); $container = new ServiceManager((new ConfigProvider())->getDependencies()); $container->setService(AuthorizationServer::class, $authServer); diff --git a/test/AuthorizationHandlerTest.php b/test/AuthorizationHandlerTest.php index 70970763..33c9eb93 100644 --- a/test/AuthorizationHandlerTest.php +++ b/test/AuthorizationHandlerTest.php @@ -39,9 +39,7 @@ public function testHandleUsesAuthorizationServerService(): void ->shouldBeCalled() ->willReturn($expectedResponse); - $subject = new AuthorizationHandler($server->reveal(), function () use ($expectedResponse): ResponseInterface { - return $expectedResponse; - }); + $subject = new AuthorizationHandler($server->reveal(), static fn(): ResponseInterface => $expectedResponse); self::assertSame($expectedResponse, $subject->handle($request->reveal())); } @@ -58,9 +56,7 @@ public function testInvalidResponseFactoryThrowsTypeError() $server->completeAuthorizationRequest(Argument::any()) ->shouldNotBeCalled(); - $subject = new AuthorizationHandler($server->reveal(), function () { - return new stdClass(); - }); + $subject = new AuthorizationHandler($server->reveal(), static fn(): stdClass => new stdClass()); $this->expectException(TypeError::class); $subject->handle($request->reveal()); diff --git a/test/AuthorizationMiddlewareFactoryTest.php b/test/AuthorizationMiddlewareFactoryTest.php index eb7af43e..7c7240d6 100644 --- a/test/AuthorizationMiddlewareFactoryTest.php +++ b/test/AuthorizationMiddlewareFactoryTest.php @@ -55,7 +55,7 @@ public function testRaisesTypeErrorForInvalidAuthorizationServer() ->willReturn(new stdClass()); $this->container ->get(ResponseInterface::class) - ->willReturn(function () { + ->willReturn(static function (): void { }); $factory = new AuthorizationMiddlewareFactory(); @@ -101,9 +101,7 @@ public function testFactoryReturnsInstanceWhenAppropriateDependenciesArePresentI ->willReturn($this->authServer->reveal()); $this->container ->get(ResponseInterface::class) - ->willReturn(function () { - return $this->response; - }) + ->willReturn(fn(): MockObject => $this->response) ->shouldBeCalled(); $factory = new AuthorizationMiddlewareFactory(); diff --git a/test/AuthorizationMiddlewareTest.php b/test/AuthorizationMiddlewareTest.php index e7b1f740..25421cd0 100644 --- a/test/AuthorizationMiddlewareTest.php +++ b/test/AuthorizationMiddlewareTest.php @@ -49,9 +49,7 @@ protected function setUp(): void $this->serverRequest = $this->prophesize(ServerRequestInterface::class); $this->authRequest = $this->prophesize(AuthorizationRequest::class); $this->handler = $this->prophesize(RequestHandlerInterface::class); - $this->responseFactory = function () { - return $this->response; - }; + $this->responseFactory = fn(): MockObject => $this->response; } public function testConstructor() diff --git a/test/AuthorizationServerFactoryTest.php b/test/AuthorizationServerFactoryTest.php index 0502528c..47beac93 100644 --- a/test/AuthorizationServerFactoryTest.php +++ b/test/AuthorizationServerFactoryTest.php @@ -128,7 +128,7 @@ public function testInvokeWithListenerConfig() 'event_listeners' => [ [ RequestEvent::CLIENT_AUTHENTICATION_FAILED, - function (RequestEvent $event) { + static function (RequestEvent $event): void { // do something }, ], diff --git a/test/Entity/UserEntityTest.php b/test/Entity/UserEntityTest.php index c89186a1..53dc81d4 100644 --- a/test/Entity/UserEntityTest.php +++ b/test/Entity/UserEntityTest.php @@ -11,8 +11,7 @@ class UserEntityTest extends TestCase { - /** @var UserEntity */ - private $entity; + private UserEntity $entity; protected function setUp(): void { diff --git a/test/InMemoryContainer.php b/test/InMemoryContainer.php index e5962ac0..a3a4e834 100644 --- a/test/InMemoryContainer.php +++ b/test/InMemoryContainer.php @@ -13,7 +13,7 @@ final class InMemoryContainer implements ContainerInterface { /** @var array */ - private $services = []; + private array $services = []; /** * @param string $id diff --git a/test/OAuth2AdapterFactoryTest.php b/test/OAuth2AdapterFactoryTest.php index 332146b2..280c3345 100644 --- a/test/OAuth2AdapterFactoryTest.php +++ b/test/OAuth2AdapterFactoryTest.php @@ -52,17 +52,9 @@ protected function setUp(): void $this->resourceServer = $this->prophesize(ResourceServer::class); $this->response = $this->createMock(ResponseInterface::class); - $this->responseFactory = function () { - return $this->response; - }; + $this->responseFactory = fn(): MockObject => $this->response; $this->user = $this->prophesize(UserInterface::class); - $this->userFactory = function ( - string $identity, - array $roles = [], - array $details = [] - ) { - return $this->user->reveal($identity, $roles, $details); - }; + $this->userFactory = fn(string $identity, array $roles = [], array $details = []) => $this->user->reveal(); } public function testConstructor() diff --git a/test/OAuth2AdapterTest.php b/test/OAuth2AdapterTest.php index da218739..bc468250 100644 --- a/test/OAuth2AdapterTest.php +++ b/test/OAuth2AdapterTest.php @@ -38,16 +38,9 @@ protected function setUp(): void { $this->resourceServer = $this->prophesize(ResourceServer::class); $this->response = $this->createMock(ResponseInterface::class); - $this->responseFactory = function (): ResponseInterface { - return $this->response; - }; - $this->userFactory = function ( - string $identity, - array $roles = [], - array $details = [] - ) { - return new DefaultUser($identity, $roles, $details); - }; + $this->responseFactory = fn(): ResponseInterface => $this->response; + $this->userFactory = static fn(string $identity, array $roles = [], array $details = []): DefaultUser + => new DefaultUser($identity, $roles, $details); } public function testConstructor() diff --git a/test/Pdo/OAuth2PdoMiddlewareTest.php b/test/Pdo/OAuth2PdoMiddlewareTest.php index d842e8d9..590fd8a7 100644 --- a/test/Pdo/OAuth2PdoMiddlewareTest.php +++ b/test/Pdo/OAuth2PdoMiddlewareTest.php @@ -70,38 +70,29 @@ class OAuth2PdoMiddlewareTest extends TestCase private const CODE_VERIFIER = 'dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk'; - /** @var AccessTokenRepository */ - private $accessTokenRepository; + private AccessTokenRepository $accessTokenRepository; - /** @var AuthCodeRepository */ - private $authCodeRepository; + private AuthCodeRepository $authCodeRepository; - /** @var AuthorizationServer */ - private $authServer; + private AuthorizationServer $authServer; - /** @var ClientRepository */ - private $clientRepository; + private ClientRepository $clientRepository; /** @var RequestHandlerInterface|ObjectProphecy */ private $handler; - /** @var PdoService */ - private $pdoService; + private PdoService $pdoService; - /** @var RefreshTokenRepository */ - private $refreshTokenRepository; + private RefreshTokenRepository $refreshTokenRepository; - /** @var Response */ - private $response; + private Response $response; /** @var callable */ private $responseFactory; - /** @var ScopeRepository */ - private $scopeRepository; + private ScopeRepository $scopeRepository; - /** @var UserRepository */ - private $userRepository; + private UserRepository $userRepository; public static function setUpBeforeClass(): void { @@ -151,9 +142,7 @@ protected function setUp(): void ); $this->handler = $this->prophesize(RequestHandlerInterface::class); - $this->responseFactory = function () { - return $this->response; - }; + $this->responseFactory = fn(): Response => $this->response; } /** @@ -511,8 +500,7 @@ private function buildConsumerAuthMiddleware(AuthorizationHandler $authHandler): { return new class ($authHandler) implements RequestHandlerInterface { - /** @var AuthorizationHandler */ - private $handler; + private AuthorizationHandler $handler; public function __construct(AuthorizationHandler $handler) { diff --git a/test/Psr17ResponseFactoryTraitTest.php b/test/Psr17ResponseFactoryTraitTest.php index f3bfe68d..ac5fe6c2 100644 --- a/test/Psr17ResponseFactoryTraitTest.php +++ b/test/Psr17ResponseFactoryTraitTest.php @@ -14,8 +14,7 @@ final class Psr17ResponseFactoryTraitTest extends TestCase { - /** @var Psr17ResponseFactoryTraitImplementation */ - private $factory; + private Psr17ResponseFactoryTraitImplementation $factory; protected function setUp(): void { @@ -32,9 +31,8 @@ public function configurationsWithOverriddenResponseInterfaceFactory(): Generato [ 'dependencies' => [ 'factories' => [ - ResponseInterface::class => function (): ResponseInterface { - return $this->createMock(ResponseInterface::class); - }, + ResponseInterface::class + => fn(): ResponseInterface => $this->createMock(ResponseInterface::class), ], ], ], @@ -55,9 +53,7 @@ public function configurationsWithOverriddenResponseInterfaceFactory(): Generato 'dependencies' => [ 'delegators' => [ ResponseInterface::class => [ - function (): ResponseInterface { - return $this->createMock(ResponseInterface::class); - }, + fn(): ResponseInterface => $this->createMock(ResponseInterface::class), ], ], ], @@ -93,9 +89,7 @@ public function testWontUseResponseFactoryInterfaceFromContainerWhenApplicationF $container->set('config', $config); $container->set(ResponseFactoryInterface::class, $responseFactory); $response = $this->createMock(ResponseInterface::class); - $container->set(ResponseInterface::class, function () use ($response): ResponseInterface { - return $response; - }); + $container->set(ResponseInterface::class, static fn(): ResponseInterface => $response); $detectedResponseFactory = ($this->factory)($container); self::assertNotSame($responseFactory, $detectedResponseFactory); diff --git a/test/Repository/Pdo/AccessTokenRepositoryFactoryTest.php b/test/Repository/Pdo/AccessTokenRepositoryFactoryTest.php index 3dd955ba..0295f190 100644 --- a/test/Repository/Pdo/AccessTokenRepositoryFactoryTest.php +++ b/test/Repository/Pdo/AccessTokenRepositoryFactoryTest.php @@ -9,14 +9,14 @@ use Mezzio\Authentication\OAuth2\Repository\Pdo\PdoService; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; use Psr\Container\ContainerInterface; class AccessTokenRepositoryFactoryTest extends TestCase { use ProphecyTrait; - /** @var ContainerInterface */ - private $container; + private ObjectProphecy $container; protected function setUp(): void { diff --git a/test/Repository/Pdo/AccessTokenRepositoryTest.php b/test/Repository/Pdo/AccessTokenRepositoryTest.php index 63498b69..61546907 100644 --- a/test/Repository/Pdo/AccessTokenRepositoryTest.php +++ b/test/Repository/Pdo/AccessTokenRepositoryTest.php @@ -25,8 +25,7 @@ class AccessTokenRepositoryTest extends TestCase { use ProphecyTrait; - /** @var AccessTokenRepository */ - private $repo; + private AccessTokenRepository $repo; protected function setUp(): void { diff --git a/test/Repository/Pdo/AuthCodeRepositoryFactoryTest.php b/test/Repository/Pdo/AuthCodeRepositoryFactoryTest.php index acf6ae98..85d41a77 100644 --- a/test/Repository/Pdo/AuthCodeRepositoryFactoryTest.php +++ b/test/Repository/Pdo/AuthCodeRepositoryFactoryTest.php @@ -9,14 +9,14 @@ use Mezzio\Authentication\OAuth2\Repository\Pdo\PdoService; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; use Psr\Container\ContainerInterface; class AuthCodeRepositoryFactoryTest extends TestCase { use ProphecyTrait; - /** @var ContainerInterface */ - private $container; + private ObjectProphecy $container; protected function setUp(): void { diff --git a/test/Repository/Pdo/ClientRepositoryFactoryTest.php b/test/Repository/Pdo/ClientRepositoryFactoryTest.php index eb3418d7..130ef244 100644 --- a/test/Repository/Pdo/ClientRepositoryFactoryTest.php +++ b/test/Repository/Pdo/ClientRepositoryFactoryTest.php @@ -9,14 +9,14 @@ use Mezzio\Authentication\OAuth2\Repository\Pdo\PdoService; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; use Psr\Container\ContainerInterface; class ClientRepositoryFactoryTest extends TestCase { use ProphecyTrait; - /** @var ContainerInterface */ - private $container; + private ObjectProphecy $container; protected function setUp(): void { diff --git a/test/Repository/Pdo/ClientRepositoryTest.php b/test/Repository/Pdo/ClientRepositoryTest.php index 75ce0ad4..48426e92 100644 --- a/test/Repository/Pdo/ClientRepositoryTest.php +++ b/test/Repository/Pdo/ClientRepositoryTest.php @@ -41,7 +41,7 @@ public function testGetClientEntityReturnsNullIfNoRowReturned() { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':clientIdentifier', 'client_id')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement) { + $statement->execute()->will(function () use ($statement): bool { $statement->fetch()->willReturn([]); return true; }); @@ -62,7 +62,7 @@ public function testGetClientEntityReturnsCorrectEntity() $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':clientIdentifier', 'client_id')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement, $name, $redirect) { + $statement->execute()->will(function () use ($statement, $name, $redirect): bool { $statement->fetch()->willReturn([ 'name' => $name, 'redirect' => $redirect, @@ -122,7 +122,7 @@ public function testValidateClientReturnsFalseIfNoRowReturned(): void { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':clientIdentifier', 'client_id')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement) { + $statement->execute()->will(function () use ($statement): bool { $statement->fetch()->willReturn([]); return true; }); @@ -149,7 +149,7 @@ public function testValidateClientReturnsFalseIfRowIndicatesNotGranted(string $g { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':clientIdentifier', 'client_id')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement, $rowReturned) { + $statement->execute()->will(function () use ($statement, $rowReturned): bool { $statement->fetch()->willReturn($rowReturned); return true; }); @@ -171,7 +171,7 @@ public function testValidateClientReturnsFalseForNonMatchingClientSecret() { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':clientIdentifier', 'client_id')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement) { + $statement->execute()->will(function () use ($statement): bool { $statement->fetch()->willReturn([ 'password_client' => true, 'secret' => 'bar', @@ -198,7 +198,7 @@ public function testValidateClientReturnsFalseForEmptyClientSecret() { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':clientIdentifier', 'client_id')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement) { + $statement->execute()->will(function () use ($statement): bool { $statement->fetch()->willReturn([ 'password_client' => true, 'secret' => null, diff --git a/test/Repository/Pdo/RefreshTokenRepositoryFactoryTest.php b/test/Repository/Pdo/RefreshTokenRepositoryFactoryTest.php index f9426124..0bffae06 100644 --- a/test/Repository/Pdo/RefreshTokenRepositoryFactoryTest.php +++ b/test/Repository/Pdo/RefreshTokenRepositoryFactoryTest.php @@ -9,14 +9,14 @@ use Mezzio\Authentication\OAuth2\Repository\Pdo\RefreshTokenRepositoryFactory; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; use Psr\Container\ContainerInterface; class RefreshTokenRepositoryFactoryTest extends TestCase { use ProphecyTrait; - /** @var ContainerInterface */ - private $container; + private ObjectProphecy $container; protected function setUp(): void { diff --git a/test/Repository/Pdo/ScopeRepositoryFactoryTest.php b/test/Repository/Pdo/ScopeRepositoryFactoryTest.php index 50a5d8aa..1d15fbc5 100644 --- a/test/Repository/Pdo/ScopeRepositoryFactoryTest.php +++ b/test/Repository/Pdo/ScopeRepositoryFactoryTest.php @@ -9,14 +9,14 @@ use Mezzio\Authentication\OAuth2\Repository\Pdo\ScopeRepositoryFactory; use PHPUnit\Framework\TestCase; use Prophecy\PhpUnit\ProphecyTrait; +use Prophecy\Prophecy\ObjectProphecy; use Psr\Container\ContainerInterface; class ScopeRepositoryFactoryTest extends TestCase { use ProphecyTrait; - /** @var ContainerInterface */ - private $container; + private ObjectProphecy $container; protected function setUp(): void { diff --git a/test/Repository/Pdo/UserRepositoryTest.php b/test/Repository/Pdo/UserRepositoryTest.php index d5c16b6b..d071b529 100644 --- a/test/Repository/Pdo/UserRepositoryTest.php +++ b/test/Repository/Pdo/UserRepositoryTest.php @@ -53,7 +53,7 @@ public function testGetUserEntityByCredentialsReturnsNullIfPasswordVerificationF { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':username', 'username')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement) { + $statement->execute()->will(function () use ($statement): bool { $statement->fetch()->willReturn([ 'password' => 'not-the-same-password', ]); @@ -80,7 +80,7 @@ public function testGetUserEntityByCredentialsReturnsNullIfUserIsNotFound() { $statement = $this->prophesize(PDOStatement::class); $statement->bindParam(':username', 'username')->shouldBeCalled(); - $statement->execute()->will(function () use ($statement) { + $statement->execute()->will(function () use ($statement): bool { $statement->fetch()->willReturn(null); return true; }); diff --git a/test/TokenEndpointHandlerFactoryTest.php b/test/TokenEndpointHandlerFactoryTest.php index b5f1e4da..871055bd 100644 --- a/test/TokenEndpointHandlerFactoryTest.php +++ b/test/TokenEndpointHandlerFactoryTest.php @@ -20,8 +20,7 @@ class TokenEndpointHandlerFactoryTest extends TestCase { use ProphecyTrait; - /** @var TokenEndpointHandlerFactory */ - private $subject; + private TokenEndpointHandlerFactory $subject; protected function setUp(): void { @@ -40,7 +39,7 @@ public function testEmptyContainerThrowsTypeError() public function testCreatesTokenEndpointHandler() { $server = $this->prophesize(AuthorizationServer::class); - $responseFactory = function () { + $responseFactory = static function (): void { }; $container = $this->prophesize(ContainerInterface::class);