Revert usage of "short" namespaces in use directives.

We started using partially-qualified names as an experiment but we are
reverting to using fully-qualified names + aliases in use directives.
This commit is contained in:
Daniele Alessandri
2013-12-15 14:33:31 +01:00
parent aa9aafe926
commit 7e89719ceb
19 changed files with 144 additions and 116 deletions
+48 -41
View File
@@ -13,14 +13,21 @@ namespace Predis;
use InvalidArgumentException;
use UnexpectedValueException;
use Predis\Command;
use Predis\Configuration;
use Predis\Connection;
use Predis\Monitor;
use Predis\Pipeline;
use Predis\PubSub;
use Predis\Response;
use Predis\Transaction;
use Predis\Command\CommandInterface;
use Predis\Command\RawCommand;
use Predis\Command\ScriptCommand;
use Predis\Configuration\Options;
use Predis\Configuration\OptionsInterface;
use Predis\Connection\ConnectionInterface;
use Predis\Connection\AggregateConnectionInterface;
use Predis\Connection\ParametersInterface;
use Predis\Monitor\Consumer as MonitorConsumer;
use Predis\Pipeline\Pipeline;
use Predis\PubSub\Consumer as PubSubConsumer;
use Predis\Response\ErrorInterface as ErrorResponseInterface;
use Predis\Response\ResponseInterface;
use Predis\Response\ServerException;
use Predis\Transaction\MultiExec as TransactionMultiExec;
/**
* Client class used for connecting and executing commands on Redis.
@@ -61,10 +68,10 @@ class Client implements ClientInterface
protected function createOptions($options)
{
if (is_array($options)) {
return new Configuration\Options($options);
return new Options($options);
}
if ($options instanceof Configuration\OptionsInterface) {
if ($options instanceof OptionsInterface) {
return $options;
}
@@ -85,15 +92,15 @@ class Client implements ClientInterface
* - Callable
*
* @param mixed $parameters Connection parameters or connection instance.
* @return Connection\ConnectionInterface
* @return ConnectionInterface
*/
protected function createConnection($parameters)
{
if ($parameters instanceof Connection\ConnectionInterface) {
if ($parameters instanceof ConnectionInterface) {
return $parameters;
}
if ($parameters instanceof Connection\ParametersInterface || is_string($parameters)) {
if ($parameters instanceof ParametersInterface || is_string($parameters)) {
return $this->options->connections->create($parameters);
}
@@ -142,7 +149,7 @@ class Client implements ClientInterface
return function () use ($callable) {
$connection = call_user_func_array($callable, func_get_args());
if (!$connection instanceof Connection\ConnectionInterface) {
if (!$connection instanceof ConnectionInterface) {
throw new UnexpectedValueException(
'The callable connection initializer returned an invalid type'
);
@@ -234,11 +241,11 @@ class Client implements ClientInterface
* client is in cluster or replication mode.
*
* @param string $connectionID Index or alias of the single connection.
* @return Connection\SingleConnectionInterface
* @return SingleConnectionInterface
*/
public function getConnectionById($connectionID)
{
if (!$this->connection instanceof Connection\AggregateConnectionInterface) {
if (!$this->connection instanceof AggregateConnectionInterface) {
throw new NotSupportedException(
'Retrieving connections by ID is supported only when using aggregate connections'
);
@@ -263,11 +270,11 @@ class Client implements ClientInterface
{
$error = false;
$command = new Command\RawCommand($arguments);
$command = new RawCommand($arguments);
$response = $this->connection->executeCommand($command);
if ($response instanceof Response\ResponseInterface) {
if ($response instanceof Response\ErrorInterface) {
if ($response instanceof ResponseInterface) {
if ($response instanceof ErrorResponseInterface) {
$error = true;
}
@@ -304,13 +311,13 @@ class Client implements ClientInterface
/**
* {@inheritdoc}
*/
public function executeCommand(Command\CommandInterface $command)
public function executeCommand(CommandInterface $command)
{
$response = $this->connection->executeCommand($command);
if ($response instanceof Response\ResponseInterface) {
if ($response instanceof Response\ErrorInterface) {
$response = $this->onResponseError($command, $response);
if ($response instanceof ResponseInterface) {
if ($response instanceof ErrorResponseInterface) {
$response = $this->onErrorResponse($command, $response);
}
return $response;
@@ -322,21 +329,21 @@ class Client implements ClientInterface
/**
* Handles -ERR responses returned by Redis.
*
* @param Command\CommandInterface $command Redis command that generated the error.
* @param Response\ErrorInterface $response Instance of the error response.
* @param CommandInterface $command Redis command that generated the error.
* @param ErrorResponseInterface $response Instance of the error response.
* @return mixed
*/
protected function onResponseError(
Command\CommandInterface $command,
Response\ErrorInterface $response
protected function onErrorResponse(
CommandInterface $command,
ErrorResponseInterface $response
) {
if ($command instanceof Command\ScriptCommand && $response->getErrorType() === 'NOSCRIPT') {
if ($command instanceof ScriptCommand && $response->getErrorType() === 'NOSCRIPT') {
$eval = $this->createCommand('eval');
$eval->setRawArguments($command->getEvalArguments());
$response = $this->executeCommand($eval);
if (!$response instanceof Response\ResponseInterface) {
if (!$response instanceof ResponseInterface) {
$response = $command->parseResponse($response);
}
@@ -344,7 +351,7 @@ class Client implements ClientInterface
}
if ($this->options->exceptions) {
throw new Response\ServerException($response->getMessage());
throw new ServerException($response->getMessage());
}
return $response;
@@ -385,7 +392,7 @@ class Client implements ClientInterface
* a pipeline executed inside the optionally provided callable object.
*
* @param mixed $arg,... Options for the context, or a callable, or both.
* @return Pipeline\Pipeline|array
* @return Pipeline|array
*/
public function pipeline(/* arguments */)
{
@@ -397,7 +404,7 @@ class Client implements ClientInterface
*
* @param array $options Options for the context.
* @param mixed $callable Optional callable used to execute the context.
* @return Pipeline\Pipeline|array
* @return Pipeline|array
*/
protected function createPipeline(array $options = null, $callable = null)
{
@@ -423,7 +430,7 @@ class Client implements ClientInterface
* of a transaction executed inside the optionally provided callable object.
*
* @param mixed $arg,... Options for the context, or a callable, or both.
* @return Transaction\MultiExec|array
* @return TransactionMultiExec|array
*/
public function transaction(/* arguments */)
{
@@ -435,11 +442,11 @@ class Client implements ClientInterface
*
* @param array $options Options for the context.
* @param mixed $callable Optional callable used to execute the context.
* @return Transaction\MultiExec|array
* @return TransactionMultiExec|array
*/
protected function createTransaction(array $options = null, $callable = null)
{
$transaction = new Transaction\MultiExec($this, $options);
$transaction = new TransactionMultiExec($this, $options);
if (isset($callable)) {
return $transaction->execute($callable);
@@ -453,7 +460,7 @@ class Client implements ClientInterface
* inside the optionally provided callable object.
*
* @param mixed $arg,... Options for the context, or a callable, or both.
* @return PubSub\Consumer|NULL
* @return PubSubConsumer|NULL
*/
public function pubSubLoop(/* arguments */)
{
@@ -465,11 +472,11 @@ class Client implements ClientInterface
*
* @param array $options Options for the context.
* @param mixed $callable Optional callable used to execute the context.
* @return PubSub\Consumer|NULL
* @return PubSubConsumer|NULL
*/
protected function createPubSub(array $options = null, $callable = null)
{
$pubsub = new PubSub\Consumer($this, $options);
$pubsub = new PubSubConsumer($this, $options);
if (!isset($callable)) {
return $pubsub;
@@ -485,10 +492,10 @@ class Client implements ClientInterface
/**
* Creates a new monitor consumer and returns it.
*
* @return Monitor\Consumer
* @return MonitorConsumer
*/
public function monitor()
{
return new Monitor\Consumer($this);
return new MonitorConsumer($this);
}
}
@@ -11,13 +11,17 @@
namespace Predis\Command\Processor;
use IteratorAggregate;
use Countable;
/**
* A command processor chain processes a command using multiple chained command
* processor before it is sent to Redis.
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
interface CommandProcessorChainInterface extends CommandProcessorInterface, \IteratorAggregate, \Countable
interface CommandProcessorChainInterface
extends CommandProcessorInterface, IteratorAggregate, Countable
{
/**
* Adds the given command processor.
@@ -12,7 +12,8 @@
namespace Predis\Configuration;
use InvalidArgumentException;
use Predis\Connection;
use Predis\Connection\Factory;
use Predis\Connection\FactoryInterface;
/**
* Configures a connection factory used by the client to create new connection
@@ -27,7 +28,7 @@ class ConnectionFactoryOption implements OptionInterface
*/
public function filter(OptionsInterface $options, $value)
{
if ($value instanceof Connection\FactoryInterface) {
if ($value instanceof FactoryInterface) {
return $value;
} else if (is_array($value)) {
$factory = $this->getDefault($options);
@@ -47,6 +48,6 @@ class ConnectionFactoryOption implements OptionInterface
*/
public function getDefault(OptionsInterface $options)
{
return new Connection\Factory();
return new Factory();
}
}
+9 -7
View File
@@ -12,7 +12,9 @@
namespace Predis\Configuration;
use InvalidArgumentException;
use Predis\Profile;
use Predis\Profile\Factory;
use Predis\Profile\ProfileInterface;
use Predis\Profile\RedisProfile;
/**
* Configures the server profile to be used by the client to create command
@@ -26,11 +28,11 @@ class ProfileOption implements OptionInterface
* Sets the commands processors that need to be applied to the profile.
*
* @param OptionsInterface $options Client options.
* @param Profile\ProfileInterface $profile Server profile.
* @param ProfileInterface $profile Server profile.
*/
protected function setProcessors(OptionsInterface $options, Profile\ProfileInterface $profile)
protected function setProcessors(OptionsInterface $options, ProfileInterface $profile)
{
if (isset($options->prefix) && $profile instanceof Profile\RedisProfile) {
if (isset($options->prefix) && $profile instanceof RedisProfile) {
$profile->setProcessor($options->prefix);
}
}
@@ -41,9 +43,9 @@ class ProfileOption implements OptionInterface
public function filter(OptionsInterface $options, $value)
{
if (is_string($value)) {
$value = Profile\Factory::get($value);
$value = Factory::get($value);
$this->setProcessors($options, $value);
} else if (!$value instanceof Profile\ProfileInterface) {
} else if (!$value instanceof ProfileInterface) {
throw new InvalidArgumentException('Invalid value for the profile option');
}
@@ -55,7 +57,7 @@ class ProfileOption implements OptionInterface
*/
public function getDefault(OptionsInterface $options)
{
$profile = Profile\Factory::getDefault();
$profile = Factory::getDefault();
$this->setProcessors($options, $profile);
return $profile;
+3 -3
View File
@@ -13,7 +13,7 @@ namespace Predis\Connection;
use InvalidArgumentException;
use ReflectionClass;
use Predis\Command;
use Predis\Command\RawCommand;
/**
* Standard connection factory for creating connections to Redis nodes.
@@ -124,13 +124,13 @@ class Factory implements FactoryInterface
if (isset($parameters->password)) {
$connection->addConnectCommand(
new Command\RawCommand(array('AUTH', $parameters->password))
new RawCommand(array('AUTH', $parameters->password))
);
}
if (isset($parameters->database)) {
$connection->addConnectCommand(
new Command\RawCommand(array('SELECT', $parameters->database))
new RawCommand(array('SELECT', $parameters->database))
);
}
}
@@ -13,7 +13,8 @@ namespace Predis\Connection;
use Predis\NotSupportedException;
use Predis\Command\CommandInterface;
use Predis\Response;
use Predis\Response\Error as ErrorResponse;
use Predis\Response\Status as StatusResponse;
/**
* This class provides the implementation of a Predis connection that uses the
@@ -133,7 +134,7 @@ class PhpiredisSocketConnection extends AbstractConnection
private function getStatusHandler()
{
return function ($payload) {
return Response\Status::get($payload);
return StatusResponse::get($payload);
};
}
@@ -145,7 +146,7 @@ class PhpiredisSocketConnection extends AbstractConnection
protected function getErrorHandler()
{
return function ($payload) {
return new Response\Error($payload);
return new ErrorResponse($payload);
};
}
@@ -13,7 +13,8 @@ namespace Predis\Connection;
use Predis\NotSupportedException;
use Predis\Command\CommandInterface;
use Predis\Response;
use Predis\Response\Error as ErrorResponse;
use Predis\Response\Status as StatusResponse;
/**
* This class provides the implementation of a Predis connection that uses PHP's
@@ -115,7 +116,7 @@ class PhpiredisStreamConnection extends StreamConnection
protected function getStatusHandler()
{
return function ($payload) {
return Response\Status::get($payload);
return StatusResponse::get($payload);
};
}
@@ -127,7 +128,7 @@ class PhpiredisStreamConnection extends StreamConnection
protected function getErrorHandler()
{
return function ($errorMessage) {
return new Response\Error($errorMessage);
return new ErrorResponse($errorMessage);
};
}
+9 -7
View File
@@ -14,8 +14,10 @@ namespace Predis\Connection;
use Countable;
use IteratorAggregate;
use Predis\NotSupportedException;
use Predis\Cluster;
use Predis\Cluster\Distributor;
use Predis\Cluster\PredisStrategy as PredisClusterStrategy;
use Predis\Cluster\StrategyInterface as ClusterStrategyInterface;
use Predis\Cluster\Distributor\DistributorInterface;
use Predis\Cluster\Distributor\HashRing;
use Predis\Command\CommandInterface;
/**
@@ -32,14 +34,14 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co
private $distributor;
/**
* @param Distributor\DistributorInterface $distributor Distributor instance.
* @param DistributorInterface $distributor Distributor instance.
*/
public function __construct(Distributor\DistributorInterface $distributor = null)
public function __construct(DistributorInterface $distributor = null)
{
$distributor = $distributor ?: new Distributor\HashRing();
$distributor = $distributor ?: new HashRing();
$this->pool = array();
$this->strategy = new Cluster\PredisStrategy($distributor->getHashGenerator());
$this->strategy = new PredisClusterStrategy($distributor->getHashGenerator());
$this->distributor = $distributor;
}
@@ -168,7 +170,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co
* Returns the underlying command hash strategy used to hash commands by
* using keys found in their arguments.
*
* @return Cluster\StrategyInterface
* @return ClusterStrategyInterface
*/
public function getClusterStrategy()
{
+9 -9
View File
@@ -16,11 +16,11 @@ use Countable;
use IteratorAggregate;
use OutOfBoundsException;
use Predis\NotSupportedException;
use Predis\Cluster;
use Predis\Cluster\RedisStrategy as RedisClusterStrategy;
use Predis\Command\CommandInterface;
use Predis\Command\RawCommand;
use Predis\Protocol;
use Predis\Response;
use Predis\Protocol\ProtocolException;
use Predis\Response\ErrorInterface as ErrorResponseInterface;
/**
* Abstraction for a Redis-backed cluster of nodes (Redis >= 3.0.0).
@@ -59,7 +59,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou
*/
public function __construct(FactoryInterface $connections = null)
{
$this->strategy = new Cluster\RedisStrategy();
$this->strategy = new RedisClusterStrategy();
$this->connections = $connections ?: new Factory();
}
@@ -350,10 +350,10 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou
* Handles -ERR responses from Redis.
*
* @param CommandInterface $command Command that generated the -ERR response.
* @param Response\ErrorInterface $error Redis error response object.
* @param ErrorResponseInterface $error Redis error response object.
* @return mixed
*/
protected function onErrorResponse(CommandInterface $command, Response\ErrorInterface $error)
protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $error)
{
$details = explode(' ', $error->getMessage(), 2);
@@ -409,7 +409,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou
return $response;
default:
throw new Protocol\ProtocolException(
throw new ProtocolException(
"Unexpected request type for a move request: $request"
);
}
@@ -439,7 +439,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou
$connection = $this->getConnection($command);
$response = $connection->executeCommand($command);
if ($response instanceof Response\ErrorInterface) {
if ($response instanceof ErrorResponseInterface) {
return $this->onErrorResponse($command, $response);
}
@@ -466,7 +466,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou
* Returns the underlying command hash strategy used to hash commands by
* using keys found in their arguments.
*
* @return Cluster\StrategyInterface
* @return ClusterStrategyInterface
*/
public function getClusterStrategy()
{
+4 -3
View File
@@ -12,7 +12,8 @@
namespace Predis\Connection;
use Predis\Command\CommandInterface;
use Predis\Response;
use Predis\Response\Error as ErrorResponse;
use Predis\Response\Status as StatusResponse;
/**
* Standard connection to Redis servers implemented on top of PHP's streams.
@@ -190,7 +191,7 @@ class StreamConnection extends AbstractConnection
switch ($prefix) {
case '+': // inline
return Response\Status::get($payload);
return StatusResponse::get($payload);
case '$': // bulk
$size = (int) $payload;
@@ -234,7 +235,7 @@ class StreamConnection extends AbstractConnection
return (int) $payload;
case '-': // error
return new Response\Error($payload);
return new ErrorResponse($payload);
default:
$this->onProtocolError("Unknown prefix: '$prefix'");
+4 -3
View File
@@ -16,7 +16,8 @@ use Predis\NotSupportedException;
use Predis\Command\CommandInterface;
use Predis\Connection\ConnectionException;
use Predis\Protocol\ProtocolException;
use Predis\Response;
use Predis\Response\Error as ErrorResponse;
use Predis\Response\Status as StatusResponse;
/**
* This class implements a Predis connection that actually talks with Webdis
@@ -152,7 +153,7 @@ class WebdisConnection implements SingleConnectionInterface
protected function getStatusHandler()
{
return function ($payload) {
return Response\Status::get($payload);
return StatusResponse::get($payload);
};
}
@@ -164,7 +165,7 @@ class WebdisConnection implements SingleConnectionInterface
protected function getErrorHandler()
{
return function ($payload) {
return new Response\Error($payload);
return new ErrorResponse($payload);
};
}
+7 -6
View File
@@ -16,8 +16,9 @@ use Predis\ClientException;
use Predis\ClientInterface;
use Predis\Connection\ConnectionInterface;
use Predis\Connection\SingleConnectionInterface;
use Predis\Profile;
use Predis\Response;
use Predis\Response\ErrorInterface as ErrorResponseInterface;
use Predis\Response\ResponseInterface;
use Predis\Response\ServerException;
/**
* Command pipeline wrapped into a MULTI / EXEC transaction.
@@ -73,9 +74,9 @@ class Atomic extends Pipeline
foreach ($commands as $command) {
$response = $connection->readResponse($command);
if ($response instanceof Response\ErrorInterface) {
if ($response instanceof ErrorResponseInterface) {
$connection->executeCommand($profile->createCommand('discard'));
throw new Response\ServerException($response->getMessage());
throw new ServerException($response->getMessage());
}
}
@@ -102,9 +103,9 @@ class Atomic extends Pipeline
$command = $commands->dequeue();
$response = $executed[$i];
if (!$response instanceof Response\ResponseInterface) {
if (!$response instanceof ResponseInterface) {
$responses[] = $command->parseResponse($response);
} else if ($response instanceof Response\ErrorInterface && $exceptions) {
} else if ($response instanceof ErrorResponseInterface && $exceptions) {
$this->exception($connection, $response);
} else {
$responses[] = $response;
+8 -6
View File
@@ -21,7 +21,9 @@ use Predis\ExecutableContextInterface;
use Predis\Command\CommandInterface;
use Predis\Connection\ConnectionInterface;
use Predis\Connection\ReplicationConnectionInterface;
use Predis\Response;
use Predis\Response\ErrorInterface as ErrorResponseInterface;
use Predis\Response\ResponseInterface;
use Predis\Response\ServerException;
/**
* Implementation of a command pipeline in which write and read operations of
@@ -85,14 +87,14 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface
* Throws an exception on -ERR responses returned by Redis.
*
* @param ConnectionInterface $connection Redis connection that returned the error.
* @param Response\ErrorInterface $response Instance of the error response.
* @param ErrorResponseInterface $response Instance of the error response.
*/
protected function exception(ConnectionInterface $connection, Response\ErrorInterface $response)
protected function exception(ConnectionInterface $connection, ErrorResponseInterface $response)
{
$connection->disconnect();
$message = $response->getMessage();
throw new Response\ServerException($message);
throw new ServerException($message);
}
/**
@@ -132,9 +134,9 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface
$command = $commands->dequeue();
$response = $connection->readResponse($command);
if (!$response instanceof Response\ResponseInterface) {
if (!$response instanceof ResponseInterface) {
$responses[] = $command->parseResponse($response);
} else if ($response instanceof Response\ErrorInterface && $exceptions) {
} else if ($response instanceof ErrorResponseInterface && $exceptions) {
$this->exception($connection, $response);
} else {
$responses[] = $response;
@@ -12,7 +12,7 @@
namespace Predis\Protocol\Text\Handler;
use Predis\Connection\ComposableConnectionInterface;
use Predis\Response;
use Predis\Response\Error;
/**
* Handler for the error response type in the standard Redis wire protocol.
@@ -28,6 +28,6 @@ class ErrorResponse implements ResponseHandlerInterface
*/
public function handle(ComposableConnectionInterface $connection, $payload)
{
return new Response\Error($payload);
return new Error($payload);
}
}
@@ -12,7 +12,7 @@
namespace Predis\Protocol\Text\Handler;
use Predis\Connection\ComposableConnectionInterface;
use Predis\Response;
use Predis\Response\Status;
/**
* Handler for the status response type in the standard Redis wire protocol. It
@@ -29,6 +29,6 @@ class StatusResponse implements ResponseHandlerInterface
*/
public function handle(ComposableConnectionInterface $connection, $payload)
{
return new Response\Status($payload);
return Status::get($payload);
}
}
@@ -13,7 +13,7 @@ namespace Predis\Protocol\Text\Handler;
use Predis\CommunicationException;
use Predis\Connection\ComposableConnectionInterface;
use Predis\Response\Iterator\MultiBulk;
use Predis\Response\Iterator\MultiBulk as MultiBulkIterator;
use Predis\Protocol\ProtocolException;
/**
@@ -41,6 +41,6 @@ class StreamableMultiBulkResponse implements ResponseHandlerInterface
));
}
return new MultiBulk($connection, $length);
return new MultiBulkIterator($connection, $length);
}
}
@@ -16,8 +16,9 @@ use Predis\Command\CommandInterface;
use Predis\Connection\ComposableConnectionInterface;
use Predis\Protocol\ProtocolException;
use Predis\Protocol\ProtocolProcessorInterface;
use Predis\Response;
use Predis\Response\Iterator;
use Predis\Response\Status as StatusResponse;
use Predis\Response\Error as ErrorResponse;
use Predis\Response\Iterator\MultiBulk as MultiBulkIterator;
/**
* Protocol processor for the standard Redis wire protocol.
@@ -59,7 +60,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface
switch ($prefix) {
case '+': // inline
return new Response\Status($payload);
return new StatusResponse($payload);
case '$': // bulk
$size = (int) $payload;
@@ -75,7 +76,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface
return null;
}
if ($this->mbiterable) {
return new Iterator\MultiBulk($connection, $count);
return new MultiBulkIterator($connection, $count);
}
$multibulk = array();
@@ -90,7 +91,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface
return (int) $payload;
case '-': // error
return new Response\Error($payload);
return new ErrorResponse($payload);
default:
CommunicationException::handle(new ProtocolException(
@@ -13,7 +13,7 @@ namespace Predis\Response\Iterator;
use Iterator;
use Countable;
use Predis\Response;
use Predis\Response\ResponseInterface;
/**
* Iterator that abstracts the access to multibulk responses allowing them to be
@@ -27,7 +27,7 @@ use Predis\Response;
*
* @author Daniele Alessandri <suppakilla@gmail.com>
*/
abstract class MultiBulkIterator implements Iterator, Countable, Response\ResponseInterface
abstract class MultiBulkIterator implements Iterator, Countable, ResponseInterface
{
protected $current;
protected $position;
+12 -8
View File
@@ -11,6 +11,7 @@
namespace Predis\Transaction;
use Exception;
use InvalidArgumentException;
use SplQueue;
use Predis\BasicClientInterface;
@@ -19,7 +20,10 @@ use Predis\ClientInterface;
use Predis\CommunicationException;
use Predis\ExecutableContextInterface;
use Predis\NotSupportedException;
use Predis\Response;
use Predis\Response\ErrorInterface as ErrorResponseInterface;
use Predis\Response\ResponseInterface;
use Predis\Response\ServerException;
use Predis\Response\Status as StatusResponse;
use Predis\Command\CommandInterface;
use Predis\Connection\AggregateConnectionInterface;
use Predis\Protocol\ProtocolException;
@@ -171,8 +175,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
$command = $this->client->createCommand($commandID, $arguments);
$response = $this->client->executeCommand($command);
if ($response instanceof Response\Error) {
throw new Response\ServerException($response->getMessage());
if ($response instanceof ErrorResponseInterface) {
throw new ServerException($response->getMessage());
}
return $response;
@@ -193,7 +197,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
return $response;
}
if ($response != 'QUEUED' && !$response instanceof Response\Status) {
if ($response != 'QUEUED' && !$response instanceof StatusResponse) {
$this->onProtocolError('The server did not respond with a QUEUED status response');
}
@@ -375,8 +379,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
for ($i = 0; $i < $size; $i++) {
$cmdResponse = $execResponse[$i];
if ($cmdResponse instanceof Response\ErrorInterface && $this->exceptions) {
throw new Response\ServerException($cmdResponse->getMessage());
if ($cmdResponse instanceof ErrorResponseInterface && $this->exceptions) {
throw new ServerException($cmdResponse->getMessage());
}
$response[$i] = $commands->dequeue()->parseResponse($cmdResponse);
@@ -399,9 +403,9 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
call_user_func($callable, $this);
} catch (CommunicationException $exception) {
// NOOP
} catch (Response\ServerException $exception) {
} catch (ServerException $exception) {
// NOOP
} catch (\Exception $exception) {
} catch (Exception $exception) {
$this->discard();
}