From 7282ca2b5294a64eee160672dae0eb7e67da1788 Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Fri, 24 Jul 2015 19:05:28 +0200 Subject: [PATCH] Remove unneeded "use" imports. --- src/Client.php | 10 ++++------ src/Cluster/ClusterStrategy.php | 3 +-- .../Distributor/EmptyRingException.php | 4 +--- .../Iterator/CursorBasedIterator.php | 3 +-- src/Collection/Iterator/ListKey.php | 6 ++---- src/Command/Processor/KeyPrefixProcessor.php | 3 +-- src/Command/Processor/ProcessorChain.php | 11 ++++------- src/Command/RawCommand.php | 4 +--- src/CommunicationException.php | 5 ++--- src/Configuration/ClusterOption.php | 3 +-- src/Configuration/ConnectionFactoryOption.php | 3 +-- src/Configuration/ProfileOption.php | 3 +-- src/Configuration/ReplicationOption.php | 3 +-- .../Aggregate/MasterSlaveReplication.php | 6 ++---- src/Connection/Aggregate/PredisCluster.php | 7 ++----- src/Connection/Aggregate/RedisCluster.php | 12 ++++-------- src/Connection/CompositeStreamConnection.php | 3 +-- src/Connection/Factory.php | 11 ++++------- src/Connection/Parameters.php | 6 ++---- src/Connection/WebdisConnection.php | 3 +-- src/Monitor/Consumer.php | 3 +-- src/Pipeline/Atomic.php | 3 +-- src/Pipeline/ConnectionErrorProof.php | 7 +++---- src/Pipeline/FireAndForget.php | 3 +-- src/Pipeline/Pipeline.php | 19 ++++++++----------- src/PredisException.php | 4 +--- src/Profile/Factory.php | 6 ++---- src/Profile/RedisProfile.php | 6 ++---- src/PubSub/AbstractConsumer.php | 4 +--- src/PubSub/DispatcherLoop.php | 4 +--- src/Response/Iterator/MultiBulkIterator.php | 4 +--- src/Response/Iterator/MultiBulkTuple.php | 10 +++------- src/Session/Handler.php | 3 +-- src/Transaction/MultiExec.php | 11 ++++------- tests/Predis/ClientTest.php | 7 +++---- .../ConnectionFactoryOptionTest.php | 4 +--- .../Configuration/ExceptionsOptionTest.php | 3 +-- tests/Predis/Configuration/OptionsTest.php | 3 +-- .../Configuration/ProfileOptionTest.php | 4 +--- tests/Predis/Pipeline/PipelineTest.php | 10 ++++------ 40 files changed, 78 insertions(+), 149 deletions(-) diff --git a/src/Client.php b/src/Client.php index 9730dfda..9c902dcf 100644 --- a/src/Client.php +++ b/src/Client.php @@ -11,8 +11,6 @@ namespace Predis; -use InvalidArgumentException; -use UnexpectedValueException; use Predis\Command\CommandInterface; use Predis\Command\RawCommand; use Predis\Command\ScriptCommand; @@ -80,7 +78,7 @@ class Client implements ClientInterface return $options; } - throw new InvalidArgumentException('Invalid type for client options.'); + throw new \InvalidArgumentException('Invalid type for client options.'); } /** @@ -142,7 +140,7 @@ class Client implements ClientInterface return $connection; } - throw new InvalidArgumentException('Invalid type for connection parameters.'); + throw new \InvalidArgumentException('Invalid type for connection parameters.'); } /** @@ -159,7 +157,7 @@ class Client implements ClientInterface $connection = call_user_func_array($callable, func_get_args()); if (!$connection instanceof ConnectionInterface) { - throw new UnexpectedValueException( + throw new \UnexpectedValueException( 'The callable connection initializer returned an invalid type.' ); } @@ -198,7 +196,7 @@ class Client implements ClientInterface public function getClientFor($connectionID) { if (!$connection = $this->getConnectionById($connectionID)) { - throw new InvalidArgumentException("Invalid connection ID: $connectionID."); + throw new \InvalidArgumentException("Invalid connection ID: $connectionID."); } return new static($connection, $this->options); diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index 65b8ca01..5dab2f1f 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -11,7 +11,6 @@ namespace Predis\Cluster; -use InvalidArgumentException; use Predis\Command\CommandInterface; use Predis\Command\ScriptCommand; @@ -202,7 +201,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 cb53b383..039f2f2e 100644 --- a/src/Cluster/Distributor/EmptyRingException.php +++ b/src/Cluster/Distributor/EmptyRingException.php @@ -11,13 +11,11 @@ namespace Predis\Cluster\Distributor; -use Exception; - /** * Exception class that identifies empty rings. * * @author Daniele Alessandri */ -class EmptyRingException extends Exception +class EmptyRingException extends \Exception { } diff --git a/src/Collection/Iterator/CursorBasedIterator.php b/src/Collection/Iterator/CursorBasedIterator.php index 940c7aee..922883f0 100644 --- a/src/Collection/Iterator/CursorBasedIterator.php +++ b/src/Collection/Iterator/CursorBasedIterator.php @@ -11,7 +11,6 @@ namespace Predis\Collection\Iterator; -use Iterator; use Predis\ClientInterface; use Predis\NotSupportedException; @@ -28,7 +27,7 @@ use Predis\NotSupportedException; * * @author Daniele Alessandri */ -abstract class CursorBasedIterator implements Iterator +abstract class CursorBasedIterator implements \Iterator { protected $client; protected $match; diff --git a/src/Collection/Iterator/ListKey.php b/src/Collection/Iterator/ListKey.php index 89879262..7a6eb479 100644 --- a/src/Collection/Iterator/ListKey.php +++ b/src/Collection/Iterator/ListKey.php @@ -11,8 +11,6 @@ namespace Predis\Collection\Iterator; -use InvalidArgumentException; -use Iterator; use Predis\ClientInterface; use Predis\NotSupportedException; @@ -30,7 +28,7 @@ use Predis\NotSupportedException; * * @link http://redis.io/commands/lrange */ -class ListKey implements Iterator +class ListKey implements \Iterator { protected $client; protected $count; @@ -54,7 +52,7 @@ class ListKey implements Iterator $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; diff --git a/src/Command/Processor/KeyPrefixProcessor.php b/src/Command/Processor/KeyPrefixProcessor.php index 0f371820..a610b417 100644 --- a/src/Command/Processor/KeyPrefixProcessor.php +++ b/src/Command/Processor/KeyPrefixProcessor.php @@ -11,7 +11,6 @@ namespace Predis\Command\Processor; -use InvalidArgumentException; use Predis\Command\CommandInterface; use Predis\Command\PrefixableCommandInterface; @@ -220,7 +219,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 e5f0071b..0a4768b0 100644 --- a/src/Command/Processor/ProcessorChain.php +++ b/src/Command/Processor/ProcessorChain.php @@ -11,9 +11,6 @@ namespace Predis\Command\Processor; -use ArrayAccess; -use ArrayIterator; -use InvalidArgumentException; use Predis\Command\CommandInterface; /** @@ -21,7 +18,7 @@ use Predis\Command\CommandInterface; * * @author Daniele Alessandri */ -class ProcessorChain implements ArrayAccess, ProcessorInterface +class ProcessorChain implements \ArrayAccess, ProcessorInterface { private $processors = array(); @@ -74,11 +71,11 @@ class ProcessorChain implements ArrayAccess, ProcessorInterface /** * Returns an iterator over the list of command processor in the chain. * - * @return ArrayIterator + * @return \ArrayIterator */ public function getIterator() { - return new ArrayIterator($this->processors); + return new \ArrayIterator($this->processors); } /** @@ -113,7 +110,7 @@ class ProcessorChain implements ArrayAccess, ProcessorInterface public function offsetSet($index, $processor) { if (!$processor instanceof ProcessorInterface) { - throw new InvalidArgumentException( + throw new \InvalidArgumentException( 'A processor chain accepts only instances of '. "'Predis\Command\Processor\ProcessorInterface'." ); diff --git a/src/Command/RawCommand.php b/src/Command/RawCommand.php index cc072400..2dd48ca1 100644 --- a/src/Command/RawCommand.php +++ b/src/Command/RawCommand.php @@ -11,8 +11,6 @@ namespace Predis\Command; -use InvalidArgumentException; - /** * Class for generic "anonymous" Redis commands. * @@ -37,7 +35,7 @@ class RawCommand implements CommandInterface public function __construct(array $arguments) { if (!$arguments) { - throw new InvalidArgumentException( + throw new \InvalidArgumentException( 'The arguments array must contain at least the command ID.' ); } diff --git a/src/CommunicationException.php b/src/CommunicationException.php index 9f18ca23..13fe357c 100644 --- a/src/CommunicationException.php +++ b/src/CommunicationException.php @@ -11,7 +11,6 @@ namespace Predis; -use Exception; use Predis\Connection\NodeConnectionInterface; /** @@ -27,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 $innerException Inner exception for wrapping the original error. + * @param \Exception $innerException Inner exception for wrapping the original error. */ public function __construct( NodeConnectionInterface $connection, $message = null, $code = null, - Exception $innerException = null + \Exception $innerException = null ) { parent::__construct($message, $code, $innerException); $this->connection = $connection; diff --git a/src/Configuration/ClusterOption.php b/src/Configuration/ClusterOption.php index 62f03231..69e36de7 100644 --- a/src/Configuration/ClusterOption.php +++ b/src/Configuration/ClusterOption.php @@ -11,7 +11,6 @@ namespace Predis\Configuration; -use InvalidArgumentException; use Predis\Connection\Aggregate\ClusterInterface; use Predis\Connection\Aggregate\PredisCluster; use Predis\Connection\Aggregate\RedisCluster; @@ -59,7 +58,7 @@ class ClusterOption implements OptionInterface } if (!$value instanceof ClusterInterface) { - throw new InvalidArgumentException( + throw new \InvalidArgumentException( "An instance of type 'Predis\Connection\Aggregate\ClusterInterface' was expected." ); } diff --git a/src/Configuration/ConnectionFactoryOption.php b/src/Configuration/ConnectionFactoryOption.php index 70e027f7..ba38df96 100644 --- a/src/Configuration/ConnectionFactoryOption.php +++ b/src/Configuration/ConnectionFactoryOption.php @@ -11,7 +11,6 @@ namespace Predis\Configuration; -use InvalidArgumentException; use Predis\Connection\Factory; use Predis\Connection\FactoryInterface; @@ -39,7 +38,7 @@ class ConnectionFactoryOption implements OptionInterface return $factory; } else { - throw new InvalidArgumentException( + throw new \InvalidArgumentException( 'Invalid value provided for the connections option.' ); } diff --git a/src/Configuration/ProfileOption.php b/src/Configuration/ProfileOption.php index 300f7d47..864936e0 100644 --- a/src/Configuration/ProfileOption.php +++ b/src/Configuration/ProfileOption.php @@ -11,7 +11,6 @@ namespace Predis\Configuration; -use InvalidArgumentException; use Predis\Profile\Factory; use Predis\Profile\ProfileInterface; use Predis\Profile\RedisProfile; @@ -51,7 +50,7 @@ class ProfileOption implements OptionInterface $value = Factory::get($value); $this->setProcessors($options, $value); } elseif (!$value instanceof ProfileInterface) { - throw new InvalidArgumentException('Invalid value for the profile option.'); + throw new \InvalidArgumentException('Invalid value for the profile option.'); } return $value; diff --git a/src/Configuration/ReplicationOption.php b/src/Configuration/ReplicationOption.php index 57af933b..fd2c8108 100644 --- a/src/Configuration/ReplicationOption.php +++ b/src/Configuration/ReplicationOption.php @@ -11,7 +11,6 @@ namespace Predis\Configuration; -use InvalidArgumentException; use Predis\Connection\Aggregate\MasterSlaveReplication; use Predis\Connection\Aggregate\ReplicationInterface; @@ -47,7 +46,7 @@ class ReplicationOption implements OptionInterface return $asbool ? $this->getDefault($options) : null; } - throw new InvalidArgumentException( + throw new \InvalidArgumentException( "An instance of type 'Predis\Connection\Aggregate\ReplicationInterface' was expected." ); } diff --git a/src/Connection/Aggregate/MasterSlaveReplication.php b/src/Connection/Aggregate/MasterSlaveReplication.php index 93a679fe..3104a753 100644 --- a/src/Connection/Aggregate/MasterSlaveReplication.php +++ b/src/Connection/Aggregate/MasterSlaveReplication.php @@ -11,8 +11,6 @@ namespace Predis\Connection\Aggregate; -use InvalidArgumentException; -use RuntimeException; use Predis\Command\CommandInterface; use Predis\Connection\NodeConnectionInterface; use Predis\Replication\ReplicationStrategy; @@ -45,7 +43,7 @@ class MasterSlaveReplication implements ReplicationInterface protected function check() { if (!isset($this->master) || !$this->slaves) { - throw new RuntimeException('Replication needs one master and at least one slave.'); + throw new \RuntimeException('Replication needs one master and at least one slave.'); } } @@ -147,7 +145,7 @@ class MasterSlaveReplication implements ReplicationInterface $connection = $this->getConnectionById($connection); } 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; diff --git a/src/Connection/Aggregate/PredisCluster.php b/src/Connection/Aggregate/PredisCluster.php index 8286a9fa..7fb92800 100644 --- a/src/Connection/Aggregate/PredisCluster.php +++ b/src/Connection/Aggregate/PredisCluster.php @@ -11,9 +11,6 @@ namespace Predis\Connection\Aggregate; -use ArrayIterator; -use Countable; -use IteratorAggregate; use Predis\NotSupportedException; use Predis\Cluster\PredisStrategy; use Predis\Cluster\StrategyInterface; @@ -28,7 +25,7 @@ use Predis\Connection\NodeConnectionInterface; * * @todo Add the ability to remove connections from pool. */ -class PredisCluster implements ClusterInterface, IteratorAggregate, Countable +class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable { private $pool; private $strategy; @@ -191,7 +188,7 @@ class PredisCluster implements ClusterInterface, IteratorAggregate, Countable */ public function getIterator() { - return new ArrayIterator($this->pool); + return new \ArrayIterator($this->pool); } /** diff --git a/src/Connection/Aggregate/RedisCluster.php b/src/Connection/Aggregate/RedisCluster.php index 4d87c16d..3ffe4535 100644 --- a/src/Connection/Aggregate/RedisCluster.php +++ b/src/Connection/Aggregate/RedisCluster.php @@ -11,10 +11,6 @@ namespace Predis\Connection\Aggregate; -use ArrayIterator; -use Countable; -use IteratorAggregate; -use OutOfBoundsException; use Predis\NotSupportedException; use Predis\Cluster\StrategyInterface; use Predis\Cluster\RedisStrategy as RedisClusterStrategy; @@ -46,7 +42,7 @@ use Predis\Response\ErrorInterface as ErrorResponseInterface; * * @author Daniele Alessandri */ -class RedisCluster implements ClusterInterface, IteratorAggregate, Countable +class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable { private $useClusterSlots = true; private $defaultParameters = array(); @@ -236,7 +232,7 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable $last < 0x0000 || $last > 0x3FFF || $last < $first ) { - throw new OutOfBoundsException( + throw new \OutOfBoundsException( "Invalid slot range for $connection: [$first-$last]." ); } @@ -324,7 +320,7 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable public function getConnectionBySlot($slot) { if ($slot < 0x0000 || $slot > 0x3FFF) { - throw new OutOfBoundsException("Invalid slot [$slot]."); + throw new \OutOfBoundsException("Invalid slot [$slot]."); } if (isset($this->slots[$slot])) { @@ -494,7 +490,7 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable */ public function getIterator() { - return new ArrayIterator(array_values($this->pool)); + return new \ArrayIterator(array_values($this->pool)); } /** diff --git a/src/Connection/CompositeStreamConnection.php b/src/Connection/CompositeStreamConnection.php index 85187703..7a353405 100644 --- a/src/Connection/CompositeStreamConnection.php +++ b/src/Connection/CompositeStreamConnection.php @@ -11,7 +11,6 @@ namespace Predis\Connection; -use InvalidArgumentException; use Predis\Command\CommandInterface; use Predis\Protocol\ProtocolProcessorInterface; use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor; @@ -60,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 f2882804..b097d63e 100644 --- a/src/Connection/Factory.php +++ b/src/Connection/Factory.php @@ -11,9 +11,6 @@ namespace Predis\Connection; -use InvalidArgumentException; -use UnexpectedValueException; -use ReflectionClass; use Predis\Command\RawCommand; /** @@ -47,10 +44,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 +83,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 +96,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 8c8a0d52..4bc59b57 100644 --- a/src/Connection/Parameters.php +++ b/src/Connection/Parameters.php @@ -11,8 +11,6 @@ namespace Predis\Connection; -use InvalidArgumentException; - /** * Container for connection parameters used to initialize connections to Redis. * @@ -87,7 +85,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 (isset($parsed['query'])) { @@ -120,7 +118,7 @@ class Parameters implements ParametersInterface public static function parseIANA($uri) { if (!$parsed = parse_url($uri)) { - throw new InvalidArgumentException("Invalid parameters URI: $uri"); + throw new \InvalidArgumentException("Invalid parameters URI: $uri"); } if (isset($parsed['query'])) { diff --git a/src/Connection/WebdisConnection.php b/src/Connection/WebdisConnection.php index 192d93e7..e4c8aef4 100644 --- a/src/Connection/WebdisConnection.php +++ b/src/Connection/WebdisConnection.php @@ -11,7 +11,6 @@ namespace Predis\Connection; -use InvalidArgumentException; use Predis\NotSupportedException; use Predis\Command\CommandInterface; use Predis\Protocol\ProtocolException; @@ -60,7 +59,7 @@ class WebdisConnection implements NodeConnectionInterface $this->assertExtensions(); if ($parameters->scheme !== 'http') { - throw new InvalidArgumentException("Invalid scheme: '{$parameters->scheme}'."); + throw new \InvalidArgumentException("Invalid scheme: '{$parameters->scheme}'."); } $this->parameters = $parameters; diff --git a/src/Monitor/Consumer.php b/src/Monitor/Consumer.php index 58e9d2b9..55555e02 100644 --- a/src/Monitor/Consumer.php +++ b/src/Monitor/Consumer.php @@ -11,7 +11,6 @@ namespace Predis\Monitor; -use Iterator; use Predis\ClientInterface; use Predis\NotSupportedException; use Predis\Connection\AggregateConnectionInterface; @@ -21,7 +20,7 @@ use Predis\Connection\AggregateConnectionInterface; * * @author Daniele Alessandri */ -class Consumer implements Iterator +class Consumer implements \Iterator { private $client; private $valid; diff --git a/src/Pipeline/Atomic.php b/src/Pipeline/Atomic.php index 16d36ca8..1c9c92aa 100644 --- a/src/Pipeline/Atomic.php +++ b/src/Pipeline/Atomic.php @@ -11,7 +11,6 @@ namespace Predis\Pipeline; -use SplQueue; use Predis\ClientException; use Predis\ClientInterface; use Predis\Connection\ConnectionInterface; @@ -60,7 +59,7 @@ class Atomic extends Pipeline /** * {@inheritdoc} */ - protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) + protected function executePipeline(ConnectionInterface $connection, \SplQueue $commands) { $profile = $this->getClient()->getProfile(); $connection->executeCommand($profile->createCommand('multi')); diff --git a/src/Pipeline/ConnectionErrorProof.php b/src/Pipeline/ConnectionErrorProof.php index ea864d5f..bcd03197 100644 --- a/src/Pipeline/ConnectionErrorProof.php +++ b/src/Pipeline/ConnectionErrorProof.php @@ -11,7 +11,6 @@ namespace Predis\Pipeline; -use SplQueue; use Predis\NotSupportedException; use Predis\CommunicationException; use Predis\Connection\ConnectionInterface; @@ -39,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); @@ -55,7 +54,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - protected function executeSingleNode(NodeConnectionInterface $connection, SplQueue $commands) + protected function executeSingleNode(NodeConnectionInterface $connection, \SplQueue $commands) { $responses = array(); $sizeOfPipe = count($commands); @@ -87,7 +86,7 @@ class ConnectionErrorProof extends Pipeline /** * {@inheritdoc} */ - protected function executeCluster(ClusterInterface $connection, SplQueue $commands) + protected function executeCluster(ClusterInterface $connection, \SplQueue $commands) { $responses = array(); $sizeOfPipe = count($commands); diff --git a/src/Pipeline/FireAndForget.php b/src/Pipeline/FireAndForget.php index b4e563e1..95a062b6 100644 --- a/src/Pipeline/FireAndForget.php +++ b/src/Pipeline/FireAndForget.php @@ -11,7 +11,6 @@ namespace Predis\Pipeline; -use SplQueue; use Predis\Connection\ConnectionInterface; /** @@ -24,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 05b02673..499c91db 100644 --- a/src/Pipeline/Pipeline.php +++ b/src/Pipeline/Pipeline.php @@ -11,9 +11,6 @@ namespace Predis\Pipeline; -use Exception; -use InvalidArgumentException; -use SplQueue; use Predis\ClientContextInterface; use Predis\ClientException; use Predis\ClientInterface; @@ -46,7 +43,7 @@ class Pipeline implements ClientContextInterface public function __construct(ClientInterface $client) { $this->client = $client; - $this->pipeline = new SplQueue(); + $this->pipeline = new \SplQueue(); } /** @@ -126,11 +123,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); @@ -168,7 +165,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; @@ -197,13 +194,13 @@ class Pipeline implements ClientContextInterface * * @return array * - * @throws Exception - * @throws InvalidArgumentException + * @throws \Exception + * @throws \InvalidArgumentException */ 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; @@ -215,7 +212,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 867f54cb..122bde16 100644 --- a/src/PredisException.php +++ b/src/PredisException.php @@ -11,13 +11,11 @@ namespace Predis; -use Exception; - /** * Base exception class for Predis-related errors. * * @author Daniele Alessandri */ -abstract class PredisException extends Exception +abstract class PredisException extends \Exception { } diff --git a/src/Profile/Factory.php b/src/Profile/Factory.php index bbd881a1..dc055c53 100644 --- a/src/Profile/Factory.php +++ b/src/Profile/Factory.php @@ -11,8 +11,6 @@ namespace Predis\Profile; -use InvalidArgumentException; -use ReflectionClass; use Predis\ClientException; /** @@ -71,10 +69,10 @@ final class Factory */ public static function define($alias, $class) { - $reflection = new ReflectionClass($class); + $reflection = new \ReflectionClass($class); if (!$reflection->isSubclassOf('Predis\Profile\ProfileInterface')) { - throw new InvalidArgumentException("The class '$class' is not a valid profile class."); + throw new \InvalidArgumentException("The class '$class' is not a valid profile class."); } self::$profiles[$alias] = $class; diff --git a/src/Profile/RedisProfile.php b/src/Profile/RedisProfile.php index acfd802e..3ef31688 100644 --- a/src/Profile/RedisProfile.php +++ b/src/Profile/RedisProfile.php @@ -11,8 +11,6 @@ namespace Predis\Profile; -use InvalidArgumentException; -use ReflectionClass; use Predis\ClientException; use Predis\Command\Processor\ProcessorInterface; @@ -111,10 +109,10 @@ abstract class RedisProfile implements ProfileInterface */ public function defineCommand($commandID, $class) { - $reflection = new ReflectionClass($class); + $reflection = new \ReflectionClass($class); if (!$reflection->isSubclassOf('Predis\Command\CommandInterface')) { - throw new InvalidArgumentException("The class '$class' is not a valid command class."); + throw new \InvalidArgumentException("The class '$class' is not a valid command class."); } $this->commands[strtoupper($commandID)] = $class; diff --git a/src/PubSub/AbstractConsumer.php b/src/PubSub/AbstractConsumer.php index f9bd11fc..250eca5c 100644 --- a/src/PubSub/AbstractConsumer.php +++ b/src/PubSub/AbstractConsumer.php @@ -11,14 +11,12 @@ namespace Predis\PubSub; -use Iterator; - /** * Base implementation of a PUB/SUB consumer abstraction based on PHP iterators. * * @author Daniele Alessandri */ -abstract class AbstractConsumer implements Iterator +abstract class AbstractConsumer implements \Iterator { const SUBSCRIBE = 'subscribe'; const UNSUBSCRIBE = 'unsubscribe'; diff --git a/src/PubSub/DispatcherLoop.php b/src/PubSub/DispatcherLoop.php index e14ef91a..0d4a08ef 100644 --- a/src/PubSub/DispatcherLoop.php +++ b/src/PubSub/DispatcherLoop.php @@ -11,8 +11,6 @@ namespace Predis\PubSub; -use InvalidArgumentException; - /** * Method-dispatcher loop built around the client-side abstraction of a Redis * PUB / SUB context. @@ -46,7 +44,7 @@ class DispatcherLoop 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 e94d5007..5d328869 100644 --- a/src/Response/Iterator/MultiBulkIterator.php +++ b/src/Response/Iterator/MultiBulkIterator.php @@ -11,8 +11,6 @@ namespace Predis\Response\Iterator; -use Iterator; -use Countable; use Predis\Response\ResponseInterface; /** @@ -27,7 +25,7 @@ use Predis\Response\ResponseInterface; * * @author Daniele Alessandri */ -abstract class MultiBulkIterator implements Iterator, Countable, ResponseInterface +abstract class MultiBulkIterator implements \Iterator, \Countable, ResponseInterface { protected $current; protected $position; diff --git a/src/Response/Iterator/MultiBulkTuple.php b/src/Response/Iterator/MultiBulkTuple.php index 19c504cf..2b6f593c 100644 --- a/src/Response/Iterator/MultiBulkTuple.php +++ b/src/Response/Iterator/MultiBulkTuple.php @@ -11,10 +11,6 @@ namespace Predis\Response\Iterator; -use OuterIterator; -use InvalidArgumentException; -use UnexpectedValueException; - /** * Outer iterator consuming streamable multibulk responses by yielding tuples of * keys and values. @@ -24,7 +20,7 @@ use UnexpectedValueException; * * @author Daniele Alessandri */ -class MultiBulkTuple extends MultiBulk implements OuterIterator +class MultiBulkTuple extends MultiBulk implements \OuterIterator { private $iterator; @@ -52,13 +48,13 @@ class MultiBulkTuple extends MultiBulk implements OuterIterator 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.'); } } diff --git a/src/Session/Handler.php b/src/Session/Handler.php index c21bd8e7..bbe741bd 100644 --- a/src/Session/Handler.php +++ b/src/Session/Handler.php @@ -11,7 +11,6 @@ namespace Predis\Session; -use SessionHandlerInterface; use Predis\ClientInterface; /** @@ -24,7 +23,7 @@ use Predis\ClientInterface; * * @author Daniele Alessandri */ -class Handler implements SessionHandlerInterface +class Handler implements \SessionHandlerInterface { protected $client; protected $ttl; diff --git a/src/Transaction/MultiExec.php b/src/Transaction/MultiExec.php index 041e3c2f..09f36f60 100644 --- a/src/Transaction/MultiExec.php +++ b/src/Transaction/MultiExec.php @@ -11,9 +11,6 @@ namespace Predis\Transaction; -use Exception; -use InvalidArgumentException; -use SplQueue; use Predis\ClientContextInterface; use Predis\ClientException; use Predis\ClientInterface; @@ -115,7 +112,7 @@ class MultiExec implements ClientContextInterface protected function reset() { $this->state->reset(); - $this->commands = new SplQueue(); + $this->commands = new \SplQueue(); } /** @@ -316,7 +313,7 @@ class MultiExec implements ClientContextInterface * * @param mixed $callable Callback for execution. * - * @throws InvalidArgumentException + * @throws \InvalidArgumentException * @throws ClientException */ private function checkBeforeExecution($callable) @@ -329,7 +326,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()) { @@ -436,7 +433,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 3144105e..58c226b5 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -11,7 +11,6 @@ namespace Predis; -use ReflectionProperty; use PredisTestCase; /** @@ -688,7 +687,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)); @@ -741,11 +740,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)); } diff --git a/tests/Predis/Configuration/ConnectionFactoryOptionTest.php b/tests/Predis/Configuration/ConnectionFactoryOptionTest.php index 8568f8ff..437b279a 100644 --- a/tests/Predis/Configuration/ConnectionFactoryOptionTest.php +++ b/tests/Predis/Configuration/ConnectionFactoryOptionTest.php @@ -11,8 +11,6 @@ namespace Predis\Configuration; -use InvalidArgumentException; -use stdClass; use PredisTestCase; /** @@ -79,6 +77,6 @@ class ConnectionFactoryOptionTest extends PredisTestCase $option = new ConnectionFactoryOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $option->filter($options, new stdClass()); + $option->filter($options, new \stdClass()); } } diff --git a/tests/Predis/Configuration/ExceptionsOptionTest.php b/tests/Predis/Configuration/ExceptionsOptionTest.php index 2a731e63..b7d7780a 100644 --- a/tests/Predis/Configuration/ExceptionsOptionTest.php +++ b/tests/Predis/Configuration/ExceptionsOptionTest.php @@ -11,7 +11,6 @@ namespace Predis\Configuration; -use stdClass; use PredisTestCase; /** @@ -61,7 +60,7 @@ class ExceptionsOptionTest extends PredisTestCase $option = new ExceptionsOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $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/OptionsTest.php b/tests/Predis/Configuration/OptionsTest.php index 4a7bcf5d..7764fdbf 100644 --- a/tests/Predis/Configuration/OptionsTest.php +++ b/tests/Predis/Configuration/OptionsTest.php @@ -11,7 +11,6 @@ namespace Predis\Configuration; -use stdClass; use PredisTestCase; /** @@ -161,7 +160,7 @@ class OptionsTest extends PredisTestCase */ public function testLazilyInitializesCustomOptionValueUsingObjectWithInvokeMagicMethod() { - $custom = new stdClass(); + $custom = new \stdClass(); // NOTE: closure values are covered by this test since they define __invoke(). $callable = $this->getMock('stdClass', array('__invoke')); diff --git a/tests/Predis/Configuration/ProfileOptionTest.php b/tests/Predis/Configuration/ProfileOptionTest.php index d8b10c7e..a2fde40e 100644 --- a/tests/Predis/Configuration/ProfileOptionTest.php +++ b/tests/Predis/Configuration/ProfileOptionTest.php @@ -11,8 +11,6 @@ namespace Predis\Configuration; -use InvalidArgumentException; -use stdClass; use PredisTestCase; use Predis\Command\Processor\KeyPrefixProcessor; use Predis\Profile; @@ -147,7 +145,7 @@ class ProfileOptionTest extends PredisTestCase $option = new ProfileOption(); $options = $this->getMock('Predis\Configuration\OptionsInterface'); - $option->filter($options, new stdClass()); + $option->filter($options, new \stdClass()); } /** diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index f8a1b0e9..14c3a350 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -11,8 +11,6 @@ namespace Predis\Pipeline; -use Exception; -use InvalidArgumentException; use PredisTestCase; use Predis\Client; use Predis\ClientException; @@ -349,7 +347,7 @@ class PipelineTest extends PredisTestCase $pipe->echo('two'); throw new ClientException('TEST'); }); - } catch (Exception $exception) { + } catch (\Exception $exception) { // NOOP } @@ -426,7 +424,7 @@ class PipelineTest extends PredisTestCase $pipe->set('foo', 'bar'); throw new ClientException('TEST'); }); - } catch (Exception $exception) { + } catch (\Exception $exception) { // NOOP } @@ -452,7 +450,7 @@ class PipelineTest extends PredisTestCase $pipe->lpush('foo', 'bar'); $pipe->set('hoge', 'piyo'); }); - } catch (Exception $exception) { + } catch (\Exception $exception) { // NOOP } @@ -507,7 +505,7 @@ class PipelineTest extends PredisTestCase { return function ($command) { if (($id = $command->getId()) !== 'ECHO') { - throw new InvalidArgumentException("Expected ECHO, got {$id}"); + throw new \InvalidArgumentException("Expected ECHO, got {$id}"); } list($echoed) = $command->getArguments();