Skip to content

Commit

Permalink
Merge pull request #19 from samsonasik/apply-php74
Browse files Browse the repository at this point in the history
Apply PHP 7.4 syntax and typed property
  • Loading branch information
Ocramius committed Sep 17, 2022
2 parents f2ec3e5 + 13e3b56 commit fdd7059
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
8 changes: 4 additions & 4 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
</UndefinedClass>
</file>
<file src="test/AuthorizationMiddlewareFactoryTest.php">
<MissingClosureReturnType occurrences="1">
<code>function () {</code>
<MissingClosureReturnType occurrences="2">
<code>fn()</code>
</MissingClosureReturnType>
<MissingReturnType occurrences="2">
<code>testFactory</code>
Expand Down Expand Up @@ -76,8 +76,8 @@
<code>Argument::that([$this-&gt;request, 'reveal'])</code>
<code>Argument::that([$this-&gt;request, 'reveal'])</code>
</InvalidArgument>
<MissingClosureReturnType occurrences="1">
<code>function () {</code>
<MissingClosureReturnType occurrences="2">
<code>fn()</code>
</MissingClosureReturnType>
<MissingReturnType occurrences="4">
<code>testConstructor</code>
Expand Down
8 changes: 3 additions & 5 deletions src/AuthorizationMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
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;
use Psr\Http\Server\RequestHandlerInterface;

class AuthorizationMiddleware implements MiddlewareInterface
{
/** @var AuthorizationInterface */
private $authorization;
private AuthorizationInterface $authorization;

/** @var callable */
private $responseFactory;
Expand All @@ -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();
}

/**
Expand Down
7 changes: 2 additions & 5 deletions test/AuthorizationMiddlewareFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions test/AuthorizationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

class ConfigProviderTest extends TestCase
{
/** @var ConfigProvider */
private $provider;
private ConfigProvider $provider;

protected function setUp(): void
{
Expand Down

0 comments on commit fdd7059

Please sign in to comment.