Skip to content

Commit

Permalink
Merge pull request #15 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 authored Sep 13, 2022
2 parents a6eff6d + 0491022 commit 3c637eb
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 26 deletions.
7 changes: 3 additions & 4 deletions src/CsrfMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Mezzio\Csrf;

use Mezzio\Csrf\CsrfGuardFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
Expand All @@ -23,11 +24,9 @@ class CsrfMiddleware implements MiddlewareInterface
{
public const GUARD_ATTRIBUTE = 'csrf';

/** @var string */
private $attributeKey;
private string $attributeKey;

/** @var CsrfGuardFactoryInterface */
private $guardFactory;
private CsrfGuardFactoryInterface $guardFactory;

public function __construct(
CsrfGuardFactoryInterface $guardFactory,
Expand Down
3 changes: 1 addition & 2 deletions src/FlashCsrfGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class FlashCsrfGuard implements CsrfGuardInterface
{
/** @var FlashMessagesInterface */
private $flashMessages;
private FlashMessagesInterface $flashMessages;

public function __construct(FlashMessagesInterface $flashMessages)
{
Expand Down
3 changes: 1 addition & 2 deletions src/FlashCsrfGuardFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

class FlashCsrfGuardFactory implements CsrfGuardFactoryInterface
{
/** @var string */
private $attributeKey;
private string $attributeKey;

public function __construct(string $attributeKey = FlashMessageMiddleware::FLASH_ATTRIBUTE)
{
Expand Down
3 changes: 1 addition & 2 deletions src/SessionCsrfGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class SessionCsrfGuard implements CsrfGuardInterface
{
/** @var SessionInterface */
private $session;
private SessionInterface $session;

public function __construct(SessionInterface $session)
{
Expand Down
3 changes: 1 addition & 2 deletions src/SessionCsrfGuardFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@

class SessionCsrfGuardFactory implements CsrfGuardFactoryInterface
{
/** @var string */
private $attributeKey;
private string $attributeKey;

public function __construct(string $attributeKey = SessionMiddleware::SESSION_ATTRIBUTE)
{
Expand Down
3 changes: 1 addition & 2 deletions test/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

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

protected function setUp(): void
{
Expand Down
4 changes: 2 additions & 2 deletions test/CsrfMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

class CsrfMiddlewareTest extends TestCase
{
/** @var MockObject<CsrfGuardFactoryInterface> */
private $guardFactory;
/** @var MockObject&CsrfGuardFactoryInterface */
private CsrfGuardFactoryInterface $guardFactory;

protected function setUp(): void
{
Expand Down
9 changes: 4 additions & 5 deletions test/FlashCsrfGuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

class FlashCsrfGuardTest extends TestCase
{
/** @var MockObject<FlashMessagesInterface> */
private $flash;
/** @var FlashCsrfGuard */
private $guard;
/** @var MockObject&FlashMessagesInterface */
private FlashMessagesInterface $flash;
private FlashCsrfGuard $guard;

protected function setUp(): void
{
Expand All @@ -39,7 +38,7 @@ public function testGenerateTokenStoresTokenInFlashAndReturnsIt(string $keyName)
$this->flash->expects(self::atLeastOnce())->method('flash')
->with(
$keyName,
$this->callback(function ($token) use (&$expected) {
$this->callback(function ($token) use (&$expected): bool {
$this->assertMatchesRegularExpression('/^[a-f0-9]{32}$/', $token);
$expected = $token;
return true;
Expand Down
9 changes: 4 additions & 5 deletions test/SessionCsrfGuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@

class SessionCsrfGuardTest extends TestCase
{
/** @var MockObject<SessionInterface> */
private $session;
/** @var SessionCsrfGuard */
private $guard;
/** @var MockObject&SessionInterface */
private SessionInterface $session;
private SessionCsrfGuard $guard;

protected function setUp(): void
{
Expand All @@ -39,7 +38,7 @@ public function testGenerateTokenStoresTokenInSessionAndReturnsIt(string $keyNam
$this->session->expects(self::atLeastOnce())->method('set')
->with(
$keyName,
$this->callback(function ($token) use (&$expected) {
$this->callback(function ($token) use (&$expected): bool {
$this->assertMatchesRegularExpression('/^[a-f0-9]{32}$/', $token);
$expected = $token;
return true;
Expand Down

0 comments on commit 3c637eb

Please sign in to comment.