Skip to content

Commit fdd7059

Browse files
authored
Merge pull request #19 from samsonasik/apply-php74
Apply PHP 7.4 syntax and typed property
2 parents f2ec3e5 + 13e3b56 commit fdd7059

5 files changed

+11
-19
lines changed

psalm-baseline.xml

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
</UndefinedClass>
3434
</file>
3535
<file src="test/AuthorizationMiddlewareFactoryTest.php">
36-
<MissingClosureReturnType occurrences="1">
37-
<code>function () {</code>
36+
<MissingClosureReturnType occurrences="2">
37+
<code>fn()</code>
3838
</MissingClosureReturnType>
3939
<MissingReturnType occurrences="2">
4040
<code>testFactory</code>
@@ -76,8 +76,8 @@
7676
<code>Argument::that([$this-&gt;request, 'reveal'])</code>
7777
<code>Argument::that([$this-&gt;request, 'reveal'])</code>
7878
</InvalidArgument>
79-
<MissingClosureReturnType occurrences="1">
80-
<code>function () {</code>
79+
<MissingClosureReturnType occurrences="2">
80+
<code>fn()</code>
8181
</MissingClosureReturnType>
8282
<MissingReturnType occurrences="4">
8383
<code>testConstructor</code>

src/AuthorizationMiddleware.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
namespace Mezzio\Authorization;
66

77
use Mezzio\Authentication\UserInterface;
8+
use Mezzio\Authorization\AuthorizationInterface;
89
use Psr\Http\Message\ResponseInterface;
910
use Psr\Http\Message\ServerRequestInterface;
1011
use Psr\Http\Server\MiddlewareInterface;
1112
use Psr\Http\Server\RequestHandlerInterface;
1213

1314
class AuthorizationMiddleware implements MiddlewareInterface
1415
{
15-
/** @var AuthorizationInterface */
16-
private $authorization;
16+
private AuthorizationInterface $authorization;
1717

1818
/** @var callable */
1919
private $responseFactory;
@@ -23,9 +23,7 @@ public function __construct(AuthorizationInterface $authorization, callable $res
2323
$this->authorization = $authorization;
2424

2525
// Ensures type safety of the composed factory
26-
$this->responseFactory = function () use ($responseFactory): ResponseInterface {
27-
return $responseFactory();
28-
};
26+
$this->responseFactory = static fn(): ResponseInterface => $responseFactory();
2927
}
3028

3129
/**

test/AuthorizationMiddlewareFactoryTest.php

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ class AuthorizationMiddlewareFactoryTest extends TestCase
2323
/** @var ContainerInterface|ObjectProphecy */
2424
private $container;
2525

26-
/** @var AuthorizationMiddlewareFactory */
27-
private $factory;
26+
private AuthorizationMiddlewareFactory $factory;
2827

2928
/** @var AuthorizationInterface|ObjectProphecy */
3029
private $authorization;
@@ -41,9 +40,7 @@ protected function setUp(): void
4140
$this->factory = new AuthorizationMiddlewareFactory();
4241
$this->authorization = $this->prophesize(AuthorizationInterface::class);
4342
$this->responsePrototype = $this->prophesize(ResponseInterface::class);
44-
$this->responseFactory = function () {
45-
return $this->responsePrototype->reveal();
46-
};
43+
$this->responseFactory = fn() => $this->responsePrototype->reveal();
4744

4845
$this->container
4946
->get(AuthorizationInterface::class)

test/AuthorizationMiddlewareTest.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ protected function setUp(): void
4141
$this->request = $this->prophesize(ServerRequestInterface::class);
4242
$this->handler = $this->prophesize(RequestHandlerInterface::class);
4343
$this->responsePrototype = $this->prophesize(ResponseInterface::class);
44-
$this->responseFactory = function () {
45-
return $this->responsePrototype->reveal();
46-
};
44+
$this->responseFactory = fn() => $this->responsePrototype->reveal();
4745
}
4846

4947
public function testConstructor()

test/ConfigProviderTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111
class ConfigProviderTest extends TestCase
1212
{
13-
/** @var ConfigProvider */
14-
private $provider;
13+
private ConfigProvider $provider;
1514

1615
protected function setUp(): void
1716
{

0 commit comments

Comments
 (0)