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.
@ -12,52 +13,45 @@
namespace Predis\Command;
/**
* Class for generic "anonymous" Redis commands.
* Class representing a generic Redis command.
*
* This command class does not filter input arguments or parse responses, but
* can be used to leverage the standard Predis API to execute any command simply
* by providing the needed arguments following the command signature as defined
* by Redis in its documentation.
* Arguments and responses for these commands are not normalized and they follow
* what is defined by the Redis documentation.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
* Raw commands can be useful when implementing higher level abstractions on top
* of Predis\Client or managing internals like Redis Sentinel or Cluster as they
* are not potentially subject to hijacking from third party libraries when they
* override command handlers for standard Redis commands.
*/
class RawCommand implements CommandInterface
final class RawCommand implements CommandInterface
{
private $slot;
private $commandID;
private $arguments;
/**
* @param array $arguments Command ID and its arguments.
*
* @throws \InvalidArgumentException
* @param string $commandID Command ID
* @param array $arguments Command arguments
*/
public function __construct(array $arguments)
public function __construct($commandID, array $arguments = [])
{
if (!$arguments) {
throw new \InvalidArgumentException(
'The arguments array must contain at least the command ID.'
);
}
$this->commandID = strtoupper(array_shift($arguments));
$this->arguments = $arguments;
$this->commandID = strtoupper($commandID);
$this->setArguments($arguments);
}
/**
* Creates a new raw command using a variadic method.
*
* @param string $commandID Redis command ID.
* @param string ... Arguments list for the command.
* @param string $commandID Redis command ID
* @param string ...$args Arguments list for the command
*
* @return CommandInterface
*/
public static function create($commandID /* [ $arg, ... */)
public static function create($commandID, ...$args)
{
$arguments = func_get_args();
$command = new self($arguments);
return $command;
return new static(array_shift($arguments), $arguments);
}
/**
@ -116,9 +110,7 @@ class RawCommand implements CommandInterface
*/
public function getSlot()
{
if (isset($this->slot)) {
return $this->slot;
}
return $this->slot ?? null;
}
/**