8000 bug #41495 [HttpFoundation] Add ReturnTypeWillChange to SessionHandle… · symfony/symfony@b439213 · GitHub
[go: up one dir, main page]

Skip to content

Commit b439213

Browse files
committed
bug #41495 [HttpFoundation] Add ReturnTypeWillChange to SessionHandlers (nikic)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- [HttpFoundation] Add ReturnTypeWillChange to SessionHandlers | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | maybe? | Tickets | | License | MIT | Doc PR | <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch 5.x. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry --> This adds `#[ReturnTypeWillChange]` annotations for `SessionHandler` methods to satisfy the [Tentative Return Types RFC](https://wiki.php.net/rfc/internal_method_return_types). This doesn't cover all classes (e.g. `MockPdo` is also affected), just the ones relating to `SessionHandler` etc. It's worth noting that the `gc()` method is spec'd as `int|false` on our side, so I've updated type hints accordingly. The method used to return bool prior to PHP 7.1. Commits ------- 8954b4f [HttpFoundation] Add ReturnTypeWillChange to SessionHandlers
2 parents ca61cd6 + 8954b4f commit b439213

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/AbstractSessionHandler.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ abstract class AbstractSessionHandler implements \SessionHandlerInterface, \Sess
3131
/**
3232
* @return bool
3333
*/
34+
#[\ReturnTypeWillChange]
3435
public function open($savePath, $sessionName)
3536
{
3637
$this->sessionName = $sessionName;
@@ -66,6 +67,7 @@ abstract protected function doDestroy($sessionId);
6667
/**
6768
* @return bool
6869
*/
70+
#[\ReturnTypeWillChange]
6971
public function validateId($sessionId)
7072
{
7173
$this->prefetchData = $this->read($sessionId);
@@ -86,6 +88,7 @@ public function validateId($sessionId)
8688
/**
8789
* @return string
8890
*/
91+
#[\ReturnTypeWillChange]
8992
public function read($sessionId)
9093
{
9194
if (null !== $this->prefetchId) {
@@ -109,6 +112,7 @@ public function read($sessionId)
109112
/**
110113
* @return bool
111114
*/
115+
#[\ReturnTypeWillChange]
112116
public function write($sessionId, $data)
113117
{
114118
if (null === $this->igbinaryEmptyData) {
@@ -126,6 +130,7 @@ public function write($sessionId, $data)
126130
/**
127131
* @return bool
128132
*/
133+
#[\ReturnTypeWillChange]
129134
public function destroy($sessionId)
130135
{
131136
if (!headers_sent() && filter_var(ini_get('session.use_cookies'), \FILTER_VALIDATE_BOOLEAN)) {

src/Symfony/Component/HttpFoundation/Session/Storage/Handler/StrictSessionHandler.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public function __construct(\SessionHandlerInterface $handler)
3333
/**
3434
* @return bool
3535
*/
36+
#[\ReturnTypeWillChange]
3637
public function open($savePath, $sessionName)
3738
{
3839
parent::open($savePath, $sessionName);
@@ -51,6 +52,7 @@ protected function doRead($sessionId)
5152
/**
5253
* @return bool
5354
*/
55+
#[\ReturnTypeWillChange]
5456
public function updateTimestamp($sessionId, $data)
5557
{
5658
return $this->write($sessionId, $data);
@@ -67,6 +69,7 @@ protected function doWrite($sessionId, $data)
6769
/**
6870
* @return bool
6971
*/
72+
#[\ReturnTypeWillChange]
7073
public function destroy($sessionId)
7174
{
7275
$this->doDestroy = true;
@@ -88,14 +91,16 @@ protected function doDestroy($sessionId)
8891
/**
8992
* @return bool
9093
*/
94+
#[\ReturnTypeWillChange]
9195
public function close()
9296
{
9397
return $this->handler->close();
9498
}
9599

96100
/**
97-
* @return bool
101+
* @return int|false
98102
*/
103+
#[\ReturnTypeWillChange]
99104
public function gc($maxlifetime)
100105
{
101106
return $this->handler->gc($maxlifetime);

src/Symfony/Component/HttpFoundation/Session/Storage/Proxy/SessionHandlerProxy.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function getHandler()
3838
/**
3939
* @return bool
4040
*/
41+
#[\ReturnTypeWillChange]
4142
public function open($savePath, $sessionName)
4243
{
4344
return (bool) $this->handler->open($savePath, $sessionName);
@@ -46,6 +47,7 @@ public function open($savePath, $sessionName)
4647
/**
4748
* @return bool
4849
*/
50+
#[\ReturnTypeWillChange]
4951
public function close()
5052
{
5153
return (bool) $this->handler->close();
@@ -54,6 +56,7 @@ public function close()
5456
/**
5557
* @return string
5658
*/
59+
#[\ReturnTypeWillChange]
5760
public function read($sessionId)
5861
{
5962
return (string) $this->handler->read($sessionId);
@@ -62,6 +65,7 @@ public function read($sessionId)
6265
/**
6366
* @return bool
6467
*/
68+
#[\ReturnTypeWillChange]
6569
public function write($sessionId, $data)
6670
{
6771
return (bool) $this->handler->write($sessionId, $data);
@@ -70,22 +74,25 @@ public function write($sessionId, $data)
7074
/**
7175
* @return bool
7276
*/
77+
#[\ReturnTypeWillChange]
7378
public function destroy($sessionId)
7479
{
7580
return (bool) $this->handler->destroy($sessionId);
7681
}
7782

7883
/**
79-
* @return bool
84+
* @return int|false
8085
*/
86+
#[\ReturnTypeWillChange]
8187
public function gc($maxlifetime)
8288
{
83-
return (bool) $this->handler->gc($maxlifetime);
89+
return $this->handler->gc($maxlifetime);
8490
}
8591

8692
/**
8793
* @return bool
8894
*/
95+
#[\ReturnTypeWillChange]
8996
public function validateId($sessionId)
9097
{
9198
return !$this->handler instanceof \SessionUpdateTimestampHandlerInterface || $this->handler->validateId($sessionId);
@@ -94,6 +101,7 @@ public function validateId($sessionId)
94101
/**
95102
* @return bool
96103
*/
104+
#[\ReturnTypeWillChange]
97105
public function updateTimestamp($sessionId, $data)
98106
{
99107
return $this->handler instanceof \SessionUpdateTimestampHandlerInterface ? $this->handler->updateTimestamp($sessionId, $data) : $this->write($sessionId, $data);

0 commit comments

Comments
 (0)
0