Skip to content

Commit

Permalink
Merge pull request #21 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 20, 2022
2 parents dee1834 + 0118b89 commit 6536e85
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
13 changes: 3 additions & 10 deletions src/LaminasAuthentication.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
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;

public function setUp(): void
{
Expand Down
8 changes: 2 additions & 6 deletions test/LaminasAuthenticationFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 2 additions & 6 deletions test/LaminasAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6536e85

Please sign in to comment.