From 02e43143d3fc660af1fc30faf43953fb86e3f5da Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 17 Dec 2013 12:53:36 +0100 Subject: [PATCH] Run php-cs against codebase. --- lib/Predis/BasicClientInterface.php | 2 +- lib/Predis/Client.php | 47 ++++++++++--------- lib/Predis/ClientInterface.php | 4 +- .../Distributor/DistributorInterface.php | 4 +- lib/Predis/Cluster/Distributor/HashRing.php | 26 +++++----- .../Cluster/Hash/HashGeneratorInterface.php | 2 +- lib/Predis/Cluster/PredisStrategy.php | 21 +++++---- lib/Predis/Cluster/RedisStrategy.php | 13 ++--- lib/Predis/Cluster/StrategyInterface.php | 4 +- .../Iterator/CursorBasedIterator.php | 8 ++-- lib/Predis/Collection/Iterator/ListKey.php | 4 +- lib/Predis/Command/Command.php | 10 ++-- lib/Predis/Command/CommandInterface.php | 2 +- lib/Predis/Command/HashScan.php | 2 +- lib/Predis/Command/KeyScan.php | 2 +- .../Command/Processor/KeyPrefixProcessor.php | 21 +++++---- lib/Predis/Command/RawCommand.php | 4 +- lib/Predis/Command/ScriptCommand.php | 2 +- lib/Predis/Command/ServerClient.php | 2 +- lib/Predis/Command/ServerInfo.php | 4 +- lib/Predis/Command/SetScan.php | 2 +- lib/Predis/Command/ZSetAdd.php | 2 +- lib/Predis/Command/ZSetRange.php | 3 +- lib/Predis/Command/ZSetScan.php | 2 +- lib/Predis/Command/ZSetUnionStore.php | 2 +- lib/Predis/CommunicationException.php | 8 ++-- lib/Predis/Configuration/ClusterOption.php | 4 +- .../Configuration/ConnectionFactoryOption.php | 2 +- lib/Predis/Configuration/OptionInterface.php | 4 +- lib/Predis/Configuration/Options.php | 1 + lib/Predis/Configuration/OptionsInterface.php | 8 ++-- lib/Predis/Configuration/ProfileOption.php | 2 +- lib/Predis/Connection/AbstractConnection.php | 6 +-- .../AggregateConnectionInterface.php | 8 ++-- .../ComposableConnectionInterface.php | 2 - .../Connection/ComposableStreamConnection.php | 4 +- lib/Predis/Connection/ConnectionInterface.php | 4 +- lib/Predis/Connection/Factory.php | 2 +- lib/Predis/Connection/FactoryInterface.php | 10 ++-- lib/Predis/Connection/Parameters.php | 12 ++--- lib/Predis/Connection/ParametersInterface.php | 4 +- .../Connection/PhpiredisSocketConnection.php | 6 +-- lib/Predis/Connection/PredisCluster.php | 8 ++-- lib/Predis/Connection/RedisCluster.php | 24 +++++----- lib/Predis/Connection/StreamConnection.php | 14 +++--- lib/Predis/Connection/WebdisConnection.php | 10 ++-- lib/Predis/ExecutableContextInterface.php | 2 +- lib/Predis/Pipeline/Atomic.php | 2 +- lib/Predis/Pipeline/ConnectionErrorProof.php | 2 +- lib/Predis/Pipeline/Pipeline.php | 18 +++---- lib/Predis/Profile/Factory.php | 2 +- lib/Predis/Profile/ProfileInterface.php | 8 ++-- lib/Predis/Profile/RedisProfile.php | 6 +-- lib/Predis/Profile/RedisVersion200.php | 1 - lib/Predis/Profile/RedisVersion220.php | 2 - lib/Predis/Profile/RedisVersion240.php | 3 -- lib/Predis/Profile/RedisVersion260.php | 4 -- lib/Predis/Profile/RedisVersion280.php | 5 -- .../Protocol/ProtocolProcessorInterface.php | 4 +- .../Protocol/RequestSerializerInterface.php | 2 +- .../Protocol/ResponseReaderInterface.php | 2 +- .../Text/ComposableProtocolProcessor.php | 2 +- .../Text/Handler/ResponseHandlerInterface.php | 6 +-- .../Protocol/Text/ProtocolProcessor.php | 11 +++-- lib/Predis/Protocol/Text/ResponseReader.php | 6 +-- lib/Predis/PubSub/AbstractConsumer.php | 14 +++--- lib/Predis/PubSub/Consumer.php | 4 +- lib/Predis/PubSub/DispatcherLoop.php | 4 +- .../Replication/ReplicationStrategy.php | 13 ++--- lib/Predis/Response/Error.php | 1 + lib/Predis/Response/Iterator/MultiBulk.php | 2 +- .../Response/Iterator/MultiBulkIterator.php | 2 +- lib/Predis/Response/Status.php | 2 + lib/Predis/Session/Handler.php | 7 +-- .../Transaction/AbortedMultiExecException.php | 4 +- lib/Predis/Transaction/MultiExec.php | 25 +++++----- lib/Predis/Transaction/MultiExecState.php | 2 +- 77 files changed, 248 insertions(+), 258 deletions(-) diff --git a/lib/Predis/BasicClientInterface.php b/lib/Predis/BasicClientInterface.php index 6f77d913..307d6d00 100644 --- a/lib/Predis/BasicClientInterface.php +++ b/lib/Predis/BasicClientInterface.php @@ -24,7 +24,7 @@ interface BasicClientInterface /** * Executes the specified Redis command. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return mixed */ public function executeCommand(CommandInterface $command); diff --git a/lib/Predis/Client.php b/lib/Predis/Client.php index 25747f19..67fb8f53 100644 --- a/lib/Predis/Client.php +++ b/lib/Predis/Client.php @@ -48,7 +48,7 @@ class Client implements ClientInterface /** * @param mixed $parameters Connection parameters for one or more servers. - * @param mixed $options Options to configure some behaviours of the client. + * @param mixed $options Options to configure some behaviours of the client. */ public function __construct($parameters = null, $options = null) { @@ -62,7 +62,7 @@ class Client implements ClientInterface * types of arguments or simply returns the passed argument if it is an * instance of Predis\Configuration\OptionsInterface. * - * @param mixed $options Client options. + * @param mixed $options Client options. * @return OptionsInterface */ protected function createOptions($options) @@ -91,7 +91,7 @@ class Client implements ClientInterface * - String * - Callable * - * @param mixed $parameters Connection parameters or connection instance. + * @param mixed $parameters Connection parameters or connection instance. * @return ConnectionInterface */ protected function createConnection($parameters) @@ -141,7 +141,7 @@ class Client implements ClientInterface * Wraps a callable to make sure that its returned value represents a valid * connection type. * - * @param mixed $callable + * @param mixed $callable * @return mixed */ protected function getConnectionInitializerWrapper($callable) @@ -240,7 +240,7 @@ class Client implements ClientInterface * Retrieves the specified connection from the aggregate connection when the * client is in cluster or replication mode. * - * @param string $connectionID Index or alias of the single connection. + * @param string $connectionID Index or alias of the single connection. * @return SingleConnectionInterface */ public function getConnectionById($connectionID) @@ -262,8 +262,8 @@ class Client implements ClientInterface * It is possibile to indentify Redis error responses from normal responses * using the second optional argument which is populated by reference. * - * @param array $arguments Command arguments as defined by the command signature. - * @param bool $error Set to TRUE when Redis returned an error response. + * @param array $arguments Command arguments as defined by the command signature. + * @param bool $error Set to TRUE when Redis returned an error response. * @return mixed */ public function executeRaw(array $arguments, &$error = null) @@ -288,8 +288,8 @@ class Client implements ClientInterface * Creates a Redis command with the specified arguments and sends a request * to the server. * - * @param string $commandID Command ID. - * @param array $arguments Arguments for the command. + * @param string $commandID Command ID. + * @param array $arguments Arguments for the command. * @return mixed */ public function __call($commandID, $arguments) @@ -329,8 +329,8 @@ class Client implements ClientInterface /** * Handles -ERR responses returned by Redis. * - * @param CommandInterface $command Redis command that generated the error. - * @param ErrorResponseInterface $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 onErrorResponse( @@ -363,8 +363,8 @@ class Client implements ClientInterface * simply an utility method to create Redis contexts instances since they * follow a common initialization path. * - * @param string $initializer Method name. - * @param array $argv Arguments for the method. + * @param string $initializer Method name. + * @param array $argv Arguments for the method. * @return mixed */ private function sharedContextFactory($initializer, $argv = null) @@ -380,6 +380,7 @@ class Client implements ClientInterface case 2: list($arg0, $arg1) = $argv; + return $this->$initializer($arg0, $arg1); default: @@ -391,7 +392,7 @@ class Client implements ClientInterface * Creates a new pipeline context and returns it, or returns the results of * a pipeline executed inside the optionally provided callable object. * - * @param mixed $arg,... Options for the context, or a callable, or both. + * @param mixed $arg,... Options for the context, or a callable, or both. * @return Pipeline|array */ public function pipeline(/* arguments */) @@ -402,15 +403,15 @@ class Client implements ClientInterface /** * Actual pipeline context initializer method. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable used to execute the context. + * @param array $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. * @return Pipeline|array */ protected function createPipeline(array $options = null, $callable = null) { if (isset($options['atomic']) && $options['atomic']) { $class = 'Predis\Pipeline\Atomic'; - } else if (isset($options['fire-and-forget']) && $options['fire-and-forget']) { + } elseif (isset($options['fire-and-forget']) && $options['fire-and-forget']) { $class = 'Predis\Pipeline\FireAndForget'; } else { $class = 'Predis\Pipeline\Pipeline'; @@ -429,7 +430,7 @@ class Client implements ClientInterface * Creates a new transaction context and returns it, or returns the results * of a transaction executed inside the optionally provided callable object. * - * @param mixed $arg,... Options for the context, or a callable, or both. + * @param mixed $arg,... Options for the context, or a callable, or both. * @return TransactionMultiExec|array */ public function transaction(/* arguments */) @@ -440,8 +441,8 @@ class Client implements ClientInterface /** * Actual transaction context initializer method. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable used to execute the context. + * @param array $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. * @return TransactionMultiExec|array */ protected function createTransaction(array $options = null, $callable = null) @@ -459,7 +460,7 @@ class Client implements ClientInterface * Creates a new publis/subscribe context and returns it, or starts its loop * inside the optionally provided callable object. * - * @param mixed $arg,... Options for the context, or a callable, or both. + * @param mixed $arg,... Options for the context, or a callable, or both. * @return PubSubConsumer|NULL */ public function pubSubLoop(/* arguments */) @@ -470,8 +471,8 @@ class Client implements ClientInterface /** * Actual publish/subscribe context initializer method. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable used to execute the context. + * @param array $options Options for the context. + * @param mixed $callable Optional callable used to execute the context. * @return PubSubConsumer|NULL */ protected function createPubSub(array $options = null, $callable = null) diff --git a/lib/Predis/ClientInterface.php b/lib/Predis/ClientInterface.php index 36dd5193..4815eb8a 100644 --- a/lib/Predis/ClientInterface.php +++ b/lib/Predis/ClientInterface.php @@ -58,8 +58,8 @@ interface ClientInterface extends BasicClientInterface /** * Creates a new instance of the specified Redis command. * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. + * @param string $method Command ID. + * @param array $arguments Arguments for the command. * @return CommandInterface */ public function createCommand($method, $arguments = array()); diff --git a/lib/Predis/Cluster/Distributor/DistributorInterface.php b/lib/Predis/Cluster/Distributor/DistributorInterface.php index 6a22a9fe..853320f9 100644 --- a/lib/Predis/Cluster/Distributor/DistributorInterface.php +++ b/lib/Predis/Cluster/Distributor/DistributorInterface.php @@ -24,8 +24,8 @@ interface DistributorInterface /** * Adds a node to the distributor with an optional weight. * - * @param mixed $node Node object. - * @param int $weight Weight for the node. + * @param mixed $node Node object. + * @param int $weight Weight for the node. */ public function add($node, $weight = null); diff --git a/lib/Predis/Cluster/Distributor/HashRing.php b/lib/Predis/Cluster/Distributor/HashRing.php index f0a32eb6..2316de32 100644 --- a/lib/Predis/Cluster/Distributor/HashRing.php +++ b/lib/Predis/Cluster/Distributor/HashRing.php @@ -34,7 +34,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface private $nodes = array(); /** - * @param int $replicas Number of replicas in the ring. + * @param int $replicas Number of replicas in the ring. * @param mixed $nodeHashCallback Callback returning a string used to calculate the hash of nodes. */ public function __construct($replicas = self::DEFAULT_REPLICAS, $nodeHashCallback = null) @@ -46,8 +46,8 @@ class HashRing implements DistributorInterface, HashGeneratorInterface /** * Adds a node to the ring with an optional weight. * - * @param mixed $node Node object. - * @param int $weight Weight for the node. + * @param mixed $node Node object. + * @param int $weight Weight for the node. */ public function add($node, $weight = null) { @@ -148,10 +148,10 @@ class HashRing implements DistributorInterface, HashGeneratorInterface /** * Implements the logic needed to add a node to the hashring. * - * @param array $ring Source hashring. - * @param mixed $node Node object to be added. - * @param int $totalNodes Total number of nodes. - * @param int $replicas Number of replicas in the ring. + * @param array $ring Source hashring. + * @param mixed $node Node object to be added. + * @param int $totalNodes Total number of nodes. + * @param int $replicas Number of replicas in the ring. * @param float $weightRatio Weight ratio for the node. */ protected function addNodeToRing(&$ring, $node, $totalNodes, $replicas, $weightRatio) @@ -181,7 +181,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface /** * Calculates the hash for the specified value. * - * @param string $value Input value. + * @param string $value Input value. * @return int */ public function hash($value) @@ -200,7 +200,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface /** * Calculates the corrisponding key of a node distributed in the hashring. * - * @param int $key Computed hash of a key. + * @param int $key Computed hash of a key. * @return int */ private function getNodeKey($key) @@ -216,7 +216,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface if ($item > $key) { $upper = $index - 1; - } else if ($item < $key) { + } elseif ($item < $key) { $lower = $index + 1; } else { return $item; @@ -229,9 +229,9 @@ class HashRing implements DistributorInterface, HashGeneratorInterface /** * Implements a strategy to deal with wrap-around errors during binary searches. * - * @param int $upper - * @param int $lower - * @param int $ringKeysCount + * @param int $upper + * @param int $lower + * @param int $ringKeysCount * @return int */ protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) diff --git a/lib/Predis/Cluster/Hash/HashGeneratorInterface.php b/lib/Predis/Cluster/Hash/HashGeneratorInterface.php index e20fea26..f54266a7 100644 --- a/lib/Predis/Cluster/Hash/HashGeneratorInterface.php +++ b/lib/Predis/Cluster/Hash/HashGeneratorInterface.php @@ -22,7 +22,7 @@ interface HashGeneratorInterface /** * Generates an hash from a string to be used for distribution. * - * @param string $value String value. + * @param string $value String value. * @return int */ public function hash($value); diff --git a/lib/Predis/Cluster/PredisStrategy.php b/lib/Predis/Cluster/PredisStrategy.php index 38761ef5..37955177 100644 --- a/lib/Predis/Cluster/PredisStrategy.php +++ b/lib/Predis/Cluster/PredisStrategy.php @@ -180,7 +180,7 @@ class PredisStrategy implements StrategyInterface * handler for the specified command ID is removed. * * @param string $commandID Command ID. - * @param mixed $callback A valid callable object, or NULL to unset the handler. + * @param mixed $callback A valid callable object, or NULL to unset the handler. */ public function setCommandHandler($commandID, $callback = null) { @@ -188,6 +188,7 @@ class PredisStrategy implements StrategyInterface if (!isset($callback)) { unset($this->commands[$commandID]); + return; } @@ -203,7 +204,7 @@ class PredisStrategy implements StrategyInterface /** * Extracts the key from the first argument of a command instance. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromFirstArgument(CommandInterface $command) @@ -215,7 +216,7 @@ class PredisStrategy implements StrategyInterface * Extracts the key from a command with multiple keys only when all keys in * the arguments array produce the same hash. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromAllArguments(CommandInterface $command) @@ -231,7 +232,7 @@ class PredisStrategy implements StrategyInterface * Extracts the key from a command with multiple keys only when all keys in * the arguments array produce the same hash. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromInterleavedArguments(CommandInterface $command) @@ -251,7 +252,7 @@ class PredisStrategy implements StrategyInterface /** * Extracts the key from BLPOP and BRPOP commands. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromBlockingListCommands(CommandInterface $command) @@ -266,7 +267,7 @@ class PredisStrategy implements StrategyInterface /** * Extracts the key from BITOP command. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromBitOp(CommandInterface $command) @@ -281,7 +282,7 @@ class PredisStrategy implements StrategyInterface /** * Extracts the key from ZINTERSTORE and ZUNIONSTORE commands. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromZsetAggregationCommands(CommandInterface $command) @@ -297,7 +298,7 @@ class PredisStrategy implements StrategyInterface /** * Extracts the key from EVAL and EVALSHA commands. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromScriptingCommands(CommandInterface $command) @@ -346,7 +347,7 @@ class PredisStrategy implements StrategyInterface /** * Checks if the specified array of keys will generate the same hash. * - * @param array $keys Array of keys. + * @param array $keys Array of keys. * @return Boolean */ protected function checkSameHashForKeys(array $keys) @@ -374,7 +375,7 @@ class PredisStrategy implements StrategyInterface * Returns only the hashable part of a key (delimited by "{...}"), or the * whole key if a key tag is not found in the string. * - * @param string $key A key. + * @param string $key A key. * @return string */ protected function extractKeyTag($key) diff --git a/lib/Predis/Cluster/RedisStrategy.php b/lib/Predis/Cluster/RedisStrategy.php index 7a603c79..b5918e4b 100644 --- a/lib/Predis/Cluster/RedisStrategy.php +++ b/lib/Predis/Cluster/RedisStrategy.php @@ -165,7 +165,7 @@ class RedisStrategy implements StrategyInterface * handler for the specified command ID is removed. * * @param string $commandID Command ID. - * @param mixed $callback A valid callable object, or NULL to unset the handler. + * @param mixed $callback A valid callable object, or NULL to unset the handler. */ public function setCommandHandler($commandID, $callback = null) { @@ -173,6 +173,7 @@ class RedisStrategy implements StrategyInterface if (!isset($callback)) { unset($this->commands[$commandID]); + return; } @@ -188,7 +189,7 @@ class RedisStrategy implements StrategyInterface /** * Extracts the key from the first argument of a command instance. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromFirstArgument(CommandInterface $command) @@ -200,7 +201,7 @@ class RedisStrategy implements StrategyInterface * Extracts the key from a command that can accept multiple keys ensuring * that only one key is actually specified to comply with redis-cluster. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromAllArguments(CommandInterface $command) @@ -216,7 +217,7 @@ class RedisStrategy implements StrategyInterface * Extracts the key from a command that can accept multiple keys ensuring * that only one key is actually specified to comply with redis-cluster. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromInterleavedArguments(CommandInterface $command) @@ -232,7 +233,7 @@ class RedisStrategy implements StrategyInterface * Extracts the key from BLPOP and BRPOP commands ensuring that only one key * is actually specified to comply with redis-cluster. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromBlockingListCommands(CommandInterface $command) @@ -247,7 +248,7 @@ class RedisStrategy implements StrategyInterface /** * Extracts the key from EVAL and EVALSHA commands. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromScriptingCommands(CommandInterface $command) diff --git a/lib/Predis/Cluster/StrategyInterface.php b/lib/Predis/Cluster/StrategyInterface.php index 848e507a..40782639 100644 --- a/lib/Predis/Cluster/StrategyInterface.php +++ b/lib/Predis/Cluster/StrategyInterface.php @@ -27,7 +27,7 @@ interface StrategyInterface * Returns the hash for the given command using the specified algorithm, or * null when the command cannot be hashed. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return int */ public function getHash(CommandInterface $command); @@ -35,7 +35,7 @@ interface StrategyInterface /** * Returns the hash for the given key using the specified algorithm. * - * @param string $key Key string. + * @param string $key Key string. * @return string */ public function getKeyHash($key); diff --git a/lib/Predis/Collection/Iterator/CursorBasedIterator.php b/lib/Predis/Collection/Iterator/CursorBasedIterator.php index 5ec110c1..75eaa366 100644 --- a/lib/Predis/Collection/Iterator/CursorBasedIterator.php +++ b/lib/Predis/Collection/Iterator/CursorBasedIterator.php @@ -43,8 +43,8 @@ abstract class CursorBasedIterator implements Iterator /** * @param ClientInterface $client Client connected to Redis. - * @param string $match Pattern to match during the server-side iteration. - * @param int $count Hint used by Redis to compute the number of results per iteration. + * @param string $match Pattern to match during the server-side iteration. + * @param int $count Hint used by Redis to compute the number of results per iteration. */ public function __construct(ClientInterface $client, $match = null, $count = null) { @@ -108,7 +108,7 @@ abstract class CursorBasedIterator implements Iterator * * @return array */ - protected abstract function executeCommand(); + abstract protected function executeCommand(); /** * Populates the local buffer of elements fetched from the server during @@ -171,7 +171,7 @@ abstract class CursorBasedIterator implements Iterator if ($this->elements) { $this->extractNext(); - } else if ($this->cursor) { + } elseif ($this->cursor) { $this->next(); } else { $this->valid = false; diff --git a/lib/Predis/Collection/Iterator/ListKey.php b/lib/Predis/Collection/Iterator/ListKey.php index aa10d8d4..795edd8a 100644 --- a/lib/Predis/Collection/Iterator/ListKey.php +++ b/lib/Predis/Collection/Iterator/ListKey.php @@ -43,8 +43,8 @@ class ListKey implements Iterator /** * @param ClientInterface $client Client connected to Redis. - * @param string $key Redis list key. - * @param int $count Number of items retrieved on each fetch operation. + * @param string $key Redis list key. + * @param int $count Number of items retrieved on each fetch operation. */ public function __construct(ClientInterface $client, $key, $count = 10) { diff --git a/lib/Predis/Command/Command.php b/lib/Predis/Command/Command.php index c11aba38..aac869a6 100644 --- a/lib/Predis/Command/Command.php +++ b/lib/Predis/Command/Command.php @@ -24,7 +24,7 @@ abstract class Command implements CommandInterface /** * Returns a filtered array of the arguments. * - * @param array $arguments List of arguments. + * @param array $arguments List of arguments. * @return array */ protected function filterArguments(array $arguments) @@ -99,8 +99,8 @@ abstract class Command implements CommandInterface /** * Helper function used to reduce a list of arguments to a string. * - * @param string $accumulator Temporary string. - * @param string $argument Current argument. + * @param string $accumulator Temporary string. + * @param string $argument Current argument. * @return string */ protected function toStringArgumentReducer($accumulator, $argument) @@ -131,7 +131,7 @@ abstract class Command implements CommandInterface /** * Normalizes the arguments array passed to a Redis command. * - * @param array $arguments Arguments for a command. + * @param array $arguments Arguments for a command. * @return array */ public static function normalizeArguments(array $arguments) @@ -146,7 +146,7 @@ abstract class Command implements CommandInterface /** * Normalizes the arguments array passed to a variadic Redis command. * - * @param array $arguments Arguments for a command. + * @param array $arguments Arguments for a command. * @return array */ public static function normalizeVariadic(array $arguments) diff --git a/lib/Predis/Command/CommandInterface.php b/lib/Predis/Command/CommandInterface.php index 822949cc..ce16ab95 100644 --- a/lib/Predis/Command/CommandInterface.php +++ b/lib/Predis/Command/CommandInterface.php @@ -71,7 +71,7 @@ interface CommandInterface /** * Parses a raw response and returns a PHP object. * - * @param string $data Binary string containing the whole response. + * @param string $data Binary string containing the whole response. * @return mixed */ public function parseResponse($data); diff --git a/lib/Predis/Command/HashScan.php b/lib/Predis/Command/HashScan.php index 0f66ceb8..c9ff3fcb 100644 --- a/lib/Predis/Command/HashScan.php +++ b/lib/Predis/Command/HashScan.php @@ -41,7 +41,7 @@ class HashScan extends Command /** * Returns a list of options and modifiers compatible with Redis. * - * @param array $options List of options. + * @param array $options List of options. * @return array */ protected function prepareOptions($options) diff --git a/lib/Predis/Command/KeyScan.php b/lib/Predis/Command/KeyScan.php index cbd693e8..0ecf2184 100644 --- a/lib/Predis/Command/KeyScan.php +++ b/lib/Predis/Command/KeyScan.php @@ -41,7 +41,7 @@ class KeyScan extends Command /** * Returns a list of options and modifiers compatible with Redis. * - * @param array $options List of options. + * @param array $options List of options. * @return array */ protected function prepareOptions($options) diff --git a/lib/Predis/Command/Processor/KeyPrefixProcessor.php b/lib/Predis/Command/Processor/KeyPrefixProcessor.php index a56c67c7..68c2a30e 100644 --- a/lib/Predis/Command/Processor/KeyPrefixProcessor.php +++ b/lib/Predis/Command/Processor/KeyPrefixProcessor.php @@ -179,7 +179,7 @@ class KeyPrefixProcessor implements ProcessorInterface { if ($command instanceof PrefixableCommandInterface) { $command->prefixKeys($this->prefix); - } else if (isset($this->commands[$commandID = strtoupper($command->getId())])) { + } elseif (isset($this->commands[$commandID = strtoupper($command->getId())])) { call_user_func($this->commands[$commandID], $command, $this->prefix); } } @@ -196,7 +196,7 @@ class KeyPrefixProcessor implements ProcessorInterface * associated handler for the specified command ID is removed. * * @param string $commandID The ID of the command to be handled. - * @param mixed $callback A valid callable object or NULL. + * @param mixed $callback A valid callable object or NULL. */ public function setCommandHandler($commandID, $callback = null) { @@ -204,6 +204,7 @@ class KeyPrefixProcessor implements ProcessorInterface if (!isset($callback)) { unset($this->commands[$commandID]); + return; } @@ -228,7 +229,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix only the first argument. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function first(CommandInterface $command, $prefix) { @@ -242,7 +243,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix to all the arguments. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function all(CommandInterface $command, $prefix) { @@ -259,7 +260,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix only to even arguments in the list. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function interleaved(CommandInterface $command, $prefix) { @@ -278,7 +279,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix to all the arguments but the first one. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function skipFirst(CommandInterface $command, $prefix) { @@ -297,7 +298,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix to all the arguments but the last one. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function skipLast(CommandInterface $command, $prefix) { @@ -316,7 +317,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix to the keys of a SORT command. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function sort(CommandInterface $command, $prefix) { @@ -353,7 +354,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix to the keys of an EVAL-based command. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function evalKeys(CommandInterface $command, $prefix) { @@ -370,7 +371,7 @@ class KeyPrefixProcessor implements ProcessorInterface * Applies the specified prefix to the keys of Z[INTERSECTION|UNION]STORE. * * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. + * @param string $prefix Prefix string. */ public static function zsetStore(CommandInterface $command, $prefix) { diff --git a/lib/Predis/Command/RawCommand.php b/lib/Predis/Command/RawCommand.php index 90ce9db4..0e334efc 100644 --- a/lib/Predis/Command/RawCommand.php +++ b/lib/Predis/Command/RawCommand.php @@ -129,8 +129,8 @@ class RawCommand implements CommandInterface /** * Helper function used to reduce a list of arguments to a string. * - * @param string $accumulator Temporary string. - * @param string $argument Current argument. + * @param string $accumulator Temporary string. + * @param string $argument Current argument. * @return string */ protected function toStringArgumentReducer($accumulator, $argument) diff --git a/lib/Predis/Command/ScriptCommand.php b/lib/Predis/Command/ScriptCommand.php index c8a138c9..1ea20333 100644 --- a/lib/Predis/Command/ScriptCommand.php +++ b/lib/Predis/Command/ScriptCommand.php @@ -25,7 +25,7 @@ abstract class ScriptCommand extends ServerEvalSHA * * @return string */ - public abstract function getScript(); + abstract public function getScript(); /** * Specifies the number of arguments that should be considered as keys. diff --git a/lib/Predis/Command/ServerClient.php b/lib/Predis/Command/ServerClient.php index 68950f49..287dfc11 100644 --- a/lib/Predis/Command/ServerClient.php +++ b/lib/Predis/Command/ServerClient.php @@ -49,7 +49,7 @@ class ServerClient extends Command /** * Parses the response to CLIENT LIST and returns a structured list. * - * @param string $data Response buffer. + * @param string $data Response buffer. * @return array */ protected function parseClientList($data) diff --git a/lib/Predis/Command/ServerInfo.php b/lib/Predis/Command/ServerInfo.php index e22c0262..63f7e27c 100644 --- a/lib/Predis/Command/ServerInfo.php +++ b/lib/Predis/Command/ServerInfo.php @@ -58,7 +58,7 @@ class ServerInfo extends Command /** * Extracts the statistics of each logical DB from the string buffer. * - * @param string $str Response buffer. + * @param string $str Response buffer. * @return array */ protected function parseDatabaseStats($str) @@ -76,7 +76,7 @@ class ServerInfo extends Command /** * Parses the response and extracts the allocation statistics. * - * @param string $str Response buffer. + * @param string $str Response buffer. * @return array */ protected function parseAllocationStats($str) diff --git a/lib/Predis/Command/SetScan.php b/lib/Predis/Command/SetScan.php index b336ff01..28771dd6 100644 --- a/lib/Predis/Command/SetScan.php +++ b/lib/Predis/Command/SetScan.php @@ -41,7 +41,7 @@ class SetScan extends Command /** * Returns a list of options and modifiers compatible with Redis. * - * @param array $options List of options. + * @param array $options List of options. * @return array */ protected function prepareOptions($options) diff --git a/lib/Predis/Command/ZSetAdd.php b/lib/Predis/Command/ZSetAdd.php index b30075df..71c57630 100644 --- a/lib/Predis/Command/ZSetAdd.php +++ b/lib/Predis/Command/ZSetAdd.php @@ -33,7 +33,7 @@ class ZSetAdd extends Command if (count($arguments) === 2 && is_array($arguments[1])) { $flattened = array($arguments[0]); - foreach($arguments[1] as $member => $score) { + foreach ($arguments[1] as $member => $score) { $flattened[] = $score; $flattened[] = $member; } diff --git a/lib/Predis/Command/ZSetRange.php b/lib/Predis/Command/ZSetRange.php index 3313b6f8..c01d8f78 100644 --- a/lib/Predis/Command/ZSetRange.php +++ b/lib/Predis/Command/ZSetRange.php @@ -41,6 +41,7 @@ class ZSetRange extends Command if ($lastType === 'array') { $options = $this->prepareOptions(array_pop($arguments)); + return array_merge($arguments, $options); } } @@ -51,7 +52,7 @@ class ZSetRange extends Command /** * Returns a list of options and modifiers compatible with Redis. * - * @param array $options List of options. + * @param array $options List of options. * @return array */ protected function prepareOptions($options) diff --git a/lib/Predis/Command/ZSetScan.php b/lib/Predis/Command/ZSetScan.php index fa3150d5..6e926dc2 100644 --- a/lib/Predis/Command/ZSetScan.php +++ b/lib/Predis/Command/ZSetScan.php @@ -41,7 +41,7 @@ class ZSetScan extends Command /** * Returns a list of options and modifiers compatible with Redis. * - * @param array $options List of options. + * @param array $options List of options. * @return array */ protected function prepareOptions($options) diff --git a/lib/Predis/Command/ZSetUnionStore.php b/lib/Predis/Command/ZSetUnionStore.php index 3b1a9e18..fb96e679 100644 --- a/lib/Predis/Command/ZSetUnionStore.php +++ b/lib/Predis/Command/ZSetUnionStore.php @@ -50,7 +50,7 @@ class ZSetUnionStore extends Command /** * Returns a list of options and modifiers compatible with Redis. * - * @param array $options List of options. + * @param array $options List of options. * @return array */ private function prepareOptions($options) diff --git a/lib/Predis/CommunicationException.php b/lib/Predis/CommunicationException.php index eee976cf..33951dfb 100644 --- a/lib/Predis/CommunicationException.php +++ b/lib/Predis/CommunicationException.php @@ -23,10 +23,10 @@ abstract class CommunicationException extends PredisException private $connection; /** - * @param SingleConnectionInterface $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 SingleConnectionInterface $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. */ public function __construct( SingleConnectionInterface $connection, diff --git a/lib/Predis/Configuration/ClusterOption.php b/lib/Predis/Configuration/ClusterOption.php index 87e21f0b..048cd4ba 100644 --- a/lib/Predis/Configuration/ClusterOption.php +++ b/lib/Predis/Configuration/ClusterOption.php @@ -28,8 +28,8 @@ class ClusterOption implements OptionInterface /** * Creates a new cluster connection from on a known descriptive name. * - * @param OptionsInterface $options Instance of the client options. - * @param string $id Descriptive identifier of the cluster type (`predis`, `redis-cluster`) + * @param OptionsInterface $options Instance of the client options. + * @param string $id Descriptive identifier of the cluster type (`predis`, `redis-cluster`) * @return ClusterConnectionInterface */ protected function createByDescription(OptionsInterface $options, $id) diff --git a/lib/Predis/Configuration/ConnectionFactoryOption.php b/lib/Predis/Configuration/ConnectionFactoryOption.php index d56ec33f..70e027f7 100644 --- a/lib/Predis/Configuration/ConnectionFactoryOption.php +++ b/lib/Predis/Configuration/ConnectionFactoryOption.php @@ -30,7 +30,7 @@ class ConnectionFactoryOption implements OptionInterface { if ($value instanceof FactoryInterface) { return $value; - } else if (is_array($value)) { + } elseif (is_array($value)) { $factory = $this->getDefault($options); foreach ($value as $scheme => $initializer) { diff --git a/lib/Predis/Configuration/OptionInterface.php b/lib/Predis/Configuration/OptionInterface.php index 123bd358..9e6f730a 100644 --- a/lib/Predis/Configuration/OptionInterface.php +++ b/lib/Predis/Configuration/OptionInterface.php @@ -22,7 +22,7 @@ interface OptionInterface /** * Filters and validates the passed value. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return mixed */ public function filter(OptionsInterface $options, $value); @@ -30,7 +30,7 @@ interface OptionInterface /** * Returns the default value for the option. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return mixed */ public function getDefault(OptionsInterface $options); diff --git a/lib/Predis/Configuration/Options.php b/lib/Predis/Configuration/Options.php index 01ccbedd..ba527cf0 100644 --- a/lib/Predis/Configuration/Options.php +++ b/lib/Predis/Configuration/Options.php @@ -58,6 +58,7 @@ class Options implements OptionsInterface if (isset($this->handlers[$option])) { $handler = $this->handlers[$option]; $handler = new $handler(); + return $handler->getDefault($this); } } diff --git a/lib/Predis/Configuration/OptionsInterface.php b/lib/Predis/Configuration/OptionsInterface.php index 9300a19e..9ce0ddcb 100644 --- a/lib/Predis/Configuration/OptionsInterface.php +++ b/lib/Predis/Configuration/OptionsInterface.php @@ -21,7 +21,7 @@ interface OptionsInterface /** * Returns the default value for the given option. * - * @param string $option Name of the option. + * @param string $option Name of the option. * @return mixed */ public function getDefault($option); @@ -29,7 +29,7 @@ interface OptionsInterface /** * Checks if the given option has been set by the user upon initialization. * - * @param string $option Name of the option. + * @param string $option Name of the option. * @return bool */ public function defined($option); @@ -37,7 +37,7 @@ interface OptionsInterface /** * Checks if the given option has been set and does not evaluate to NULL. * - * @param string $option Name of the option. + * @param string $option Name of the option. * @return bool */ public function __isset($option); @@ -45,7 +45,7 @@ interface OptionsInterface /** * Returns the value of the given option. * - * @param string $option Name of the option. + * @param string $option Name of the option. * @return mixed */ public function __get($option); diff --git a/lib/Predis/Configuration/ProfileOption.php b/lib/Predis/Configuration/ProfileOption.php index 5421b542..45385e6b 100644 --- a/lib/Predis/Configuration/ProfileOption.php +++ b/lib/Predis/Configuration/ProfileOption.php @@ -45,7 +45,7 @@ class ProfileOption implements OptionInterface if (is_string($value)) { $value = Factory::get($value); $this->setProcessors($options, $value); - } else if (!$value instanceof ProfileInterface) { + } elseif (!$value instanceof ProfileInterface) { throw new InvalidArgumentException('Invalid value for the profile option.'); } diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index bb8cb2ee..ab26c43f 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/lib/Predis/Connection/AbstractConnection.php @@ -14,7 +14,6 @@ namespace Predis\Connection; use InvalidArgumentException; use Predis\ClientException; use Predis\CommunicationException; -use Predis\NotSupportedException; use Predis\Command\CommandInterface; use Predis\Protocol\ProtocolException; @@ -74,7 +73,7 @@ abstract class AbstractConnection implements SingleConnectionInterface * * @return mixed */ - protected abstract function createResource(); + abstract protected function createResource(); /** * {@inheritdoc} @@ -118,6 +117,7 @@ abstract class AbstractConnection implements SingleConnectionInterface public function executeCommand(CommandInterface $command) { $this->writeRequest($command); + return $this->readResponse($command); } @@ -133,7 +133,7 @@ abstract class AbstractConnection implements SingleConnectionInterface * Helper method to handle connection errors. * * @param string $message Error message. - * @param int $code Error code. + * @param int $code Error code. */ protected function onConnectionError($message, $code = null) { diff --git a/lib/Predis/Connection/AggregateConnectionInterface.php b/lib/Predis/Connection/AggregateConnectionInterface.php index 87c35c8e..583934a2 100644 --- a/lib/Predis/Connection/AggregateConnectionInterface.php +++ b/lib/Predis/Connection/AggregateConnectionInterface.php @@ -31,15 +31,15 @@ interface AggregateConnectionInterface extends ConnectionInterface /** * Removes the specified connection instance from the aggregate connection. * - * @param SingleConnectionInterface $connection Connection instance. - * @return bool Returns true if the connection was in the pool. + * @param SingleConnectionInterface $connection Connection instance. + * @return bool Returns true if the connection was in the pool. */ public function remove(SingleConnectionInterface $connection); /** * Returns the connection instance in charge for the given command. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return SingleConnectionInterface */ public function getConnection(CommandInterface $command); @@ -47,7 +47,7 @@ interface AggregateConnectionInterface extends ConnectionInterface /** * Returns a connection instance from the aggregate connection by its alias. * - * @param string $connectionID Connection alias. + * @param string $connectionID Connection alias. * @return SingleConnectionInterface */ public function getConnectionById($connectionID); diff --git a/lib/Predis/Connection/ComposableConnectionInterface.php b/lib/Predis/Connection/ComposableConnectionInterface.php index 1e78aaef..d141a8ca 100644 --- a/lib/Predis/Connection/ComposableConnectionInterface.php +++ b/lib/Predis/Connection/ComposableConnectionInterface.php @@ -11,8 +11,6 @@ namespace Predis\Connection; -use Predis\Protocol\ProtocolInterface; - /** * Defines a connection to communicate with a single Redis server that leverages * an external protocol processor to handle pluggable protocol handlers. diff --git a/lib/Predis/Connection/ComposableStreamConnection.php b/lib/Predis/Connection/ComposableStreamConnection.php index 626d5377..d9d9d7f7 100644 --- a/lib/Predis/Connection/ComposableStreamConnection.php +++ b/lib/Predis/Connection/ComposableStreamConnection.php @@ -26,8 +26,8 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC protected $protocol; /** - * @param ParametersInterface $parameters Initialization parameters for the connection. - * @param ProtocolProcessorInterface $protocol Protocol processor. + * @param ParametersInterface $parameters Initialization parameters for the connection. + * @param ProtocolProcessorInterface $protocol Protocol processor. */ public function __construct( ParametersInterface $parameters, diff --git a/lib/Predis/Connection/ConnectionInterface.php b/lib/Predis/Connection/ConnectionInterface.php index fefdc9f5..98181701 100644 --- a/lib/Predis/Connection/ConnectionInterface.php +++ b/lib/Predis/Connection/ConnectionInterface.php @@ -48,7 +48,7 @@ interface ConnectionInterface /** * Reads the response to the given command from the connection. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return mixed */ public function readResponse(CommandInterface $command); @@ -57,7 +57,7 @@ interface ConnectionInterface * Writes a request for the given command over the connection and reads back * the response returned by Redis. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return mixed */ public function executeCommand(CommandInterface $command); diff --git a/lib/Predis/Connection/Factory.php b/lib/Predis/Connection/Factory.php index d4d7c560..942cb760 100644 --- a/lib/Predis/Connection/Factory.php +++ b/lib/Predis/Connection/Factory.php @@ -33,7 +33,7 @@ class Factory implements FactoryInterface * implementing Predis\Connection\SingleConnectionInterface. Optionally, * callable objects are used for lazy initialization of connection objects. * - * @param mixed $initializer FQN of a connection class or a callable for lazy initialization. + * @param mixed $initializer FQN of a connection class or a callable for lazy initialization. * @return mixed */ protected function checkInitializer($initializer) diff --git a/lib/Predis/Connection/FactoryInterface.php b/lib/Predis/Connection/FactoryInterface.php index 787f3a35..3cd5e905 100644 --- a/lib/Predis/Connection/FactoryInterface.php +++ b/lib/Predis/Connection/FactoryInterface.php @@ -21,8 +21,8 @@ interface FactoryInterface /** * Defines or overrides the connection class identified by a scheme prefix. * - * @param string $scheme Target connection scheme. - * @param mixed $initializer Fully-qualified name of a class or a callable for lazy initialization. + * @param string $scheme Target connection scheme. + * @param mixed $initializer Fully-qualified name of a class or a callable for lazy initialization. */ public function define($scheme, $initializer); @@ -36,7 +36,7 @@ interface FactoryInterface /** * Creates a new connection object. * - * @param mixed $parameters Initialization parameters for the connection. + * @param mixed $parameters Initialization parameters for the connection. * @return SingleConnectionInterface */ public function create($parameters); @@ -44,8 +44,8 @@ interface FactoryInterface /** * Aggregates single connections into an aggregate connection instance. * - * @param AggregateConnectionInterface $aggregate Aggregate connection instance. - * @param array $parameters List of parameters for each connection. + * @param AggregateConnectionInterface $aggregate Aggregate connection instance. + * @param array $parameters List of parameters for each connection. */ public function aggregate(AggregateConnectionInterface $aggregate, array $parameters); } diff --git a/lib/Predis/Connection/Parameters.php b/lib/Predis/Connection/Parameters.php index c066d40d..ba93b9ef 100644 --- a/lib/Predis/Connection/Parameters.php +++ b/lib/Predis/Connection/Parameters.php @@ -69,7 +69,7 @@ class Parameters implements ParametersInterface * Creates a new instance by supplying the initial parameters either in the * form of an URI string or a named array. * - * @param array|string $parameters Set of connection parameters. + * @param array|string $parameters Set of connection parameters. * @return Parameters */ public static function create($parameters) @@ -84,7 +84,7 @@ class Parameters implements ParametersInterface /** * Parses an URI string returning an array of connection parameters. * - * @param string $uri URI string. + * @param string $uri URI string. * @return array */ public static function parse($uri) @@ -111,7 +111,7 @@ class Parameters implements ParametersInterface /** * Validates and converts each value of the connection parameters array. * - * @param array $parameters Connection parameters. + * @param array $parameters Connection parameters. * @return array */ private function filter(array $parameters) @@ -130,7 +130,7 @@ class Parameters implements ParametersInterface /** * Validates value as boolean. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return boolean */ private static function castBoolean($value) @@ -141,7 +141,7 @@ class Parameters implements ParametersInterface /** * Validates value as float. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return float */ private static function castFloat($value) @@ -152,7 +152,7 @@ class Parameters implements ParametersInterface /** * Validates value as integer. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return int */ private static function castInteger($value) diff --git a/lib/Predis/Connection/ParametersInterface.php b/lib/Predis/Connection/ParametersInterface.php index 1a901074..a07f39a5 100644 --- a/lib/Predis/Connection/ParametersInterface.php +++ b/lib/Predis/Connection/ParametersInterface.php @@ -21,7 +21,7 @@ interface ParametersInterface /** * Checks if the specified parameters is set. * - * @param string $property Name of the property. + * @param string $property Name of the property. * @return Boolean */ public function __isset($parameter); @@ -29,7 +29,7 @@ interface ParametersInterface /** * Returns the value of the specified parameter. * - * @param string $parameter Name of the parameter. + * @param string $parameter Name of the parameter. * @return mixed */ public function __get($parameter); diff --git a/lib/Predis/Connection/PhpiredisSocketConnection.php b/lib/Predis/Connection/PhpiredisSocketConnection.php index 28cb0bd5..ed75af9f 100644 --- a/lib/Predis/Connection/PhpiredisSocketConnection.php +++ b/lib/Predis/Connection/PhpiredisSocketConnection.php @@ -186,7 +186,7 @@ class PhpiredisSocketConnection extends AbstractConnection /** * Sets options on the socket resource from the connection parameters. * - * @param resource $socket Socket resource. + * @param resource $socket Socket resource. * @param ParametersInterface $parameters Parameters used to initialize the connection. */ private function setSocketOptions($socket, ParametersInterface $parameters) @@ -226,7 +226,7 @@ class PhpiredisSocketConnection extends AbstractConnection /** * Gets the address from the connection parameters. * - * @param ParametersInterface $parameters Parameters used to initialize the connection. + * @param ParametersInterface $parameters Parameters used to initialize the connection. * @return string */ private static function getAddress(ParametersInterface $parameters) @@ -251,7 +251,7 @@ class PhpiredisSocketConnection extends AbstractConnection /** * Opens the actual connection to the server with a timeout. * - * @param ParametersInterface $parameters Parameters used to initialize the connection. + * @param ParametersInterface $parameters Parameters used to initialize the connection. * @return string */ private function connectWithTimeout(ParametersInterface $parameters) diff --git a/lib/Predis/Connection/PredisCluster.php b/lib/Predis/Connection/PredisCluster.php index 43e5e522..ca1195fe 100644 --- a/lib/Predis/Connection/PredisCluster.php +++ b/lib/Predis/Connection/PredisCluster.php @@ -114,8 +114,8 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * Removes a connection instance using its alias or index. * - * @param string $connectionID Alias or index of a connection. - * @return bool Returns true if the connection was in the pool. + * @param string $connectionID Alias or index of a connection. + * @return bool Returns true if the connection was in the pool. */ public function removeById($connectionID) { @@ -155,7 +155,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * Retrieves a connection instance from the cluster using a key. * - * @param string $key Key string. + * @param string $key Key string. * @return SingleConnectionInterface */ public function getConnectionByKey($key) @@ -220,7 +220,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * Executes the specified Redis command on all the nodes of a cluster. * - * @param CommandInterface $command A Redis command. + * @param CommandInterface $command A Redis command. * @return array */ public function executeCommandOnNodes(CommandInterface $command) diff --git a/lib/Predis/Connection/RedisCluster.php b/lib/Predis/Connection/RedisCluster.php index d30aabcf..802f2232 100644 --- a/lib/Predis/Connection/RedisCluster.php +++ b/lib/Predis/Connection/RedisCluster.php @@ -126,8 +126,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Removes a connection instance by using its identifier. * - * @param string $connectionID Connection identifier. - * @return bool True if the connection was in the pool. + * @param string $connectionID Connection identifier. + * @return bool True if the connection was in the pool. */ public function removeById($connectionID) { @@ -213,8 +213,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Pre-associates a connection to a slots range to avoid runtime guessing. * - * @param int $first Initial slot of the range. - * @param int $last Last slot of the range. + * @param int $first Initial slot of the range. + * @param int $last Last slot of the range. * @param SingleConnectionInterface|string $connection ID or connection instance. */ public function setSlots($first, $last, $connection) @@ -237,7 +237,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou * slots map, falling back to the same logic used by Redis to initialize a * cluster (best-effort). * - * @param int $slot Slot index. + * @param int $slot Slot index. * @return string Connection ID. */ protected function guessNode($slot) @@ -282,7 +282,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Returns the connection currently associated to a given slot. * - * @param int $slot Slot index. + * @param int $slot Slot index. * @return SingleConnectionInterface */ public function getConnectionBySlot($slot) @@ -338,7 +338,7 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou * The connection is added to the connections pool if not yet included. * * @param SingleConnectionInterface $connection Connection instance. - * @param int $slot Target slot index. + * @param int $slot Target slot index. */ protected function move(SingleConnectionInterface $connection, $slot) { @@ -349,8 +349,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Handles -ERR responses from Redis. * - * @param CommandInterface $command Command that generated the -ERR response. - * @param ErrorResponseInterface $error Redis error response object. + * @param CommandInterface $command Command that generated the -ERR response. + * @param ErrorResponseInterface $error Redis error response object. * @return mixed */ protected function onErrorResponse(CommandInterface $command, ErrorResponseInterface $error) @@ -371,9 +371,9 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou * Handles -MOVED and -ASK responses by re-executing the command on the node * specified by the Redis response. * - * @param CommandInterface $command Command that generated the -MOVE or -ASK response. - * @param string $request Type of request (either 'MOVED' or 'ASK'). - * @param string $details Parameters of the MOVED/ASK request. + * @param CommandInterface $command Command that generated the -MOVE or -ASK response. + * @param string $request Type of request (either 'MOVED' or 'ASK'). + * @param string $details Parameters of the MOVED/ASK request. * @return mixed */ protected function onMoveRequest(CommandInterface $command, $request, $details) diff --git a/lib/Predis/Connection/StreamConnection.php b/lib/Predis/Connection/StreamConnection.php index 4f98e36b..02b23268 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/lib/Predis/Connection/StreamConnection.php @@ -61,7 +61,7 @@ class StreamConnection extends AbstractConnection /** * Initializes a TCP stream resource. * - * @param ParametersInterface $parameters Initialization parameters for the connection. + * @param ParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function tcpStreamInitializer(ParametersInterface $parameters) @@ -103,7 +103,7 @@ class StreamConnection extends AbstractConnection /** * Initializes a UNIX stream resource. * - * @param ParametersInterface $parameters Initialization parameters for the connection. + * @param ParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function unixStreamInitializer(ParametersInterface $parameters) @@ -190,10 +190,10 @@ class StreamConnection extends AbstractConnection $payload = substr($chunk, 1, -2); switch ($prefix) { - case '+': // inline + case '+': return StatusResponse::get($payload); - case '$': // bulk + case '$': $size = (int) $payload; if ($size === -1) { @@ -216,7 +216,7 @@ class StreamConnection extends AbstractConnection return substr($bulkData, 0, -2); - case '*': // multi bulk + case '*': $count = (int) $payload; if ($count === -1) { @@ -231,10 +231,10 @@ class StreamConnection extends AbstractConnection return $multibulk; - case ':': // integer + case ':': return (int) $payload; - case '-': // error + case '-': return new ErrorResponse($payload); default: diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index effeda62..6a03cb1c 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/lib/Predis/Connection/WebdisConnection.php @@ -106,7 +106,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Initializes cURL. * - * @param ParametersInterface $parameters Initialization parameters for the connection. + * @param ParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function createCurl(ParametersInterface $parameters) @@ -132,7 +132,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Initializes the phpiredis protocol reader. * - * @param ParametersInterface $parameters Initialization parameters for the connection. + * @param ParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function createReader(ParametersInterface $parameters) @@ -172,8 +172,8 @@ class WebdisConnection implements SingleConnectionInterface /** * Feeds the phpredis reader resource with the data read from the network. * - * @param resource $resource Reader resource. - * @param string $buffer Buffer of data read from a connection. + * @param resource $resource Reader resource. + * @param string $buffer Buffer of data read from a connection. * @return int */ protected function feedReader($resource, $buffer) @@ -210,7 +210,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Checks if the specified command is supported by this connection class. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getCommandId(CommandInterface $command) diff --git a/lib/Predis/ExecutableContextInterface.php b/lib/Predis/ExecutableContextInterface.php index b9411fc8..b4443b4e 100644 --- a/lib/Predis/ExecutableContextInterface.php +++ b/lib/Predis/ExecutableContextInterface.php @@ -22,7 +22,7 @@ interface ExecutableContextInterface /** * Starts the execution of the context. * - * @param mixed $callable Optional callback for execution. + * @param mixed $callable Optional callback for execution. * @return array */ public function execute($callable = null); diff --git a/lib/Predis/Pipeline/Atomic.php b/lib/Predis/Pipeline/Atomic.php index e6825c33..316800f4 100644 --- a/lib/Predis/Pipeline/Atomic.php +++ b/lib/Predis/Pipeline/Atomic.php @@ -106,7 +106,7 @@ class Atomic extends Pipeline if (!$response instanceof ResponseInterface) { $responses[] = $command->parseResponse($response); - } else if ($response instanceof ErrorResponseInterface && $exceptions) { + } elseif ($response instanceof ErrorResponseInterface && $exceptions) { $this->exception($connection, $response); } else { $responses[] = $response; diff --git a/lib/Predis/Pipeline/ConnectionErrorProof.php b/lib/Predis/Pipeline/ConnectionErrorProof.php index 7f50470a..1f2183af 100644 --- a/lib/Predis/Pipeline/ConnectionErrorProof.php +++ b/lib/Predis/Pipeline/ConnectionErrorProof.php @@ -42,7 +42,7 @@ class ConnectionErrorProof extends Pipeline { if ($connection instanceof SingleConnectionInterface) { return $this->executeSingleNode($connection, $commands); - } else if ($connection instanceof ClusterConnectionInterface) { + } elseif ($connection instanceof ClusterConnectionInterface) { return $this->executeCluster($connection, $commands); } else { $class = get_class($connection); diff --git a/lib/Predis/Pipeline/Pipeline.php b/lib/Predis/Pipeline/Pipeline.php index 4e503bf3..0f2e569b 100644 --- a/lib/Predis/Pipeline/Pipeline.php +++ b/lib/Predis/Pipeline/Pipeline.php @@ -51,8 +51,8 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Queues a command into the pipeline buffer. * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. + * @param string $method Command ID. + * @param array $arguments Arguments for the command. * @return Pipeline */ public function __call($method, $arguments) @@ -86,8 +86,8 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Throws an exception on -ERR responses returned by Redis. * - * @param ConnectionInterface $connection Redis connection that returned the error. - * @param ErrorResponseInterface $response Instance of the error response. + * @param ConnectionInterface $connection Redis connection that returned the error. + * @param ErrorResponseInterface $response Instance of the error response. */ protected function exception(ConnectionInterface $connection, ErrorResponseInterface $response) { @@ -117,8 +117,8 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface * Implements the logic to flush the queued commands and read the responses * from the current connection. * - * @param ConnectionInterface $connection Current connection instance. - * @param SplQueue $commands Queued commands. + * @param ConnectionInterface $connection Current connection instance. + * @param SplQueue $commands Queued commands. * @return array */ protected function executePipeline(ConnectionInterface $connection, SplQueue $commands) @@ -136,7 +136,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface if (!$response instanceof ResponseInterface) { $responses[] = $command->parseResponse($response); - } else if ($response instanceof ErrorResponseInterface && $exceptions) { + } elseif ($response instanceof ErrorResponseInterface && $exceptions) { $this->exception($connection, $response); } else { $responses[] = $response; @@ -149,7 +149,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Flushes the buffer holding all of the commands queued so far. * - * @param bool $send Specifies if the commands in the buffer should be sent to Redis. + * @param bool $send Specifies if the commands in the buffer should be sent to Redis. * @return Pipeline */ public function flushPipeline($send = true) @@ -181,7 +181,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Handles the actual execution of the whole pipeline. * - * @param mixed $callable Optional callback for execution. + * @param mixed $callable Optional callback for execution. * @return array */ public function execute($callable = null) diff --git a/lib/Predis/Profile/Factory.php b/lib/Predis/Profile/Factory.php index d0e9c5bb..8d65911b 100644 --- a/lib/Predis/Profile/Factory.php +++ b/lib/Predis/Profile/Factory.php @@ -81,7 +81,7 @@ final class Factory /** * Returns the specified server profile. * - * @param string $version Profile version or alias. + * @param string $version Profile version or alias. * @return ProfileInterface */ public static function get($version) diff --git a/lib/Predis/Profile/ProfileInterface.php b/lib/Predis/Profile/ProfileInterface.php index 4a2b7c4c..07386fe3 100644 --- a/lib/Predis/Profile/ProfileInterface.php +++ b/lib/Predis/Profile/ProfileInterface.php @@ -32,7 +32,7 @@ interface ProfileInterface /** * Checks if the profile supports the specified command. * - * @param string $commandID Command ID. + * @param string $commandID Command ID. * @return Boolean */ public function supportsCommand($commandID); @@ -40,7 +40,7 @@ interface ProfileInterface /** * Checks if the profile supports the specified list of commands. * - * @param array $commandIDs List of command IDs. + * @param array $commandIDs List of command IDs. * @return string */ public function supportsCommands(array $commandIDs); @@ -48,8 +48,8 @@ interface ProfileInterface /** * Creates a new command instance. * - * @param string $commandID Command ID. - * @param array $arguments Arguments for the command. + * @param string $commandID Command ID. + * @param array $arguments Arguments for the command. * @return CommandInterface */ public function createCommand($commandID, $arguments = array()); diff --git a/lib/Predis/Profile/RedisProfile.php b/lib/Predis/Profile/RedisProfile.php index 5e3715da..030091df 100644 --- a/lib/Predis/Profile/RedisProfile.php +++ b/lib/Predis/Profile/RedisProfile.php @@ -40,7 +40,7 @@ abstract class RedisProfile implements ProfileInterface * * @return array */ - protected abstract function getSupportedCommands(); + abstract protected function getSupportedCommands(); /** * {@inheritdoc} @@ -68,7 +68,7 @@ abstract class RedisProfile implements ProfileInterface * Returns the fully-qualified name of a class representing the specified * command ID registered in the current server profile. * - * @param string $commandID Command ID. + * @param string $commandID Command ID. * @return string */ public function getCommandClass($commandID) @@ -103,7 +103,7 @@ abstract class RedisProfile implements ProfileInterface /** * Defines a new command in the server profile. * - * @param string $commandID Command ID. + * @param string $commandID Command ID. * @param string $commandClass Fully-qualified name of a Predis\Command\CommandInterface. */ public function defineCommand($commandID, $class) diff --git a/lib/Predis/Profile/RedisVersion200.php b/lib/Predis/Profile/RedisVersion200.php index 54093e56..5b9ae514 100644 --- a/lib/Predis/Profile/RedisVersion200.php +++ b/lib/Predis/Profile/RedisVersion200.php @@ -121,7 +121,6 @@ class RedisVersion200 extends RedisProfile 'SHUTDOWN' => 'Predis\Command\ServerShutdown', 'BGREWRITEAOF' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ diff --git a/lib/Predis/Profile/RedisVersion220.php b/lib/Predis/Profile/RedisVersion220.php index a16883b8..146fbe83 100644 --- a/lib/Predis/Profile/RedisVersion220.php +++ b/lib/Predis/Profile/RedisVersion220.php @@ -121,7 +121,6 @@ class RedisVersion220 extends RedisProfile 'SHUTDOWN' => 'Predis\Command\ServerShutdown', 'BGREWRITEAOF' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -170,7 +169,6 @@ class RedisVersion220 extends RedisProfile /* remote server control commands */ 'CONFIG' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ diff --git a/lib/Predis/Profile/RedisVersion240.php b/lib/Predis/Profile/RedisVersion240.php index 2bd088ee..d3c08dbe 100644 --- a/lib/Predis/Profile/RedisVersion240.php +++ b/lib/Predis/Profile/RedisVersion240.php @@ -121,7 +121,6 @@ class RedisVersion240 extends RedisProfile 'SHUTDOWN' => 'Predis\Command\ServerShutdown', 'BGREWRITEAOF' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -170,7 +169,6 @@ class RedisVersion240 extends RedisProfile /* remote server control commands */ 'CONFIG' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ @@ -200,7 +198,6 @@ class RedisVersion240 extends RedisProfile 'OBJECT' => 'Predis\Command\ServerObject', 'SLOWLOG' => 'Predis\Command\ServerSlowlog', - /* ---------------- Redis 2.4 ---------------- */ /* remote server control commands */ diff --git a/lib/Predis/Profile/RedisVersion260.php b/lib/Predis/Profile/RedisVersion260.php index f3b04994..9551b46b 100644 --- a/lib/Predis/Profile/RedisVersion260.php +++ b/lib/Predis/Profile/RedisVersion260.php @@ -123,7 +123,6 @@ class RedisVersion260 extends RedisProfile 'SHUTDOWN' => 'Predis\Command\ServerShutdown', 'BGREWRITEAOF' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -172,7 +171,6 @@ class RedisVersion260 extends RedisProfile /* remote server control commands */ 'CONFIG' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ @@ -202,13 +200,11 @@ class RedisVersion260 extends RedisProfile 'OBJECT' => 'Predis\Command\ServerObject', 'SLOWLOG' => 'Predis\Command\ServerSlowlog', - /* ---------------- Redis 2.4 ---------------- */ /* remote server control commands */ 'CLIENT' => 'Predis\Command\ServerClient', - /* ---------------- Redis 2.6 ---------------- */ /* commands operating on the key space */ diff --git a/lib/Predis/Profile/RedisVersion280.php b/lib/Predis/Profile/RedisVersion280.php index 386cb738..5ac22012 100644 --- a/lib/Predis/Profile/RedisVersion280.php +++ b/lib/Predis/Profile/RedisVersion280.php @@ -123,7 +123,6 @@ class RedisVersion280 extends RedisProfile 'SHUTDOWN' => 'Predis\Command\ServerShutdown', 'BGREWRITEAOF' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -172,7 +171,6 @@ class RedisVersion280 extends RedisProfile /* remote server control commands */ 'CONFIG' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ @@ -202,13 +200,11 @@ class RedisVersion280 extends RedisProfile 'OBJECT' => 'Predis\Command\ServerObject', 'SLOWLOG' => 'Predis\Command\ServerSlowlog', - /* ---------------- Redis 2.4 ---------------- */ /* remote server control commands */ 'CLIENT' => 'Predis\Command\ServerClient', - /* ---------------- Redis 2.6 ---------------- */ /* commands operating on the key space */ @@ -235,7 +231,6 @@ class RedisVersion280 extends RedisProfile 'TIME' => 'Predis\Command\ServerTime', 'SENTINEL' => 'Predis\Command\ServerSentinel', - /* ---------------- Redis 2.8 ---------------- */ /* commands operating on the key space */ diff --git a/lib/Predis/Protocol/ProtocolProcessorInterface.php b/lib/Predis/Protocol/ProtocolProcessorInterface.php index 14423f85..795c55a6 100644 --- a/lib/Predis/Protocol/ProtocolProcessorInterface.php +++ b/lib/Predis/Protocol/ProtocolProcessorInterface.php @@ -26,14 +26,14 @@ interface ProtocolProcessorInterface * Writes a request over a connection to Redis. * * @param ComposableConnectionInterface $connection Redis connection. - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. */ public function write(ComposableConnectionInterface $connection, CommandInterface $command); /** * Reads a response from a connection to Redis. * - * @param ComposableConnectionInterface $connection Redis connection. + * @param ComposableConnectionInterface $connection Redis connection. * @return mixed */ public function read(ComposableConnectionInterface $connection); diff --git a/lib/Predis/Protocol/RequestSerializerInterface.php b/lib/Predis/Protocol/RequestSerializerInterface.php index 03bef43e..bcfb4561 100644 --- a/lib/Predis/Protocol/RequestSerializerInterface.php +++ b/lib/Predis/Protocol/RequestSerializerInterface.php @@ -23,7 +23,7 @@ interface RequestSerializerInterface /** * Serializes a Redis command. * - * @param CommandInterface $command Redis command. + * @param CommandInterface $command Redis command. * @return string */ public function serialize(CommandInterface $command); diff --git a/lib/Predis/Protocol/ResponseReaderInterface.php b/lib/Predis/Protocol/ResponseReaderInterface.php index da517ed9..ce25b7e2 100644 --- a/lib/Predis/Protocol/ResponseReaderInterface.php +++ b/lib/Predis/Protocol/ResponseReaderInterface.php @@ -24,7 +24,7 @@ interface ResponseReaderInterface /** * Reads a response from a connection to Redis. * - * @param ComposableConnectionInterface $connection Redis connection. + * @param ComposableConnectionInterface $connection Redis connection. * @return mixed */ public function read(ComposableConnectionInterface $connection); diff --git a/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php b/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php index 96418d72..c6e1a3f7 100644 --- a/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php +++ b/lib/Predis/Protocol/Text/ComposableProtocolProcessor.php @@ -31,7 +31,7 @@ class ComposableProtocolProcessor implements ProtocolProcessorInterface /** * @param RequestSerializerInterface $serializer Request serializer. - * @param ResponseReaderInterface $reader Response reader. + * @param ResponseReaderInterface $reader Response reader. */ public function __construct( RequestSerializerInterface $serializer = null, diff --git a/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php b/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php index f50decf6..b61ca1d8 100644 --- a/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php +++ b/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php @@ -24,9 +24,9 @@ interface ResponseHandlerInterface * Deserializes a response returned by Redis and reads more data from the * connection if needed. * - * @param ComposableConnectionInterface $connection Redis connection. - * @param string $payload String payload. + * @param ComposableConnectionInterface $connection Redis connection. + * @param string $payload String payload. * @return mixed */ - function handle(ComposableConnectionInterface $connection, $payload); + public function handle(ComposableConnectionInterface $connection, $payload); } diff --git a/lib/Predis/Protocol/Text/ProtocolProcessor.php b/lib/Predis/Protocol/Text/ProtocolProcessor.php index 73203a37..d9a35d03 100644 --- a/lib/Predis/Protocol/Text/ProtocolProcessor.php +++ b/lib/Predis/Protocol/Text/ProtocolProcessor.php @@ -59,17 +59,18 @@ class ProtocolProcessor implements ProtocolProcessorInterface $payload = substr($chunk, 1); switch ($prefix) { - case '+': // inline + case '+': return new StatusResponse($payload); - case '$': // bulk + case '$': $size = (int) $payload; if ($size === -1) { return null; } + return substr($connection->readBuffer($size + 2), 0, -2); - case '*': // multi bulk + case '*': $count = (int) $payload; if ($count === -1) { @@ -87,10 +88,10 @@ class ProtocolProcessor implements ProtocolProcessorInterface return $multibulk; - case ':': // integer + case ':': return (int) $payload; - case '-': // error + case '-': return new ErrorResponse($payload); default: diff --git a/lib/Predis/Protocol/Text/ResponseReader.php b/lib/Predis/Protocol/Text/ResponseReader.php index 939738ef..cfb9eb6b 100644 --- a/lib/Predis/Protocol/Text/ResponseReader.php +++ b/lib/Predis/Protocol/Text/ResponseReader.php @@ -53,7 +53,7 @@ class ResponseReader implements ResponseReaderInterface /** * Sets the handler for the specified prefix identifying the response type. * - * @param string $prefix Identifier of the type of response. + * @param string $prefix Identifier of the type of response. * @param Handler\ResponseHandlerInterface $handler Response handler. */ public function setHandler($prefix, Handler\ResponseHandlerInterface $handler) @@ -64,7 +64,7 @@ class ResponseReader implements ResponseReaderInterface /** * Returns the response handler associated to a certain type of response. * - * @param string $prefix Identifier of the type of response. + * @param string $prefix Identifier of the type of response. * @return ResponseHandlerInterface */ public function getHandler($prefix) @@ -101,7 +101,7 @@ class ResponseReader implements ResponseReaderInterface * connection. * * @param ComposableConnectionInterface $connection Redis connection that generated the error. - * @param string $message Error message. + * @param string $message Error message. */ protected function onProtocolError(ComposableConnectionInterface $connection, $message) { diff --git a/lib/Predis/PubSub/AbstractConsumer.php b/lib/Predis/PubSub/AbstractConsumer.php index e980ff77..f1f135e6 100644 --- a/lib/Predis/PubSub/AbstractConsumer.php +++ b/lib/Predis/PubSub/AbstractConsumer.php @@ -45,7 +45,7 @@ abstract class AbstractConsumer implements Iterator /** * Checks if the specified flag is valid based on the state of the consumer. * - * @param int $value Flag. + * @param int $value Flag. * @return Boolean */ protected function isFlagSet($value) @@ -99,7 +99,7 @@ abstract class AbstractConsumer implements Iterator * Closes the context by unsubscribing from all the subscribed channels. The * context can be forcefully closed by dropping the underlying connection. * - * @param bool $drop Indicates if the context should be closed by dropping the connection. + * @param bool $drop Indicates if the context should be closed by dropping the connection. * @return bool Returns false when there are no pending messages. */ public function stop($drop = false) @@ -126,15 +126,15 @@ abstract class AbstractConsumer implements Iterator /** * Closes the underlying connection when forcing a disconnection. */ - protected abstract function disconnect(); + abstract protected function disconnect(); /** * Writes a Redis command on the underlying connection. * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. + * @param string $method Command ID. + * @param array $arguments Arguments for the command. */ - protected abstract function writeRequest($method, $arguments); + abstract protected function writeRequest($method, $arguments); /** * {@inheritdoc} @@ -203,5 +203,5 @@ abstract class AbstractConsumer implements Iterator * * @return array */ - protected abstract function getValue(); + abstract protected function getValue(); } diff --git a/lib/Predis/PubSub/Consumer.php b/lib/Predis/PubSub/Consumer.php index 2651114a..cf219ca2 100644 --- a/lib/Predis/PubSub/Consumer.php +++ b/lib/Predis/PubSub/Consumer.php @@ -28,8 +28,8 @@ class Consumer extends AbstractConsumer private $options; /** - * @param ClientInterface $client Client instance used by the consumer. - * @param array $options Options for the consumer initialization. + * @param ClientInterface $client Client instance used by the consumer. + * @param array $options Options for the consumer initialization. */ public function __construct(ClientInterface $client, array $options = null) { diff --git a/lib/Predis/PubSub/DispatcherLoop.php b/lib/Predis/PubSub/DispatcherLoop.php index 763ee22c..fea03196 100644 --- a/lib/Predis/PubSub/DispatcherLoop.php +++ b/lib/Predis/PubSub/DispatcherLoop.php @@ -91,7 +91,7 @@ class DispatcherLoop /** * Binds a callback to a channel. * - * @param string $channel Channel name. + * @param string $channel Channel name. * @param Callable $callback A callback. */ public function attachCallback($channel, $callback) @@ -138,7 +138,7 @@ class DispatcherLoop if (isset($this->callbacks[$message->channel])) { $callback = $this->callbacks[$message->channel]; call_user_func($callback, $message->payload); - } else if (isset($this->defaultCallback)) { + } elseif (isset($this->defaultCallback)) { $callback = $this->defaultCallback; call_user_func($callback, $message); } diff --git a/lib/Predis/Replication/ReplicationStrategy.php b/lib/Predis/Replication/ReplicationStrategy.php index 6c47d4d2..a0af0575 100644 --- a/lib/Predis/Replication/ReplicationStrategy.php +++ b/lib/Predis/Replication/ReplicationStrategy.php @@ -39,7 +39,7 @@ class ReplicationStrategy * Returns if the specified command will perform a read-only operation * on Redis or not. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return bool */ public function isReadOperation(CommandInterface $command) @@ -77,7 +77,7 @@ class ReplicationStrategy * Returns if the specified command is not allowed for execution in a master * / slave replication context. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return bool */ public function isDisallowedOperation(CommandInterface $command) @@ -89,12 +89,13 @@ class ReplicationStrategy * Checks if a SORT command is a readable operation by parsing the arguments * array of the specified commad instance. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return bool */ protected function isSortReadOnly(CommandInterface $command) { $arguments = $command->getArguments(); + return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE'; } @@ -106,7 +107,7 @@ class ReplicationStrategy * if the specified command performs a read or a write operation. * * @param string $commandID Command ID. - * @param mixed $readonly A boolean value or a callable object. + * @param mixed $readonly A boolean value or a callable object. */ public function setCommandReadOnly($commandID, $readonly = true) { @@ -126,8 +127,8 @@ class ReplicationStrategy * if the passed instance of EVAL or EVALSHA performs write operations or * not. * - * @param string $script Body of the Lua script. - * @param mixed $readonly A boolean value or a callable object. + * @param string $script Body of the Lua script. + * @param mixed $readonly A boolean value or a callable object. */ public function setScriptReadOnly($script, $readonly = true) { diff --git a/lib/Predis/Response/Error.php b/lib/Predis/Response/Error.php index 346e5915..270f96fa 100644 --- a/lib/Predis/Response/Error.php +++ b/lib/Predis/Response/Error.php @@ -43,6 +43,7 @@ class Error implements ErrorInterface public function getErrorType() { list($errorType, ) = explode(' ', $this->getMessage(), 2); + return $errorType; } diff --git a/lib/Predis/Response/Iterator/MultiBulk.php b/lib/Predis/Response/Iterator/MultiBulk.php index bd7df278..12189f3e 100644 --- a/lib/Predis/Response/Iterator/MultiBulk.php +++ b/lib/Predis/Response/Iterator/MultiBulk.php @@ -24,7 +24,7 @@ class MultiBulk extends MultiBulkIterator /** * @param SingleConnectionInterface $connection Connection to Redis. - * @param int $size Number of elements of the multibulk response. + * @param int $size Number of elements of the multibulk response. */ public function __construct(SingleConnectionInterface $connection, $size) { diff --git a/lib/Predis/Response/Iterator/MultiBulkIterator.php b/lib/Predis/Response/Iterator/MultiBulkIterator.php index 823c9829..5f48969c 100644 --- a/lib/Predis/Response/Iterator/MultiBulkIterator.php +++ b/lib/Predis/Response/Iterator/MultiBulkIterator.php @@ -104,5 +104,5 @@ abstract class MultiBulkIterator implements Iterator, Countable, ResponseInterfa /** * {@inheritdoc} */ - protected abstract function getValue(); + abstract protected function getValue(); } diff --git a/lib/Predis/Response/Status.php b/lib/Predis/Response/Status.php index b350349c..0438e951 100644 --- a/lib/Predis/Response/Status.php +++ b/lib/Predis/Response/Status.php @@ -66,12 +66,14 @@ class Status implements ResponseInterface if (!isset(self::$OK)) { self::$OK = new self('OK'); } + return self::$OK; case 'OK': if (!isset(self::$QUEUED)) { self::$QUEUED = new self('QUEUED'); } + return self::$QUEUED; default: diff --git a/lib/Predis/Session/Handler.php b/lib/Predis/Session/Handler.php index fea6fa79..c21bd8e7 100644 --- a/lib/Predis/Session/Handler.php +++ b/lib/Predis/Session/Handler.php @@ -30,8 +30,8 @@ class Handler implements SessionHandlerInterface protected $ttl; /** - * @param ClientInterface $client Fully initialized client instance. - * @param array $options Session handler options. + * @param ClientInterface $client Fully initialized client instance. + * @param array $options Session handler options. */ public function __construct(ClientInterface $client, array $options = array()) { @@ -69,7 +69,6 @@ class Handler implements SessionHandlerInterface public function open($save_path, $session_id) { // NOOP - return true; } @@ -79,7 +78,6 @@ class Handler implements SessionHandlerInterface public function close() { // NOOP - return true; } @@ -89,7 +87,6 @@ class Handler implements SessionHandlerInterface public function gc($maxlifetime) { // NOOP - return true; } diff --git a/lib/Predis/Transaction/AbortedMultiExecException.php b/lib/Predis/Transaction/AbortedMultiExecException.php index f8be4819..b36f38aa 100644 --- a/lib/Predis/Transaction/AbortedMultiExecException.php +++ b/lib/Predis/Transaction/AbortedMultiExecException.php @@ -24,8 +24,8 @@ class AbortedMultiExecException extends PredisException /** * @param MultiExec $transaction Transaction that generated the exception. - * @param string $message Error message. - * @param int $code Error code. + * @param string $message Error message. + * @param int $code Error code. */ public function __construct(MultiExec $transaction, $message, $code = null) { diff --git a/lib/Predis/Transaction/MultiExec.php b/lib/Predis/Transaction/MultiExec.php index ac15d42a..f8049160 100644 --- a/lib/Predis/Transaction/MultiExec.php +++ b/lib/Predis/Transaction/MultiExec.php @@ -21,7 +21,6 @@ use Predis\CommunicationException; use Predis\ExecutableContextInterface; use Predis\NotSupportedException; use Predis\Response\ErrorInterface as ErrorResponseInterface; -use Predis\Response\ResponseInterface; use Predis\Response\ServerException; use Predis\Response\Status as StatusResponse; use Predis\Command\CommandInterface; @@ -45,8 +44,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface protected $modeCAS = false; /** - * @param ClientInterface $client Client instance used by the transaction. - * @param array $options Initialization options. + * @param ClientInterface $client Client instance used by the transaction. + * @param array $options Initialization options. */ public function __construct(ClientInterface $client, array $options = null) { @@ -83,8 +82,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Configures the transaction using the provided options. * - * @param ClientInterface $client Underlying client instance. - * @param array $options Array of options for the transaction. + * @param ClientInterface $client Underlying client instance. + * @param array $options Array of options for the transaction. **/ protected function configure(ClientInterface $client, array $options) { @@ -151,8 +150,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Dynamically invokes a Redis command with the specified arguments. * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. + * @param string $method Command ID. + * @param array $arguments Arguments for the command. * @return mixed */ public function __call($method, $arguments) @@ -166,8 +165,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Executes a Redis command bypassing the transaction logic. * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. + * @param string $method Command ID. + * @param array $arguments Arguments for the command. * @return mixed */ protected function call($commandID, $arguments = array()) @@ -185,7 +184,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Executes the specified Redis command. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return mixed */ public function executeCommand(CommandInterface $command) @@ -209,7 +208,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Executes WATCH against one or more keys. * - * @param string|array $keys One or more keys. + * @param string|array $keys One or more keys. * @return mixed */ public function watch($keys) @@ -316,7 +315,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface 'Cannot execute a transaction block after using fluent interface.' ); } - } else if ($this->attempts) { + } elseif ($this->attempts) { $this->discard(); throw new InvalidArgumentException( @@ -328,7 +327,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Handles the actual execution of the whole transaction. * - * @param mixed $callable Optional callback for execution. + * @param mixed $callable Optional callback for execution. * @return array */ public function execute($callable = null) diff --git a/lib/Predis/Transaction/MultiExecState.php b/lib/Predis/Transaction/MultiExecState.php index 0ac4b5b8..daddefbb 100644 --- a/lib/Predis/Transaction/MultiExecState.php +++ b/lib/Predis/Transaction/MultiExecState.php @@ -77,7 +77,7 @@ class MultiExecState /** * Returns if the specified flag or set of flags is set. * - * @param int $flags Flag + * @param int $flags Flag * @return bool */ public function check($flags)