From 774566538e78b9fd1e489c5f6025b0781e50b14f Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sun, 11 Aug 2019 01:40:42 +0200 Subject: [PATCH] Upgraded to `doctrine/coding-standard` 6.0 --- composer.json | 2 +- src/Storageless/Http/SessionMiddleware.php | 22 +++--- .../Session/DefaultSessionData.php | 6 +- src/Storageless/Session/LazySession.php | 2 - src/Storageless/Session/SessionInterface.php | 11 +-- .../Http/SessionMiddlewareTest.php | 76 ++++++++++--------- .../Session/DefaultSessionDataTest.php | 41 +++++----- .../Session/LazySessionTest.php | 3 +- 8 files changed, 87 insertions(+), 76 deletions(-) diff --git a/composer.json b/composer.json index d0b0472c..00dce170 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ "phpstan/phpstan-phpunit": "^0.11.2", "phpstan/phpstan-strict-rules": "^0.11.1", "squizlabs/php_codesniffer": "^3.4.2", - "doctrine/coding-standard": "^4.0.0" + "doctrine/coding-standard": "^6.0.0" }, "replace": { "ocramius/psr7-session": "self.version" diff --git a/src/Storageless/Http/SessionMiddleware.php b/src/Storageless/Http/SessionMiddleware.php index acf932b0..d4bd7703 100644 --- a/src/Storageless/Http/SessionMiddleware.php +++ b/src/Storageless/Http/SessionMiddleware.php @@ -20,9 +20,11 @@ namespace PSR7Sessions\Storageless\Http; +use BadMethodCallException; use Dflydev\FigCookies\FigResponseCookies; use Dflydev\FigCookies\Modifier\SameSite; use Dflydev\FigCookies\SetCookie; +use InvalidArgumentException; use Lcobucci\Clock\Clock; use Lcobucci\Clock\SystemClock; use Lcobucci\JWT\Builder; @@ -30,6 +32,7 @@ use Lcobucci\JWT\Signer; use Lcobucci\JWT\Token; use Lcobucci\JWT\ValidationData; +use OutOfBoundsException; use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Server\MiddlewareInterface; @@ -37,6 +40,7 @@ use PSR7Sessions\Storageless\Session\DefaultSessionData; use PSR7Sessions\Storageless\Session\LazySession; use PSR7Sessions\Storageless\Session\SessionInterface; +use stdClass; final class SessionMiddleware implements MiddlewareInterface { @@ -137,8 +141,8 @@ public static function fromAsymmetricKeyDefaults( /** * {@inheritdoc} * - * @throws \BadMethodCallException - * @throws \InvalidArgumentException + * @throws BadMethodCallException + * @throws InvalidArgumentException */ public function process(Request $request, RequestHandlerInterface $delegate) : Response { @@ -168,7 +172,7 @@ private function parseToken(Request $request) : ?Token try { $token = $this->tokenParser->parse($cookies[$cookieName]); - } catch (\InvalidArgumentException $invalidToken) { + } catch (InvalidArgumentException $invalidToken) { return null; } @@ -180,7 +184,7 @@ private function parseToken(Request $request) : ?Token } /** - * @throws \OutOfBoundsException + * @throws OutOfBoundsException */ private function extractSessionContainer(?Token $token) : SessionInterface { @@ -194,16 +198,16 @@ private function extractSessionContainer(?Token $token) : SessionInterface } return DefaultSessionData::fromDecodedTokenData( - (object) $token->getClaim(self::SESSION_CLAIM, new \stdClass()) + (object) $token->getClaim(self::SESSION_CLAIM, new stdClass()) ); - } catch (\BadMethodCallException $invalidToken) { + } catch (BadMethodCallException $invalidToken) { return DefaultSessionData::newEmptySession(); } } /** - * @throws \BadMethodCallException - * @throws \InvalidArgumentException + * @throws BadMethodCallException + * @throws InvalidArgumentException */ private function appendToken(SessionInterface $sessionContainer, Response $response, ?Token $token) : Response { @@ -230,7 +234,7 @@ private function shouldTokenBeRefreshed(?Token $token) : bool } /** - * @throws \BadMethodCallException + * @throws BadMethodCallException */ private function getTokenCookie(SessionInterface $sessionContainer) : SetCookie { diff --git a/src/Storageless/Session/DefaultSessionData.php b/src/Storageless/Session/DefaultSessionData.php index f4fef1bc..c884d315 100644 --- a/src/Storageless/Session/DefaultSessionData.php +++ b/src/Storageless/Session/DefaultSessionData.php @@ -21,6 +21,8 @@ namespace PSR7Sessions\Storageless\Session; use InvalidArgumentException; +use JsonSerializable; +use stdClass; use const JSON_PRESERVE_ZERO_FRACTION; use function array_key_exists; use function count; @@ -51,7 +53,7 @@ private function __construct() { } - public static function fromDecodedTokenData(\stdClass $data) : self + public static function fromDecodedTokenData(stdClass $data) : self { $instance = new self(); @@ -157,7 +159,7 @@ public function jsonSerialize() : object } /** - * @param int|bool|string|float|mixed[]|object|\JsonSerializable|null $value + * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value * * @return int|bool|string|float|mixed[] */ diff --git a/src/Storageless/Session/LazySession.php b/src/Storageless/Session/LazySession.php index 4173429b..fa30774a 100644 --- a/src/Storageless/Session/LazySession.php +++ b/src/Storageless/Session/LazySession.php @@ -114,7 +114,6 @@ public function jsonSerialize() : object /** * Get or initialize the session - * */ private function getRealSession() : SessionInterface { @@ -123,7 +122,6 @@ private function getRealSession() : SessionInterface /** * Type-safe wrapper that ensures that the given callback returns the expected type of object, when called - * */ private function loadSession() : SessionInterface { diff --git a/src/Storageless/Session/SessionInterface.php b/src/Storageless/Session/SessionInterface.php index b751d4f0..8e39ed4d 100644 --- a/src/Storageless/Session/SessionInterface.php +++ b/src/Storageless/Session/SessionInterface.php @@ -20,14 +20,15 @@ namespace PSR7Sessions\Storageless\Session; -interface SessionInterface extends \JsonSerializable +use JsonSerializable; + +interface SessionInterface extends JsonSerializable { /** * Stores a given value in the session * - * @param int|bool|string|float|mixed[]|object|\JsonSerializable|null $value allows any nested combination of the previous - * types as well - * + * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value allows any nested combination of the previous + * types as well */ public function set(string $key, $value) : void; @@ -35,7 +36,7 @@ public function set(string $key, $value) : void; * Retrieves a value from the session - if the value doesn't exist, then it uses the given $default, but transformed * into a immutable and safely manipulated scalar or array * - * @param int|bool|string|float|mixed[]|object|\JsonSerializable|null $default + * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $default * * @return int|bool|string|float|mixed[]|null */ diff --git a/test/StoragelessTest/Http/SessionMiddlewareTest.php b/test/StoragelessTest/Http/SessionMiddlewareTest.php index f50eacc1..1b2b0a70 100644 --- a/test/StoragelessTest/Http/SessionMiddlewareTest.php +++ b/test/StoragelessTest/Http/SessionMiddlewareTest.php @@ -20,16 +20,19 @@ namespace PSR7SessionsTest\Storageless\Http; +use DateTime; use DateTimeImmutable; use Dflydev\FigCookies\FigResponseCookies; use Dflydev\FigCookies\Modifier\SameSite; use Dflydev\FigCookies\SetCookie; +use InvalidArgumentException; use Lcobucci\Clock\FrozenClock; use Lcobucci\Clock\SystemClock; use Lcobucci\JWT\Builder; use Lcobucci\JWT\Parser; use Lcobucci\JWT\Signer; use Lcobucci\JWT\Signer\Hmac\Sha256; +use OutOfBoundsException; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; @@ -118,7 +121,7 @@ public function testSessionContainerCanBeReusedOverMultipleRequests(SessionMiddl $sessionValue = uniqid('', true); $checkingMiddleware = $this->fakeDelegate( - function (ServerRequestInterface $request) use ($sessionValue) { + static function (ServerRequestInterface $request) use ($sessionValue) { /** @var SessionInterface $session */ $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE); @@ -155,7 +158,7 @@ public function testSessionContainerCanBeCreatedEvenIfTokenDataIsMalformed(Sessi $sessionValue = uniqid('not valid session data', true); $checkingMiddleware = $this->fakeDelegate( - function (ServerRequestInterface $request) use ($sessionValue) { + static function (ServerRequestInterface $request) use ($sessionValue) { /** @var SessionInterface $session */ $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE); @@ -168,8 +171,8 @@ function (ServerRequestInterface $request) use ($sessionValue) { $this->createTokenWithCustomClaim( $middleware, - new \DateTime('-1 day'), - new \DateTime('+1 day'), + new DateTime('-1 day'), + new DateTime('+1 day'), 'not valid session data' ); @@ -178,8 +181,8 @@ function (ServerRequestInterface $request) use ($sessionValue) { ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => $this->createTokenWithCustomClaim( $middleware, - new \DateTime('-1 day'), - new \DateTime('+1 day'), + new DateTime('-1 day'), + new DateTime('+1 day'), $sessionValue ), ]), @@ -196,8 +199,8 @@ public function testWillIgnoreRequestsWithExpiredTokens(SessionMiddleware $middl ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => $this->createToken( $middleware, - new \DateTime('-1 day'), - new \DateTime('-2 day') + new DateTime('-1 day'), + new DateTime('-2 day') ), ]); @@ -213,8 +216,8 @@ public function testWillIgnoreRequestsWithTokensFromFuture(SessionMiddleware $mi ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => $this->createToken( $middleware, - new \DateTime('+1 day'), - new \DateTime('-2 day') + new DateTime('+1 day'), + new DateTime('-2 day') ), ]); @@ -229,8 +232,8 @@ public function testWillIgnoreUnSignedTokens(SessionMiddleware $middleware) : vo $unsignedToken = (new ServerRequest()) ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => (string) (new Builder()) - ->setIssuedAt((new \DateTime('-1 day'))->getTimestamp()) - ->setExpiration((new \DateTime('+1 day'))->getTimestamp()) + ->setIssuedAt((new DateTime('-1 day'))->getTimestamp()) + ->setExpiration((new DateTime('+1 day'))->getTimestamp()) ->set(SessionMiddleware::SESSION_CLAIM, DefaultSessionData::fromTokenData(['foo' => 'bar'])) ->getToken(), ]); @@ -246,7 +249,7 @@ public function testWillNotRefreshSignedTokensWithoutIssuedAt(SessionMiddleware $unsignedToken = (new ServerRequest()) ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => (string) (new Builder()) - ->setExpiration((new \DateTime('+1 day'))->getTimestamp()) + ->setExpiration((new DateTime('+1 day'))->getTimestamp()) ->set(SessionMiddleware::SESSION_CLAIM, DefaultSessionData::fromTokenData(['foo' => 'bar'])) ->sign($this->getSigner($middleware), $this->getSignatureKey($middleware)) ->getToken(), @@ -260,7 +263,7 @@ public function testWillRefreshTokenWithIssuedAtExactlyAtTokenRefreshTimeThresho // forcing ourselves to think of time as a mutable value: $time = time() + random_int(-100, +100); - $clock = new FrozenClock(new \DateTimeImmutable('@' . $time)); + $clock = new FrozenClock(new DateTimeImmutable('@' . $time)); $middleware = new SessionMiddleware( new Sha256(), @@ -284,7 +287,7 @@ public function testWillRefreshTokenWithIssuedAtExactlyAtTokenRefreshTimeThresho ]); $tokenString = $this - ->getCookie($middleware->process($requestWithTokenIssuedInThePast, $this->fakeDelegate(function () { + ->getCookie($middleware->process($requestWithTokenIssuedInThePast, $this->fakeDelegate(static function () { return new Response(); }))) ->getValue(); @@ -307,7 +310,7 @@ public function testWillSkipInjectingSessionCookiesWhenSessionIsNotChanged(Sessi $middleware->process(new ServerRequest(), $this->writingMiddleware()) ), $this->fakeDelegate( - function (ServerRequestInterface $request) { + static function (ServerRequestInterface $request) { /** @var SessionInterface $session */ $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE); @@ -333,7 +336,7 @@ public function testWillSendExpirationCookieWhenSessionContentsAreCleared(Sessio $middleware->process(new ServerRequest(), $this->writingMiddleware()) ), $this->fakeDelegate( - function (ServerRequestInterface $request) { + static function (ServerRequestInterface $request) { /** @var SessionInterface $session */ $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE); @@ -436,7 +439,7 @@ public function testSessionTokenParsingIsDelayedWhenSessionIsNotBeingUsed() : vo $middleware->process( $request, - $this->fakeDelegate(function (ServerRequestInterface $request) { + $this->fakeDelegate(static function (ServerRequestInterface $request) { self::assertInstanceOf( SessionInterface::class, $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE) @@ -464,8 +467,8 @@ public function testShouldRegenerateTokenWhenRequestHasATokenThatIsAboutToExpire $expiringToken = (new ServerRequest()) ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => (string) (new Builder()) - ->setIssuedAt((new \DateTime('-800 second'))->getTimestamp()) - ->setExpiration((new \DateTime('+200 second'))->getTimestamp()) + ->setIssuedAt((new DateTime('-800 second'))->getTimestamp()) + ->setExpiration((new DateTime('+200 second'))->getTimestamp()) ->set(SessionMiddleware::SESSION_CLAIM, DefaultSessionData::fromTokenData(['foo' => 'bar'])) ->sign($this->getSigner($middleware), $this->getSignatureKey($middleware)) ->getToken(), @@ -473,7 +476,7 @@ public function testShouldRegenerateTokenWhenRequestHasATokenThatIsAboutToExpire $initialResponse = new Response(); - $response = $middleware->process($expiringToken, $this->fakeDelegate(function () use ($initialResponse) { + $response = $middleware->process($expiringToken, $this->fakeDelegate(static function () use ($initialResponse) { return $initialResponse; })); @@ -501,8 +504,8 @@ public function testShouldNotRegenerateTokenWhenRequestHasATokenThatIsFarFromExp $validToken = (new ServerRequest()) ->withCookieParams([ SessionMiddleware::DEFAULT_COOKIE => (string) (new Builder()) - ->setIssuedAt((new \DateTime('-100 second'))->getTimestamp()) - ->setExpiration((new \DateTime('+900 second'))->getTimestamp()) + ->setIssuedAt((new DateTime('-100 second'))->getTimestamp()) + ->setExpiration((new DateTime('+900 second'))->getTimestamp()) ->set(SessionMiddleware::SESSION_CLAIM, DefaultSessionData::fromTokenData(['foo' => 'bar'])) ->sign($this->getSigner($middleware), $this->getSignatureKey($middleware)) ->getToken(), @@ -567,10 +570,10 @@ public function testFromSymmetricKeyDefaultsWillHaveALaxSameSitePolicy() : void } /** - * @group #46 + * @throws InvalidArgumentException + * @throws OutOfBoundsException * - * @throws \InvalidArgumentException - * @throws \OutOfBoundsException + * @group #46 */ public function testFromAsymmetricKeyDefaultsWillHaveADefaultSessionPath() : void { @@ -625,10 +628,12 @@ private function ensureSameResponse( $handleRequest ->expects(self::once()) ->method('handle') - ->willReturnCallback(function (ServerRequestInterface $serverRequest) use ($next, & $initialResponse) { - $initialResponse = $next->handle($serverRequest); + ->willReturnCallback(static function (ServerRequestInterface $serverRequest) use ($next, & $initialResponse) { + $response = $next->handle($serverRequest); - return $initialResponse; + $initialResponse = $response; + + return $response; }); } @@ -648,13 +653,13 @@ private function ensureClearsSessionCookie( $cookie = $this->getCookie($response); - self::assertLessThan((new \DateTime('-29 day'))->getTimestamp(), $cookie->getExpires()); + self::assertLessThan((new DateTime('-29 day'))->getTimestamp(), $cookie->getExpires()); self::assertEmpty($cookie->getValue()); return $response; } - private function createToken(SessionMiddleware $middleware, \DateTime $issuedAt, \DateTime $expiration) : string + private function createToken(SessionMiddleware $middleware, DateTime $issuedAt, DateTime $expiration) : string { return (string) (new Builder()) ->setIssuedAt($issuedAt->getTimestamp()) @@ -667,8 +672,8 @@ private function createToken(SessionMiddleware $middleware, \DateTime $issuedAt, /** @param mixed $claim */ private function createTokenWithCustomClaim( SessionMiddleware $middleware, - \DateTime $issuedAt, - \DateTime $expiration, + DateTime $issuedAt, + DateTime $expiration, $claim ) : string { return (string) (new Builder()) @@ -682,7 +687,7 @@ private function createTokenWithCustomClaim( private function emptyValidationMiddleware() : RequestHandlerInterface { return $this->fakeDelegate( - function (ServerRequestInterface $request) { + static function (ServerRequestInterface $request) { $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE); self::assertInstanceOf(SessionInterface::class, $session); @@ -696,7 +701,7 @@ function (ServerRequestInterface $request) { private function writingMiddleware(string $value = 'bar') : RequestHandlerInterface { return $this->fakeDelegate( - function (ServerRequestInterface $request) use ($value) { + static function (ServerRequestInterface $request) use ($value) { /** @var SessionInterface $session */ $session = $request->getAttribute(SessionMiddleware::SESSION_ATTRIBUTE); $session->set('foo', $value); @@ -720,7 +725,6 @@ private function fakeDelegate(callable $callback) : RequestHandlerInterface } /** - * * @return ServerRequest */ private function requestWithResponseCookies(ResponseInterface $response) : ServerRequestInterface diff --git a/test/StoragelessTest/Session/DefaultSessionDataTest.php b/test/StoragelessTest/Session/DefaultSessionDataTest.php index e0a47d6c..64ce479f 100644 --- a/test/StoragelessTest/Session/DefaultSessionDataTest.php +++ b/test/StoragelessTest/Session/DefaultSessionDataTest.php @@ -24,6 +24,7 @@ use JsonSerializable; use PHPUnit\Framework\TestCase; use PSR7Sessions\Storageless\Session\DefaultSessionData; +use ReflectionClass; use stdClass; use const PHP_INT_MAX; use const PHP_INT_MIN; @@ -104,9 +105,9 @@ public function testStorageKeysAreConvertedToStringKeys() : void } /** - * @dataProvider storageScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value + * + * @dataProvider storageScalarDataProvider */ public function testContainerDataIsStoredAndRetrieved(string $key, $value) : void { @@ -117,9 +118,9 @@ public function testContainerDataIsStoredAndRetrieved(string $key, $value) : voi } /** - * @dataProvider storageScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value + * + * @dataProvider storageScalarDataProvider */ public function testSettingDataInAContainerMarksTheContainerAsMutated(string $key, $value) : void { @@ -146,9 +147,9 @@ public function testChangingTheDataTypeOfAValueIsConsideredAsAChange() : void } /** - * @dataProvider storageScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value + * + * @dataProvider storageScalarDataProvider */ public function testContainerIsNotChangedWhenScalarDataIsSetAndOverwrittenInIt(string $key, $value) : void { @@ -162,9 +163,9 @@ public function testContainerIsNotChangedWhenScalarDataIsSetAndOverwrittenInIt(s } /** - * @dataProvider storageNonScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $nonScalarValue + * + * @dataProvider storageNonScalarDataProvider */ public function testContainerIsNotChangedWhenNonScalarDataIsSetAndOverwrittenInIt($nonScalarValue) : void { @@ -178,9 +179,9 @@ public function testContainerIsNotChangedWhenNonScalarDataIsSetAndOverwrittenInI } /** - * @dataProvider storageScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value + * + * @dataProvider storageScalarDataProvider */ public function testContainerBuiltWithDataContainsData(string $key, $value) : void { @@ -191,9 +192,9 @@ public function testContainerBuiltWithDataContainsData(string $key, $value) : vo } /** - * @dataProvider storageScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value + * + * @dataProvider storageScalarDataProvider */ public function testContainerBuiltWithStdClassContainsData(string $key, $value) : void { @@ -208,10 +209,10 @@ public function testContainerBuiltWithStdClassContainsData(string $key, $value) } /** - * @dataProvider storageNonScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $nonScalar * @param int|bool|string|float|mixed[]|null $expectedScalar + * + * @dataProvider storageNonScalarDataProvider */ public function testContainerStoresScalarValueFromNestedObjects($nonScalar, $expectedScalar) : void { @@ -225,9 +226,9 @@ public function testContainerStoresScalarValueFromNestedObjects($nonScalar, $exp } /** - * @dataProvider storageScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $value + * + * @dataProvider storageScalarDataProvider */ public function testGetWillReturnDefaultValueOnNonExistingKey(string $key, $value) : void { @@ -238,10 +239,10 @@ public function testGetWillReturnDefaultValueOnNonExistingKey(string $key, $valu } /** - * @dataProvider storageNonScalarDataProvider - * * @param int|bool|string|float|mixed[]|object|JsonSerializable|null $nonScalar * @param int|bool|string|float|mixed[]|null $expectedScalar + * + * @dataProvider storageNonScalarDataProvider */ public function testGetWillReturnScalarCastDefaultValueOnNonExistingKey($nonScalar, $expectedScalar) : void { @@ -250,7 +251,7 @@ public function testGetWillReturnScalarCastDefaultValueOnNonExistingKey($nonScal public function testAllMethodsAreCoveredByAnInterfacedMethod() : void { - $reflection = new \ReflectionClass(DefaultSessionData::class); + $reflection = new ReflectionClass(DefaultSessionData::class); $interfaces = $reflection->getInterfaces(); foreach ($reflection->getMethods() as $method) { @@ -260,7 +261,7 @@ public function testAllMethodsAreCoveredByAnInterfacedMethod() : void self::assertNotEmpty(array_filter( $interfaces, - function (\ReflectionClass $interface) use ($method) { + 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 89cf4baf..77b59fbe 100644 --- a/test/StoragelessTest/Session/LazySessionTest.php +++ b/test/StoragelessTest/Session/LazySessionTest.php @@ -24,6 +24,7 @@ use PHPUnit\Framework\TestCase; use PSR7Sessions\Storageless\Session\LazySession; use PSR7Sessions\Storageless\Session\SessionInterface; +use stdClass; use function uniqid; /** @@ -47,7 +48,7 @@ protected function setUp() : void { $this->wrappedSession = $this->createMock(SessionInterface::class); /** @var callable|MockObject $sessionLoader */ - $sessionLoader = $this->getMockBuilder(\stdClass::class)->setMethods(['__invoke'])->getMock(); + $sessionLoader = $this->getMockBuilder(stdClass::class)->setMethods(['__invoke'])->getMock(); $this->sessionLoader = $sessionLoader; $this->lazySession = LazySession::fromContainerBuildingCallback($this->sessionLoader); }