From 0118b893b3803406ba65c986e6b1890f8ded95d3 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 17 Sep 2022 23:36:00 +0700 Subject: [PATCH] Apply PHP 7.4 syntax and typed property Signed-off-by: Abdul Malik Ikhsan --- src/LaminasAuthentication.php | 13 +++---------- test/ConfigProviderTest.php | 3 +-- test/LaminasAuthenticationFactoryTest.php | 8 ++------ test/LaminasAuthenticationTest.php | 8 ++------ 4 files changed, 8 insertions(+), 24 deletions(-) diff --git a/src/LaminasAuthentication.php b/src/LaminasAuthentication.php index fcd735b..f62b874 100644 --- a/src/LaminasAuthentication.php +++ b/src/LaminasAuthentication.php @@ -44,22 +44,15 @@ public function __construct( if (is_callable($responseFactory)) { // Ensures type safety of the composed factory $responseFactory = new CallableResponseFactoryDecorator( - static function () use ($responseFactory): ResponseInterface { - return $responseFactory(); - } + static fn(): ResponseInterface => $responseFactory() ); } $this->responseFactory = $responseFactory; // Ensures type safety of the composed factory - $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); } public function authenticate(ServerRequestInterface $request): ?UserInterface diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index 647631f..ccf1f66 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -10,8 +10,7 @@ class ConfigProviderTest extends TestCase { - /** @var ConfigProvider */ - private $provider; + private ConfigProvider $provider; public function setUp(): void { diff --git a/test/LaminasAuthenticationFactoryTest.php b/test/LaminasAuthenticationFactoryTest.php index e7360cc..c387552 100644 --- a/test/LaminasAuthenticationFactoryTest.php +++ b/test/LaminasAuthenticationFactoryTest.php @@ -38,13 +38,9 @@ public function setUp(): void { $this->authService = $this->createMock(AuthenticationService::class); $this->responsePrototype = $this->createMock(ResponseInterface::class); - $this->responseFactory = function (): ResponseInterface { - return $this->responsePrototype; - }; + $this->responseFactory = fn(): ResponseInterface => $this->responsePrototype; $this->userPrototype = $this->createMock(UserInterface::class); - $this->userFactory = function (): UserInterface { - return $this->userPrototype; - }; + $this->userFactory = fn(): UserInterface => $this->userPrototype; } public function testInvokeWithEmptyContainer(): void diff --git a/test/LaminasAuthenticationTest.php b/test/LaminasAuthenticationTest.php index 4f213ec..2f3739a 100644 --- a/test/LaminasAuthenticationTest.php +++ b/test/LaminasAuthenticationTest.php @@ -36,13 +36,9 @@ public function setUp(): void { $this->request = $this->createMock(ServerRequestInterface::class); $this->authService = $this->createMock(AuthenticationService::class); - $this->responseFactory = function (): ResponseInterface { - return $this->createMock(ResponseInterface::class); - }; + $this->responseFactory = fn(): ResponseInterface => $this->createMock(ResponseInterface::class); $this->userPrototype = $this->createMock(UserInterface::class); - $this->userFactory = function (): UserInterface { - return $this->userPrototype; - }; + $this->userFactory = fn(): UserInterface => $this->userPrototype; } public function testConstructor(): void