diff --git a/lib/Predis/BasicClientInterface.php b/lib/Predis/BasicClientInterface.php index a25f4102..625f5dc0 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 A Redis command. + * @param CommandInterface $command A Redis command. * @return mixed */ public function executeCommand(CommandInterface $command); diff --git a/lib/Predis/Client.php b/lib/Predis/Client.php index 46a29726..65165d92 100644 --- a/lib/Predis/Client.php +++ b/lib/Predis/Client.php @@ -41,7 +41,7 @@ class Client implements ClientInterface * Initializes a new client with optional connection parameters and client options. * * @param mixed $parameters Connection parameters for one or multiple servers. - * @param mixed $options Options that specify certain behaviours for the client. + * @param mixed $options Options that specify certain behaviours for the client. */ public function __construct($parameters = null, $options = null) { @@ -55,7 +55,7 @@ class Client implements ClientInterface * arguments (string, array, Predis\Profile\ServerProfile) or returns the * passed object if it is an instance of Predis\Option\ClientOptions. * - * @param mixed $options Client options. + * @param mixed $options Client options. * @return ClientOptions */ protected function filterOptions($options) @@ -80,7 +80,7 @@ class Client implements ClientInterface * types of arguments (string, array) or returns the passed object if it * implements Predis\Connection\ConnectionInterface. * - * @param mixed $parameters Connection parameters or instance. + * @param mixed $parameters Connection parameters or instance. * @return ConnectionInterface */ protected function initializeConnection($parameters) @@ -202,7 +202,7 @@ class Client implements ClientInterface /** * Retrieves a single connection out of an aggregated connections instance. * - * @param string $connectionId Index or alias of the connection. + * @param string $connectionId Index or alias of the connection. * @return Connection\SingleConnectionInterface */ public function getConnectionById($connectionId) @@ -218,8 +218,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) @@ -259,8 +259,8 @@ class Client implements ClientInterface /** * Handles -ERR responses returned by Redis. * - * @param CommandInterface $command The command that generated the error. - * @param ResponseErrorInterface $response The error response instance. + * @param CommandInterface $command The command that generated the error. + * @param ResponseErrorInterface $response The error response instance. * @return mixed */ protected function onResponseError(CommandInterface $command, ResponseErrorInterface $response) @@ -290,8 +290,8 @@ class Client implements ClientInterface * * TODO: Invert $argv and $initializer. * - * @param array $argv Arguments for the initializer. - * @param string $initializer The initializer method. + * @param array $argv Arguments for the initializer. + * @param string $initializer The initializer method. * @return mixed */ private function sharedInitializer($argv, $initializer) @@ -302,10 +302,12 @@ class Client implements ClientInterface case 1: list($arg0) = $argv; + return is_array($arg0) ? $this->$initializer($arg0) : $this->$initializer(null, $arg0); case 2: list($arg0, $arg1) = $argv; + return $this->$initializer($arg0, $arg1); default: @@ -317,7 +319,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, a callable object, or both. + * @param mixed $arg,... Options for the context, a callable object, or both. * @return PipelineContext|array */ public function pipeline(/* arguments */) @@ -328,8 +330,8 @@ class Client implements ClientInterface /** * Pipeline context initializer. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable object used to execute the context. + * @param array $options Options for the context. + * @param mixed $callable Optional callable object used to execute the context. * @return PipelineContext|array */ protected function initPipeline(Array $options = null, $callable = null) @@ -349,8 +351,8 @@ class Client implements ClientInterface /** * Executes a pipeline context when a callable object is passed. * - * @param array $options Options of the context initialization. - * @param mixed $callable Optional callable object used to execute the context. + * @param array $options Options of the context initialization. + * @param mixed $callable Optional callable object used to execute the context. * @return PipelineContext|array */ private function pipelineExecute(PipelineContext $pipeline, $callable) @@ -366,7 +368,7 @@ class Client implements ClientInterface * as it will replace Client::multiExec() in the next major * version of the library. * - * @param mixed $arg,... Options for the context, a callable object, or both. + * @param mixed $arg,... Options for the context, a callable object, or both. * @return MultiExecContext|array */ public function multiExec(/* arguments */) @@ -378,7 +380,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, a callable object, or both. + * @param mixed $arg,... Options for the context, a callable object, or both. * @return MultiExecContext|array */ public function transaction(/* arguments */) @@ -389,13 +391,14 @@ class Client implements ClientInterface /** * Transaction context initializer. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable object used to execute the context. + * @param array $options Options for the context. + * @param mixed $callable Optional callable object used to execute the context. * @return MultiExecContext|array */ protected function initMultiExec(Array $options = null, $callable = null) { $transaction = new MultiExecContext($this, $options ?: array()); + return isset($callable) ? $transaction->execute($callable) : $transaction; } @@ -408,7 +411,7 @@ class Client implements ClientInterface * Client::pubSubLoop() to create Predis\PubSub\PubSubContext * instances from now on. * - * @param mixed $arg,... Options for the context, a callable object, or both. + * @param mixed $arg,... Options for the context, a callable object, or both. * @return PubSubExecContext|array */ public function pubSub(/* arguments */) @@ -420,7 +423,7 @@ class Client implements ClientInterface * Creates a new Publish / Subscribe context and returns it, or executes it * inside the optionally provided callable object. * - * @param mixed $arg,... Options for the context, a callable object, or both. + * @param mixed $arg,... Options for the context, a callable object, or both. * @return PubSubExecContext|array */ public function pubSubLoop(/* arguments */) @@ -431,8 +434,8 @@ class Client implements ClientInterface /** * Publish / Subscribe context initializer. * - * @param array $options Options for the context. - * @param mixed $callable Optional callable object used to execute the context. + * @param array $options Options for the context. + * @param mixed $callable Optional callable object used to execute the context. * @return PubSubContext */ protected function initPubSub(Array $options = null, $callable = null) diff --git a/lib/Predis/ClientInterface.php b/lib/Predis/ClientInterface.php index 767c3da8..b4b3d47a 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 The name of a Redis command. - * @param array $arguments The arguments for the command. + * @param string $method The name of a Redis command. + * @param array $arguments The arguments for the command. * @return Command\CommandInterface */ public function createCommand($method, $arguments = array()); diff --git a/lib/Predis/Cluster/CommandHashStrategyInterface.php b/lib/Predis/Cluster/CommandHashStrategyInterface.php index bfea0503..810700b6 100644 --- a/lib/Predis/Cluster/CommandHashStrategyInterface.php +++ b/lib/Predis/Cluster/CommandHashStrategyInterface.php @@ -27,7 +27,7 @@ interface CommandHashStrategyInterface * Returns the hash for the given command using the specified algorithm, or null * if the command cannot be hashed. * - * @param CommandInterface $command Command to be hashed. + * @param CommandInterface $command Command to be hashed. * @return int */ public function getHash(CommandInterface $command); @@ -35,7 +35,7 @@ interface CommandHashStrategyInterface /** * Returns the hash for the given key using the specified algorithm. * - * @param string $key Key to be hashed. + * @param string $key Key to be hashed. * @return string */ public function getKeyHash($key); diff --git a/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php b/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php index 2b07936b..cde9a568 100644 --- a/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php +++ b/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php @@ -24,8 +24,8 @@ interface DistributionStrategyInterface /** * 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/Distribution/HashRing.php b/lib/Predis/Cluster/Distribution/HashRing.php index 8958929b..7aed2071 100644 --- a/lib/Predis/Cluster/Distribution/HashRing.php +++ b/lib/Predis/Cluster/Distribution/HashRing.php @@ -34,7 +34,7 @@ class HashRing implements DistributionStrategyInterface, 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 the string used to calculate the hash of a node. */ public function __construct($replicas = self::DEFAULT_REPLICAS, $nodeHashCallback = null) @@ -46,8 +46,8 @@ class HashRing implements DistributionStrategyInterface, 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) { @@ -143,10 +143,10 @@ class HashRing implements DistributionStrategyInterface, 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) @@ -176,7 +176,7 @@ class HashRing implements DistributionStrategyInterface, HashGeneratorInterface /** * Calculates the hash for the specified value. * - * @param string $value Input value. + * @param string $value Input value. * @return int */ public function hash($value) @@ -195,7 +195,7 @@ class HashRing implements DistributionStrategyInterface, 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) @@ -211,7 +211,7 @@ class HashRing implements DistributionStrategyInterface, HashGeneratorInterface if ($item > $key) { $upper = $index - 1; - } else if ($item < $key) { + } elseif ($item < $key) { $lower = $index + 1; } else { return $item; @@ -224,9 +224,9 @@ class HashRing implements DistributionStrategyInterface, 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/Distribution/KetamaPureRing.php b/lib/Predis/Cluster/Distribution/KetamaPureRing.php index d68fa959..9edbe4df 100644 --- a/lib/Predis/Cluster/Distribution/KetamaPureRing.php +++ b/lib/Predis/Cluster/Distribution/KetamaPureRing.php @@ -55,6 +55,7 @@ class KetamaPureRing extends HashRing public function hash($value) { $hash = unpack('V', md5($value, true)); + return $hash[1]; } diff --git a/lib/Predis/Cluster/Hash/HashGeneratorInterface.php b/lib/Predis/Cluster/Hash/HashGeneratorInterface.php index 891320d1..62e46cf7 100644 --- a/lib/Predis/Cluster/Hash/HashGeneratorInterface.php +++ b/lib/Predis/Cluster/Hash/HashGeneratorInterface.php @@ -22,7 +22,7 @@ interface HashGeneratorInterface /** * Generates an hash that is used by the distributor algorithm * - * @param string $value Value used to generate the hash. + * @param string $value Value used to generate the hash. * @return int */ public function hash($value); diff --git a/lib/Predis/Cluster/PredisClusterHashStrategy.php b/lib/Predis/Cluster/PredisClusterHashStrategy.php index d2e72c35..b162957e 100644 --- a/lib/Predis/Cluster/PredisClusterHashStrategy.php +++ b/lib/Predis/Cluster/PredisClusterHashStrategy.php @@ -180,7 +180,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface * 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) { @@ -188,6 +188,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface if (!isset($callback)) { unset($this->commands[$commandId]); + return; } @@ -201,7 +202,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface /** * 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) @@ -213,7 +214,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface * 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) @@ -229,7 +230,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface * 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) @@ -249,7 +250,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface /** * 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) @@ -264,7 +265,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface /** * Extracts the key from BITOP command. * - * @param CommandInterface $command Command instance. + * @param CommandInterface $command Command instance. * @return string */ protected function getKeyFromBitOp(CommandInterface $command) @@ -279,7 +280,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface /** * 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) @@ -295,7 +296,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface /** * 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) @@ -344,7 +345,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface /** * 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) @@ -372,7 +373,7 @@ class PredisClusterHashStrategy implements CommandHashStrategyInterface * 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/RedisClusterHashStrategy.php b/lib/Predis/Cluster/RedisClusterHashStrategy.php index dfee5cca..a048c4ae 100644 --- a/lib/Predis/Cluster/RedisClusterHashStrategy.php +++ b/lib/Predis/Cluster/RedisClusterHashStrategy.php @@ -166,7 +166,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface * 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) { @@ -174,6 +174,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface if (!isset($callback)) { unset($this->commands[$commandId]); + return; } @@ -187,7 +188,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface /** * 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) @@ -199,7 +200,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface * 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) @@ -215,7 +216,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface * 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) @@ -231,7 +232,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface * 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) @@ -246,7 +247,7 @@ class RedisClusterHashStrategy implements CommandHashStrategyInterface /** * 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/Collection/Iterator/CursorBasedIterator.php b/lib/Predis/Collection/Iterator/CursorBasedIterator.php index 5d07597b..c0f9bafe 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 Hints 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 Hints used by Redis to compute the number of results per iteration. */ public function __construct(ClientInterface $client, $match = null, $count = null) { @@ -109,7 +109,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 @@ -172,7 +172,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 86c40ff7..220e4823 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/AbstractCommand.php b/lib/Predis/Command/AbstractCommand.php index 1974e39d..b1996578 100644 --- a/lib/Predis/Command/AbstractCommand.php +++ b/lib/Predis/Command/AbstractCommand.php @@ -24,7 +24,7 @@ abstract class AbstractCommand 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 AbstractCommand 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 AbstractCommand 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 AbstractCommand 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 0be8c81c..369073cb 100644 --- a/lib/Predis/Command/CommandInterface.php +++ b/lib/Predis/Command/CommandInterface.php @@ -69,7 +69,7 @@ interface CommandInterface /** * Parses a reply buffer and returns a PHP object. * - * @param string $data Binary string containing the whole reply. + * @param string $data Binary string containing the whole reply. * @return mixed */ public function parseResponse($data); diff --git a/lib/Predis/Command/HashScan.php b/lib/Predis/Command/HashScan.php index 0ca20886..d1efc255 100644 --- a/lib/Predis/Command/HashScan.php +++ b/lib/Predis/Command/HashScan.php @@ -41,7 +41,7 @@ class HashScan extends PrefixableCommand /** * 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 79953cba..8b68bae3 100644 --- a/lib/Predis/Command/KeyScan.php +++ b/lib/Predis/Command/KeyScan.php @@ -41,7 +41,7 @@ class KeyScan extends AbstractCommand /** * 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/PrefixHelpers.php b/lib/Predis/Command/PrefixHelpers.php index 0c37d6f8..83e2e9a6 100644 --- a/lib/Predis/Command/PrefixHelpers.php +++ b/lib/Predis/Command/PrefixHelpers.php @@ -22,7 +22,7 @@ class PrefixHelpers * 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) { @@ -36,7 +36,7 @@ class PrefixHelpers * 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) { @@ -53,7 +53,7 @@ class PrefixHelpers * 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) { @@ -72,7 +72,7 @@ class PrefixHelpers * 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) { @@ -91,7 +91,7 @@ class PrefixHelpers * 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) { diff --git a/lib/Predis/Command/RawCommand.php b/lib/Predis/Command/RawCommand.php index 37feb8a9..2bc3056b 100644 --- a/lib/Predis/Command/RawCommand.php +++ b/lib/Predis/Command/RawCommand.php @@ -127,8 +127,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/ScriptedCommand.php b/lib/Predis/Command/ScriptedCommand.php index 9c0065c5..67855c03 100644 --- a/lib/Predis/Command/ScriptedCommand.php +++ b/lib/Predis/Command/ScriptedCommand.php @@ -25,7 +25,7 @@ abstract class ScriptedCommand 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 de17c84c..ca145794 100644 --- a/lib/Predis/Command/ServerClient.php +++ b/lib/Predis/Command/ServerClient.php @@ -50,7 +50,7 @@ class ServerClient extends AbstractCommand * Parses the reply buffer and returns the list of clients returned by * the CLIENT LIST command. * - * @param string $data Reply buffer + * @param string $data Reply buffer * @return array */ protected function parseClientList($data) diff --git a/lib/Predis/Command/ServerInfo.php b/lib/Predis/Command/ServerInfo.php index 6dd351fe..899b16b1 100644 --- a/lib/Predis/Command/ServerInfo.php +++ b/lib/Predis/Command/ServerInfo.php @@ -58,7 +58,7 @@ class ServerInfo extends AbstractCommand /** * Parses the reply buffer and extracts the statistics of each logical DB. * - * @param string $str Reply buffer. + * @param string $str Reply buffer. * @return array */ protected function parseDatabaseStats($str) @@ -76,7 +76,7 @@ class ServerInfo extends AbstractCommand /** * Parses the reply buffer and extracts the allocation statistics. * - * @param string $str Reply buffer. + * @param string $str Reply buffer. * @return array */ protected function parseAllocationStats($str) diff --git a/lib/Predis/Command/SetScan.php b/lib/Predis/Command/SetScan.php index 9efa80b8..27b6de2b 100644 --- a/lib/Predis/Command/SetScan.php +++ b/lib/Predis/Command/SetScan.php @@ -41,7 +41,7 @@ class SetScan extends PrefixableCommand /** * 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 e0b1c53b..2dd86da5 100644 --- a/lib/Predis/Command/ZSetAdd.php +++ b/lib/Predis/Command/ZSetAdd.php @@ -33,7 +33,7 @@ class ZSetAdd extends PrefixableCommand 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 7403873a..cd2edee9 100644 --- a/lib/Predis/Command/ZSetRange.php +++ b/lib/Predis/Command/ZSetRange.php @@ -41,6 +41,7 @@ class ZSetRange extends PrefixableCommand if ($lastType === 'array') { $options = $this->prepareOptions(array_pop($arguments)); + return array_merge($arguments, $options); } } @@ -51,7 +52,7 @@ class ZSetRange extends PrefixableCommand /** * 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 fad09c15..41d22e54 100644 --- a/lib/Predis/Command/ZSetScan.php +++ b/lib/Predis/Command/ZSetScan.php @@ -41,7 +41,7 @@ class ZSetScan extends PrefixableCommand /** * 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 ba971766..725d2b0c 100644 --- a/lib/Predis/Command/ZSetUnionStore.php +++ b/lib/Predis/Command/ZSetUnionStore.php @@ -50,7 +50,7 @@ class ZSetUnionStore extends PrefixableCommand /** * 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 c9e75e23..0e181be0 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, $message = null, $code = null, \Exception $innerException = null diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index 96a84ae9..f68aa6fb 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/lib/Predis/Connection/AbstractConnection.php @@ -73,7 +73,7 @@ abstract class AbstractConnection implements SingleConnectionInterface * * @return mixed */ - protected abstract function createResource(); + abstract protected function createResource(); /** * {@inheritdoc} @@ -117,6 +117,7 @@ abstract class AbstractConnection implements SingleConnectionInterface public function executeCommand(CommandInterface $command) { $this->writeCommand($command); + return $this->readResponse($command); } @@ -132,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) { @@ -152,8 +153,8 @@ abstract class AbstractConnection implements SingleConnectionInterface /** * Helper method to handle not supported connection parameters. * - * @param string $option Name of the option. - * @param mixed $parameters Parameters used to initialize the connection. + * @param string $option Name of the option. + * @param mixed $parameters Parameters used to initialize the connection. */ protected function onInvalidOption($option, $parameters = null) { diff --git a/lib/Predis/Connection/AggregatedConnectionInterface.php b/lib/Predis/Connection/AggregatedConnectionInterface.php index bd1065c0..924656c2 100644 --- a/lib/Predis/Connection/AggregatedConnectionInterface.php +++ b/lib/Predis/Connection/AggregatedConnectionInterface.php @@ -31,15 +31,15 @@ interface AggregatedConnectionInterface extends ConnectionInterface * Removes the specified connection instance from the aggregated * connection. * - * @param SingleConnectionInterface $connection Instance of a connection. - * @return Boolean Returns true if the connection was in the pool. + * @param SingleConnectionInterface $connection Instance of a connection. + * @return Boolean Returns true if the connection was in the pool. */ public function remove(SingleConnectionInterface $connection); /** * Gets the actual connection instance in charge of the specified command. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Instance of a Redis command. * @return SingleConnectionInterface */ public function getConnection(CommandInterface $command); @@ -48,7 +48,7 @@ interface AggregatedConnectionInterface extends ConnectionInterface * Retrieves a connection instance from the aggregated connection * using an alias. * - * @param string $connectionId Alias of a connection + * @param string $connectionId Alias of a connection * @return SingleConnectionInterface */ public function getConnectionById($connectionId); diff --git a/lib/Predis/Connection/ComposableStreamConnection.php b/lib/Predis/Connection/ComposableStreamConnection.php index 34aaa9b3..0c863025 100644 --- a/lib/Predis/Connection/ComposableStreamConnection.php +++ b/lib/Predis/Connection/ComposableStreamConnection.php @@ -27,7 +27,7 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC /** * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @param ProtocolInterface $protocol A protocol processor. + * @param ProtocolInterface $protocol A protocol processor. */ public function __construct(ConnectionParametersInterface $parameters, ProtocolInterface $protocol = null) { diff --git a/lib/Predis/Connection/ConnectionFactory.php b/lib/Predis/Connection/ConnectionFactory.php index 5527232b..1023adbc 100644 --- a/lib/Predis/Connection/ConnectionFactory.php +++ b/lib/Predis/Connection/ConnectionFactory.php @@ -11,7 +11,6 @@ namespace Predis\Connection; -use Predis\Profile\ServerProfile; use Predis\Profile\ServerProfileInterface; /** @@ -55,7 +54,7 @@ class ConnectionFactory implements ConnectionFactoryInterface * 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/ConnectionFactoryInterface.php b/lib/Predis/Connection/ConnectionFactoryInterface.php index 0ac6be7c..8bade2bf 100644 --- a/lib/Predis/Connection/ConnectionFactoryInterface.php +++ b/lib/Predis/Connection/ConnectionFactoryInterface.php @@ -22,8 +22,8 @@ interface ConnectionFactoryInterface /** * Defines or overrides the connection class identified by a scheme prefix. * - * @param string $scheme URI scheme identifying the connection class. - * @param mixed $initializer FQN of a connection class or a callable object for lazy initialization. + * @param string $scheme URI scheme identifying the connection class. + * @param mixed $initializer FQN of a connection class or a callable object for lazy initialization. */ public function define($scheme, $initializer); @@ -37,7 +37,7 @@ interface ConnectionFactoryInterface /** * Creates a new connection object. * - * @param mixed $parameters Parameters for the connection. + * @param mixed $parameters Parameters for the connection. * @return SingleConnectionInterface */ public function create($parameters); @@ -45,8 +45,8 @@ interface ConnectionFactoryInterface /** * Prepares an aggregation of connection objects. * - * @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class. - * @param array $parameters List of parameters for each connection object. + * @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class. + * @param array $parameters List of parameters for each connection object. * @return AggregatedConnectionInterface */ public function createAggregated(AggregatedConnectionInterface $cluster, Array $parameters); diff --git a/lib/Predis/Connection/ConnectionInterface.php b/lib/Predis/Connection/ConnectionInterface.php index b30de09f..49690f67 100644 --- a/lib/Predis/Connection/ConnectionInterface.php +++ b/lib/Predis/Connection/ConnectionInterface.php @@ -48,7 +48,7 @@ interface ConnectionInterface /** * Reads the reply for a Redis command from the connection. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Instance of a Redis command. * @return mixed */ public function readResponse(CommandInterface $command); @@ -56,7 +56,7 @@ interface ConnectionInterface /** * Writes a Redis command to the connection and reads back the reply. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Instance of a Redis command. * @return mixed */ public function executeCommand(CommandInterface $command); diff --git a/lib/Predis/Connection/ConnectionParameters.php b/lib/Predis/Connection/ConnectionParameters.php index 76cf812e..4712c5bc 100644 --- a/lib/Predis/Connection/ConnectionParameters.php +++ b/lib/Predis/Connection/ConnectionParameters.php @@ -71,7 +71,7 @@ class ConnectionParameters implements ConnectionParametersInterface /** * Validates value as boolean. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return boolean */ private static function castBoolean($value) @@ -82,7 +82,7 @@ class ConnectionParameters implements ConnectionParametersInterface /** * Validates value as float. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return float */ private static function castFloat($value) @@ -93,7 +93,7 @@ class ConnectionParameters implements ConnectionParametersInterface /** * Validates value as integer. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return int */ private static function castInteger($value) @@ -104,7 +104,7 @@ class ConnectionParameters implements ConnectionParametersInterface /** * Parses an URI string and returns an array of connection parameters. * - * @param string $uri Connection string. + * @param string $uri Connection string. * @return array */ public static function parseURI($uri) @@ -131,7 +131,7 @@ class ConnectionParameters implements ConnectionParametersInterface /** * 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) diff --git a/lib/Predis/Connection/ConnectionParametersInterface.php b/lib/Predis/Connection/ConnectionParametersInterface.php index 3e3cb380..380efaca 100644 --- a/lib/Predis/Connection/ConnectionParametersInterface.php +++ b/lib/Predis/Connection/ConnectionParametersInterface.php @@ -22,7 +22,7 @@ interface ConnectionParametersInterface /** * 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); @@ -30,7 +30,7 @@ interface ConnectionParametersInterface /** * 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/PhpiredisConnection.php b/lib/Predis/Connection/PhpiredisConnection.php index 08c66471..e006a73f 100644 --- a/lib/Predis/Connection/PhpiredisConnection.php +++ b/lib/Predis/Connection/PhpiredisConnection.php @@ -137,7 +137,7 @@ class PhpiredisConnection extends AbstractConnection /** * Gets the handler used by the protocol reader to handle Redis errors. * - * @param Boolean $throw_errors Specify if Redis errors throw exceptions. + * @param Boolean $throw_errors Specify if Redis errors throw exceptions. * @return \Closure */ private function getErrorHandler() @@ -184,7 +184,7 @@ class PhpiredisConnection extends AbstractConnection /** * Sets options on the socket resource from the connection parameters. * - * @param resource $socket Socket resource. + * @param resource $socket Socket resource. * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. */ private function setSocketOptions($socket, ConnectionParametersInterface $parameters) @@ -224,7 +224,7 @@ class PhpiredisConnection extends AbstractConnection /** * Gets the address from the connection parameters. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. * @return string */ private function getAddress(ConnectionParametersInterface $parameters) @@ -239,6 +239,7 @@ class PhpiredisConnection extends AbstractConnection if (($addresses = gethostbynamel($host)) === false) { $this->onConnectionError("Cannot resolve the address of $host"); } + return $addresses[array_rand($addresses)]; } @@ -248,7 +249,7 @@ class PhpiredisConnection extends AbstractConnection /** * Opens the actual connection to the server with a timeout. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. * @return string */ private function connectWithTimeout(ConnectionParametersInterface $parameters) diff --git a/lib/Predis/Connection/PhpiredisStreamConnection.php b/lib/Predis/Connection/PhpiredisStreamConnection.php index d0fe4354..ef9b6aa9 100644 --- a/lib/Predis/Connection/PhpiredisStreamConnection.php +++ b/lib/Predis/Connection/PhpiredisStreamConnection.php @@ -133,7 +133,7 @@ class PhpiredisStreamConnection extends StreamConnection /** * Gets the handler used by the protocol reader to handle Redis errors. * - * @param Boolean $throw_errors Specify if Redis errors throw exceptions. + * @param Boolean $throw_errors Specify if Redis errors throw exceptions. * @return \Closure */ protected function getErrorHandler() @@ -156,6 +156,7 @@ class PhpiredisStreamConnection extends StreamConnection if ($buffer === false || $buffer === '') { $this->onConnectionError('Error while reading bytes from the server'); + return; } diff --git a/lib/Predis/Connection/PredisCluster.php b/lib/Predis/Connection/PredisCluster.php index 1290bce5..e4f83591 100644 --- a/lib/Predis/Connection/PredisCluster.php +++ b/lib/Predis/Connection/PredisCluster.php @@ -112,7 +112,7 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \ /** * Removes a connection instance using its alias or index. * - * @param string $connectionId Alias or index of a connection. + * @param string $connectionId Alias or index of a connection. * @return Boolean Returns true if the connection was in the pool. */ public function removeById($connectionId) @@ -151,7 +151,7 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \ /** * Retrieves a connection instance from the cluster using a key. * - * @param string $key Key of a Redis value. + * @param string $key Key of a Redis value. * @return SingleConnectionInterface */ public function getConnectionByKey($key) @@ -216,7 +216,7 @@ class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \ /** * 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 f68a32ed..faffcd70 100644 --- a/lib/Predis/Connection/RedisCluster.php +++ b/lib/Predis/Connection/RedisCluster.php @@ -127,8 +127,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) { @@ -214,8 +214,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) @@ -238,7 +238,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) @@ -283,7 +283,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) @@ -339,7 +339,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) { @@ -350,8 +350,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou /** * Handles -ERR responses from Redis. * - * @param CommandInterface $command Command that generated the -ERR response. - * @param ResponseErrorInterface $error Redis error response object. + * @param CommandInterface $command Command that generated the -ERR response. + * @param ResponseErrorInterface $error Redis error response object. * @return mixed */ protected function onErrorResponse(CommandInterface $command, ResponseErrorInterface $error) @@ -372,9 +372,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 f2d0329f..a42788b2 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/lib/Predis/Connection/StreamConnection.php @@ -73,7 +73,7 @@ class StreamConnection extends AbstractConnection /** * Initializes a TCP stream resource. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. * @return resource */ private function tcpStreamInitializer(ConnectionParametersInterface $parameters) @@ -115,7 +115,7 @@ class StreamConnection extends AbstractConnection /** * Initializes a UNIX stream resource. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. * @return resource */ private function unixStreamInitializer(ConnectionParametersInterface $parameters) @@ -212,7 +212,7 @@ class StreamConnection extends AbstractConnection $payload = substr($chunk, 1, -2); switch ($prefix) { - case '+': // inline + case '+': switch ($payload) { case 'OK': return true; @@ -224,7 +224,7 @@ class StreamConnection extends AbstractConnection return $payload; } - case '$': // bulk + case '$': $size = (int) $payload; if ($size === -1) { return null; @@ -246,7 +246,7 @@ class StreamConnection extends AbstractConnection return substr($bulkData, 0, -2); - case '*': // multi bulk + case '*': $count = (int) $payload; if ($count === -1) { @@ -264,10 +264,10 @@ class StreamConnection extends AbstractConnection return $multibulk; - case ':': // integer + case ':': return (int) $payload; - case '-': // error + case '-': return new ResponseError($payload); default: diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index 4c1ea898..b8972686 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/lib/Predis/Connection/WebdisConnection.php @@ -102,7 +102,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Initializes cURL. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. * @return resource */ private function initializeCurl(ConnectionParametersInterface $parameters) @@ -128,7 +128,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Initializes phpiredis' protocol reader. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. * @return resource */ private function initializeReader(ConnectionParametersInterface $parameters) @@ -168,8 +168,8 @@ class WebdisConnection implements SingleConnectionInterface /** * Feeds phpredis' reader resource with the data read from the network. * - * @param resource $resource Reader resource. - * @param string $buffer Buffer with the reply read from the network. + * @param resource $resource Reader resource. + * @param string $buffer Buffer with the reply read from the network. * @return int */ protected function feedReader($resource, $buffer) @@ -206,7 +206,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Checks if the specified command is supported by this connection class. * - * @param CommandInterface $command The instance of a Redis command. + * @param CommandInterface $command The instance of a Redis command. * @return string */ protected function getCommandId(CommandInterface $command) diff --git a/lib/Predis/ExecutableContextInterface.php b/lib/Predis/ExecutableContextInterface.php index 9b0017ae..1cb1e83b 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/Helpers.php b/lib/Predis/Helpers.php index 33fa33ae..064f72d2 100644 --- a/lib/Predis/Helpers.php +++ b/lib/Predis/Helpers.php @@ -43,7 +43,7 @@ class Helpers * Normalizes the arguments array passed to a Redis command. * * @deprecated Deprecated since v0.8.3 - moved in Predis\Command\AbstractCommand::normalizeArguments() - * @param array $arguments Arguments for a command. + * @param array $arguments Arguments for a command. * @return array */ public static function filterArrayArguments(Array $arguments) @@ -59,7 +59,7 @@ class Helpers * Normalizes the arguments array passed to a variadic Redis command. * * @deprecated Deprecated since v0.8.3 - moved in Predis\Command\AbstractCommand::normalizeVariadic() - * @param array $arguments Arguments for a command. + * @param array $arguments Arguments for a command. * @return array */ public static function filterVariadicValues(Array $arguments) diff --git a/lib/Predis/Iterator/MultiBulkResponse.php b/lib/Predis/Iterator/MultiBulkResponse.php index a7bbad81..317a006c 100644 --- a/lib/Predis/Iterator/MultiBulkResponse.php +++ b/lib/Predis/Iterator/MultiBulkResponse.php @@ -96,5 +96,5 @@ abstract class MultiBulkResponse implements \Iterator, \Countable, ResponseObjec /** * {@inheritdoc} */ - protected abstract function getValue(); + abstract protected function getValue(); } diff --git a/lib/Predis/Iterator/MultiBulkResponseSimple.php b/lib/Predis/Iterator/MultiBulkResponseSimple.php index 2dee7223..c127cc4e 100644 --- a/lib/Predis/Iterator/MultiBulkResponseSimple.php +++ b/lib/Predis/Iterator/MultiBulkResponseSimple.php @@ -24,7 +24,7 @@ class MultiBulkResponseSimple extends MultiBulkResponse /** * @param SingleConnectionInterface $connection Connection to Redis. - * @param int $size Number of elements of the multibulk reply. + * @param int $size Number of elements of the multibulk reply. */ public function __construct(SingleConnectionInterface $connection, $size) { diff --git a/lib/Predis/Option/ClientCluster.php b/lib/Predis/Option/ClientCluster.php index dff626f7..fca9796e 100644 --- a/lib/Predis/Option/ClientCluster.php +++ b/lib/Predis/Option/ClientCluster.php @@ -25,7 +25,7 @@ class ClientCluster extends AbstractOption /** * Checks if the specified value is a valid instance of ClusterConnectionInterface. * - * @param ClusterConnectionInterface $cluster Instance of a connection cluster. + * @param ClusterConnectionInterface $cluster Instance of a connection cluster. * @return ClusterConnectionInterface */ protected function checkInstance($cluster) @@ -54,8 +54,8 @@ class ClientCluster extends AbstractOption /** * Returns an initializer for the specified FQN or type. * - * @param string $fqnOrType Type of cluster or FQN of a class implementing ClusterConnectionInterface. - * @param ClientOptionsInterface $options Instance of the client options. + * @param string $fqnOrType Type of cluster or FQN of a class implementing ClusterConnectionInterface. + * @param ClientOptionsInterface $options Instance of the client options. * @return \Closure */ protected function getInitializer(ClientOptionsInterface $options, $fqnOrType) @@ -79,6 +79,7 @@ class ClientCluster extends AbstractOption if (is_string($fqnOrType) && !class_exists($fqnOrType)) { throw new \InvalidArgumentException("Class $fqnOrType does not exist"); } + return function () use ($fqnOrType) { return new $fqnOrType(); }; diff --git a/lib/Predis/Option/ClientOptions.php b/lib/Predis/Option/ClientOptions.php index d835524a..61a0fa8a 100644 --- a/lib/Predis/Option/ClientOptions.php +++ b/lib/Predis/Option/ClientOptions.php @@ -51,7 +51,7 @@ class ClientOptions implements ClientOptionsInterface /** * Initializes client options handlers. * - * @param array $options List of client options values. + * @param array $options List of client options values. * @return array */ protected function initialize(Array $options) @@ -75,7 +75,7 @@ class ClientOptions implements ClientOptionsInterface /** * Checks if the specified option is set. * - * @param string $option Name of the option. + * @param string $option Name of the option. * @return Boolean */ public function __isset($option) @@ -86,7 +86,7 @@ class ClientOptions implements ClientOptionsInterface /** * Returns the value of the specified option. * - * @param string $option Name of the option. + * @param string $option Name of the option. * @return mixed */ public function __get($option) @@ -107,7 +107,7 @@ class ClientOptions implements ClientOptionsInterface /** * Returns the default value for the specified option. * - * @param string|OptionInterface $option Name or instance of the option. + * @param string|OptionInterface $option Name or instance of the option. * @return mixed */ public function getDefault($option) diff --git a/lib/Predis/Option/ClientReplication.php b/lib/Predis/Option/ClientReplication.php index 61e02681..ad703083 100644 --- a/lib/Predis/Option/ClientReplication.php +++ b/lib/Predis/Option/ClientReplication.php @@ -24,7 +24,7 @@ class ClientReplication extends AbstractOption /** * Checks if the specified value is a valid instance of ReplicationConnectionInterface. * - * @param ReplicationConnectionInterface $connection Instance of a replication connection. + * @param ReplicationConnectionInterface $connection Instance of a replication connection. * @return ReplicationConnectionInterface */ protected function checkInstance($connection) diff --git a/lib/Predis/Option/CustomOption.php b/lib/Predis/Option/CustomOption.php index 067907b1..848c8b94 100644 --- a/lib/Predis/Option/CustomOption.php +++ b/lib/Predis/Option/CustomOption.php @@ -33,8 +33,8 @@ class CustomOption implements OptionInterface /** * Checks if the specified value in the options array is a callable object. * - * @param array $options Array of options - * @param string $key Target option. + * @param array $options Array of options + * @param string $key Target option. */ private function ensureCallable($options, $key) { diff --git a/lib/Predis/Option/OptionInterface.php b/lib/Predis/Option/OptionInterface.php index 415b8c1b..ab6bc807 100644 --- a/lib/Predis/Option/OptionInterface.php +++ b/lib/Predis/Option/OptionInterface.php @@ -21,7 +21,7 @@ interface OptionInterface /** * Filters (and optionally converts) the passed value. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return mixed */ public function filter(ClientOptionsInterface $options, $value); @@ -29,7 +29,7 @@ interface OptionInterface /** * Returns a default value for the option. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return mixed */ public function getDefault(ClientOptionsInterface $options); @@ -38,7 +38,7 @@ interface OptionInterface * Filters a value and, if no value is specified, returns * the default one defined by the option. * - * @param mixed $value Input value. + * @param mixed $value Input value. * @return mixed */ public function __invoke(ClientOptionsInterface $options, $value); diff --git a/lib/Predis/Pipeline/MultiExecExecutor.php b/lib/Predis/Pipeline/MultiExecExecutor.php index d9550bda..5f6c09e4 100644 --- a/lib/Predis/Pipeline/MultiExecExecutor.php +++ b/lib/Predis/Pipeline/MultiExecExecutor.php @@ -100,8 +100,8 @@ class MultiExecExecutor implements PipelineExecutorInterface /** * Consumes an iterator response returned by EXEC. * - * @param SplQueue $commands Pipelined commands - * @param Iterator $responses Responses returned by EXEC. + * @param SplQueue $commands Pipelined commands + * @param Iterator $responses Responses returned by EXEC. * @return array */ protected function consumeIteratorResponse(SplQueue $commands, Iterator $responses) @@ -129,8 +129,8 @@ class MultiExecExecutor implements PipelineExecutorInterface /** * Consumes an array response returned by EXEC. * - * @param SplQueue $commands Pipelined commands - * @param Array $responses Responses returned by EXEC. + * @param SplQueue $commands Pipelined commands + * @param Array $responses Responses returned by EXEC. * @return array */ protected function consumeArrayResponse(SplQueue $commands, Array &$responses) diff --git a/lib/Predis/Pipeline/PipelineContext.php b/lib/Predis/Pipeline/PipelineContext.php index 92b09d85..e2c14afb 100644 --- a/lib/Predis/Pipeline/PipelineContext.php +++ b/lib/Predis/Pipeline/PipelineContext.php @@ -34,7 +34,7 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac private $running = false; /** - * @param ClientInterface $client Client instance used by the context. + * @param ClientInterface $client Client instance used by the context. * @param PipelineExecutorInterface $executor Pipeline executor instace. */ public function __construct(ClientInterface $client, PipelineExecutorInterface $executor = null) @@ -48,7 +48,7 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac * Returns a pipeline executor depending on the kind of the underlying * connection and the passed options. * - * @param ClientInterface $client Client instance used by the context. + * @param ClientInterface $client Client instance used by the context. * @return PipelineExecutorInterface */ protected function createExecutor(ClientInterface $client) @@ -65,8 +65,8 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac /** * 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 PipelineContext */ public function __call($method, $arguments) @@ -100,7 +100,7 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac /** * Flushes the buffer that holds the queued commands. * - * @param Boolean $send Specifies if the commands in the buffer should be sent to Redis. + * @param Boolean $send Specifies if the commands in the buffer should be sent to Redis. * @return PipelineContext */ public function flushPipeline($send = true) @@ -134,7 +134,7 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac /** * 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/Pipeline/PipelineExecutorInterface.php b/lib/Predis/Pipeline/PipelineExecutorInterface.php index 76f1c447..74b7d414 100644 --- a/lib/Predis/Pipeline/PipelineExecutorInterface.php +++ b/lib/Predis/Pipeline/PipelineExecutorInterface.php @@ -25,8 +25,8 @@ interface PipelineExecutorInterface /** * Writes a list of commands to the network and reads back their replies. * - * @param ConnectionInterface $connection Connection to Redis. - * @param SplQueue $commands Commands queued for execution. + * @param ConnectionInterface $connection Connection to Redis. + * @param SplQueue $commands Commands queued for execution. * @return array */ public function execute(ConnectionInterface $connection, SplQueue $commands); diff --git a/lib/Predis/Pipeline/StandardExecutor.php b/lib/Predis/Pipeline/StandardExecutor.php index 805395a5..75f05205 100644 --- a/lib/Predis/Pipeline/StandardExecutor.php +++ b/lib/Predis/Pipeline/StandardExecutor.php @@ -56,9 +56,9 @@ class StandardExecutor implements PipelineExecutorInterface /** * Handles a response object. * - * @param ConnectionInterface $connection - * @param CommandInterface $command - * @param ResponseObjectInterface $response + * @param ConnectionInterface $connection + * @param CommandInterface $command + * @param ResponseObjectInterface $response * @return mixed */ protected function onResponseObject(ConnectionInterface $connection, CommandInterface $command, ResponseObjectInterface $response) @@ -77,8 +77,8 @@ class StandardExecutor implements PipelineExecutorInterface /** * Handles -ERR responses returned by Redis. * - * @param ConnectionInterface $connection The connection that returned the error. - * @param ResponseErrorInterface $response The error response instance. + * @param ConnectionInterface $connection The connection that returned the error. + * @param ResponseErrorInterface $response The error response instance. */ protected function onResponseError(ConnectionInterface $connection, ResponseErrorInterface $response) { diff --git a/lib/Predis/Profile/ServerProfile.php b/lib/Predis/Profile/ServerProfile.php index a6429641..75462faa 100644 --- a/lib/Predis/Profile/ServerProfile.php +++ b/lib/Predis/Profile/ServerProfile.php @@ -41,7 +41,7 @@ abstract class ServerProfile implements ServerProfileInterface, CommandProcessin * * @return array */ - protected abstract function getSupportedCommands(); + abstract protected function getSupportedCommands(); /** * Returns the default server profile. @@ -86,7 +86,7 @@ abstract class ServerProfile implements ServerProfileInterface, CommandProcessin /** * Registers a new server profile. * - * @param string $alias Profile version or alias. + * @param string $alias Profile version or alias. * @param string $profileClass FQN of a class implementing Predis\Profile\ServerProfileInterface. */ public static function define($alias, $profileClass) @@ -107,7 +107,7 @@ abstract class ServerProfile implements ServerProfileInterface, CommandProcessin /** * Returns the specified server profile. * - * @param string $version Profile version or alias. + * @param string $version Profile version or alias. * @return ServerProfileInterface */ public static function get($version) @@ -151,7 +151,7 @@ abstract class ServerProfile implements ServerProfileInterface, CommandProcessin * Returns the FQN of the class that represent the specified command ID * registered in the current server profile. * - * @param string $command Command ID. + * @param string $command Command ID. * @return string */ public function getCommandClass($command) @@ -186,7 +186,7 @@ abstract class ServerProfile implements ServerProfileInterface, CommandProcessin /** * Defines a new commands in the server profile. * - * @param string $alias Command ID. + * @param string $alias Command ID. * @param string $command FQN of a class implementing Predis\Command\CommandInterface. */ public function defineCommand($alias, $command) diff --git a/lib/Predis/Profile/ServerProfileInterface.php b/lib/Predis/Profile/ServerProfileInterface.php index 39477cbb..93eb541a 100644 --- a/lib/Predis/Profile/ServerProfileInterface.php +++ b/lib/Predis/Profile/ServerProfileInterface.php @@ -32,7 +32,7 @@ interface ServerProfileInterface /** * Checks if the profile supports the specified command. * - * @param string $command Command ID. + * @param string $command Command ID. * @return Boolean */ public function supportsCommand($command); @@ -40,7 +40,7 @@ interface ServerProfileInterface /** * Checks if the profile supports the specified list of commands. * - * @param array $commands List of command IDs. + * @param array $commands List of command IDs. * @return string */ public function supportsCommands(Array $commands); @@ -48,8 +48,8 @@ interface ServerProfileInterface /** * Creates a new command instance. * - * @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/Profile/ServerVersion20.php b/lib/Predis/Profile/ServerVersion20.php index 42b0b088..4fae3f9e 100644 --- a/lib/Predis/Profile/ServerVersion20.php +++ b/lib/Predis/Profile/ServerVersion20.php @@ -121,7 +121,6 @@ class ServerVersion20 extends ServerProfile 'shutdown' => 'Predis\Command\ServerShutdown', 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ diff --git a/lib/Predis/Profile/ServerVersion22.php b/lib/Predis/Profile/ServerVersion22.php index e97f422b..2fe4fca9 100644 --- a/lib/Predis/Profile/ServerVersion22.php +++ b/lib/Predis/Profile/ServerVersion22.php @@ -121,7 +121,6 @@ class ServerVersion22 extends ServerProfile 'shutdown' => 'Predis\Command\ServerShutdown', 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -170,7 +169,6 @@ class ServerVersion22 extends ServerProfile /* remote server control commands */ 'config' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ diff --git a/lib/Predis/Profile/ServerVersion24.php b/lib/Predis/Profile/ServerVersion24.php index 20569c6f..455d5b6d 100644 --- a/lib/Predis/Profile/ServerVersion24.php +++ b/lib/Predis/Profile/ServerVersion24.php @@ -121,7 +121,6 @@ class ServerVersion24 extends ServerProfile 'shutdown' => 'Predis\Command\ServerShutdown', 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -170,7 +169,6 @@ class ServerVersion24 extends ServerProfile /* remote server control commands */ 'config' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ @@ -200,7 +198,6 @@ class ServerVersion24 extends ServerProfile 'object' => 'Predis\Command\ServerObject', 'slowlog' => 'Predis\Command\ServerSlowlog', - /* ---------------- Redis 2.4 ---------------- */ /* remote server control commands */ diff --git a/lib/Predis/Profile/ServerVersion26.php b/lib/Predis/Profile/ServerVersion26.php index af3c0d29..9f8b60dc 100644 --- a/lib/Predis/Profile/ServerVersion26.php +++ b/lib/Predis/Profile/ServerVersion26.php @@ -123,7 +123,6 @@ class ServerVersion26 extends ServerProfile 'shutdown' => 'Predis\Command\ServerShutdown', 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -172,7 +171,6 @@ class ServerVersion26 extends ServerProfile /* remote server control commands */ 'config' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ @@ -202,13 +200,11 @@ class ServerVersion26 extends ServerProfile '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/ServerVersion28.php b/lib/Predis/Profile/ServerVersion28.php index f2474ee7..ca2e2e09 100644 --- a/lib/Predis/Profile/ServerVersion28.php +++ b/lib/Predis/Profile/ServerVersion28.php @@ -123,7 +123,6 @@ class ServerVersion28 extends ServerProfile 'shutdown' => 'Predis\Command\ServerShutdown', 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - /* ---------------- Redis 2.0 ---------------- */ /* commands operating on string values */ @@ -172,7 +171,6 @@ class ServerVersion28 extends ServerProfile /* remote server control commands */ 'config' => 'Predis\Command\ServerConfig', - /* ---------------- Redis 2.2 ---------------- */ /* commands operating on the key space */ @@ -202,13 +200,11 @@ class ServerVersion28 extends ServerProfile '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 */ @@ -234,7 +230,6 @@ class ServerVersion28 extends ServerProfile 'info' => 'Predis\Command\ServerInfoV26x', 'time' => 'Predis\Command\ServerTime', - /* ---------------- Redis 2.8 ---------------- */ /* commands operating on the key space */ diff --git a/lib/Predis/Protocol/CommandSerializerInterface.php b/lib/Predis/Protocol/CommandSerializerInterface.php index 2671aece..f57f1ad6 100644 --- a/lib/Predis/Protocol/CommandSerializerInterface.php +++ b/lib/Predis/Protocol/CommandSerializerInterface.php @@ -23,7 +23,7 @@ interface CommandSerializerInterface /** * 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/ProtocolInterface.php b/lib/Predis/Protocol/ProtocolInterface.php index 5595d350..cebe0e54 100644 --- a/lib/Predis/Protocol/ProtocolInterface.php +++ b/lib/Predis/Protocol/ProtocolInterface.php @@ -26,7 +26,7 @@ interface ProtocolInterface extends ResponseReaderInterface * Writes a Redis command on the specified connection. * * @param ComposableConnectionInterface $connection Connection to Redis. - * @param CommandInterface $command Redis command. + * @param CommandInterface $command Redis command. */ public function write(ComposableConnectionInterface $connection, CommandInterface $command); @@ -34,7 +34,7 @@ interface ProtocolInterface extends ResponseReaderInterface * Sets the options for the protocol processor. * * @param string $option Name of the option. - * @param mixed $value Value of the option. + * @param mixed $value Value of the option. */ public function setOption($option, $value); } diff --git a/lib/Predis/Protocol/ResponseHandlerInterface.php b/lib/Predis/Protocol/ResponseHandlerInterface.php index 0ea2ca46..7900fe65 100644 --- a/lib/Predis/Protocol/ResponseHandlerInterface.php +++ b/lib/Predis/Protocol/ResponseHandlerInterface.php @@ -24,9 +24,9 @@ interface ResponseHandlerInterface * Parses a type of reply returned by Redis and reads more data from the * connection if needed. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $payload Initial payload of the reply. + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $payload Initial payload of the reply. * @return mixed */ - function handle(ComposableConnectionInterface $connection, $payload); + public function handle(ComposableConnectionInterface $connection, $payload); } diff --git a/lib/Predis/Protocol/ResponseReaderInterface.php b/lib/Predis/Protocol/ResponseReaderInterface.php index 04281121..a89cb750 100644 --- a/lib/Predis/Protocol/ResponseReaderInterface.php +++ b/lib/Predis/Protocol/ResponseReaderInterface.php @@ -24,7 +24,7 @@ interface ResponseReaderInterface /** * Reads replies from a connection to Redis and deserializes them. * - * @param ComposableConnectionInterface $connection Connection to Redis. + * @param ComposableConnectionInterface $connection Connection to Redis. * @return mixed */ public function read(ComposableConnectionInterface $connection); diff --git a/lib/Predis/Protocol/Text/ResponseBulkHandler.php b/lib/Predis/Protocol/Text/ResponseBulkHandler.php index 7b9a9650..29792cc7 100644 --- a/lib/Predis/Protocol/Text/ResponseBulkHandler.php +++ b/lib/Predis/Protocol/Text/ResponseBulkHandler.php @@ -28,8 +28,8 @@ class ResponseBulkHandler implements ResponseHandlerInterface /** * Handles a bulk reply returned by Redis. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $lengthString Bytes size of the bulk reply. + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $lengthString Bytes size of the bulk reply. * @return string */ public function handle(ComposableConnectionInterface $connection, $lengthString) diff --git a/lib/Predis/Protocol/Text/ResponseIntegerHandler.php b/lib/Predis/Protocol/Text/ResponseIntegerHandler.php index 36556f33..866a25f1 100644 --- a/lib/Predis/Protocol/Text/ResponseIntegerHandler.php +++ b/lib/Predis/Protocol/Text/ResponseIntegerHandler.php @@ -28,8 +28,8 @@ class ResponseIntegerHandler implements ResponseHandlerInterface /** * Handles an integer reply returned by Redis. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $number String representation of an integer. + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $number String representation of an integer. * @return int */ public function handle(ComposableConnectionInterface $connection, $number) diff --git a/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php b/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php index 2f31f321..06bffad2 100644 --- a/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php +++ b/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php @@ -28,8 +28,8 @@ class ResponseMultiBulkHandler implements ResponseHandlerInterface /** * Handles a multi-bulk reply returned by Redis. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $lengthString Number of items in the multi-bulk reply. + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $lengthString Number of items in the multi-bulk reply. * @return array */ public function handle(ComposableConnectionInterface $connection, $lengthString) diff --git a/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php b/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php index 77bc19f6..bed3eda9 100644 --- a/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php +++ b/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php @@ -29,8 +29,8 @@ class ResponseMultiBulkStreamHandler implements ResponseHandlerInterface /** * Handles a multi-bulk reply returned by Redis in a streamable fashion. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $lengthString Number of items in the multi-bulk reply. + * @param ComposableConnectionInterface $connection Connection to Redis. + * @param string $lengthString Number of items in the multi-bulk reply. * @return MultiBulkResponseSimple */ public function handle(ComposableConnectionInterface $connection, $lengthString) diff --git a/lib/Predis/Protocol/Text/TextProtocol.php b/lib/Predis/Protocol/Text/TextProtocol.php index 04d5bcaf..eef07044 100644 --- a/lib/Predis/Protocol/Text/TextProtocol.php +++ b/lib/Predis/Protocol/Text/TextProtocol.php @@ -72,7 +72,7 @@ class TextProtocol implements ProtocolInterface $payload = substr($chunk, 1); switch ($prefix) { - case '+': // inline + case '+': switch ($payload) { case 'OK': return true; @@ -84,14 +84,15 @@ class TextProtocol implements ProtocolInterface return $payload; } - case '$': // bulk + case '$': $size = (int) $payload; if ($size === -1) { return null; } + return substr($connection->readBytes($size + 2), 0, -2); - case '*': // multi bulk + case '*': $count = (int) $payload; if ($count === -1) { @@ -109,10 +110,10 @@ class TextProtocol implements ProtocolInterface return $multibulk; - case ':': // integer + case ':': return (int) $payload; - case '-': // error + case '-': return new ResponseError($payload); default: diff --git a/lib/Predis/Protocol/Text/TextResponseReader.php b/lib/Predis/Protocol/Text/TextResponseReader.php index 5364a219..ab02f3aa 100644 --- a/lib/Predis/Protocol/Text/TextResponseReader.php +++ b/lib/Predis/Protocol/Text/TextResponseReader.php @@ -55,7 +55,7 @@ class TextResponseReader implements ResponseReaderInterface * Sets a response handler for a certain prefix that identifies a type of * reply that can be returned by Redis. * - * @param string $prefix Identifier for a type of reply. + * @param string $prefix Identifier for a type of reply. * @param ResponseHandlerInterface $handler Response handler for the reply. */ public function setHandler($prefix, ResponseHandlerInterface $handler) @@ -67,7 +67,7 @@ class TextResponseReader implements ResponseReaderInterface * Returns the response handler associated to a certain type of reply that * can be returned by Redis. * - * @param string $prefix Identifier for a type of reply. + * @param string $prefix Identifier for a type of reply. * @return ResponseHandlerInterface */ public function getHandler($prefix) @@ -104,7 +104,7 @@ class TextResponseReader implements ResponseReaderInterface * reply from a connection to Redis. * * @param ComposableConnectionInterface $connection Connection to Redis that generated the error. - * @param string $message Error message. + * @param string $message Error message. */ private function protocolError(ComposableConnectionInterface $connection, $message) { diff --git a/lib/Predis/PubSub/AbstractPubSubContext.php b/lib/Predis/PubSub/AbstractPubSubContext.php index 87186b22..575626d3 100644 --- a/lib/Predis/PubSub/AbstractPubSubContext.php +++ b/lib/Predis/PubSub/AbstractPubSubContext.php @@ -43,7 +43,7 @@ abstract class AbstractPubSubContext implements \Iterator /** * Checks if the specified flag is valid in the state of the context. * - * @param int $value Flag. + * @param int $value Flag. * @return Boolean */ protected function isFlagSet($value) @@ -98,7 +98,7 @@ abstract class AbstractPubSubContext implements \Iterator * Optionally, the context can be forcefully closed by dropping the * underlying connection. * - * @param Boolean $force Forcefully close the context by closing the connection. + * @param Boolean $force Forcefully close the context by closing the connection. * @return Boolean Returns false if there are no pending messages. */ public function closeContext($force = false) @@ -125,15 +125,15 @@ abstract class AbstractPubSubContext implements \Iterator /** * Closes the underlying connection on forced disconnection. */ - protected abstract function disconnect(); + abstract protected function disconnect(); /** * Writes a Redis command on the underlying connection. * - * @param string $method ID of the command. - * @param array $arguments List of arguments. + * @param string $method ID of the command. + * @param array $arguments List of arguments. */ - protected abstract function writeCommand($method, $arguments); + abstract protected function writeCommand($method, $arguments); /** * {@inheritdoc} @@ -202,5 +202,5 @@ abstract class AbstractPubSubContext implements \Iterator * * @return array */ - protected abstract function getValue(); + abstract protected function getValue(); } diff --git a/lib/Predis/PubSub/DispatcherLoop.php b/lib/Predis/PubSub/DispatcherLoop.php index 0a16b195..c35b7075 100644 --- a/lib/Predis/PubSub/DispatcherLoop.php +++ b/lib/Predis/PubSub/DispatcherLoop.php @@ -90,7 +90,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) @@ -137,7 +137,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/PubSub/PubSubContext.php b/lib/Predis/PubSub/PubSubContext.php index 50f8dc13..199cd6d0 100644 --- a/lib/Predis/PubSub/PubSubContext.php +++ b/lib/Predis/PubSub/PubSubContext.php @@ -28,8 +28,8 @@ class PubSubContext extends AbstractPubSubContext private $options; /** - * @param ClientInterface $client Client instance used by the context. - * @param array $options Options for the context initialization. + * @param ClientInterface $client Client instance used by the context. + * @param array $options Options for the context initialization. */ public function __construct(ClientInterface $client, Array $options = null) { diff --git a/lib/Predis/Replication/ReplicationStrategy.php b/lib/Predis/Replication/ReplicationStrategy.php index c64f3e99..fd8e3b4e 100644 --- a/lib/Predis/Replication/ReplicationStrategy.php +++ b/lib/Predis/Replication/ReplicationStrategy.php @@ -39,7 +39,7 @@ class ReplicationStrategy * Returns if the specified command performs a read-only operation * against a key stored on Redis. * - * @param CommandInterface $command Instance of Redis command. + * @param CommandInterface $command Instance of Redis command. * @return Boolean */ public function isReadOperation(CommandInterface $command) @@ -75,7 +75,7 @@ class ReplicationStrategy * Returns if the specified command is disallowed in a master/slave * replication context. * - * @param CommandInterface $command Instance of Redis command. + * @param CommandInterface $command Instance of Redis command. * @return Boolean */ public function isDisallowedOperation(CommandInterface $command) @@ -87,12 +87,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 Instance of Redis command. + * @param CommandInterface $command Instance of Redis command. * @return Boolean */ protected function isSortReadOnly(CommandInterface $command) { $arguments = $command->getArguments(); + return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE'; } @@ -103,7 +104,7 @@ class ReplicationStrategy * instance of a command performs write operations or not. * * @param string $commandID ID of the command. - * @param mixed $readonly A boolean or a callable object. + * @param mixed $readonly A boolean or a callable object. */ public function setCommandReadOnly($commandID, $readonly = true) { @@ -123,8 +124,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 or a callable object. + * @param string $script Body of the Lua script. + * @param mixed $readonly A boolean or a callable object. */ public function setScriptReadOnly($script, $readonly = true) { diff --git a/lib/Predis/ResponseError.php b/lib/Predis/ResponseError.php index f6f310ea..0ab9a8a7 100644 --- a/lib/Predis/ResponseError.php +++ b/lib/Predis/ResponseError.php @@ -43,6 +43,7 @@ class ResponseError implements ResponseErrorInterface public function getErrorType() { list($errorType, ) = explode(' ', $this->getMessage(), 2); + return $errorType; } diff --git a/lib/Predis/ResponseQueued.php b/lib/Predis/ResponseQueued.php index c9786fbb..c6d90c0c 100644 --- a/lib/Predis/ResponseQueued.php +++ b/lib/Predis/ResponseQueued.php @@ -32,7 +32,7 @@ class ResponseQueued implements ResponseObjectInterface /** * Returns the value of the specified property. * - * @param string $property Name of the property. + * @param string $property Name of the property. * @return mixed */ public function __get($property) @@ -43,7 +43,7 @@ class ResponseQueued implements ResponseObjectInterface /** * Checks if the specified property is set. * - * @param string $property Name of the property. + * @param string $property Name of the property. * @return Boolean */ public function __isset($property) diff --git a/lib/Predis/Session/SessionHandler.php b/lib/Predis/Session/SessionHandler.php index eba793ac..dc4e4be3 100644 --- a/lib/Predis/Session/SessionHandler.php +++ b/lib/Predis/Session/SessionHandler.php @@ -30,8 +30,8 @@ class SessionHandler 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()) { @@ -64,7 +64,6 @@ class SessionHandler implements SessionHandlerInterface public function open($save_path, $session_id) { // NOOP - return true; } @@ -74,7 +73,6 @@ class SessionHandler implements SessionHandlerInterface public function close() { // NOOP - return true; } @@ -84,7 +82,6 @@ class SessionHandler implements SessionHandlerInterface public function gc($maxlifetime) { // NOOP - return true; } diff --git a/lib/Predis/Transaction/AbortedMultiExecException.php b/lib/Predis/Transaction/AbortedMultiExecException.php index bccaa870..81eed8b8 100644 --- a/lib/Predis/Transaction/AbortedMultiExecException.php +++ b/lib/Predis/Transaction/AbortedMultiExecException.php @@ -24,8 +24,8 @@ class AbortedMultiExecException extends PredisException /** * @param MultiExecContext $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(MultiExecContext $transaction, $message, $code = null) { diff --git a/lib/Predis/Transaction/MultiExecContext.php b/lib/Predis/Transaction/MultiExecContext.php index 882c2b41..5eac61be 100644 --- a/lib/Predis/Transaction/MultiExecContext.php +++ b/lib/Predis/Transaction/MultiExecContext.php @@ -47,8 +47,8 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa protected $commands; /** - * @param ClientInterface $client Client instance used by the context. - * @param array $options Options for the context initialization. + * @param ClientInterface $client Client instance used by the context. + * @param array $options Options for the context initialization. */ public function __construct(ClientInterface $client, Array $options = null) { @@ -101,7 +101,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa /** * Checks is a flag is set. * - * @param int $flags Flag + * @param int $flags Flag * @return Boolean */ protected function checkState($flags) @@ -185,8 +185,8 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa /** * 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) @@ -200,7 +200,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa /** * Executes the specified Redis command. * - * @param CommandInterface $command A Redis command. + * @param CommandInterface $command A Redis command. * @return mixed */ public function executeCommand(CommandInterface $command) @@ -224,7 +224,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa /** * Executes WATCH on 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) @@ -331,7 +331,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa /** * 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)