minor #41626 [HttpFoundation] Handle new tentative return types (derrabus)
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpFoundation] Handle new tentative return types
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | Part of #41552
| License | MIT
| Doc PR | N/A
Commits
-------
1d24bce18f
[HttpFoundation] Handle tentative return types
This commit is contained in:
commit
c17ed9ee5d
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user