diff --git a/src/Client.php b/src/Client.php index d70fa676..0b3c051f 100644 --- a/src/Client.php +++ b/src/Client.php @@ -29,6 +29,10 @@ use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ResponseInterface; use Predis\Response\ServerException; use Predis\Transaction\MultiExec as MultiExecTransaction; +use IteratorAggregate; +use ReturnTypeWillChange; +use ArrayIterator; +use InvalidArgumentException; /** * Client class used for connecting and executing commands on Redis. @@ -39,7 +43,7 @@ use Predis\Transaction\MultiExec as MultiExecTransaction; * * @template-implements \IteratorAggregate */ -class Client implements ClientInterface, \IteratorAggregate +class Client implements ClientInterface, IteratorAggregate { const VERSION = '2.1.1'; @@ -68,7 +72,7 @@ class Client implements ClientInterface, \IteratorAggregate * * @param array|OptionsInterface $options Set of client options * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return OptionsInterface */ @@ -79,7 +83,7 @@ class Client implements ClientInterface, \IteratorAggregate } elseif ($options instanceof OptionsInterface) { return $options; } else { - throw new \InvalidArgumentException('Invalid type for client options'); + throw new InvalidArgumentException('Invalid type for client options'); } } @@ -104,7 +108,7 @@ class Client implements ClientInterface, \IteratorAggregate * @param OptionsInterface $options Client options container * @param mixed $parameters Connection parameters * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return ConnectionInterface */ @@ -128,7 +132,7 @@ class Client implements ClientInterface, \IteratorAggregate } elseif ($options->defined('aggregate') && $initializer = $options->aggregate) { return $initializer($parameters, false); } else { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'Array of connection parameters requires `cluster`, `replication` or `aggregate` client option' ); } @@ -138,13 +142,13 @@ class Client implements ClientInterface, \IteratorAggregate $connection = call_user_func($parameters, $options); if (!$connection instanceof ConnectionInterface) { - throw new \InvalidArgumentException('Callable parameters must return a valid connection'); + throw new InvalidArgumentException('Callable parameters must return a valid connection'); } return $connection; } - throw new \InvalidArgumentException('Invalid type for connection parameters'); + throw new InvalidArgumentException('Invalid type for connection parameters'); } /** @@ -198,16 +202,16 @@ class Client implements ClientInterface, \IteratorAggregate $selector = strtolower($selector); if (!in_array($selector, ['id', 'key', 'slot', 'role', 'alias', 'command'])) { - throw new \InvalidArgumentException("Invalid selector type: `$selector`"); + throw new InvalidArgumentException("Invalid selector type: `$selector`"); } if (!method_exists($this->connection, $method = "getConnectionBy$selector")) { $class = get_class($this->connection); - throw new \InvalidArgumentException("Selecting connection by $selector is not supported by $class"); + throw new InvalidArgumentException("Selecting connection by $selector is not supported by $class"); } if (!$connection = $this->connection->$method($value)) { - throw new \InvalidArgumentException("Cannot find a connection by $selector matching `$value`"); + throw new InvalidArgumentException("Cannot find a connection by $selector matching `$value`"); } return new static($connection, $this->getOptions()); @@ -514,14 +518,14 @@ class Client implements ClientInterface, \IteratorAggregate /** * @return Traversable */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function getIterator() { $clients = []; $connection = $this->getConnection(); if (!$connection instanceof Traversable) { - return new \ArrayIterator([ + return new ArrayIterator([ (string) $connection => new static($connection, $this->getOptions()) ]); } @@ -530,6 +534,6 @@ class Client implements ClientInterface, \IteratorAggregate $clients[(string) $node] = new static($node, $this->getOptions()); } - return new \ArrayIterator($clients); + return new ArrayIterator($clients); } } diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index a693e172..509f4834 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -14,6 +14,7 @@ namespace Predis\Cluster; use Predis\Command\CommandInterface; use Predis\Command\ScriptCommand; +use InvalidArgumentException; /** * Common class implementing the logic needed to support clustering strategies. @@ -197,7 +198,7 @@ abstract class ClusterStrategy implements StrategyInterface * @param string $commandID Command ID. * @param mixed $callback A valid callable object, or NULL to unset the handler. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function setCommandHandler($commandID, $callback = null) { @@ -210,7 +211,7 @@ abstract class ClusterStrategy implements StrategyInterface } if (!is_callable($callback)) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'The argument must be a callable object or NULL.' ); } diff --git a/src/Cluster/Distributor/EmptyRingException.php b/src/Cluster/Distributor/EmptyRingException.php index b919ea3b..481451fa 100644 --- a/src/Cluster/Distributor/EmptyRingException.php +++ b/src/Cluster/Distributor/EmptyRingException.php @@ -11,10 +11,11 @@ */ namespace Predis\Cluster\Distributor; +use Exception; /** * Exception class that identifies empty rings. */ -class EmptyRingException extends \Exception +class EmptyRingException extends Exception { } diff --git a/src/Cluster/SlotMap.php b/src/Cluster/SlotMap.php index 0784e716..3dae34cb 100644 --- a/src/Cluster/SlotMap.php +++ b/src/Cluster/SlotMap.php @@ -11,11 +11,17 @@ */ namespace Predis\Cluster; +use ArrayAccess; +use IteratorAggregate; +use Countable; +use ReturnTypeWillChange; +use ArrayIterator; +use OutOfBoundsException; /** * Slot map for redis-cluster. */ -class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable +class SlotMap implements ArrayAccess, IteratorAggregate, Countable { private $slots = []; @@ -91,12 +97,12 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable * @param int $last Last slot of the range. * @param NodeConnectionInterface|string $connection ID or connection instance. * - * @throws \OutOfBoundsException + * @throws OutOfBoundsException */ public function setSlots($first, $last, $connection) { if (!static::isValidRange($first, $last)) { - throw new \OutOfBoundsException("Invalid slot range $first-$last for `$connection`"); + throw new OutOfBoundsException("Invalid slot range $first-$last for `$connection`"); } $this->slots += array_fill($first, $last - $first + 1, (string) $connection); @@ -113,7 +119,7 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable public function getSlots($first, $last) { if (!static::isValidRange($first, $last)) { - throw new \OutOfBoundsException("Invalid slot range $first-$last"); + throw new OutOfBoundsException("Invalid slot range $first-$last"); } return array_intersect_key($this->slots, array_fill($first, $last - $first + 1, null)); @@ -126,7 +132,7 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable * * @return bool */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetExists($slot) { return isset($this->slots[$slot]); @@ -139,7 +145,7 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable * * @return string */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetGet($slot) { if (isset($this->slots[$slot])) { @@ -155,11 +161,11 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable * * @return string */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetSet($slot, $connection) { if (!static::isValid($slot)) { - throw new \OutOfBoundsException("Invalid slot $slot for `$connection`"); + throw new OutOfBoundsException("Invalid slot $slot for `$connection`"); } $this->slots[(int) $slot] = (string) $connection; @@ -172,7 +178,7 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable * * @return string */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetUnset($slot) { unset($this->slots[$slot]); @@ -183,7 +189,7 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable * * @return int */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function count() { return count($this->slots); @@ -192,11 +198,11 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable /** * Returns an iterator over the slot map. * - * @return \ArrayIterator + * @return ArrayIterator */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function getIterator() { - return new \ArrayIterator($this->slots); + return new ArrayIterator($this->slots); } } diff --git a/src/Collection/Iterator/CursorBasedIterator.php b/src/Collection/Iterator/CursorBasedIterator.php index 4a5413b4..28aed560 100644 --- a/src/Collection/Iterator/CursorBasedIterator.php +++ b/src/Collection/Iterator/CursorBasedIterator.php @@ -14,6 +14,8 @@ namespace Predis\Collection\Iterator; use Predis\ClientInterface; use Predis\NotSupportedException; +use Iterator; +use ReturnTypeWillChange; /** * Provides the base implementation for a fully-rewindable PHP iterator that can @@ -26,7 +28,7 @@ use Predis\NotSupportedException; * * @see http://redis.io/commands/scan */ -abstract class CursorBasedIterator implements \Iterator +abstract class CursorBasedIterator implements Iterator { protected $client; protected $match; @@ -138,7 +140,7 @@ abstract class CursorBasedIterator implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function rewind() { $this->reset(); @@ -148,7 +150,7 @@ abstract class CursorBasedIterator implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function current() { return $this->current; @@ -157,7 +159,7 @@ abstract class CursorBasedIterator implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function key() { return $this->position; @@ -166,7 +168,7 @@ abstract class CursorBasedIterator implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function next() { tryFetch: { @@ -187,7 +189,7 @@ abstract class CursorBasedIterator implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function valid() { return $this->valid; diff --git a/src/Collection/Iterator/ListKey.php b/src/Collection/Iterator/ListKey.php index 56f09309..28616900 100644 --- a/src/Collection/Iterator/ListKey.php +++ b/src/Collection/Iterator/ListKey.php @@ -14,6 +14,9 @@ namespace Predis\Collection\Iterator; use Predis\ClientInterface; use Predis\NotSupportedException; +use Iterator; +use ReturnTypeWillChange; +use InvalidArgumentException; /** * Abstracts the iteration of items stored in a list by leveraging the LRANGE @@ -27,7 +30,7 @@ use Predis\NotSupportedException; * * @see http://redis.io/commands/lrange */ -class ListKey implements \Iterator +class ListKey implements Iterator { protected $client; protected $count; @@ -44,14 +47,14 @@ class ListKey implements \Iterator * @param string $key Redis list key. * @param int $count Number of items retrieved on each fetch operation. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function __construct(ClientInterface $client, $key, $count = 10) { $this->requiredCommand($client, 'LRANGE'); if ((false === $count = filter_var($count, FILTER_VALIDATE_INT)) || $count < 0) { - throw new \InvalidArgumentException('The $count argument must be a positive integer.'); + throw new InvalidArgumentException('The $count argument must be a positive integer.'); } $this->client = $client; @@ -127,7 +130,7 @@ class ListKey implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function rewind() { $this->reset(); @@ -137,7 +140,7 @@ class ListKey implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function current() { return $this->current; @@ -146,7 +149,7 @@ class ListKey implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function key() { return $this->position; @@ -155,7 +158,7 @@ class ListKey implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function next() { if (!$this->elements && $this->fetchmore) { @@ -172,7 +175,7 @@ class ListKey implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function valid() { return $this->valid; diff --git a/src/Command/Factory.php b/src/Command/Factory.php index 9d89abbe..0c3e0b33 100644 --- a/src/Command/Factory.php +++ b/src/Command/Factory.php @@ -14,6 +14,7 @@ namespace Predis\Command; use Predis\ClientException; use Predis\Command\Processor\ProcessorInterface; +use InvalidArgumentException; /** * Base command factory class. @@ -88,12 +89,12 @@ abstract class Factory implements FactoryInterface * @param string $commandID Command ID * @param string $commandClass FQCN of a class implementing Predis\Command\CommandInterface * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function define(string $commandID, string $commandClass): void { if (!is_a($commandClass, 'Predis\Command\CommandInterface', true)) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( "Class $commandClass must implement Predis\Command\CommandInterface" ); } diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index 90cdf22f..6acdb409 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -14,6 +14,7 @@ namespace Predis\Command\Processor; use Predis\Command\CommandInterface; use Predis\Command\PrefixableCommandInterface; +use InvalidArgumentException; /** * Command processor capable of prefixing keys stored in the arguments of Redis @@ -226,7 +227,7 @@ class KeyPrefixProcessor implements ProcessorInterface * @param string $commandID The ID of the command to be handled. * @param mixed $callback A valid callable object or NULL. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function setCommandHandler($commandID, $callback = null) { @@ -239,7 +240,7 @@ class KeyPrefixProcessor implements ProcessorInterface } if (!is_callable($callback)) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'Callback must be a valid callable object or NULL' ); } diff --git a/src/Command/Processor/ProcessorChain.php b/src/Command/Processor/ProcessorChain.php index d387e092..24caa345 100644 --- a/src/Command/Processor/ProcessorChain.php +++ b/src/Command/Processor/ProcessorChain.php @@ -13,11 +13,16 @@ namespace Predis\Command\Processor; use Predis\Command\CommandInterface; +use ArrayAccess; +use ArrayIterator; +use InvalidArgumentException; +use ReturnTypeWillChange; +use Traversable; /** * Default implementation of a command processors chain. */ -class ProcessorChain implements \ArrayAccess, ProcessorInterface +class ProcessorChain implements ArrayAccess, ProcessorInterface { private $processors = []; @@ -70,11 +75,11 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface /** * Returns an iterator over the list of command processor in the chain. * - * @return \Traversable + * @return Traversable */ public function getIterator() { - return new \ArrayIterator($this->processors); + return new ArrayIterator($this->processors); } /** @@ -90,7 +95,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetExists($index) { return isset($this->processors[$index]); @@ -99,7 +104,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetGet($index) { return $this->processors[$index]; @@ -108,11 +113,11 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetSet($index, $processor) { if (!$processor instanceof ProcessorInterface) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'Processor chain accepts only instances of `Predis\Command\Processor\ProcessorInterface`' ); } @@ -123,7 +128,7 @@ class ProcessorChain implements \ArrayAccess, ProcessorInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function offsetUnset($index) { unset($this->processors[$index]); diff --git a/src/CommunicationException.php b/src/CommunicationException.php index e7ab3aaf..b80e3194 100644 --- a/src/CommunicationException.php +++ b/src/CommunicationException.php @@ -13,6 +13,7 @@ namespace Predis; use Predis\Connection\NodeConnectionInterface; +use Exception; /** * Base exception class for network-related errors. @@ -25,13 +26,13 @@ abstract class CommunicationException extends PredisException * @param NodeConnectionInterface $connection Connection that generated the exception. * @param string $message Error message. * @param int $code Error code. - * @param \Exception|null $innerException Inner exception for wrapping the original error. + * @param Exception|null $innerException Inner exception for wrapping the original error. */ public function __construct( NodeConnectionInterface $connection, $message = "", $code = 0, - \Exception $innerException = null + Exception $innerException = null ) { parent::__construct( is_null($message) ? '' : $message, diff --git a/src/Configuration/Option/CRC16.php b/src/Configuration/Option/CRC16.php index 096680d7..5f7d5256 100644 --- a/src/Configuration/Option/CRC16.php +++ b/src/Configuration/Option/CRC16.php @@ -15,6 +15,7 @@ namespace Predis\Configuration\Option; use Predis\Cluster\Hash; use Predis\Configuration\OptionInterface; use Predis\Configuration\OptionsInterface; +use InvalidArgumentException; /** * Configures an hash generator used by the redis-cluster connection backend. @@ -36,7 +37,7 @@ class CRC16 implements OptionInterface } elseif ($description === 'phpiredis') { return new Hash\PhpiredisCRC16(); } else { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'String value for the crc16 option must be either `predis` or `phpiredis`' ); } @@ -57,7 +58,7 @@ class CRC16 implements OptionInterface return $value; } else { $class = get_class($this); - throw new \InvalidArgumentException("$class expects a valid hash generator"); + throw new InvalidArgumentException("$class expects a valid hash generator"); } } diff --git a/src/Configuration/Option/Commands.php b/src/Configuration/Option/Commands.php index 137227e2..e2e237a4 100644 --- a/src/Configuration/Option/Commands.php +++ b/src/Configuration/Option/Commands.php @@ -17,6 +17,7 @@ use Predis\Command\RawFactory; use Predis\Command\RedisFactory; use Predis\Configuration\OptionInterface; use Predis\Configuration\OptionsInterface; +use InvalidArgumentException; /** * Configures a connection factory to be used by the client. @@ -39,7 +40,7 @@ class Commands implements OptionInterface } elseif(is_string($value)) { return $this->createFactoryByString($options, $value); } else { - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '%s expects a valid command factory', static::class )); @@ -102,7 +103,7 @@ class Commands implements OptionInterface return $this->createRawFactory($options); default: - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '%s does not recognize `%s` as a supported configuration string', static::class, $value @@ -120,7 +121,7 @@ class Commands implements OptionInterface $commands = new RawFactory(); if (isset($options->prefix)) { - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '%s does not support key prefixing', RawFactory::class )); } diff --git a/src/Configuration/Option/Connections.php b/src/Configuration/Option/Connections.php index 4d0349a8..2ef642b0 100644 --- a/src/Configuration/Option/Connections.php +++ b/src/Configuration/Option/Connections.php @@ -18,6 +18,7 @@ use Predis\Connection\Factory; use Predis\Connection\FactoryInterface; use Predis\Connection\PhpiredisStreamConnection; use Predis\Connection\PhpiredisSocketConnection; +use InvalidArgumentException; /** * Configures a new connection factory instance. @@ -44,7 +45,7 @@ class Connections implements OptionInterface } elseif (is_string($value)) { return $this->createFactoryByString($options, $value); } else { - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '%s expects a valid connection factory', static::class )); } @@ -119,7 +120,7 @@ class Connections implements OptionInterface return $factory; default: - throw new \InvalidArgumentException(sprintf( + throw new InvalidArgumentException(sprintf( '%s does not recognize `%s` as a supported configuration string', static::class, $value )); } diff --git a/src/Connection/AbstractConnection.php b/src/Connection/AbstractConnection.php index 71fdd7f5..bdfeef24 100644 --- a/src/Connection/AbstractConnection.php +++ b/src/Connection/AbstractConnection.php @@ -15,6 +15,7 @@ namespace Predis\Connection; use Predis\Command\CommandInterface; use Predis\CommunicationException; use Predis\Protocol\ProtocolException; +use InvalidArgumentException; /** * Base class with the common logic used by connection classes to communicate @@ -50,7 +51,7 @@ abstract class AbstractConnection implements NodeConnectionInterface * * @param ParametersInterface $parameters Initialization parameters for the connection. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return ParametersInterface */ diff --git a/src/Connection/Cluster/PredisCluster.php b/src/Connection/Cluster/PredisCluster.php index 07311979..5a5f9c93 100644 --- a/src/Connection/Cluster/PredisCluster.php +++ b/src/Connection/Cluster/PredisCluster.php @@ -17,6 +17,10 @@ use Predis\Cluster\StrategyInterface; use Predis\Command\CommandInterface; use Predis\Connection\NodeConnectionInterface; use Predis\NotSupportedException; +use IteratorAggregate; +use Countable; +use ReturnTypeWillChange; +use ArrayIterator; /** * Abstraction for a cluster of aggregate connections to various Redis servers @@ -24,7 +28,7 @@ use Predis\NotSupportedException; * * @todo Add the ability to remove connections from pool. */ -class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable +class PredisCluster implements ClusterInterface, IteratorAggregate, Countable { /** * @var NodeConnectionInterface[] @@ -203,7 +207,7 @@ class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function count() { return count($this->pool); @@ -212,10 +216,10 @@ class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function getIterator() { - return new \ArrayIterator($this->pool); + return new ArrayIterator($this->pool); } /** diff --git a/src/Connection/Cluster/RedisCluster.php b/src/Connection/Cluster/RedisCluster.php index a02e89bd..9a9a24f5 100644 --- a/src/Connection/Cluster/RedisCluster.php +++ b/src/Connection/Cluster/RedisCluster.php @@ -25,6 +25,12 @@ use Predis\NotSupportedException; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ServerException; use Predis\Response\Error as ErrorResponse; +use IteratorAggregate; +use Countable; +use Throwable; +use ReturnTypeWillChange; +use ArrayIterator; +use OutOfBoundsException; /** * Abstraction for a Redis-backed cluster of nodes (Redis >= 3.0.0). @@ -46,7 +52,7 @@ use Predis\Response\Error as ErrorResponse; * Asking for the cluster configuration to Redis is actually done by issuing a * CLUSTER SLOTS command to a random node in the pool. */ -class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable +class RedisCluster implements ClusterInterface, IteratorAggregate, Countable { private $useClusterSlots = true; private $pool = []; @@ -362,14 +368,14 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable * * @param int $slot Slot index. * - * @throws \OutOfBoundsException + * @throws OutOfBoundsException * * @return NodeConnectionInterface */ public function getConnectionBySlot($slot) { if (!SlotMap::isValid($slot)) { - throw new \OutOfBoundsException("Invalid slot [$slot]."); + throw new OutOfBoundsException("Invalid slot [$slot]."); } if (isset($this->slots[$slot])) { @@ -522,7 +528,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable throw new ServerException($message); } } - } catch (\Throwable $exception) { + } catch (Throwable $exception) { usleep($retryAfter * 1000); $retryAfter = $retryAfter * 2; @@ -583,7 +589,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function count() { return count($this->pool); @@ -592,7 +598,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function getIterator() { if ($this->slotmap->isEmpty()) { @@ -609,7 +615,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable $connections[] = $connection; } - return new \ArrayIterator($connections); + return new ArrayIterator($connections); } /** diff --git a/src/Connection/CompositeStreamConnection.php b/src/Connection/CompositeStreamConnection.php index 6ad7c1de..ea5a1a80 100644 --- a/src/Connection/CompositeStreamConnection.php +++ b/src/Connection/CompositeStreamConnection.php @@ -15,6 +15,7 @@ namespace Predis\Connection; use Predis\Command\CommandInterface; use Predis\Protocol\ProtocolProcessorInterface; use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; +use InvalidArgumentException; /** * Connection abstraction to Redis servers based on PHP's stream that uses an @@ -58,7 +59,7 @@ class CompositeStreamConnection extends StreamConnection implements CompositeCon public function readBuffer($length) { if ($length <= 0) { - throw new \InvalidArgumentException('Length parameter must be greater than 0.'); + throw new InvalidArgumentException('Length parameter must be greater than 0.'); } $value = ''; diff --git a/src/Connection/Factory.php b/src/Connection/Factory.php index 5535344e..38ba04fc 100644 --- a/src/Connection/Factory.php +++ b/src/Connection/Factory.php @@ -13,6 +13,9 @@ namespace Predis\Connection; use Predis\Command\RawCommand; +use ReflectionClass; +use UnexpectedValueException; +use InvalidArgumentException; /** * Standard connection factory for creating connections to Redis nodes. @@ -37,7 +40,7 @@ class Factory implements FactoryInterface * * @param mixed $initializer FQN of a connection class or a callable for lazy initialization. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return mixed */ @@ -47,10 +50,10 @@ class Factory implements FactoryInterface return $initializer; } - $class = new \ReflectionClass($initializer); + $class = new ReflectionClass($initializer); if (!$class->isSubclassOf('Predis\Connection\NodeConnectionInterface')) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'A connection initializer must be a valid connection class or a callable object.' ); } @@ -86,7 +89,7 @@ class Factory implements FactoryInterface $scheme = $parameters->scheme; if (!isset($this->schemes[$scheme])) { - throw new \InvalidArgumentException("Unknown connection scheme: '$scheme'."); + throw new InvalidArgumentException("Unknown connection scheme: '$scheme'."); } $initializer = $this->schemes[$scheme]; @@ -99,7 +102,7 @@ class Factory implements FactoryInterface } if (!$connection instanceof NodeConnectionInterface) { - throw new \UnexpectedValueException( + throw new UnexpectedValueException( 'Objects returned by connection initializers must implement '. "'Predis\Connection\NodeConnectionInterface'." ); diff --git a/src/Connection/Parameters.php b/src/Connection/Parameters.php index 4df84d44..e4b11068 100644 --- a/src/Connection/Parameters.php +++ b/src/Connection/Parameters.php @@ -11,6 +11,7 @@ */ namespace Predis\Connection; +use InvalidArgumentException; /** * Container for connection parameters used to initialize connections to Redis. @@ -86,7 +87,7 @@ class Parameters implements ParametersInterface * * @param string $uri URI string. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * * @return array */ @@ -99,7 +100,7 @@ class Parameters implements ParametersInterface } if (!$parsed = parse_url($uri)) { - throw new \InvalidArgumentException("Invalid parameters URI: $uri"); + throw new InvalidArgumentException("Invalid parameters URI: $uri"); } if ( diff --git a/src/Connection/PhpiredisSocketConnection.php b/src/Connection/PhpiredisSocketConnection.php index 97e5ce09..f3c1b16b 100644 --- a/src/Connection/PhpiredisSocketConnection.php +++ b/src/Connection/PhpiredisSocketConnection.php @@ -17,6 +17,8 @@ use Predis\NotSupportedException; use Predis\Response\Error as ErrorResponse; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\Status as StatusResponse; +use InvalidArgumentException; +use Closure; /** * This class provides the implementation of a Predis connection that uses the @@ -100,7 +102,7 @@ class PhpiredisSocketConnection extends AbstractConnection break; default: - throw new \InvalidArgumentException("Invalid scheme: '$parameters->scheme'."); + throw new InvalidArgumentException("Invalid scheme: '$parameters->scheme'."); } if (isset($parameters->persistent)) { @@ -140,7 +142,7 @@ class PhpiredisSocketConnection extends AbstractConnection /** * Returns the handler used by the protocol reader for inline responses. * - * @return \Closure + * @return Closure */ protected function getStatusHandler() { @@ -158,7 +160,7 @@ class PhpiredisSocketConnection extends AbstractConnection /** * Returns the handler used by the protocol reader for error responses. * - * @return \Closure + * @return Closure */ protected function getErrorHandler() { diff --git a/src/Connection/PhpiredisStreamConnection.php b/src/Connection/PhpiredisStreamConnection.php index 3ed2082c..4ea880ab 100644 --- a/src/Connection/PhpiredisStreamConnection.php +++ b/src/Connection/PhpiredisStreamConnection.php @@ -16,6 +16,8 @@ use Predis\Command\CommandInterface; use Predis\NotSupportedException; use Predis\Response\Error as ErrorResponse; use Predis\Response\Status as StatusResponse; +use InvalidArgumentException; +use Closure; /** * This class provides the implementation of a Predis connection that uses PHP's @@ -106,10 +108,10 @@ class PhpiredisStreamConnection extends StreamConnection case 'tls': case 'rediss': - throw new \InvalidArgumentException('SSL encryption is not supported by this connection backend.'); + throw new InvalidArgumentException('SSL encryption is not supported by this connection backend.'); default: - throw new \InvalidArgumentException("Invalid scheme: '$parameters->scheme'."); + throw new InvalidArgumentException("Invalid scheme: '$parameters->scheme'."); } return $parameters; @@ -178,7 +180,7 @@ class PhpiredisStreamConnection extends StreamConnection /** * Returns the handler used by the protocol reader for inline responses. * - * @return \Closure + * @return Closure */ protected function getStatusHandler() { @@ -196,7 +198,7 @@ class PhpiredisStreamConnection extends StreamConnection /** * Returns the handler used by the protocol reader for error responses. * - * @return \Closure + * @return Closure */ protected function getErrorHandler() { diff --git a/src/Connection/Replication/MasterSlaveReplication.php b/src/Connection/Replication/MasterSlaveReplication.php index 7e63bc65..fd797f3e 100644 --- a/src/Connection/Replication/MasterSlaveReplication.php +++ b/src/Connection/Replication/MasterSlaveReplication.php @@ -21,6 +21,7 @@ use Predis\Connection\NodeConnectionInterface; use Predis\Replication\MissingMasterException; use Predis\Replication\ReplicationStrategy; use Predis\Response\ErrorInterface as ResponseErrorInterface; +use InvalidArgumentException; /** * Aggregate connection handling replication of Redis nodes configured in a @@ -234,7 +235,7 @@ class MasterSlaveReplication implements ReplicationInterface } if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) { - throw new \InvalidArgumentException('Invalid connection or connection not found.'); + throw new InvalidArgumentException('Invalid connection or connection not found.'); } $this->current = $connection; @@ -246,7 +247,7 @@ class MasterSlaveReplication implements ReplicationInterface public function switchToMaster() { if (!$connection = $this->getConnectionByRole('master')) { - throw new \InvalidArgumentException('Invalid connection or connection not found.'); + throw new InvalidArgumentException('Invalid connection or connection not found.'); } $this->switchTo($connection); @@ -258,7 +259,7 @@ class MasterSlaveReplication implements ReplicationInterface public function switchToSlave() { if (!$connection = $this->getConnectionByRole('slave')) { - throw new \InvalidArgumentException('Invalid connection or connection not found.'); + throw new InvalidArgumentException('Invalid connection or connection not found.'); } $this->switchTo($connection); diff --git a/src/Connection/Replication/SentinelReplication.php b/src/Connection/Replication/SentinelReplication.php index 6beabcf5..b1428c56 100644 --- a/src/Connection/Replication/SentinelReplication.php +++ b/src/Connection/Replication/SentinelReplication.php @@ -24,6 +24,7 @@ use Predis\Replication\RoleException; use Predis\Response\Error; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ServerException; +use InvalidArgumentException; /** * @author Daniele Alessandri @@ -628,7 +629,7 @@ class SentinelReplication implements ReplicationInterface } if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) { - throw new \InvalidArgumentException('Invalid connection or connection not found.'); + throw new InvalidArgumentException('Invalid connection or connection not found.'); } $connection->connect(); diff --git a/src/Connection/StreamConnection.php b/src/Connection/StreamConnection.php index 07513d92..cfd393a4 100644 --- a/src/Connection/StreamConnection.php +++ b/src/Connection/StreamConnection.php @@ -16,6 +16,7 @@ use Predis\Command\CommandInterface; use Predis\Response\Error as ErrorResponse; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\Status as StatusResponse; +use InvalidArgumentException; /** * Standard connection to Redis servers implemented on top of PHP's streams. @@ -62,7 +63,7 @@ class StreamConnection extends AbstractConnection break; default: - throw new \InvalidArgumentException("Invalid scheme: '$parameters->scheme'."); + throw new InvalidArgumentException("Invalid scheme: '$parameters->scheme'."); } return $parameters; @@ -86,7 +87,7 @@ class StreamConnection extends AbstractConnection return $this->tlsStreamInitializer($this->parameters); default: - throw new \InvalidArgumentException("Invalid scheme: '{$this->parameters->scheme}'."); + throw new InvalidArgumentException("Invalid scheme: '{$this->parameters->scheme}'."); } } @@ -163,7 +164,7 @@ class StreamConnection extends AbstractConnection protected function unixStreamInitializer(ParametersInterface $parameters) { if (!isset($parameters->path)) { - throw new \InvalidArgumentException('Missing UNIX domain socket path.'); + throw new InvalidArgumentException('Missing UNIX domain socket path.'); } $flags = STREAM_CLIENT_CONNECT; @@ -173,7 +174,7 @@ class StreamConnection extends AbstractConnection $flags |= STREAM_CLIENT_PERSISTENT; if ($persistent === null) { - throw new \InvalidArgumentException( + throw new InvalidArgumentException( 'Persistent connection IDs are not supported when using UNIX domain sockets.' ); } diff --git a/src/Connection/WebdisConnection.php b/src/Connection/WebdisConnection.php index 16a0b4cd..b30ba5a5 100644 --- a/src/Connection/WebdisConnection.php +++ b/src/Connection/WebdisConnection.php @@ -17,6 +17,8 @@ use Predis\NotSupportedException; use Predis\Protocol\ProtocolException; use Predis\Response\Error as ErrorResponse; use Predis\Response\Status as StatusResponse; +use Closure; +use InvalidArgumentException; /** * This class implements a Predis connection that actually talks with Webdis @@ -51,14 +53,14 @@ class WebdisConnection implements NodeConnectionInterface /** * @param ParametersInterface $parameters Initialization parameters for the connection. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ public function __construct(ParametersInterface $parameters) { $this->assertExtensions(); if ($parameters->scheme !== 'http') { - throw new \InvalidArgumentException("Invalid scheme: '{$parameters->scheme}'."); + throw new InvalidArgumentException("Invalid scheme: '{$parameters->scheme}'."); } $this->parameters = $parameters; @@ -158,7 +160,7 @@ class WebdisConnection implements NodeConnectionInterface /** * Returns the handler used by the protocol reader for inline responses. * - * @return \Closure + * @return Closure */ protected function getStatusHandler() { @@ -176,7 +178,7 @@ class WebdisConnection implements NodeConnectionInterface /** * Returns the handler used by the protocol reader for error responses. * - * @return \Closure + * @return Closure */ protected function getErrorHandler() { diff --git a/src/Monitor/Consumer.php b/src/Monitor/Consumer.php index 293b33c8..8f95b293 100644 --- a/src/Monitor/Consumer.php +++ b/src/Monitor/Consumer.php @@ -15,11 +15,13 @@ namespace Predis\Monitor; use Predis\ClientInterface; use Predis\Connection\Cluster\ClusterInterface; use Predis\NotSupportedException; +use Iterator; +use ReturnTypeWillChange; /** * Redis MONITOR consumer. */ -class Consumer implements \Iterator +class Consumer implements Iterator { private $client; private $valid; @@ -90,7 +92,7 @@ class Consumer implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function rewind() { // NOOP @@ -101,7 +103,7 @@ class Consumer implements \Iterator * * @return object */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function current() { return $this->getValue(); @@ -110,7 +112,7 @@ class Consumer implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function key() { return $this->position; @@ -119,7 +121,7 @@ class Consumer implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function next() { ++$this->position; @@ -130,7 +132,7 @@ class Consumer implements \Iterator * * @return bool */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function valid() { return $this->valid; diff --git a/src/Pipeline/Atomic.php b/src/Pipeline/Atomic.php index da799150..f5f7f0a5 100644 --- a/src/Pipeline/Atomic.php +++ b/src/Pipeline/Atomic.php @@ -19,6 +19,7 @@ use Predis\Connection\NodeConnectionInterface; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ResponseInterface; use Predis\Response\ServerException; +use SplQueue; /** * Command pipeline wrapped into a MULTI / EXEC transaction. @@ -58,7 +59,7 @@ class Atomic extends Pipeline /** * {@inheritdoc} */ - protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands) + protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) { $commandFactory = $this->getClient()->getCommandFactory(); $connection->executeCommand($commandFactory->create('multi')); diff --git a/src/Pipeline/ConnectionErrorProof.php b/src/Pipeline/ConnectionErrorProof.php index 28f73de8..9e042e72 100644 --- a/src/Pipeline/ConnectionErrorProof.php +++ b/src/Pipeline/ConnectionErrorProof.php @@ -17,6 +17,7 @@ use Predis\Connection\Cluster\ClusterInterface; use Predis\Connection\ConnectionInterface; use Predis\Connection\NodeConnectionInterface; use Predis\NotSupportedException; +use SplQueue; /** * Command pipeline that does not throw exceptions on connection errors, but @@ -37,7 +38,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands) + protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) { if ($connection instanceof NodeConnectionInterface) { return $this->executeSingleNode($connection, $commands); @@ -53,7 +54,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - protected function executeSingleNode(NodeConnectionInterface $connection, \SplQueue $commands) + protected function executeSingleNode(NodeConnectionInterface $connection, SplQueue $commands) { $responses = []; $sizeOfPipe = count($commands); @@ -85,7 +86,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - protected function executeCluster(ClusterInterface $connection, \SplQueue $commands) + protected function executeCluster(ClusterInterface $connection, SplQueue $commands) { $responses = []; $sizeOfPipe = count($commands); diff --git a/src/Pipeline/FireAndForget.php b/src/Pipeline/FireAndForget.php index 7f6f1fe4..75ee88eb 100644 --- a/src/Pipeline/FireAndForget.php +++ b/src/Pipeline/FireAndForget.php @@ -13,6 +13,7 @@ namespace Predis\Pipeline; use Predis\Connection\ConnectionInterface; +use SplQueue; /** * Command pipeline that writes commands to the servers but discards responses. @@ -22,7 +23,7 @@ class FireAndForget extends Pipeline /** * {@inheritdoc} */ - protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands) + protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) { while (!$commands->isEmpty()) { $connection->writeRequest($commands->dequeue()); diff --git a/src/Pipeline/Pipeline.php b/src/Pipeline/Pipeline.php index df7ce01d..f001036d 100644 --- a/src/Pipeline/Pipeline.php +++ b/src/Pipeline/Pipeline.php @@ -21,6 +21,9 @@ use Predis\Connection\Replication\ReplicationInterface; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ResponseInterface; use Predis\Response\ServerException; +use InvalidArgumentException; +use Exception; +use SplQueue; /** * Implementation of a command pipeline in which write and read operations of @@ -42,7 +45,7 @@ class Pipeline implements ClientContextInterface public function __construct(ClientInterface $client) { $this->client = $client; - $this->pipeline = new \SplQueue(); + $this->pipeline = new SplQueue(); } /** @@ -122,11 +125,11 @@ class Pipeline implements ClientContextInterface * from the current connection. * * @param ConnectionInterface $connection Current connection instance. - * @param \SplQueue $commands Queued commands. + * @param SplQueue $commands Queued commands. * * @return array */ - protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands) + protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) { foreach ($commands as $command) { $connection->writeRequest($command); @@ -164,7 +167,7 @@ class Pipeline implements ClientContextInterface $responses = $this->executePipeline($this->getConnection(), $this->pipeline); $this->responses = array_merge($this->responses, $responses); } else { - $this->pipeline = new \SplQueue(); + $this->pipeline = new SplQueue(); } return $this; @@ -191,15 +194,15 @@ class Pipeline implements ClientContextInterface * * @param mixed $callable Optional callback for execution. * - * @throws \Exception - * @throws \InvalidArgumentException + * @throws Exception + * @throws InvalidArgumentException * * @return array */ public function execute($callable = null) { if ($callable && !is_callable($callable)) { - throw new \InvalidArgumentException('The argument must be a callable object.'); + throw new InvalidArgumentException('The argument must be a callable object.'); } $exception = null; @@ -211,7 +214,7 @@ class Pipeline implements ClientContextInterface } $this->flushPipeline(); - } catch (\Exception $exception) { + } catch (Exception $exception) { // NOOP } diff --git a/src/PredisException.php b/src/PredisException.php index d185870d..e07bf1d7 100644 --- a/src/PredisException.php +++ b/src/PredisException.php @@ -11,10 +11,11 @@ */ namespace Predis; +use Exception; /** * Base exception class for Predis-related errors. */ -abstract class PredisException extends \Exception +abstract class PredisException extends Exception { } diff --git a/src/PubSub/AbstractConsumer.php b/src/PubSub/AbstractConsumer.php index f5944774..ea1e8f03 100644 --- a/src/PubSub/AbstractConsumer.php +++ b/src/PubSub/AbstractConsumer.php @@ -11,11 +11,13 @@ */ namespace Predis\PubSub; +use Iterator; +use ReturnTypeWillChange; /** * Base implementation of a PUB/SUB consumer abstraction based on PHP iterators. */ -abstract class AbstractConsumer implements \Iterator +abstract class AbstractConsumer implements Iterator { const SUBSCRIBE = 'subscribe'; const UNSUBSCRIBE = 'unsubscribe'; @@ -150,7 +152,7 @@ abstract class AbstractConsumer implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function rewind() { // NOOP @@ -162,7 +164,7 @@ abstract class AbstractConsumer implements \Iterator * * @return array */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function current() { return $this->getValue(); @@ -171,7 +173,7 @@ abstract class AbstractConsumer implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function key() { return $this->position; @@ -180,7 +182,7 @@ abstract class AbstractConsumer implements \Iterator /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function next() { if ($this->valid()) { @@ -195,7 +197,7 @@ abstract class AbstractConsumer implements \Iterator * * @return bool */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function valid() { $isValid = $this->isFlagSet(self::STATUS_VALID); diff --git a/src/PubSub/DispatcherLoop.php b/src/PubSub/DispatcherLoop.php index 963f38c6..df1ed0d0 100644 --- a/src/PubSub/DispatcherLoop.php +++ b/src/PubSub/DispatcherLoop.php @@ -11,6 +11,7 @@ */ namespace Predis\PubSub; +use InvalidArgumentException; /** * Method-dispatcher loop built around the client-side abstraction of a Redis @@ -38,12 +39,12 @@ class DispatcherLoop * * @param mixed $callable A callback. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException */ protected function assertCallback($callable) { if (!is_callable($callable)) { - throw new \InvalidArgumentException('The given argument must be a callable object.'); + throw new InvalidArgumentException('The given argument must be a callable object.'); } } diff --git a/src/Response/Iterator/MultiBulkIterator.php b/src/Response/Iterator/MultiBulkIterator.php index 21d9e73a..0ad284b5 100644 --- a/src/Response/Iterator/MultiBulkIterator.php +++ b/src/Response/Iterator/MultiBulkIterator.php @@ -13,6 +13,9 @@ namespace Predis\Response\Iterator; use Predis\Response\ResponseInterface; +use Iterator; +use Countable; +use ReturnTypeWillChange; /** * Iterator that abstracts the access to multibulk responses allowing them to be @@ -24,7 +27,7 @@ use Predis\Response\ResponseInterface; * Always make sure that the whole iteration is consumed (or dropped) to prevent * protocol desynchronization issues. */ -abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInterface +abstract class MultiBulkIterator implements Iterator, Countable, ResponseInterface { protected $current; protected $position; @@ -33,7 +36,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function rewind() { // NOOP @@ -42,7 +45,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function current() { return $this->current; @@ -51,7 +54,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function key() { return $this->position; @@ -60,7 +63,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function next() { if (++$this->position < $this->size) { @@ -71,7 +74,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function valid() { return $this->position < $this->size; @@ -86,7 +89,7 @@ abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInter * * @return int */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function count() { return $this->size; diff --git a/src/Response/Iterator/MultiBulkTuple.php b/src/Response/Iterator/MultiBulkTuple.php index 8ddf0561..08050278 100644 --- a/src/Response/Iterator/MultiBulkTuple.php +++ b/src/Response/Iterator/MultiBulkTuple.php @@ -11,6 +11,10 @@ */ namespace Predis\Response\Iterator; +use OuterIterator; +use ReturnTypeWillChange; +use UnexpectedValueException; +use InvalidArgumentException; /** * Outer iterator consuming streamable multibulk responses by yielding tuples of @@ -19,7 +23,7 @@ namespace Predis\Response\Iterator; * This wrapper is useful for responses to commands such as `HGETALL` that can * be iterater as $key => $value pairs. */ -class MultiBulkTuple extends MultiBulk implements \OuterIterator +class MultiBulkTuple extends MultiBulk implements OuterIterator { private $iterator; @@ -41,26 +45,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} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function getInnerIterator() { return $this->iterator; diff --git a/src/Session/Handler.php b/src/Session/Handler.php index d2c8bfa5..358058f5 100644 --- a/src/Session/Handler.php +++ b/src/Session/Handler.php @@ -13,6 +13,8 @@ namespace Predis\Session; use Predis\ClientInterface; +use SessionHandlerInterface; +use ReturnTypeWillChange; /** * Session handler class that relies on Predis\Client to store PHP's sessions @@ -22,7 +24,7 @@ use Predis\ClientInterface; * provided that a polyfill for `SessionHandlerInterface` is defined by either * you or an external package such as `symfony/http-foundation`. */ -class Handler implements \SessionHandlerInterface +class Handler implements SessionHandlerInterface { protected $client; protected $ttl; @@ -53,7 +55,7 @@ class Handler implements \SessionHandlerInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function open($save_path, $session_id) { // NOOP @@ -63,7 +65,7 @@ class Handler implements \SessionHandlerInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function close() { // NOOP @@ -73,7 +75,7 @@ class Handler implements \SessionHandlerInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function gc($maxlifetime) { // NOOP @@ -83,7 +85,7 @@ class Handler implements \SessionHandlerInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function read($session_id) { if ($data = $this->client->get($session_id)) { @@ -95,7 +97,7 @@ class Handler implements \SessionHandlerInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function write($session_id, $session_data) { $this->client->setex($session_id, $this->ttl, $session_data); @@ -106,7 +108,7 @@ class Handler implements \SessionHandlerInterface /** * {@inheritdoc} */ - #[\ReturnTypeWillChange] + #[ReturnTypeWillChange] public function destroy($session_id) { $this->client->del($session_id); diff --git a/src/Transaction/MultiExec.php b/src/Transaction/MultiExec.php index c3d3ae61..c39f55ce 100644 --- a/src/Transaction/MultiExec.php +++ b/src/Transaction/MultiExec.php @@ -23,6 +23,9 @@ use Predis\Protocol\ProtocolException; use Predis\Response\ErrorInterface as ErrorResponseInterface; use Predis\Response\ServerException; use Predis\Response\Status as StatusResponse; +use SplQueue; +use Exception; +use InvalidArgumentException; /** * Client-side abstraction of a Redis transaction based on MULTI / EXEC. @@ -111,7 +114,7 @@ class MultiExec implements ClientContextInterface protected function reset() { $this->state->reset(); - $this->commands = new \SplQueue(); + $this->commands = new SplQueue(); } /** @@ -312,7 +315,7 @@ class MultiExec implements ClientContextInterface * * @param mixed $callable Callback for execution. * - * @throws \InvalidArgumentException + * @throws InvalidArgumentException * @throws ClientException */ private function checkBeforeExecution($callable) @@ -325,7 +328,7 @@ class MultiExec implements ClientContextInterface if ($callable) { if (!is_callable($callable)) { - throw new \InvalidArgumentException('The argument must be a callable object.'); + throw new InvalidArgumentException('The argument must be a callable object.'); } if (!$this->commands->isEmpty()) { @@ -432,7 +435,7 @@ class MultiExec implements ClientContextInterface // NOOP } catch (ServerException $exception) { // NOOP - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->discard(); } diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index cb39e8b3..2864f9c7 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -19,6 +19,9 @@ use Predis\Command\Factory as CommandFactory; use Predis\Connection\NodeConnectionInterface; use Predis\Command\Processor\KeyPrefixProcessor; use Predis\Connection\Replication\MasterSlaveReplication; +use stdClass; +use ReflectionProperty; +use Iterator; /** * @@ -447,7 +450,7 @@ class ClientTest extends PredisTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Invalid type for connection parameters'); - $client = new Client(new \stdClass()); + $client = new Client(new stdClass()); } /** @@ -458,7 +461,7 @@ class ClientTest extends PredisTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Invalid type for client options'); - $client = new Client('tcp://host1', new \stdClass()); + $client = new Client('tcp://host1', new stdClass()); } /** @@ -1018,7 +1021,7 @@ class ClientTest extends PredisTestCase $this->assertInstanceOf('Predis\PubSub\Consumer', $pubsub = $client->pubSubLoop($options)); - $reflection = new \ReflectionProperty($pubsub, 'options'); + $reflection = new ReflectionProperty($pubsub, 'options'); $reflection->setAccessible(true); $this->assertSame($options, $reflection->getValue($pubsub)); @@ -1118,11 +1121,11 @@ class ClientTest extends PredisTestCase $this->assertInstanceOf('Predis\Transaction\MultiExec', $tx = $client->transaction($options)); // I hate this part but reflection is the easiest way in this case. - $property = new \ReflectionProperty($tx, 'modeCAS'); + $property = new ReflectionProperty($tx, 'modeCAS'); $property->setAccessible(true); $this->assertSame($options['cas'], $property->getValue($tx)); - $property = new \ReflectionProperty($tx, 'attempts'); + $property = new ReflectionProperty($tx, 'attempts'); $property->setAccessible(true); $this->assertSame($options['retry'], $property->getValue($tx)); } @@ -1217,7 +1220,7 @@ class ClientTest extends PredisTestCase $client = new Client($aggregate); - /** @var \Iterator */ + /** @var Iterator */ $iterator = $client->getIterator(); $this->assertInstanceOf('\Predis\Client', $nodeClient = $iterator->current()); @@ -1245,7 +1248,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockConnection('tcp://127.0.0.1:6381'); $client = new Client($connection); - /** @var \Iterator */ + /** @var Iterator */ $iterator = $client->getIterator(); $this->assertInstanceOf('\Predis\Client', $nodeClient = $iterator->current()); diff --git a/tests/Predis/Command/CommandTest.php b/tests/Predis/Command/CommandTest.php index b7c838ca..63d3c98a 100644 --- a/tests/Predis/Command/CommandTest.php +++ b/tests/Predis/Command/CommandTest.php @@ -13,6 +13,7 @@ namespace Predis\Command; use PredisTestCase; +use stdClass; /** * @@ -130,7 +131,7 @@ class CommandTest extends PredisTestCase $arguments = [[], []]; $this->assertSame($arguments, Command::normalizeArguments($arguments)); - $arguments = [new \stdClass()]; + $arguments = [new stdClass()]; $this->assertSame($arguments, Command::normalizeArguments($arguments)); } @@ -144,7 +145,7 @@ class CommandTest extends PredisTestCase $this->assertSame($arguments, Command::normalizeVariadic($arguments)); $this->assertSame($arguments, Command::normalizeVariadic(['key', ['value1', 'value2', 'value3']])); - $arguments = [new \stdClass()]; + $arguments = [new stdClass()]; $this->assertSame($arguments, Command::normalizeVariadic($arguments)); } } diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index 3cfa58df..e0cbc361 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -16,6 +16,7 @@ use PredisTestCase; use Predis\Command\RawCommand; use Predis\Command\CommandInterface; use PHPUnit\Framework\MockObject\MockObject; +use stdClass; /** * @@ -364,7 +365,7 @@ class KeyPrefixProcessorTest extends PredisTestCase $this->expectExceptionMessage('Callback must be a valid callable object or NULL'); $processor = new KeyPrefixProcessor('prefix:'); - $processor->setCommandHandler('NEWCMD', new \stdClass()); + $processor->setCommandHandler('NEWCMD', new stdClass()); } // ******************************************************************** // diff --git a/tests/Predis/Command/Processor/ProcessorChainTest.php b/tests/Predis/Command/Processor/ProcessorChainTest.php index 3070a8ae..f81209d3 100644 --- a/tests/Predis/Command/Processor/ProcessorChainTest.php +++ b/tests/Predis/Command/Processor/ProcessorChainTest.php @@ -14,6 +14,7 @@ namespace Predis\Command\Processor; use PredisTestCase; use Predis\Command\CommandInterface; +use stdClass; /** * @@ -212,7 +213,7 @@ class ProcessorChainTest extends PredisTestCase $this->expectExceptionMessage('Processor chain accepts only instances of `Predis\Command\Processor\ProcessorInterface`'); $chain = new ProcessorChain(); - $chain[0] = new \stdClass(); + $chain[0] = new stdClass(); } /** diff --git a/tests/Predis/CommunicationExceptionTest.php b/tests/Predis/CommunicationExceptionTest.php index 052ebb50..c18aadc7 100644 --- a/tests/Predis/CommunicationExceptionTest.php +++ b/tests/Predis/CommunicationExceptionTest.php @@ -14,6 +14,7 @@ namespace Predis; use PredisTestCase; use PHPUnit\Framework\MockObject\MockObject; +use Exception; /** * @@ -117,7 +118,7 @@ class CommunicationExceptionTest extends PredisTestCase * @param Connection\NodeConnectionInterface $connection Connection instance. * @param string $message Exception message. * @param int $code Exception code. - * @param \Exception $inner Inner exception. + * @param Exception $inner Inner exception. * * @return \Predis\CommunicationException */ @@ -125,7 +126,7 @@ class CommunicationExceptionTest extends PredisTestCase Connection\NodeConnectionInterface $connection, string $message, int $code = 0, - \Exception $inner = null + Exception $inner = null ) { return $this->getMockBuilder('Predis\CommunicationException') ->setConstructorArgs([$connection, $message, $code, $inner]) diff --git a/tests/Predis/Configuration/Option/CommandsTest.php b/tests/Predis/Configuration/Option/CommandsTest.php index 165c2adb..20637f3e 100644 --- a/tests/Predis/Configuration/Option/CommandsTest.php +++ b/tests/Predis/Configuration/Option/CommandsTest.php @@ -17,6 +17,7 @@ use PHPUnit\Framework\MockObject\MockObject; use Predis\Configuration\OptionsInterface; use Predis\Command\Processor\KeyPrefixProcessor; use Predis\Command\RedisFactory; +use stdClass; /** * @@ -271,7 +272,7 @@ class CommandsTest extends PredisTestCase ->method('__invoke') ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface')) ->willReturn( - new \stdClass() + new stdClass() ); $option->filter($options, $callable); @@ -290,7 +291,7 @@ class CommandsTest extends PredisTestCase /** @var OptionsInterface */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); - $option->filter($options, new \stdClass()); + $option->filter($options, new stdClass()); } /** diff --git a/tests/Predis/Configuration/Option/ConnectionsTest.php b/tests/Predis/Configuration/Option/ConnectionsTest.php index e196802a..7d7fc6a3 100644 --- a/tests/Predis/Configuration/Option/ConnectionsTest.php +++ b/tests/Predis/Configuration/Option/ConnectionsTest.php @@ -15,6 +15,7 @@ namespace Predis\Configuration\Option; use PredisTestCase; use PHPUnit\Framework\MockObject\MockObject; use Predis\Configuration\OptionsInterface; +use stdClass; /** * @@ -217,7 +218,7 @@ class ConnectionsTest extends PredisTestCase /** @var OptionsInterface */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); - $option->filter($options, new \stdClass()); + $option->filter($options, new stdClass()); } // ******************************************************************** // diff --git a/tests/Predis/Configuration/Option/ExceptionsTest.php b/tests/Predis/Configuration/Option/ExceptionsTest.php index 0d41c6f8..bd447500 100644 --- a/tests/Predis/Configuration/Option/ExceptionsTest.php +++ b/tests/Predis/Configuration/Option/ExceptionsTest.php @@ -14,6 +14,7 @@ namespace Predis\Configuration\Option; use PredisTestCase; use Predis\Configuration\OptionsInterface; +use stdClass; /** * @@ -68,7 +69,7 @@ class ExceptionsTest extends PredisTestCase /** @var OptionsInterface */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); - $this->assertFalse($option->filter($options, new \stdClass())); + $this->assertFalse($option->filter($options, new stdClass())); $this->assertFalse($option->filter($options, 'invalid')); } } diff --git a/tests/Predis/Configuration/Option/ReplicationTest.php b/tests/Predis/Configuration/Option/ReplicationTest.php index 95feecff..8381e0b1 100644 --- a/tests/Predis/Configuration/Option/ReplicationTest.php +++ b/tests/Predis/Configuration/Option/ReplicationTest.php @@ -15,6 +15,7 @@ namespace Predis\Configuration\Option; use PredisTestCase; use PHPUnit\Framework\MockObject\MockObject; use Predis\Configuration\OptionsInterface; +use ReflectionProperty; /** * @@ -62,7 +63,7 @@ class ReplicationTest extends PredisTestCase $this->assertInstanceOf('Predis\Connection\Replication\MasterSlaveReplication', $connection = $initializer([])); // TODO: I know, I know... - $reflection = new \ReflectionProperty($connection, 'autoDiscovery'); + $reflection = new ReflectionProperty($connection, 'autoDiscovery'); $reflection->setAccessible(true); $this->assertTrue($reflection->getValue($connection)); diff --git a/tests/Predis/Configuration/OptionsTest.php b/tests/Predis/Configuration/OptionsTest.php index abd0adfa..97ae6537 100644 --- a/tests/Predis/Configuration/OptionsTest.php +++ b/tests/Predis/Configuration/OptionsTest.php @@ -13,6 +13,8 @@ namespace Predis\Configuration; use PredisTestCase; +use stdClass; +use Exception; /** * @todo Use mock objects to test the inner workings of the Options class. @@ -184,7 +186,7 @@ class OptionsTest extends PredisTestCase */ public function testLazilyInitializesCustomOptionValueUsingObjectWithInvokeMagicMethod(): void { - $custom = new \stdClass(); + $custom = new stdClass(); // NOTE: closure values are covered by this test since they define __invoke(). $callable = $this->getMockBuilder('stdClass') @@ -223,7 +225,7 @@ class OptionsTest extends PredisTestCase try { $options = new Options(['custom' => 'value']); $pfx = $options->prefix; - } catch (\Exception $_) { + } catch (Exception $_) { spl_autoload_unregister($autoload); } } diff --git a/tests/Predis/Connection/ConnectionExceptionTest.php b/tests/Predis/Connection/ConnectionExceptionTest.php index 441367e8..d593d729 100644 --- a/tests/Predis/Connection/ConnectionExceptionTest.php +++ b/tests/Predis/Connection/ConnectionExceptionTest.php @@ -15,6 +15,7 @@ namespace Predis\Connection; require_once __DIR__.'/../CommunicationExceptionTest.php'; use Predis\CommunicationExceptionTest; +use Exception; /** * @@ -28,7 +29,7 @@ class ConnectionExceptionTest extends CommunicationExceptionTest NodeConnectionInterface $connection, string $message, int $code = 0, - \Exception $inner = null + Exception $inner = null ) { return new ConnectionException($connection, $message, $code, $inner); } diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index a3ed02d4..aa5550ff 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -15,6 +15,8 @@ namespace Predis\Connection; use PredisTestCase; use PHPUnit\Framework\MockObject\MockObject; use Predis\Connection\Cluster\ClusterInterface; +use ReflectionObject; +use stdClass; /** * @@ -315,7 +317,7 @@ class FactoryTest extends PredisTestCase $factory = new Factory(); // TODO: using reflection to make a protected method accessible :facepalm: - $reflection = new \ReflectionObject($factory); + $reflection = new ReflectionObject($factory); $prepareConnection = $reflection->getMethod('prepareConnection'); $prepareConnection->setAccessible(true); $prepareConnection->invoke($factory, $connection); @@ -341,7 +343,7 @@ class FactoryTest extends PredisTestCase $factory = new Factory(); // TODO: using reflection to make a protected method accessible :facepalm: - $reflection = new \ReflectionObject($factory); + $reflection = new ReflectionObject($factory); $prepareConnection = $reflection->getMethod('prepareConnection'); $prepareConnection->setAccessible(true); $prepareConnection->invoke($factory, $connection); @@ -368,7 +370,7 @@ class FactoryTest extends PredisTestCase $factory = new Factory(); // TODO: using reflection to make a protected method accessible :facepalm: - $reflection = new \ReflectionObject($factory); + $reflection = new ReflectionObject($factory); $prepareConnection = $reflection->getMethod('prepareConnection'); $prepareConnection->setAccessible(true); $prepareConnection->invoke($factory, $connection); @@ -393,7 +395,7 @@ class FactoryTest extends PredisTestCase $factory = new Factory(); // TODO: using reflection to make a protected method accessible :facepalm: - $reflection = new \ReflectionObject($factory); + $reflection = new ReflectionObject($factory); $prepareConnection = $reflection->getMethod('prepareConnection'); $prepareConnection->setAccessible(true); $prepareConnection->invoke($factory, $connection); @@ -419,7 +421,7 @@ class FactoryTest extends PredisTestCase $factory = new Factory(); // TODO: using reflection to make a protected method accessible :facepalm: - $reflection = new \ReflectionObject($factory); + $reflection = new ReflectionObject($factory); $prepareConnection = $reflection->getMethod('prepareConnection'); $prepareConnection->setAccessible(true); $prepareConnection->invoke($factory, $connection); @@ -494,7 +496,7 @@ class FactoryTest extends PredisTestCase $this->expectException('InvalidArgumentException'); $factory = new Factory(); - $factory->define('foobar', new \stdClass()); + $factory->define('foobar', new stdClass()); } /** diff --git a/tests/Predis/Connection/Replication/SentinelReplicationTest.php b/tests/Predis/Connection/Replication/SentinelReplicationTest.php index 40f47ce0..0c8f0c34 100644 --- a/tests/Predis/Connection/Replication/SentinelReplicationTest.php +++ b/tests/Predis/Connection/Replication/SentinelReplicationTest.php @@ -18,6 +18,7 @@ use Predis\Command; use Predis\Connection; use Predis\Replication; use Predis\Response; +use ReflectionProperty; /** * @@ -329,7 +330,7 @@ class SentinelReplicationTest extends PredisTestCase $replication->updateSentinels(); // TODO: sorry for the smell... - $reflection = new \ReflectionProperty($replication, 'sentinels'); + $reflection = new ReflectionProperty($replication, 'sentinels'); $reflection->setAccessible(true); $expected = [ @@ -381,7 +382,7 @@ class SentinelReplicationTest extends PredisTestCase $replication->updateSentinels(); // TODO: sorry for the smell... - $reflection = new \ReflectionProperty($replication, 'sentinels'); + $reflection = new ReflectionProperty($replication, 'sentinels'); $reflection->setAccessible(true); $expected = [ @@ -478,7 +479,7 @@ class SentinelReplicationTest extends PredisTestCase $replication->querySentinel(); // TODO: sorry for the smell... - $reflection = new \ReflectionProperty($replication, 'sentinels'); + $reflection = new ReflectionProperty($replication, 'sentinels'); $reflection->setAccessible(true); $sentinels = [ diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index 5e1bb0d9..72411204 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -18,6 +18,9 @@ use Predis\ClientInterface; use Predis\Command\CommandInterface; use Predis\Response; use PredisTestCase; +use stdClass; +use Exception; +use InvalidArgumentException; /** * @@ -311,7 +314,7 @@ class PipelineTest extends PredisTestCase { $this->expectException('InvalidArgumentException'); - $noncallable = new \stdClass(); + $noncallable = new stdClass(); $pipeline = new Pipeline(new Client()); $pipeline->execute($noncallable); @@ -381,7 +384,7 @@ class PipelineTest extends PredisTestCase $pipe->echo('two'); throw new ClientException('TEST'); }); - } catch (\Exception $exception) { + } catch (Exception $exception) { // NOOP } @@ -459,7 +462,7 @@ class PipelineTest extends PredisTestCase $pipe->set('foo', 'bar'); throw new ClientException('TEST'); }); - } catch (\Exception $exception) { + } catch (Exception $exception) { // NOOP } @@ -485,7 +488,7 @@ class PipelineTest extends PredisTestCase $pipe->lpush('foo', 'bar'); $pipe->set('hoge', 'piyo'); }); - } catch (\Exception $exception) { + } catch (Exception $exception) { // NOOP } @@ -538,7 +541,7 @@ class PipelineTest extends PredisTestCase { return function (CommandInterface $command) { if (($id = $command->getId()) !== 'ECHO') { - throw new \InvalidArgumentException("Expected ECHO, got {$id}"); + throw new InvalidArgumentException("Expected ECHO, got {$id}"); } list($echoed) = $command->getArguments(); diff --git a/tests/Predis/Protocol/ProtocolExceptionTest.php b/tests/Predis/Protocol/ProtocolExceptionTest.php index 321a2082..60c3876d 100644 --- a/tests/Predis/Protocol/ProtocolExceptionTest.php +++ b/tests/Predis/Protocol/ProtocolExceptionTest.php @@ -17,6 +17,7 @@ require_once __DIR__.'/../CommunicationExceptionTest.php'; use Predis\CommunicationException; use Predis\CommunicationExceptionTest; use Predis\Connection\NodeConnectionInterface; +use Exception; /** * @@ -30,7 +31,7 @@ class ProtocolExceptionTest extends CommunicationExceptionTest NodeConnectionInterface $connection, string $message, int $code = 0, - \Exception $inner = null + Exception $inner = null ): CommunicationException { return new ProtocolException($connection, $message, $code, $inner); } diff --git a/tests/Predis/Transaction/MultiExecTest.php b/tests/Predis/Transaction/MultiExecTest.php index 650484f6..1f7050f8 100644 --- a/tests/Predis/Transaction/MultiExecTest.php +++ b/tests/Predis/Transaction/MultiExecTest.php @@ -19,6 +19,8 @@ use PredisTestCase; use Predis\Response; use Predis\Command\CommandInterface; use Predis\Connection\NodeConnectionInterface; +use RuntimeException; +use Exception; /** * @group realm-transaction @@ -157,7 +159,7 @@ class MultiExecTest extends PredisTestCase $tx->echo('foo')->execute(function ($tx) { $tx->echo('bar'); }); - } catch (\Exception $ex) { + } catch (Exception $ex) { $exception = $ex; } @@ -499,9 +501,9 @@ class MultiExecTest extends PredisTestCase $tx->set('foo', 'bar'); $tx->get('foo'); - throw new \RuntimeException('TEST'); + throw new RuntimeException('TEST'); }); - } catch (\Exception $ex) { + } catch (Exception $ex) { // NOOP } @@ -565,7 +567,7 @@ class MultiExecTest extends PredisTestCase try { $tx->multi()->set('foo', 'bar')->echo('simulated failure')->exec(); - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $exception); $this->assertSame('ERR simulated failure on ECHO', $exception->getMessage()); } @@ -575,7 +577,7 @@ class MultiExecTest extends PredisTestCase try { $tx->multi()->set('foo', 'bar')->echo('simulated failure')->exec(); - } catch (\Exception $exception) { + } catch (Exception $exception) { $this->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $exception); $this->assertSame('ERR simulated failure on ECHO', $exception->getMessage()); } @@ -685,9 +687,9 @@ class MultiExecTest extends PredisTestCase try { $client->transaction(function (MultiExec $tx) { $tx->set('foo', 'bar'); - throw new \RuntimeException('TEST'); + throw new RuntimeException('TEST'); }); - } catch (\Exception $ex) { + } catch (Exception $ex) { $exception = $ex; }