diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 898b626..30d84c4 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -33,8 +33,8 @@ - - function () { + + fn() testFactory @@ -76,8 +76,8 @@ Argument::that([$this->request, 'reveal']) Argument::that([$this->request, 'reveal']) - - function () { + + fn() testConstructor diff --git a/src/AuthorizationMiddleware.php b/src/AuthorizationMiddleware.php index b58551b..359633a 100644 --- a/src/AuthorizationMiddleware.php +++ b/src/AuthorizationMiddleware.php @@ -5,6 +5,7 @@ namespace Mezzio\Authorization; use Mezzio\Authentication\UserInterface; +use Mezzio\Authorization\AuthorizationInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; @@ -12,8 +13,7 @@ class AuthorizationMiddleware implements MiddlewareInterface { - /** @var AuthorizationInterface */ - private $authorization; + private AuthorizationInterface $authorization; /** @var callable */ private $responseFactory; @@ -23,9 +23,7 @@ public function __construct(AuthorizationInterface $authorization, callable $res $this->authorization = $authorization; // Ensures type safety of the composed factory - $this->responseFactory = function () use ($responseFactory): ResponseInterface { - return $responseFactory(); - }; + $this->responseFactory = static fn(): ResponseInterface => $responseFactory(); } /** diff --git a/test/AuthorizationMiddlewareFactoryTest.php b/test/AuthorizationMiddlewareFactoryTest.php index 5be7220..1ac8782 100644 --- a/test/AuthorizationMiddlewareFactoryTest.php +++ b/test/AuthorizationMiddlewareFactoryTest.php @@ -23,8 +23,7 @@ class AuthorizationMiddlewareFactoryTest extends TestCase /** @var ContainerInterface|ObjectProphecy */ private $container; - /** @var AuthorizationMiddlewareFactory */ - private $factory; + private AuthorizationMiddlewareFactory $factory; /** @var AuthorizationInterface|ObjectProphecy */ private $authorization; @@ -41,9 +40,7 @@ protected function setUp(): void $this->factory = new AuthorizationMiddlewareFactory(); $this->authorization = $this->prophesize(AuthorizationInterface::class); $this->responsePrototype = $this->prophesize(ResponseInterface::class); - $this->responseFactory = function () { - return $this->responsePrototype->reveal(); - }; + $this->responseFactory = fn() => $this->responsePrototype->reveal(); $this->container ->get(AuthorizationInterface::class) diff --git a/test/AuthorizationMiddlewareTest.php b/test/AuthorizationMiddlewareTest.php index e89d3c3..9d67b61 100644 --- a/test/AuthorizationMiddlewareTest.php +++ b/test/AuthorizationMiddlewareTest.php @@ -41,9 +41,7 @@ protected function setUp(): void $this->request = $this->prophesize(ServerRequestInterface::class); $this->handler = $this->prophesize(RequestHandlerInterface::class); $this->responsePrototype = $this->prophesize(ResponseInterface::class); - $this->responseFactory = function () { - return $this->responsePrototype->reveal(); - }; + $this->responseFactory = fn() => $this->responsePrototype->reveal(); } public function testConstructor() diff --git a/test/ConfigProviderTest.php b/test/ConfigProviderTest.php index dbbd0e7..91e8009 100644 --- a/test/ConfigProviderTest.php +++ b/test/ConfigProviderTest.php @@ -10,8 +10,7 @@ class ConfigProviderTest extends TestCase { - /** @var ConfigProvider */ - private $provider; + private ConfigProvider $provider; protected function setUp(): void {