Predis to v2.2.2

This commit is contained in:
the-djmaze 2024-04-02 20:15:23 +02:00
parent f6b440adef
commit 84ffe1e552
259 changed files with 2407 additions and 9937 deletions

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -14,8 +15,6 @@ namespace Predis\Response;
/**
* Represents an error returned by Redis (-ERR responses) during the execution
* of a command on the server.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
class Error implements ErrorInterface
{
@ -42,7 +41,7 @@ class Error implements ErrorInterface
*/
public function getErrorType()
{
list($errorType) = explode(' ', $this->getMessage(), 2);
[$errorType] = explode(' ', $this->getMessage(), 2);
return $errorType;
}

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -14,8 +15,6 @@ namespace Predis\Response;
/**
* Represents an error returned by Redis (responses identified by "-" in the
* Redis protocol) during the execution of an operation on the server.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
interface ErrorInterface extends ResponseInterface
{

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -15,8 +16,6 @@ use Predis\Connection\NodeConnectionInterface;
/**
* Streamable multibulk response.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
class MultiBulk extends MultiBulkIterator
{

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -11,7 +12,10 @@
namespace Predis\Response\Iterator;
use Countable;
use Iterator;
use Predis\Response\ResponseInterface;
use ReturnTypeWillChange;
/**
* Iterator that abstracts the access to multibulk responses allowing them to be
@ -22,42 +26,44 @@ use Predis\Response\ResponseInterface;
*
* Always make sure that the whole iteration is consumed (or dropped) to prevent
* protocol desynchronization issues.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInterface
abstract class MultiBulkIterator implements Iterator, Countable, ResponseInterface
{
protected $current;
protected $position;
protected $size;
/**
* {@inheritdoc}
* @return void
*/
#[ReturnTypeWillChange]
public function rewind()
{
// NOOP
}
/**
* {@inheritdoc}
* @return mixed
*/
#[ReturnTypeWillChange]
public function current()
{
return $this->current;
}
/**
* {@inheritdoc}
* @return int|null
*/
#[ReturnTypeWillChange]
public function key()
{
return $this->position;
}
/**
* {@inheritdoc}
* @return void
*/
#[ReturnTypeWillChange]
public function next()
{
if (++$this->position < $this->size) {
@ -66,8 +72,9 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
}
/**
* {@inheritdoc}
* @return bool
*/
#[ReturnTypeWillChange]
public function valid()
{
return $this->position < $this->size;
@ -82,6 +89,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter
*
* @return int
*/
#[ReturnTypeWillChange]
public function count()
{
return $this->size;

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -11,16 +12,19 @@
namespace Predis\Response\Iterator;
use InvalidArgumentException;
use OuterIterator;
use ReturnTypeWillChange;
use UnexpectedValueException;
/**
* Outer iterator consuming streamable multibulk responses by yielding tuples of
* keys and values.
*
* This wrapper is useful for responses to commands such as `HGETALL` that can
* be iterater as $key => $value pairs.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
* be iterator as $key => $value pairs.
*/
class MultiBulkTuple extends MultiBulk implements \OuterIterator
class MultiBulkTuple extends MultiBulk implements OuterIterator
{
private $iterator;
@ -42,25 +46,26 @@ class MultiBulkTuple extends MultiBulk implements \OuterIterator
*
* @param MultiBulk $iterator Inner multibulk response iterator.
*
* @throws \InvalidArgumentException
* @throws \UnexpectedValueException
* @throws InvalidArgumentException
* @throws UnexpectedValueException
*/
protected function checkPreconditions(MultiBulk $iterator)
{
if ($iterator->getPosition() !== 0) {
throw new \InvalidArgumentException(
throw new InvalidArgumentException(
'Cannot initialize a tuple iterator using an already initiated iterator.'
);
}
if (($size = count($iterator)) % 2 !== 0) {
throw new \UnexpectedValueException('Invalid response size for a tuple iterator.');
throw new UnexpectedValueException('Invalid response size for a tuple iterator.');
}
}
/**
* {@inheritdoc}
* @return MultiBulk
*/
#[ReturnTypeWillChange]
public function getInnerIterator()
{
return $this->iterator;
@ -85,6 +90,6 @@ class MultiBulkTuple extends MultiBulk implements \OuterIterator
$v = $this->iterator->current();
$this->iterator->next();
return array($k, $v);
return [$k, $v];
}
}

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -13,8 +14,6 @@ namespace Predis\Response;
/**
* Represents a complex response object from Redis.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
interface ResponseInterface
{

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -15,8 +16,6 @@ use Predis\PredisException;
/**
* Exception class that identifies server-side Redis errors.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
class ServerException extends PredisException implements ErrorInterface
{
@ -27,7 +26,7 @@ class ServerException extends PredisException implements ErrorInterface
*/
public function getErrorType()
{
list($errorType) = explode(' ', $this->getMessage(), 2);
[$errorType] = explode(' ', $this->getMessage(), 2);
return $errorType;
}

View file

@ -3,7 +3,8 @@
/*
* This file is part of the Predis package.
*
* (c) Daniele Alessandri <suppakilla@gmail.com>
* (c) 2009-2020 Daniele Alessandri
* (c) 2021-2023 Till Krüss
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
@ -13,8 +14,6 @@ namespace Predis\Response;
/**
* Represents a status response returned by Redis.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
class Status implements ResponseInterface
{
@ -59,7 +58,7 @@ class Status implements ResponseInterface
*
* @param string $payload Status response payload.
*
* @return string
* @return self
*/
public static function get($payload)
{