PHP 8.1 and symfony/error handler deprecations (#748)

* Be sure that position always have type integer

* Annotate properly return types for SPL interfaces implementation

It is allows avoiding deprecation messages from `symfony/error-handler` like a '[info] User Deprecated: Method "Iterator::rewind()" might add "void" as a native return type declaration in the future. Do the same in implementation "Predis\Collection\Iterator\CursorBasedIterator" now to avoid errors or add an explicit @return annotation to suppress this message.'

Fixed via `symfony/error-handler` patch script: ` SYMFONY_PATCH_TYPE_DECLARATIONS="force=phpdoc&php=5.3" ./vendor/bin/patch-type-declarations` and some additional manual work

Some details about why this is necessary and how checks with trigger deprecations works: https://wouterj.nl/2021/09/symfony-6-native-typing
This commit is contained in:
Andrii Dembitskyi
2022-03-15 13:50:51 -04:00
committed by GitHub
parent 213f00042f
commit acb2460f4c
8 changed files with 32 additions and 2 deletions
@@ -138,6 +138,7 @@ abstract class CursorBasedIterator implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
@@ -148,6 +149,7 @@ abstract class CursorBasedIterator implements \Iterator
/**
* {@inheritdoc}
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
@@ -157,6 +159,7 @@ abstract class CursorBasedIterator implements \Iterator
/**
* {@inheritdoc}
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
@@ -166,6 +169,7 @@ abstract class CursorBasedIterator implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
@@ -187,6 +191,7 @@ abstract class CursorBasedIterator implements \Iterator
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
+5
View File
@@ -127,6 +127,7 @@ class ListKey implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
@@ -137,6 +138,7 @@ class ListKey implements \Iterator
/**
* {@inheritdoc}
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
@@ -146,6 +148,7 @@ class ListKey implements \Iterator
/**
* {@inheritdoc}
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
@@ -155,6 +158,7 @@ class ListKey implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
@@ -172,6 +176,7 @@ class ListKey implements \Iterator
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
+3
View File
@@ -99,6 +99,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface
/**
* {@inheritdoc}
* @return ProcessorInterface|null
*/
#[\ReturnTypeWillChange]
public function offsetGet($index)
@@ -108,6 +109,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($index, $processor)
@@ -124,6 +126,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($index)
+4 -1
View File
@@ -24,7 +24,7 @@ class Consumer implements \Iterator
{
private $client;
private $valid;
private $position;
private $position = 0;
/**
* @param ClientInterface $client Client instance used by the consumer.
@@ -90,6 +90,7 @@ class Consumer implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
@@ -110,6 +111,7 @@ class Consumer implements \Iterator
/**
* {@inheritdoc}
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
@@ -119,6 +121,7 @@ class Consumer implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
+3 -1
View File
@@ -30,7 +30,7 @@ abstract class AbstractConsumer implements \Iterator
const STATUS_SUBSCRIBED = 2; // 0b0010
const STATUS_PSUBSCRIBED = 4; // 0b0100
private $position = null;
private $position = 0;
private $statusFlags = self::STATUS_VALID;
/**
@@ -150,6 +150,7 @@ abstract class AbstractConsumer implements \Iterator
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
@@ -171,6 +172,7 @@ abstract class AbstractConsumer implements \Iterator
/**
* {@inheritdoc}
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
@@ -33,6 +33,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function rewind()
@@ -42,6 +43,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
/**
* {@inheritdoc}
* @return mixed
*/
#[\ReturnTypeWillChange]
public function current()
@@ -51,6 +53,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
/**
* {@inheritdoc}
* @return int
*/
#[\ReturnTypeWillChange]
public function key()
@@ -60,6 +63,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
/**
* {@inheritdoc}
* @return void
*/
#[\ReturnTypeWillChange]
public function next()
@@ -71,6 +75,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function valid()
+1
View File
@@ -60,6 +60,7 @@ class MultiBulkTuple extends MultiBulk implements \OuterIterator
/**
* {@inheritdoc}
* @return \Iterator
*/
#[\ReturnTypeWillChange]
public function getInnerIterator()
+6
View File
@@ -64,6 +64,7 @@ class Handler implements \SessionHandlerInterface
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function open($save_path, $session_id)
@@ -74,6 +75,7 @@ class Handler implements \SessionHandlerInterface
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function close()
@@ -84,6 +86,7 @@ class Handler implements \SessionHandlerInterface
/**
* {@inheritdoc}
* @return int|bool
*/
#[\ReturnTypeWillChange]
public function gc($maxlifetime)
@@ -94,6 +97,7 @@ class Handler implements \SessionHandlerInterface
/**
* {@inheritdoc}
* @return string
*/
#[\ReturnTypeWillChange]
public function read($session_id)
@@ -106,6 +110,7 @@ class Handler implements \SessionHandlerInterface
}
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function write($session_id, $session_data)
@@ -117,6 +122,7 @@ class Handler implements \SessionHandlerInterface
/**
* {@inheritdoc}
* @return bool
*/
#[\ReturnTypeWillChange]
public function destroy($session_id)