mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 12:09:20 +03:00
Predis to v2.2.2
This commit is contained in:
parent
f6b440adef
commit
84ffe1e552
259 changed files with 2407 additions and 9937 deletions
|
|
@ -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];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue