From 981ea8f4de4049b3ad24ac206a2385b73dfe62de Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 29 Aug 2022 05:21:21 +0000 Subject: [PATCH 1/2] Build(deps-dev): bump doctrine/coding-standard from 9.0.2 to 10.0.0 Bumps [doctrine/coding-standard](https://github.com/doctrine/coding-standard) from 9.0.2 to 10.0.0. - [Release notes](https://github.com/doctrine/coding-standard/releases) - [Commits](https://github.com/doctrine/coding-standard/compare/9.0.2...10.0.0) --- updated-dependencies: - dependency-name: doctrine/coding-standard dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- composer.lock | 46 +++++++++++++++++++++++----------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/composer.json b/composer.json index 2a31f3d1..5df40dd7 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ "psr/http-server-middleware": "^1.0.1" }, "require-dev": { - "doctrine/coding-standard": "^9.0.2", + "doctrine/coding-standard": "^10.0.0", "laminas/laminas-diactoros": "^2.16.0", "laminas/laminas-httphandlerrunner": "^2.1.0", "phpunit/phpunit": "^9.5.23", diff --git a/composer.lock b/composer.lock index 44809204..13617d92 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fe11f82f8f8be335f61785ee4c7cecee", + "content-hash": "8691440657eec022d1d1aced662e6430", "packages": [ { "name": "dflydev/fig-cookies", @@ -986,23 +986,23 @@ }, { "name": "doctrine/coding-standard", - "version": "9.0.2", + "version": "10.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/coding-standard.git", - "reference": "35a2452c6025cb739c3244b3348bcd1604df07d1" + "reference": "7903671d7d33c231c8921058b7c14b8f57cbacb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/35a2452c6025cb739c3244b3348bcd1604df07d1", - "reference": "35a2452c6025cb739c3244b3348bcd1604df07d1", + "url": "https://api.github.com/repos/doctrine/coding-standard/zipball/7903671d7d33c231c8921058b7c14b8f57cbacb7", + "reference": "7903671d7d33c231c8921058b7c14b8f57cbacb7", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", - "php": "^7.1 || ^8.0", - "slevomat/coding-standard": "^7.0.0", - "squizlabs/php_codesniffer": "^3.6.0" + "php": "^7.2 || ^8.0", + "slevomat/coding-standard": "^8.2", + "squizlabs/php_codesniffer": "^3.7" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -1035,9 +1035,9 @@ ], "support": { "issues": "https://github.com/doctrine/coding-standard/issues", - "source": "https://github.com/doctrine/coding-standard/tree/9.0.2" + "source": "https://github.com/doctrine/coding-standard/tree/10.0.0" }, - "time": "2021-04-12T15:11:14+00:00" + "time": "2022-08-26T10:53:05+00:00" }, { "name": "doctrine/instantiator", @@ -4192,37 +4192,37 @@ }, { "name": "slevomat/coding-standard", - "version": "7.2.1", + "version": "8.4.0", "source": { "type": "git", "url": "https://github.com/slevomat/coding-standard.git", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90" + "reference": "02f27326be19633a1b6ba76745390bbf9a4be0b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/aff06ae7a84e4534bf6f821dc982a93a5d477c90", - "reference": "aff06ae7a84e4534bf6f821dc982a93a5d477c90", + "url": "https://api.github.com/repos/slevomat/coding-standard/zipball/02f27326be19633a1b6ba76745390bbf9a4be0b6", + "reference": "02f27326be19633a1b6ba76745390bbf9a4be0b6", "shasum": "" }, "require": { "dealerdirect/phpcodesniffer-composer-installer": "^0.6.2 || ^0.7", "php": "^7.2 || ^8.0", - "phpstan/phpdoc-parser": "^1.5.1", - "squizlabs/php_codesniffer": "^3.6.2" + "phpstan/phpdoc-parser": ">=1.7.0 <1.8.0", + "squizlabs/php_codesniffer": "^3.7.1" }, "require-dev": { - "phing/phing": "2.17.3", + "phing/phing": "2.17.4", "php-parallel-lint/php-parallel-lint": "1.3.2", - "phpstan/phpstan": "1.4.10|1.7.1", + "phpstan/phpstan": "1.4.10|1.8.2", "phpstan/phpstan-deprecation-rules": "1.0.0", "phpstan/phpstan-phpunit": "1.0.0|1.1.1", - "phpstan/phpstan-strict-rules": "1.2.3", - "phpunit/phpunit": "7.5.20|8.5.21|9.5.20" + "phpstan/phpstan-strict-rules": "1.3.0", + "phpunit/phpunit": "7.5.20|8.5.21|9.5.21" }, "type": "phpcodesniffer-standard", "extra": { "branch-alias": { - "dev-master": "7.x-dev" + "dev-master": "8.x-dev" } }, "autoload": { @@ -4237,7 +4237,7 @@ "description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.", "support": { "issues": "https://github.com/slevomat/coding-standard/issues", - "source": "https://github.com/slevomat/coding-standard/tree/7.2.1" + "source": "https://github.com/slevomat/coding-standard/tree/8.4.0" }, "funding": [ { @@ -4249,7 +4249,7 @@ "type": "tidelift" } ], - "time": "2022-05-25T10:58:12+00:00" + "time": "2022-08-09T19:03:45+00:00" }, { "name": "squizlabs/php_codesniffer", From 49ca12e0b9e95ad3cab2af2ab08fa0c4a16b8308 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Mon, 29 Aug 2022 11:19:05 +0200 Subject: [PATCH 2/2] Applied `doctrine/coding-standard:^10` ruleset --- examples/index.php | 4 +- src/Storageless/Http/SessionMiddleware.php | 53 ++++----- .../Session/DefaultSessionData.php | 18 +-- src/Storageless/Session/LazySession.php | 2 +- .../Http/SessionMiddlewareTest.php | 110 +++++++++--------- .../Session/DefaultSessionDataTest.php | 12 +- .../Session/LazySessionTest.php | 10 +- 7 files changed, 88 insertions(+), 121 deletions(-) diff --git a/examples/index.php b/examples/index.php index 6312c047..10f69392 100644 --- a/examples/index.php +++ b/examples/index.php @@ -44,14 +44,14 @@ $sessionMiddleware = new SessionMiddleware( Configuration::forSymmetricSigner( new Sha256(), - InMemory::plainText('c9UA8QKLSmDEn4DhNeJIad/4JugZd/HvrjyKrS0jOes=') // // signature key (important: change this to your own) + InMemory::plainText('c9UA8QKLSmDEn4DhNeJIad/4JugZd/HvrjyKrS0jOes='), // // signature key (important: change this to your own) ), SetCookie::create('an-example-cookie-name') ->withSecure(false) // false on purpose, unless you have https locally ->withHttpOnly(true) ->withPath('/'), 1200, // 20 minutes - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); $myMiddleware = new class implements RequestHandlerInterface { diff --git a/src/Storageless/Http/SessionMiddleware.php b/src/Storageless/Http/SessionMiddleware.php index 4bc77810..556f3261 100644 --- a/src/Storageless/Http/SessionMiddleware.php +++ b/src/Storageless/Http/SessionMiddleware.php @@ -58,26 +58,17 @@ final class SessionMiddleware implements MiddlewareInterface private Configuration $config; - private int $expirationTime; - - private int $refreshTime; - private SetCookie $defaultCookie; - private Clock $clock; - public function __construct( Configuration $configuration, SetCookie $defaultCookie, - int $expirationTime, - Clock $clock, - int $refreshTime = self::DEFAULT_REFRESH_TIME + private int $expirationTime, + private Clock $clock, + private int $refreshTime = self::DEFAULT_REFRESH_TIME, ) { - $this->config = $configuration; - $this->defaultCookie = clone $defaultCookie; - $this->expirationTime = $expirationTime; - $this->clock = $clock; - $this->refreshTime = $refreshTime; + $this->config = $configuration; + $this->defaultCookie = clone $defaultCookie; } /** @@ -88,11 +79,11 @@ public static function fromSymmetricKeyDefaults(Signer\Key $symmetricKey, int $e return new self( Configuration::forSymmetricSigner( new Signer\Hmac\Sha256(), - $symmetricKey + $symmetricKey, ), self::buildDefaultCookie(), $expirationTime, - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); } @@ -103,17 +94,17 @@ public static function fromSymmetricKeyDefaults(Signer\Key $symmetricKey, int $e public static function fromRsaAsymmetricKeyDefaults( Signer\Key $privateRsaKey, Signer\Key $publicRsaKey, - int $expirationTime + int $expirationTime, ): self { return new self( Configuration::forAsymmetricSigner( new Signer\Rsa\Sha256(), $privateRsaKey, - $publicRsaKey + $publicRsaKey, ), self::buildDefaultCookie(), $expirationTime, - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); } @@ -142,14 +133,14 @@ public function process(Request $request, RequestHandlerInterface $handler): Res return $this->appendToken( $sessionContainer, $handler->handle($request->withAttribute(self::SESSION_ATTRIBUTE, $sessionContainer)), - $token + $token, ); } /** * Extract the token from the given request object */ - private function parseToken(Request $request): ?UnencryptedToken + private function parseToken(Request $request): UnencryptedToken|null { /** @var array $cookies */ $cookies = $request->getCookieParams(); @@ -181,10 +172,8 @@ private function parseToken(Request $request): ?UnencryptedToken return $token; } - /** - * @throws OutOfBoundsException - */ - private function extractSessionContainer(?UnencryptedToken $token): SessionInterface + /** @throws OutOfBoundsException */ + private function extractSessionContainer(UnencryptedToken|null $token): SessionInterface { if (! $token) { return DefaultSessionData::newEmptySession(); @@ -192,9 +181,9 @@ private function extractSessionContainer(?UnencryptedToken $token): SessionInter try { return DefaultSessionData::fromDecodedTokenData( - (object) $token->claims()->get(self::SESSION_CLAIM, new stdClass()) + (object) $token->claims()->get(self::SESSION_CLAIM, new stdClass()), ); - } catch (BadMethodCallException $invalidToken) { + } catch (BadMethodCallException) { return DefaultSessionData::newEmptySession(); } } @@ -203,7 +192,7 @@ private function extractSessionContainer(?UnencryptedToken $token): SessionInter * @throws BadMethodCallException * @throws InvalidArgumentException */ - private function appendToken(SessionInterface $sessionContainer, Response $response, ?Token $token): Response + private function appendToken(SessionInterface $sessionContainer, Response $response, Token|null $token): Response { $sessionContainerChanged = $sessionContainer->hasChanged(); @@ -218,15 +207,13 @@ private function appendToken(SessionInterface $sessionContainer, Response $respo return $response; } - private function shouldTokenBeRefreshed(?Token $token): bool + private function shouldTokenBeRefreshed(Token|null $token): bool { return $token !== null && $token->hasBeenIssuedBefore($this->clock->now()->sub(new DateInterval(sprintf('PT%sS', $this->refreshTime)))); } - /** - * @throws BadMethodCallException - */ + /** @throws BadMethodCallException */ private function getTokenCookie(SessionInterface $sessionContainer): SetCookie { $now = $this->clock->now(); @@ -241,7 +228,7 @@ private function getTokenCookie(SessionInterface $sessionContainer): SetCookie ->expiresAt($expiresAt) ->withClaim(self::SESSION_CLAIM, $sessionContainer) ->getToken($this->config->signer(), $this->config->signingKey()) - ->toString() + ->toString(), ) ->withExpires($expiresAt); } diff --git a/src/Storageless/Session/DefaultSessionData.php b/src/Storageless/Session/DefaultSessionData.php index 587061f1..4c8c16ab 100644 --- a/src/Storageless/Session/DefaultSessionData.php +++ b/src/Storageless/Session/DefaultSessionData.php @@ -34,22 +34,14 @@ final class DefaultSessionData implements SessionInterface { private const DEFAULT_JSON_DECODE_DEPTH = 512; - /** @var array */ - private array $data; - - /** @var array */ - private array $originalData; - /** * @param array $data * @param array $originalData */ private function __construct( - array $data, - array $originalData + private array $data, + private array $originalData, ) { - $this->data = $data; - $this->originalData = $originalData; } public static function fromDecodedTokenData(object $data): self @@ -59,9 +51,7 @@ public static function fromDecodedTokenData(object $data): self return new self($arrayShapedData, $arrayShapedData); } - /** - * @param array $data - */ + /** @param array $data */ public static function fromTokenData(array $data): self { $instance = new self([], []); @@ -147,7 +137,7 @@ private static function convertValueToScalar(int|bool|string|float|array|object| json_encode($value, JSON_PRESERVE_ZERO_FRACTION | JSON_THROW_ON_ERROR), true, self::DEFAULT_JSON_DECODE_DEPTH, - JSON_THROW_ON_ERROR + JSON_THROW_ON_ERROR, ); return $decoded; diff --git a/src/Storageless/Session/LazySession.php b/src/Storageless/Session/LazySession.php index d808259c..0fb99fd5 100644 --- a/src/Storageless/Session/LazySession.php +++ b/src/Storageless/Session/LazySession.php @@ -23,7 +23,7 @@ final class LazySession implements SessionInterface { /** @internal do not access directly: use {@see LazySession::getRealSession} instead */ - private ?SessionInterface $realSession = null; + private SessionInterface|null $realSession = null; /** * @var callable diff --git a/test/StoragelessTest/Http/SessionMiddlewareTest.php b/test/StoragelessTest/Http/SessionMiddlewareTest.php index fc5decc9..97da5a41 100644 --- a/test/StoragelessTest/Http/SessionMiddlewareTest.php +++ b/test/StoragelessTest/Http/SessionMiddlewareTest.php @@ -152,18 +152,18 @@ static function (ServerRequestInterface $request) use ($sessionValue) { self::assertTrue( $session->hasChanged(), 'ensuring that the cookie is sent again: ' - . 'non-modified session containers are not to be re-serialized into a token' + . 'non-modified session containers are not to be re-serialized into a token', ); return new Response(); - } + }, ); $firstResponse = $middleware->process(new ServerRequest(), $this->writingMiddleware($sessionValue)); $response = $middleware->process( $this->requestWithResponseCookies($firstResponse), - $checkingMiddleware + $checkingMiddleware, ); self::assertNotSame($response, $firstResponse); @@ -188,14 +188,14 @@ static function (ServerRequestInterface $request) use ($sessionValue) { self::assertFalse($session->hasChanged()); return new Response(); - } + }, ); $this->createTokenWithCustomClaim( $middleware, new DateTimeImmutable('-1 day'), new DateTimeImmutable('+1 day'), - 'not valid session data' + 'not valid session data', ); $middleware->process( @@ -205,10 +205,10 @@ static function (ServerRequestInterface $request) use ($sessionValue) { $middleware, new DateTimeImmutable('-1 day'), new DateTimeImmutable('+1 day'), - $sessionValue + $sessionValue, ), ]), - $checkingMiddleware + $checkingMiddleware, ); } @@ -225,7 +225,7 @@ public function testWillIgnoreRequestsWithExpiredTokens(callable $middlewareFact SessionMiddleware::DEFAULT_COOKIE => $this->createToken( $middleware, new DateTimeImmutable('-1 day'), - new DateTimeImmutable('-2 day') + new DateTimeImmutable('-2 day'), ), ]); @@ -249,11 +249,11 @@ public function testWillIgnoreRequestsWithNonPlainTokens(): void $configuration, SetCookie::create('COOKIE_NAME'), 100, - new FrozenClock(new DateTimeImmutable()) + new FrozenClock(new DateTimeImmutable()), ), (new ServerRequest()) ->withCookieParams(['COOKIE_NAME' => 'THE_COOKIE']), - $this->emptyValidationMiddleware() + $this->emptyValidationMiddleware(), ); } @@ -270,7 +270,7 @@ public function testWillIgnoreRequestsWithTokensFromFuture(callable $middlewareF SessionMiddleware::DEFAULT_COOKIE => $this->createToken( $middleware, new DateTimeImmutable('+1 day'), - new DateTimeImmutable('-2 day') + new DateTimeImmutable('-2 day'), ), ]); @@ -333,14 +333,14 @@ public function testWillRefreshTokenWithIssuedAtExactlyAtTokenRefreshTimeThresho $configuration = Configuration::forAsymmetricSigner( new Sha256(), $key, - $key + $key, ); $middleware = new SessionMiddleware( $configuration, SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), 1000, $clock, - 100 + 100, ); $requestWithTokenIssuedInThePast = (new ServerRequest()) @@ -378,7 +378,7 @@ public function testWillSkipInjectingSessionCookiesWhenSessionIsNotChanged(calla $this->ensureSameResponse( $middleware, $this->requestWithResponseCookies( - $middleware->process(new ServerRequest(), $this->writingMiddleware()) + $middleware->process(new ServerRequest(), $this->writingMiddleware()), ), $this->fakeDelegate( static function (ServerRequestInterface $request) { @@ -391,8 +391,8 @@ static function (ServerRequestInterface $request) { self::assertFalse($session->hasChanged()); return new Response(); - } - ) + }, + ), ); } @@ -407,7 +407,7 @@ public function testWillSendExpirationCookieWhenSessionContentsAreCleared(callab $this->ensureClearsSessionCookie( $middleware, $this->requestWithResponseCookies( - $middleware->process(new ServerRequest(), $this->writingMiddleware()) + $middleware->process(new ServerRequest(), $this->writingMiddleware()), ), $this->fakeDelegate( static function (ServerRequestInterface $request) { @@ -417,8 +417,8 @@ static function (ServerRequestInterface $request) { $session->clear(); return new Response(); - } - ) + }, + ), ); } @@ -433,7 +433,7 @@ public function testWillIgnoreMalformedTokens(callable $middlewareFactory): void $this->ensureSameResponse( $middleware, (new ServerRequest())->withCookieParams([SessionMiddleware::DEFAULT_COOKIE => 'malformed content']), - $this->emptyValidationMiddleware() + $this->emptyValidationMiddleware(), ); } @@ -442,28 +442,28 @@ public function testRejectsTokensWithInvalidSignature(): void $middleware = new SessionMiddleware( Configuration::forSymmetricSigner( new Sha256(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ), SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), 100, - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); $middlewareWithAlteredKey = new SessionMiddleware( Configuration::forSymmetricSigner( new Sha256(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ), SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), 100, - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); $this->ensureSameResponse( $middlewareWithAlteredKey, $this->requestWithResponseCookies( - $middleware->process(new ServerRequest(), $this->writingMiddleware()) + $middleware->process(new ServerRequest(), $this->writingMiddleware()), ), - $this->emptyValidationMiddleware() + $this->emptyValidationMiddleware(), ); } @@ -480,12 +480,12 @@ public function testAllowsModifyingCookieDetails(): void $middleware = new SessionMiddleware( Configuration::forSymmetricSigner( new Sha256(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ), $defaultCookie, 123456, new FrozenClock($dateTime), - 123 + 123, ); $response = $middleware->process(new ServerRequest(), $this->writingMiddleware()); @@ -516,15 +516,15 @@ public function testSessionTokenParsingIsDelayedWhenSessionIsNotBeingUsed(): voi $middleware = new SessionMiddleware( Configuration::forSymmetricSigner( $signer, - $key + $key, ), $setCookie, 100, - $currentTimeProvider + $currentTimeProvider, ); $configurationForBuiler = Configuration::forSymmetricSigner( new Sha256(), - $key + $key, ); $request = (new ServerRequest()) ->withCookieParams([ @@ -540,11 +540,11 @@ public function testSessionTokenParsingIsDelayedWhenSessionIsNotBeingUsed(): voi $this->fakeDelegate(static function (ServerRequestInterface $request) { self::assertInstanceOf( SessionInterface::class, - $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE) + $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE), ); return new Response(); - }) + }), ); } @@ -553,14 +553,14 @@ public function testShouldRegenerateTokenWhenRequestHasATokenThatIsAboutToExpire $dateTime = new DateTimeImmutable(); $configuration = Configuration::forSymmetricSigner( new Sha256(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ); $middleware = new SessionMiddleware( $configuration, SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), 1000, new FrozenClock($dateTime), - 300 + 300, ); $expiringToken = (new ServerRequest()) @@ -592,14 +592,14 @@ public function testShouldNotRegenerateTokenWhenRequestHasATokenThatIsFarFromExp { $configuration = Configuration::forSymmetricSigner( new Sha256(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ); $middleware = new SessionMiddleware( $configuration, SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), 1000, new SystemClock(new DateTimeZone(date_default_timezone_get())), - 300 + 300, ); $validToken = (new ServerRequest()) @@ -616,9 +616,7 @@ public function testShouldNotRegenerateTokenWhenRequestHasATokenThatIsFarFromExp $this->ensureSameResponse($middleware, $validToken); } - /** - * @return array> - */ + /** @return array> */ public function validMiddlewaresProvider(): array { return $this->defaultMiddlewaresProvider() + [ @@ -627,20 +625,18 @@ static function (): SessionMiddleware { return new SessionMiddleware( Configuration::forSymmetricSigner( new Signer\Hmac\Sha512(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ), SetCookie::create(SessionMiddleware::DEFAULT_COOKIE), 100, - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); }, ], ]; } - /** - * @return array> - */ + /** @return array> */ public function defaultMiddlewaresProvider(): array { return [ @@ -648,7 +644,7 @@ public function defaultMiddlewaresProvider(): array static function (): SessionMiddleware { return SessionMiddleware::fromSymmetricKeyDefaults( self::makeRandomSymmetricKey(), - 100 + 100, ); }, ], @@ -657,7 +653,7 @@ static function (): SessionMiddleware { return SessionMiddleware::fromRsaAsymmetricKeyDefaults( Signer\Key\InMemory::file(__DIR__ . '/../../keys/private_key.pem'), Signer\Key\InMemory::file(__DIR__ . '/../../keys/public_key.pem'), - 200 + 200, ); }, ], @@ -672,13 +668,13 @@ public function testMutableCookieWillNotBeUsed(): void $configuration = Configuration::forSymmetricSigner( new Sha256(), - self::makeRandomSymmetricKey() + self::makeRandomSymmetricKey(), ); $middleware = new SessionMiddleware( $configuration, $cookie, 1000, - new SystemClock(new DateTimeZone(date_default_timezone_get())) + new SystemClock(new DateTimeZone(date_default_timezone_get())), ); $cookie->mutated = true; @@ -687,14 +683,14 @@ public function testMutableCookieWillNotBeUsed(): void '__Secure-slsession=', $middleware ->process(new ServerRequest(), $this->writingMiddleware()) - ->getHeaderLine('Set-Cookie') + ->getHeaderLine('Set-Cookie'), ); } private function ensureSameResponse( SessionMiddleware $middleware, ServerRequestInterface $request, - ?RequestHandlerInterface $next = null + RequestHandlerInterface|null $next = null, ): ResponseInterface { $initialResponse = new Response(); @@ -729,7 +725,7 @@ private function ensureSameResponse( private function ensureClearsSessionCookie( SessionMiddleware $middleware, ServerRequestInterface $request, - RequestHandlerInterface $next + RequestHandlerInterface $next, ): ResponseInterface { $response = $middleware->process($request, $next); @@ -758,7 +754,7 @@ private function createTokenWithCustomClaim( SessionMiddleware $middleware, DateTimeImmutable $issuedAt, DateTimeImmutable $expiration, - mixed $claim + mixed $claim, ): string { $config = $this->getJwtConfiguration($middleware); @@ -781,7 +777,7 @@ static function (ServerRequestInterface $request) { self::assertTrue($session->isEmpty()); return new Response(); - } + }, ); } @@ -794,7 +790,7 @@ static function (ServerRequestInterface $request) use ($value) { $session->set('foo', $value); return new Response(); - } + }, ); } @@ -811,9 +807,7 @@ private function fakeDelegate(callable $callback): RequestHandlerInterface return $middleware; } - /** - * @return ServerRequest - */ + /** @return ServerRequest */ private function requestWithResponseCookies(ResponseInterface $response): ServerRequestInterface { return (new ServerRequest())->withCookieParams([ diff --git a/test/StoragelessTest/Session/DefaultSessionDataTest.php b/test/StoragelessTest/Session/DefaultSessionDataTest.php index 0d1b414a..76c4512f 100644 --- a/test/StoragelessTest/Session/DefaultSessionDataTest.php +++ b/test/StoragelessTest/Session/DefaultSessionDataTest.php @@ -33,20 +33,18 @@ use const PHP_INT_MAX; use const PHP_INT_MIN; -/** - * @covers \PSR7Sessions\Storageless\Session\DefaultSessionData - */ +/** @covers \PSR7Sessions\Storageless\Session\DefaultSessionData */ final class DefaultSessionDataTest extends TestCase { public function testEqualityOfEmptySessions(): void { self::assertEquals( DefaultSessionData::fromTokenData([]), - DefaultSessionData::newEmptySession() + DefaultSessionData::newEmptySession(), ); self::assertEquals( DefaultSessionData::fromDecodedTokenData((object) []), - DefaultSessionData::newEmptySession() + DefaultSessionData::newEmptySession(), ); } @@ -102,7 +100,7 @@ public function testStorageKeysAreConvertedToStringKeys(): void { self::assertSame( '{"0":"a","1":"b","2":"c"}', - json_encode(DefaultSessionData::fromTokenData(['a', 'b', 'c'])) + json_encode(DefaultSessionData::fromTokenData(['a', 'b', 'c'])), ); } @@ -265,7 +263,7 @@ public function testAllMethodsAreCoveredByAnInterfacedMethod(): void $interfaces, static function (ReflectionClass $interface) use ($method) { return $interface->hasMethod($method->getName()); - } + }, ), $method->getName()); } } diff --git a/test/StoragelessTest/Session/LazySessionTest.php b/test/StoragelessTest/Session/LazySessionTest.php index 521226d5..0d5874ca 100644 --- a/test/StoragelessTest/Session/LazySessionTest.php +++ b/test/StoragelessTest/Session/LazySessionTest.php @@ -28,9 +28,7 @@ use function uniqid; -/** - * @covers \PSR7Sessions\Storageless\Session\LazySession - */ +/** @covers \PSR7Sessions\Storageless\Session\LazySession */ final class LazySessionTest extends TestCase { /** @var SessionInterface&MockObject */ @@ -67,7 +65,7 @@ public function testHasChanged(): void ->method('hasChanged') ->willReturnOnConsecutiveCalls( true, - false + false, ); $this->forceWrappedSessionInitialization(); @@ -148,7 +146,7 @@ public function testIsEmpty(): void ->method('isEmpty') ->willReturnOnConsecutiveCalls( true, - false + false, ); self::assertTrue($this->lazySession->isEmpty()); @@ -165,7 +163,7 @@ public function testJsonSerialize(): void ->method('jsonSerialize') ->willReturnOnConsecutiveCalls( (object) ['foo' => 'bar'], - (object) ['baz' => 'tab'] + (object) ['baz' => 'tab'], ); self::assertEquals((object) ['foo' => 'bar'], $this->lazySession->jsonSerialize());