diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php index c6b16d11c8..c3e7ef6e60 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/MigratingSessionHandler.php @@ -41,6 +41,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function close() { $result = $this->currentHandler->close(); @@ -52,6 +53,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function destroy($sessionId) { $result = $this->currentHandler->destroy($sessionId); @@ -63,6 +65,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function gc($maxlifetime) { $result = $this->currentHandler->gc($maxlifetime); @@ -74,6 +77,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function open($savePath, $sessionName) { $result = $this->currentHandler->open($savePath, $sessionName); @@ -85,6 +89,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return string */ + #[\ReturnTypeWillChange] public function read($sessionId) { // No reading from new handler until switch-over @@ -94,6 +99,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function write($sessionId, $sessionData) { $result = $this->currentHandler->write($sessionId, $sessionData); @@ -105,6 +111,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function validateId($sessionId) { // No reading from new handler until switch-over @@ -114,6 +121,7 @@ class MigratingSessionHandler implements \SessionHandlerInterface, \SessionUpdat /** * @return bool */ + #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $sessionData) { $result = $this->currentHandler->updateTimestamp($sessionId, $sessionData); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php index 0634e46dd5..c34c25edbb 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/NullSessionHandler.php @@ -21,6 +21,7 @@ class NullSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function close() { return true; @@ -29,6 +30,7 @@ class NullSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function validateId($sessionId) { return true; @@ -45,6 +47,7 @@ class NullSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $data) { return true; @@ -69,6 +72,7 @@ class NullSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function gc($maxlifetime) { return true; diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php index db74187760..d3c5651d41 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/Handler/PdoSessionHandler.php @@ -262,6 +262,7 @@ class PdoSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function open($savePath, $sessionName) { $this->sessionExpired = false; @@ -276,6 +277,7 @@ class PdoSessionHandler extends AbstractSessionHandler /** * @return string */ + #[\ReturnTypeWillChange] public function read($sessionId) { try { @@ -290,6 +292,7 @@ class PdoSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function gc($maxlifetime) { // We delay gc() to close() so that it is executed outside the transactional and blocking read-write process. @@ -369,6 +372,7 @@ class PdoSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function updateTimestamp($sessionId, $data) { $expiry = time() + (int) ini_get('session.gc_maxlifetime'); @@ -393,6 +397,7 @@ class PdoSessionHandler extends AbstractSessionHandler /** * @return bool */ + #[\ReturnTypeWillChange] public function close() { $this->commit(); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php index 01615e6b1f..f56f753af6 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MigratingSessionHandlerTest.php @@ -75,15 +75,14 @@ class MigratingSessionHandlerTest extends TestCase $this->currentHandler->expects($this->once()) ->method('gc') ->with($maxlifetime) - ->willReturn(true); + ->willReturn(1); $this->writeOnlyHandler->expects($this->once()) ->method('gc') ->with($maxlifetime) ->willReturn(false); - $result = $this->dualHandler->gc($maxlifetime); - $this->assertTrue($result); + $this->assertSame(1, $this->dualHandler->gc($maxlifetime)); } public function testOpen() diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index c731180916..79ab73c1a4 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -371,6 +371,10 @@ class MockPdo extends \PDO $this->errorMode = null !== $errorMode ?: \PDO::ERRMODE_EXCEPTION; } + /** + * @return mixed + */ + #[\ReturnTypeWillChange] public function getAttribute($attribute) { if (\PDO::ATTR_ERRMODE === $attribute) { @@ -384,6 +388,10 @@ class MockPdo extends \PDO return parent::getAttribute($attribute); } + /** + * @return false|\PDOStatement + */ + #[\ReturnTypeWillChange] public function prepare($statement, $driverOptions = []) { return \is_callable($this->prepareResult) @@ -391,11 +399,13 @@ class MockPdo extends \PDO : $this->prepareResult; } - public function beginTransaction() + public function beginTransaction(): bool { + return true; } - public function rollBack() + public function rollBack(): bool { + return true; } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php index 353b1a02ec..4f91016ac5 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/StrictSessionHandlerTest.php @@ -181,9 +181,9 @@ class StrictSessionHandlerTest extends TestCase { $handler = $this->createMock(\SessionHandlerInterface::class); $handler->expects($this->once())->method('gc') - ->with(123)->willReturn(true); + ->with(123)->willReturn(1); $proxy = new StrictSessionHandler($handler); - $this->assertTrue($proxy->gc(123)); + $this->assertSame(1, $proxy->gc(123)); } } diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php index 27bf3e27a6..1422eccfbc 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Proxy/SessionHandlerProxyTest.php @@ -93,7 +93,9 @@ class SessionHandlerProxyTest extends TestCase public function testRead() { $this->mock->expects($this->once()) - ->method('read'); + ->method('read') + ->willReturn('foo') + ; $this->proxy->read('id'); } @@ -117,7 +119,9 @@ class SessionHandlerProxyTest extends TestCase public function testGc() { $this->mock->expects($this->once()) - ->method('gc'); + ->method('gc') + ->willReturn(1) + ; $this->proxy->gc(86400); }