From 59b5658cf5dd45212492a5284d3eacbb9c78769f Mon Sep 17 00:00:00 2001 From: Daniele Alessandri Date: Tue, 10 Dec 2013 19:21:52 +0100 Subject: [PATCH] Big batch of phpdoc improvements and minor code styling fixes. --- lib/Predis/Autoloader.php | 2 +- lib/Predis/BasicClientInterface.php | 6 +-- lib/Predis/Client.php | 9 +++-- lib/Predis/ClientInterface.php | 13 +++---- .../Distributor/DistributorInterface.php | 4 +- lib/Predis/Cluster/Distributor/HashRing.php | 2 +- lib/Predis/Cluster/Distributor/KetamaRing.php | 2 +- lib/Predis/Cluster/Hash/CRC16.php | 2 +- .../Cluster/Hash/HashGeneratorInterface.php | 8 ++-- lib/Predis/Cluster/PredisStrategy.php | 32 +++++++-------- lib/Predis/Cluster/RedisStrategy.php | 24 ++++++------ lib/Predis/Cluster/StrategyInterface.php | 12 +++--- .../Iterator/CursorBasedIterator.php | 31 ++++++++------- lib/Predis/Collection/Iterator/HashKey.php | 5 +-- lib/Predis/Collection/Iterator/Keyspace.php | 5 +-- lib/Predis/Collection/Iterator/ListKey.php | 21 +++++----- lib/Predis/Collection/Iterator/SetKey.php | 5 +-- .../Collection/Iterator/SortedSetKey.php | 5 +-- lib/Predis/Command/CommandInterface.php | 5 ++- .../CommandProcessorChainInterface.php | 8 ++-- .../Processor/CommandProcessorInterface.php | 6 +-- .../Command/Processor/KeyPrefixProcessor.php | 4 +- lib/Predis/Command/ScriptCommand.php | 4 +- lib/Predis/CommunicationException.php | 8 ++-- .../Configuration/ConnectionFactoryOption.php | 4 +- lib/Predis/Configuration/ExceptionsOption.php | 5 +-- lib/Predis/Configuration/OptionInterface.php | 4 +- lib/Predis/Configuration/Options.php | 4 +- lib/Predis/Configuration/OptionsInterface.php | 10 ++--- lib/Predis/Configuration/PrefixOption.php | 5 +-- lib/Predis/Configuration/ProfileOption.php | 7 ++-- .../Configuration/ReplicationOption.php | 19 +++++---- lib/Predis/Connection/AbstractConnection.php | 7 ++-- .../AggregatedConnectionInterface.php | 25 ++++++------ .../Connection/ClusterConnectionInterface.php | 4 +- .../ComposableConnectionInterface.php | 11 +++--- .../Connection/ComposableStreamConnection.php | 2 +- lib/Predis/Connection/ConnectionFactory.php | 7 ++-- .../Connection/ConnectionFactoryInterface.php | 17 ++++---- lib/Predis/Connection/ConnectionInterface.php | 21 +++++----- .../Connection/ConnectionParameters.php | 2 +- .../Connection/MasterSlaveReplication.php | 12 ++++-- lib/Predis/Connection/PredisCluster.php | 20 +++++----- lib/Predis/Connection/RedisCluster.php | 3 +- .../ReplicationConnectionInterface.php | 11 +++--- .../Connection/SingleConnectionInterface.php | 10 ++--- lib/Predis/Connection/StreamConnection.php | 14 +++---- lib/Predis/Connection/WebdisConnection.php | 18 ++++----- lib/Predis/ExecutableContextInterface.php | 4 +- lib/Predis/Monitor/Consumer.php | 10 ++--- lib/Predis/NotSupportedException.php | 4 +- lib/Predis/Pipeline/Pipeline.php | 12 +++--- lib/Predis/Profile/Factory.php | 6 ++- lib/Predis/Profile/RedisProfile.php | 10 ++--- lib/Predis/Profile/RedisVersion120.php | 2 +- lib/Predis/Profile/RedisVersion200.php | 2 +- lib/Predis/Profile/RedisVersion220.php | 2 +- lib/Predis/Profile/RedisVersion240.php | 2 +- lib/Predis/Profile/RedisVersion260.php | 2 +- lib/Predis/Profile/RedisVersion280.php | 2 +- lib/Predis/Protocol/ProtocolException.php | 3 +- .../Protocol/ProtocolProcessorInterface.php | 10 ++--- .../Protocol/ResponseReaderInterface.php | 4 +- .../Text/Handler/ResponseHandlerInterface.php | 8 ++-- .../Protocol/Text/Handler/StatusResponse.php | 6 +-- .../Protocol/Text/ProtocolProcessor.php | 4 +- lib/Predis/Protocol/Text/ResponseReader.php | 4 +- lib/Predis/PubSub/AbstractConsumer.php | 19 +++++---- lib/Predis/PubSub/Consumer.php | 4 +- lib/Predis/PubSub/DispatcherLoop.php | 14 +++---- .../Replication/ReplicationStrategy.php | 39 ++++++++++--------- lib/Predis/Response/Iterator/MultiBulk.php | 6 +-- .../Response/Iterator/MultiBulkTuple.php | 8 +++- lib/Predis/Response/Status.php | 6 +-- lib/Predis/Session/Handler.php | 15 ++++--- .../Transaction/AbortedMultiExecException.php | 2 +- lib/Predis/Transaction/MultiExec.php | 22 +++++------ 77 files changed, 361 insertions(+), 336 deletions(-) diff --git a/lib/Predis/Autoloader.php b/lib/Predis/Autoloader.php index d48635af..6eb4029f 100644 --- a/lib/Predis/Autoloader.php +++ b/lib/Predis/Autoloader.php @@ -12,7 +12,7 @@ namespace Predis; /** - * Implements a lightweight PSR-0 compliant autoloader. + * Implements a lightweight PSR-0 compliant autoloader for Predis. * * @author Eric Naeseth * @author Daniele Alessandri diff --git a/lib/Predis/BasicClientInterface.php b/lib/Predis/BasicClientInterface.php index a25f4102..6f77d913 100644 --- a/lib/Predis/BasicClientInterface.php +++ b/lib/Predis/BasicClientInterface.php @@ -14,8 +14,8 @@ namespace Predis; use Predis\Command\CommandInterface; /** - * Defines the interface of a basic client object or abstraction that - * can send commands to Redis. + * Defines the interface of a basic client class or abstraction that can send + * commands to Redis. * * @author Daniele Alessandri */ @@ -24,7 +24,7 @@ interface BasicClientInterface /** * Executes the specified Redis command. * - * @param CommandInterface $command A Redis command. + * @param CommandInterface $command Command instance. * @return mixed */ public function executeCommand(CommandInterface $command); diff --git a/lib/Predis/Client.php b/lib/Predis/Client.php index b0b2e0cc..72381ea4 100644 --- a/lib/Predis/Client.php +++ b/lib/Predis/Client.php @@ -147,7 +147,9 @@ class Client implements ClientInterface $connection = call_user_func_array($callable, func_get_args()); if (!$connection instanceof ConnectionInterface) { - throw new UnexpectedValueException('The callable connection initializer returned an invalid type'); + throw new UnexpectedValueException( + 'The callable connection initializer returned an invalid type' + ); } return $connection; @@ -367,8 +369,9 @@ class Client implements ClientInterface return $this->$initializer(); case 1: - list($arg0) = $argv; - return is_array($arg0) ? $this->$initializer($arg0) : $this->$initializer(null, $arg0); + return is_array($argv[0]) + ? $this->$initializer($argv[0]) + : $this->$initializer(null, $argv[0]); case 2: list($arg0, $arg1) = $argv; diff --git a/lib/Predis/ClientInterface.php b/lib/Predis/ClientInterface.php index 71d20826..36dd5193 100644 --- a/lib/Predis/ClientInterface.php +++ b/lib/Predis/ClientInterface.php @@ -17,9 +17,8 @@ use Predis\Connection\ConnectionInterface; use Predis\Profile\ProfileInterface; /** - * Interface defining the most important parts needed to create an - * high-level Redis client object that can interact with other - * building blocks of Predis. + * Interface defining the most important methods needed to create an high-level + * Redis client that can interact with other building blocks of Predis. * * @author Daniele Alessandri */ @@ -40,12 +39,12 @@ interface ClientInterface extends BasicClientInterface public function getOptions(); /** - * Opens the connection to the server. + * Opens the underlying connection to the server. */ public function connect(); /** - * Disconnects from the server. + * Closes the underlying connection from the server. */ public function disconnect(); @@ -59,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 Command ID. + * @param array $arguments Arguments for the command. * @return CommandInterface */ public function createCommand($method, $arguments = array()); diff --git a/lib/Predis/Cluster/Distributor/DistributorInterface.php b/lib/Predis/Cluster/Distributor/DistributorInterface.php index ce2af92c..6a22a9fe 100644 --- a/lib/Predis/Cluster/Distributor/DistributorInterface.php +++ b/lib/Predis/Cluster/Distributor/DistributorInterface.php @@ -14,7 +14,7 @@ namespace Predis\Cluster\Distributor; use Predis\Cluster\Hash\HashGeneratorInterface; /** - * Distributors implement the logic to automatically distribute keys among + * A distributor implements the logic to automatically distribute keys among * several nodes for client-side sharding. * * @author Daniele Alessandri @@ -37,7 +37,7 @@ interface DistributorInterface public function remove($node); /** - * Gets a node from the distributor using the computed hash of a key. + * Returns a node from the distributor using the computed hash of a key. * * @return mixed */ diff --git a/lib/Predis/Cluster/Distributor/HashRing.php b/lib/Predis/Cluster/Distributor/HashRing.php index c946d73d..601c1891 100644 --- a/lib/Predis/Cluster/Distributor/HashRing.php +++ b/lib/Predis/Cluster/Distributor/HashRing.php @@ -35,7 +35,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface /** * @param int $replicas Number of replicas in the ring. - * @param mixed $nodeHashCallback Callback returning the string used to calculate the hash of a node. + * @param mixed $nodeHashCallback Callback returning a string used to calculate the hash of nodes. */ public function __construct($replicas = self::DEFAULT_REPLICAS, $nodeHashCallback = null) { diff --git a/lib/Predis/Cluster/Distributor/KetamaRing.php b/lib/Predis/Cluster/Distributor/KetamaRing.php index 4e3c10a7..655b0c54 100644 --- a/lib/Predis/Cluster/Distributor/KetamaRing.php +++ b/lib/Predis/Cluster/Distributor/KetamaRing.php @@ -24,7 +24,7 @@ class KetamaRing extends HashRing const DEFAULT_REPLICAS = 160; /** - * @param mixed $nodeHashCallback Callback returning the string used to calculate the hash of a node. + * @param mixed $nodeHashCallback Callback returning a string used to calculate the hash of nodes. */ public function __construct($nodeHashCallback = null) { diff --git a/lib/Predis/Cluster/Hash/CRC16.php b/lib/Predis/Cluster/Hash/CRC16.php index d8922432..7e9ad0a0 100644 --- a/lib/Predis/Cluster/Hash/CRC16.php +++ b/lib/Predis/Cluster/Hash/CRC16.php @@ -12,7 +12,7 @@ namespace Predis\Cluster\Hash; /** - * This class implements the CRC-CCITT-16 algorithm used by redis-cluster. + * Hash generator implementing the CRC-CCITT-16 algorithm used by redis-cluster. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Cluster/Hash/HashGeneratorInterface.php b/lib/Predis/Cluster/Hash/HashGeneratorInterface.php index 891320d1..e20fea26 100644 --- a/lib/Predis/Cluster/Hash/HashGeneratorInterface.php +++ b/lib/Predis/Cluster/Hash/HashGeneratorInterface.php @@ -12,17 +12,17 @@ namespace Predis\Cluster\Hash; /** - * A generator of node keys implements the logic used to calculate the hash of - * a key to distribute the respective operations among nodes. + * An hash generator implements the logic used to calculate the hash of a key to + * distribute operations among Redis nodes. * * @author Daniele Alessandri */ interface HashGeneratorInterface { /** - * Generates an hash that is used by the distributor algorithm + * Generates an hash from a string to be used for distribution. * - * @param string $value Value used to generate the hash. + * @param string $value String value. * @return int */ public function hash($value); diff --git a/lib/Predis/Cluster/PredisStrategy.php b/lib/Predis/Cluster/PredisStrategy.php index d506e2cd..bb0ec85c 100644 --- a/lib/Predis/Cluster/PredisStrategy.php +++ b/lib/Predis/Cluster/PredisStrategy.php @@ -16,8 +16,8 @@ use Predis\Command\CommandInterface; use Predis\Command\ScriptCommand; /** - * Default class used by Predis for client-side sharding to calculate - * hashes out of keys of supported commands. + * Default class used by Predis for client-side sharding to calculate hashes out + * of keys for supported commands. * * @author Daniele Alessandri */ @@ -173,21 +173,21 @@ class PredisStrategy implements StrategyInterface /** * Sets an handler for the specified command ID. * - * The signature of the callback must have a single parameter - * of type Predis\Command\CommandInterface. + * The signature of the callback must have a single parameter of type + * Predis\Command\CommandInterface. * - * When the callback argument is omitted or NULL, the previously - * associated handler for the specified command ID is removed. + * When the callback argument is omitted or NULL, the previously 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 string $commandID Command ID. + * @param mixed $callback A valid callable object, or NULL to unset the handler. */ - public function setCommandHandler($commandId, $callback = null) + public function setCommandHandler($commandID, $callback = null) { - $commandId = strtoupper($commandId); + $commandID = strtoupper($commandID); if (!isset($callback)) { - unset($this->commands[$commandId]); + unset($this->commands[$commandID]); return; } @@ -195,7 +195,7 @@ class PredisStrategy implements StrategyInterface throw new \InvalidArgumentException("Callback must be a valid callable object or NULL"); } - $this->commands[$commandId] = $callback; + $this->commands[$commandID] = $callback; } /** @@ -210,8 +210,8 @@ class PredisStrategy implements StrategyInterface } /** - * Extracts the key from a command with multiple keys only when all keys - * in the arguments array produce the same hash. + * 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. * @return string @@ -226,8 +226,8 @@ class PredisStrategy implements StrategyInterface } /** - * Extracts the key from a command with multiple keys only when all keys - * in the arguments array produce the same hash. + * 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. * @return string diff --git a/lib/Predis/Cluster/RedisStrategy.php b/lib/Predis/Cluster/RedisStrategy.php index 5cbbff95..af4a5205 100644 --- a/lib/Predis/Cluster/RedisStrategy.php +++ b/lib/Predis/Cluster/RedisStrategy.php @@ -158,29 +158,31 @@ class RedisStrategy implements StrategyInterface /** * Sets an handler for the specified command ID. * - * The signature of the callback must have a single parameter - * of type Predis\Command\CommandInterface. + * The signature of the callback must have a single parameter of type + * Predis\Command\CommandInterface. * - * When the callback argument is omitted or NULL, the previously - * associated handler for the specified command ID is removed. + * When the callback argument is omitted or NULL, the previously 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 string $commandID Command ID. + * @param mixed $callback A valid callable object, or NULL to unset the handler. */ - public function setCommandHandler($commandId, $callback = null) + public function setCommandHandler($commandID, $callback = null) { - $commandId = strtoupper($commandId); + $commandID = strtoupper($commandID); if (!isset($callback)) { - unset($this->commands[$commandId]); + unset($this->commands[$commandID]); return; } if (!is_callable($callback)) { - throw new \InvalidArgumentException("Callback must be a valid callable object or NULL"); + throw new \InvalidArgumentException( + "Callback must be a valid callable object or NULL" + ); } - $this->commands[$commandId] = $callback; + $this->commands[$commandID] = $callback; } /** diff --git a/lib/Predis/Cluster/StrategyInterface.php b/lib/Predis/Cluster/StrategyInterface.php index cc7ce694..848e507a 100644 --- a/lib/Predis/Cluster/StrategyInterface.php +++ b/lib/Predis/Cluster/StrategyInterface.php @@ -14,8 +14,8 @@ namespace Predis\Cluster; use Predis\Command\CommandInterface; /** - * Interface for classes defining the strategy used to calculate an hash - * out of keys extracted from supported commands. + * Interface for classes defining the strategy used to calculate an hash out of + * keys extracted from supported commands. * * This is mostly useful to support clustering via client-side sharding. * @@ -24,10 +24,10 @@ use Predis\Command\CommandInterface; interface StrategyInterface { /** - * Returns the hash for the given command using the specified algorithm, or null - * if the command cannot be hashed. + * Returns the hash for the given command using the specified algorithm, or + * null when the command cannot be hashed. * - * @param CommandInterface $command Command to be hashed. + * @param CommandInterface $command Command instance. * @return int */ public function getHash(CommandInterface $command); @@ -35,7 +35,7 @@ interface StrategyInterface /** * Returns the hash for the given key using the specified algorithm. * - * @param string $key Key to be hashed. + * @param string $key Key string. * @return string */ public function getKeyHash($key); diff --git a/lib/Predis/Collection/Iterator/CursorBasedIterator.php b/lib/Predis/Collection/Iterator/CursorBasedIterator.php index 5d07597b..a192f4e0 100644 --- a/lib/Predis/Collection/Iterator/CursorBasedIterator.php +++ b/lib/Predis/Collection/Iterator/CursorBasedIterator.php @@ -16,13 +16,13 @@ use Predis\ClientInterface; use Predis\NotSupportedException; /** - * Provides the base implementation for a fully-rewindable PHP iterator - * that can incrementally iterate over cursor-based collections stored - * on Redis using commands in the `SCAN` family. + * Provides the base implementation for a fully-rewindable PHP iterator that can + * incrementally iterate over cursor-based collections stored on Redis using the + * commands in the `SCAN` family. * - * Given their incremental nature with multiple fetches, these kind of - * iterators offer limited guarantees about the returned elements because - * the collection can change several times during the iteration process. + * Given their incremental nature with multiple fetches, these kind of iterators + * offer limited guarantees about the returned elements because the collection + * can change several times during the iteration process. * * @see http://redis.io/commands/scan * @@ -44,7 +44,7 @@ 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 int $count Hint used by Redis to compute the number of results per iteration. */ public function __construct(ClientInterface $client, $match = null, $count = null) { @@ -56,9 +56,8 @@ abstract class CursorBasedIterator implements Iterator } /** - * Ensures that the client instance supports the specified Redis - * command required to fetch elements from the server to perform - * the iteration. + * Ensures that the client supports the specified Redis command required to + * fetch elements from the server to perform the iteration. * * @param ClientInterface Client connected to Redis. * @param string $commandID Command ID. @@ -66,7 +65,9 @@ abstract class CursorBasedIterator implements Iterator protected function requiredCommand(ClientInterface $client, $commandID) { if (!$client->getProfile()->supportsCommand($commandID)) { - throw new NotSupportedException("The specified server profile does not support the `$commandID` command."); + throw new NotSupportedException( + "The specified server profile does not support the `$commandID` command." + ); } } @@ -104,16 +105,16 @@ abstract class CursorBasedIterator implements Iterator } /** - * Fetches a new set of elements from the remote collection, - * effectively advancing the iteration process. + * Fetches a new set of elements from the remote collection, effectively + * advancing the iteration process. * * @return array */ protected abstract function executeCommand(); /** - * Populates the local buffer of elements fetched from the - * server during the iteration. + * Populates the local buffer of elements fetched from the server during + * the iteration. */ protected function fetch() { diff --git a/lib/Predis/Collection/Iterator/HashKey.php b/lib/Predis/Collection/Iterator/HashKey.php index 6fa3d9b9..196ecbc4 100644 --- a/lib/Predis/Collection/Iterator/HashKey.php +++ b/lib/Predis/Collection/Iterator/HashKey.php @@ -14,9 +14,8 @@ namespace Predis\Collection\Iterator; use Predis\ClientInterface; /** - * Abstracts the iteration of fields and values of an hash - * by leveraging the HSCAN command (Redis >= 2.8) wrapped - * in a fully-rewindable PHP iterator. + * Abstracts the iteration of fields and values of an hash by leveraging the + * HSCAN command (Redis >= 2.8) wrapped in a fully-rewindable PHP iterator. * * @author Daniele Alessandri * @link http://redis.io/commands/scan diff --git a/lib/Predis/Collection/Iterator/Keyspace.php b/lib/Predis/Collection/Iterator/Keyspace.php index 8000063f..43b1baac 100644 --- a/lib/Predis/Collection/Iterator/Keyspace.php +++ b/lib/Predis/Collection/Iterator/Keyspace.php @@ -14,9 +14,8 @@ namespace Predis\Collection\Iterator; use Predis\ClientInterface; /** - * Abstracts the iteration of the keyspace on a Redis instance - * by leveraging the SCAN command (Redis >= 2.8) wrapped in a - * fully-rewindable PHP iterator. + * Abstracts the iteration of the keyspace on a Redis instance by leveraging the + * SCAN command (Redis >= 2.8) wrapped in a fully-rewindable PHP iterator. * * @author Daniele Alessandri * @link http://redis.io/commands/scan diff --git a/lib/Predis/Collection/Iterator/ListKey.php b/lib/Predis/Collection/Iterator/ListKey.php index 86c40ff7..ad80eaee 100644 --- a/lib/Predis/Collection/Iterator/ListKey.php +++ b/lib/Predis/Collection/Iterator/ListKey.php @@ -51,7 +51,9 @@ class ListKey implements Iterator $this->requiredCommand($client, 'LRANGE'); if ((false === $count = filter_var($count, FILTER_VALIDATE_INT)) || $count < 0) { - throw new InvalidArgumentException('The $count argument must be a positive integer.'); + throw new InvalidArgumentException( + 'The $count argument must be a positive integer.' + ); } $this->client = $client; @@ -62,9 +64,8 @@ class ListKey implements Iterator } /** - * Ensures that the client instance supports the specified Redis - * command required to fetch elements from the server to perform - * the iteration. + * Ensures that the client instance supports the specified Redis command + * required to fetch elements from the server to perform the iteration. * * @param ClientInterface Client connected to Redis. * @param string $commandID Command ID. @@ -72,7 +73,9 @@ class ListKey implements Iterator protected function requiredCommand(ClientInterface $client, $commandID) { if (!$client->getProfile()->supportsCommand($commandID)) { - throw new NotSupportedException("The specified server profile does not support the `$commandID` command."); + throw new NotSupportedException( + "The specified server profile does not support the `$commandID` command." + ); } } @@ -89,8 +92,8 @@ class ListKey implements Iterator } /** - * Fetches a new set of elements from the remote collection, - * effectively advancing the iteration process. + * Fetches a new set of elements from the remote collection, effectively + * advancing the iteration process. * * @return array */ @@ -100,8 +103,8 @@ class ListKey implements Iterator } /** - * Populates the local buffer of elements fetched from the - * server during the iteration. + * Populates the local buffer of elements fetched from the server during the + * iteration. */ protected function fetch() { diff --git a/lib/Predis/Collection/Iterator/SetKey.php b/lib/Predis/Collection/Iterator/SetKey.php index 224c24f6..32be218f 100644 --- a/lib/Predis/Collection/Iterator/SetKey.php +++ b/lib/Predis/Collection/Iterator/SetKey.php @@ -14,9 +14,8 @@ namespace Predis\Collection\Iterator; use Predis\ClientInterface; /** - * Abstracts the iteration of members stored in a set by - * leveraging the SSCAN command (Redis >= 2.8) wrapped in - * a fully-rewindable PHP iterator. + * Abstracts the iteration of members stored in a set by leveraging the SSCAN + * command (Redis >= 2.8) wrapped in a fully-rewindable PHP iterator. * * @author Daniele Alessandri * @link http://redis.io/commands/scan diff --git a/lib/Predis/Collection/Iterator/SortedSetKey.php b/lib/Predis/Collection/Iterator/SortedSetKey.php index a774813b..0c37ac42 100644 --- a/lib/Predis/Collection/Iterator/SortedSetKey.php +++ b/lib/Predis/Collection/Iterator/SortedSetKey.php @@ -14,9 +14,8 @@ namespace Predis\Collection\Iterator; use Predis\ClientInterface; /** - * Abstracts the iteration of members stored in a sorted set - * by leveraging the ZSCAN command (Redis >= 2.8) wrapped in - * a fully-rewindable PHP iterator. + * Abstracts the iteration of members stored in a sorted set by leveraging the + * ZSCAN command (Redis >= 2.8) wrapped in a fully-rewindable PHP iterator. * * @author Daniele Alessandri * @link http://redis.io/commands/scan diff --git a/lib/Predis/Command/CommandInterface.php b/lib/Predis/Command/CommandInterface.php index fff844f0..822949cc 100644 --- a/lib/Predis/Command/CommandInterface.php +++ b/lib/Predis/Command/CommandInterface.php @@ -13,13 +13,14 @@ namespace Predis\Command; /** * Defines an abstraction representing a Redis command. + * * @author Daniele Alessandri */ interface CommandInterface { /** - * Gets the ID of a Redis command. - * By convention, command identifiers myst be uppercase. + * Returns the ID of the Redis command. By convention, command identifiers + * must always be uppercase. * * @return string */ diff --git a/lib/Predis/Command/Processor/CommandProcessorChainInterface.php b/lib/Predis/Command/Processor/CommandProcessorChainInterface.php index 2985ac91..2e54cf7b 100644 --- a/lib/Predis/Command/Processor/CommandProcessorChainInterface.php +++ b/lib/Predis/Command/Processor/CommandProcessorChainInterface.php @@ -20,16 +20,16 @@ namespace Predis\Command\Processor; interface CommandProcessorChainInterface extends CommandProcessorInterface, \IteratorAggregate, \Countable { /** - * Adds a command processor. + * Adds the given command processor. * - * @param CommandProcessorInterface $processor A command processor. + * @param CommandProcessorInterface $processor Command processor. */ public function add(CommandProcessorInterface $processor); /** - * Removes a command processor from the chain. + * Removes the given command processor from the chain if previously added. * - * @param CommandProcessorInterface $processor A command processor. + * @param CommandProcessorInterface $processor Command processor. */ public function remove(CommandProcessorInterface $processor); diff --git a/lib/Predis/Command/Processor/CommandProcessorInterface.php b/lib/Predis/Command/Processor/CommandProcessorInterface.php index e23eade0..8e64a7d3 100644 --- a/lib/Predis/Command/Processor/CommandProcessorInterface.php +++ b/lib/Predis/Command/Processor/CommandProcessorInterface.php @@ -14,16 +14,16 @@ namespace Predis\Command\Processor; use Predis\Command\CommandInterface; /** - * A command processor processes commands before they are sent to Redis. + * Command processor process Redis commands before they are sent to Redis. * * @author Daniele Alessandri */ interface CommandProcessorInterface { /** - * Processes a Redis command. + * Processes the given Redis command. * - * @param CommandInterface $command Redis command. + * @param CommandInterface $command Command instance. */ public function process(CommandInterface $command); } diff --git a/lib/Predis/Command/Processor/KeyPrefixProcessor.php b/lib/Predis/Command/Processor/KeyPrefixProcessor.php index 13e8adac..12f0f272 100644 --- a/lib/Predis/Command/Processor/KeyPrefixProcessor.php +++ b/lib/Predis/Command/Processor/KeyPrefixProcessor.php @@ -15,8 +15,8 @@ use Predis\Command\CommandInterface; use Predis\Command\PrefixableCommandInterface; /** - * Command processor that is used to prefix the keys contained in the arguments - * of a Redis command. + * Command processor used to prefix the keys contained in the arguments of a + * Redis command. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Command/ScriptCommand.php b/lib/Predis/Command/ScriptCommand.php index 2d496346..c8a138c9 100644 --- a/lib/Predis/Command/ScriptCommand.php +++ b/lib/Predis/Command/ScriptCommand.php @@ -12,8 +12,8 @@ namespace Predis\Command; /** - * Base class used to implement an higher level abstraction for "virtual" - * commands for Lua scripting based on EVAL and EVALSHA. + * Base class used to implement an higher level abstraction for commands based + * on Lua scripting with EVAL and EVALSHA. * * @link http://redis.io/commands/eval * @author Daniele Alessandri diff --git a/lib/Predis/CommunicationException.php b/lib/Predis/CommunicationException.php index c9e75e23..eee976cf 100644 --- a/lib/Predis/CommunicationException.php +++ b/lib/Predis/CommunicationException.php @@ -29,7 +29,10 @@ abstract class CommunicationException extends PredisException * @param \Exception $innerException Inner exception for wrapping the original error. */ public function __construct( - SingleConnectionInterface $connection, $message = null, $code = null, \Exception $innerException = null + SingleConnectionInterface $connection, + $message = null, + $code = null, + \Exception $innerException = null ) { parent::__construct($message, $code, $innerException); $this->connection = $connection; @@ -56,8 +59,7 @@ abstract class CommunicationException extends PredisException } /** - * Offers a generic and reusable method to handle exceptions generated by - * a connection object. + * Helper method to handle exceptions generated by a connection object. * * @param CommunicationException $exception Exception. */ diff --git a/lib/Predis/Configuration/ConnectionFactoryOption.php b/lib/Predis/Configuration/ConnectionFactoryOption.php index 801f4bd4..2b99a6b7 100644 --- a/lib/Predis/Configuration/ConnectionFactoryOption.php +++ b/lib/Predis/Configuration/ConnectionFactoryOption.php @@ -16,8 +16,8 @@ use Predis\Connection\ConnectionFactory; use Predis\Connection\ConnectionFactoryInterface; /** - * Configures a connection factory used by the client to - * create new connection instances to single Redis nodes. + * Configures a connection factory used by the client to create new connection + * instances for single Redis nodes. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Configuration/ExceptionsOption.php b/lib/Predis/Configuration/ExceptionsOption.php index 94143517..337733e4 100644 --- a/lib/Predis/Configuration/ExceptionsOption.php +++ b/lib/Predis/Configuration/ExceptionsOption.php @@ -12,9 +12,8 @@ namespace Predis\Configuration; /** - * Configures whether consumers (such as the client) should - * throw exceptions on Redis errors (-ERR responses) or just - * return error objects. + * Configures whether consumers (such as the client) should throw exceptions on + * Redis errors (-ERR responses) or just return instances of error responses. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Configuration/OptionInterface.php b/lib/Predis/Configuration/OptionInterface.php index 6c38d621..123bd358 100644 --- a/lib/Predis/Configuration/OptionInterface.php +++ b/lib/Predis/Configuration/OptionInterface.php @@ -12,8 +12,8 @@ namespace Predis\Configuration; /** - * Defines an handler used by Predis\Configuration\Options to - * filter, validate or get default values for a given option. + * Defines an handler used by Predis\Configuration\Options to filter, validate + * or return default values for a given option. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Configuration/Options.php b/lib/Predis/Configuration/Options.php index bc659779..01ccbedd 100644 --- a/lib/Predis/Configuration/Options.php +++ b/lib/Predis/Configuration/Options.php @@ -12,8 +12,8 @@ namespace Predis\Configuration; /** - * Manages Predis options with filtering, conversion and lazy - * initialization of values using a mini DI container approach. + * Manages Predis options with filtering, conversion and lazy initialization of + * values using a mini-DI container approach. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Configuration/OptionsInterface.php b/lib/Predis/Configuration/OptionsInterface.php index b1b00073..9300a19e 100644 --- a/lib/Predis/Configuration/OptionsInterface.php +++ b/lib/Predis/Configuration/OptionsInterface.php @@ -19,7 +19,7 @@ namespace Predis\Configuration; interface OptionsInterface { /** - * Returns the default value for the specified option. + * Returns the default value for the given option. * * @param string $option Name of the option. * @return mixed @@ -27,8 +27,7 @@ interface OptionsInterface public function getDefault($option); /** - * Checks if the specified option has been passed by - * the user at construction time. + * Checks if the given option has been set by the user upon initialization. * * @param string $option Name of the option. * @return bool @@ -36,8 +35,7 @@ interface OptionsInterface public function defined($option); /** - * Checks if the specified option has been set and - * does not evaluate to NULL. + * Checks if the given option has been set and does not evaluate to NULL. * * @param string $option Name of the option. * @return bool @@ -45,7 +43,7 @@ interface OptionsInterface public function __isset($option); /** - * Returns the value of the specified option. + * Returns the value of the given option. * * @param string $option Name of the option. * @return mixed diff --git a/lib/Predis/Configuration/PrefixOption.php b/lib/Predis/Configuration/PrefixOption.php index dd4e5747..a0172431 100644 --- a/lib/Predis/Configuration/PrefixOption.php +++ b/lib/Predis/Configuration/PrefixOption.php @@ -15,9 +15,8 @@ use Predis\Command\Processor\KeyPrefixProcessor; use Predis\Command\Processor\CommandProcessorInterface; /** - * Configures a command processor that apply the specified - * prefix string to a series of Redis commands considered - * prefixable. + * Configures a command processor that apply the specified prefix string to a + * series of Redis commands considered prefixable. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Configuration/ProfileOption.php b/lib/Predis/Configuration/ProfileOption.php index 4774b669..412b0343 100644 --- a/lib/Predis/Configuration/ProfileOption.php +++ b/lib/Predis/Configuration/ProfileOption.php @@ -15,16 +15,15 @@ use InvalidArgumentException; use Predis\Profile; /** - * Configures the server profile to be used by the client - * to create command instances depending on the specified - * version of the Redis server. + * Configures the server profile to be used by the client to create command + * instances depending on the specified version of the Redis server. * * @author Daniele Alessandri */ class ProfileOption implements OptionInterface { /** - * Sets the needed commands processors that should be applied to the profile. + * Sets the commands processors that need to be applied to the profile. * * @param OptionsInterface $options Client options. * @param Profile\ProfileInterface $profile Server profile. diff --git a/lib/Predis/Configuration/ReplicationOption.php b/lib/Predis/Configuration/ReplicationOption.php index 261f8bf6..1bba2c76 100644 --- a/lib/Predis/Configuration/ReplicationOption.php +++ b/lib/Predis/Configuration/ReplicationOption.php @@ -16,8 +16,8 @@ use Predis\Connection\MasterSlaveReplication; use Predis\Connection\ReplicationConnectionInterface; /** - * Configures an aggregate connection used for master/slave - * replication between multiple nodes. + * Configures an aggregate connection used for master/slave replication between + * multiple Redis nodes. * * @author Daniele Alessandri */ @@ -26,9 +26,9 @@ class ReplicationOption implements OptionInterface /** * {@inheritdoc} * - * @todo There's more code than needed due to a bug in filter_var() - * as discussed here https://bugs.php.net/bug.php?id=49510 - * and a different behaviour with NULL values on PHP 5.3. + * @todo There's more code than needed due to a bug in filter_var() as + * discussed here https://bugs.php.net/bug.php?id=49510 and different + * behaviours when encountering NULL values on PHP 5.3. */ public function filter(OptionsInterface $options, $value) { @@ -40,11 +40,16 @@ class ReplicationOption implements OptionInterface return $value ? $this->getDefault($options) : null; } - if (!is_object($value) && null !== $asbool = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) { + if ( + !is_object($value) && + null !== $asbool = filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) + ) { return $asbool ? $this->getDefault($options) : null; } - throw new InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); + throw new InvalidArgumentException( + 'Instance of Predis\Connection\ReplicationConnectionInterface expected' + ); } /** diff --git a/lib/Predis/Connection/AbstractConnection.php b/lib/Predis/Connection/AbstractConnection.php index ed2f0805..808533e8 100644 --- a/lib/Predis/Connection/AbstractConnection.php +++ b/lib/Predis/Connection/AbstractConnection.php @@ -19,7 +19,8 @@ use Predis\Command\CommandInterface; use Predis\Protocol\ProtocolException; /** - * Base class with the common logic used by connection classes to communicate with Redis. + * Base class with the common logic used by connection classes to communicate + * with Redis. * * @author Daniele Alessandri */ @@ -32,7 +33,7 @@ abstract class AbstractConnection implements SingleConnectionInterface protected $initCmds = array(); /** - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. */ public function __construct(ConnectionParametersInterface $parameters) { @@ -51,7 +52,7 @@ abstract class AbstractConnection implements SingleConnectionInterface /** * Checks some of the parameters used to initialize the connection. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. */ protected function assertParameters(ConnectionParametersInterface $parameters) { diff --git a/lib/Predis/Connection/AggregatedConnectionInterface.php b/lib/Predis/Connection/AggregatedConnectionInterface.php index bd1065c0..66db49e0 100644 --- a/lib/Predis/Connection/AggregatedConnectionInterface.php +++ b/lib/Predis/Connection/AggregatedConnectionInterface.php @@ -14,42 +14,41 @@ namespace Predis\Connection; use Predis\Command\CommandInterface; /** - * Defines a virtual connection composed by multiple connection objects. + * Defines a virtual connection composed of multiple connection instances to + * single Redis nodes. * * @author Daniele Alessandri */ interface AggregatedConnectionInterface extends ConnectionInterface { /** - * Adds a connection instance to the aggregated connection. + * Adds a connection instance to the aggregate connection. * - * @param SingleConnectionInterface $connection Instance of a connection. + * @param SingleConnectionInterface $connection Connection instance. */ public function add(SingleConnectionInterface $connection); /** - * Removes the specified connection instance from the aggregated - * connection. + * Removes the specified connection instance from the aggregate connection. * - * @param SingleConnectionInterface $connection Instance of a connection. - * @return Boolean Returns true if the connection was in the pool. + * @param SingleConnectionInterface $connection Connection instance. + * @return bool Returns true if the connection was in the pool. */ public function remove(SingleConnectionInterface $connection); /** - * Gets the actual connection instance in charge of the specified command. + * Returns the connection instance in charge for the given command. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Command instance. * @return SingleConnectionInterface */ public function getConnection(CommandInterface $command); /** - * Retrieves a connection instance from the aggregated connection - * using an alias. + * Returns a connection instance from the aggregate connection by its alias. * - * @param string $connectionId Alias of a connection + * @param string $connectionID Connection alias. * @return SingleConnectionInterface */ - public function getConnectionById($connectionId); + public function getConnectionById($connectionID); } diff --git a/lib/Predis/Connection/ClusterConnectionInterface.php b/lib/Predis/Connection/ClusterConnectionInterface.php index 956ef2c3..582b8aa2 100644 --- a/lib/Predis/Connection/ClusterConnectionInterface.php +++ b/lib/Predis/Connection/ClusterConnectionInterface.php @@ -12,8 +12,8 @@ namespace Predis\Connection; /** - * Defines a cluster of Redis servers formed by aggregating multiple - * connection objects. + * Defines a cluster of Redis servers formed by aggregating multiple connection + * instances to single Redis nodes. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Connection/ComposableConnectionInterface.php b/lib/Predis/Connection/ComposableConnectionInterface.php index 66604715..6eb23d28 100644 --- a/lib/Predis/Connection/ComposableConnectionInterface.php +++ b/lib/Predis/Connection/ComposableConnectionInterface.php @@ -14,28 +14,27 @@ namespace Predis\Connection; use Predis\Protocol\ProtocolInterface; /** - * Defines a connection object used to communicate with a single Redis server - * that leverages an external protocol processor to handle pluggable protocol - * handlers. + * Defines a connection to communicate with a single Redis server that leverages + * an external protocol processor to handle pluggable protocol handlers. * * @author Daniele Alessandri */ interface ComposableConnectionInterface extends SingleConnectionInterface { /** - * Gets the protocol processor used by the connection. + * Returns the protocol processor used by the connection. */ public function getProtocol(); /** - * Writes a buffer that contains a serialized Redis command. + * Writes the buffer containing a serialized command over the connection. * * @param string $buffer Serialized Redis command. */ public function writeBytes($buffer); /** - * Reads a specified number of bytes from the connection. + * Reads the given number of bytes from the connection. * * @param string */ diff --git a/lib/Predis/Connection/ComposableStreamConnection.php b/lib/Predis/Connection/ComposableStreamConnection.php index 7903c93f..73924d2c 100644 --- a/lib/Predis/Connection/ComposableStreamConnection.php +++ b/lib/Predis/Connection/ComposableStreamConnection.php @@ -26,7 +26,7 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC protected $protocol; /** - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. * @param ProtocolProcessorInterface $protocol Protocol processor. */ public function __construct( diff --git a/lib/Predis/Connection/ConnectionFactory.php b/lib/Predis/Connection/ConnectionFactory.php index 32775e8b..e97282d1 100644 --- a/lib/Predis/Connection/ConnectionFactory.php +++ b/lib/Predis/Connection/ConnectionFactory.php @@ -16,8 +16,7 @@ use ReflectionClass; use Predis\Command; /** - * Provides a default factory for Redis connections that maps URI schemes - * to connection classes implementing Predis\Connection\SingleConnectionInterface. + * Standard connection factory for creating connections to Redis nodes. * * @author Daniele Alessandri */ @@ -115,9 +114,9 @@ class ConnectionFactory implements ConnectionFactoryInterface } /** - * Prepares a connection object after its initialization. + * Prepares a connection instance after its initialization. * - * @param SingleConnectionInterface $connection Instance of a connection object. + * @param SingleConnectionInterface $connection Connection instance. */ protected function prepareConnection(SingleConnectionInterface $connection) { diff --git a/lib/Predis/Connection/ConnectionFactoryInterface.php b/lib/Predis/Connection/ConnectionFactoryInterface.php index 93762264..30211c24 100644 --- a/lib/Predis/Connection/ConnectionFactoryInterface.php +++ b/lib/Predis/Connection/ConnectionFactoryInterface.php @@ -12,8 +12,7 @@ namespace Predis\Connection; /** - * Interface that must be implemented by classes that provide their own mechanism - * to create and initialize new instances of Predis\Connection\SingleConnectionInterface. + * Interface for classes providing a factory of connections to Redis nodes. * * @author Daniele Alessandri */ @@ -22,22 +21,22 @@ 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 Target connection scheme. + * @param mixed $initializer Fully-qualified name of a class or a callable for lazy initialization. */ public function define($scheme, $initializer); /** * Undefines the connection identified by a scheme prefix. * - * @param string $scheme Parameters for the connection. + * @param string $scheme Target connection scheme. */ public function undefine($scheme); /** * Creates a new connection object. * - * @param mixed $parameters Parameters for the connection. + * @param mixed $parameters Initialization parameters for the connection. * @return SingleConnectionInterface */ public function create($parameters); @@ -45,8 +44,8 @@ interface ConnectionFactoryInterface /** * Aggregates single connections into an aggregate connection instance. * - * @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class. - * @param array $parameters List of parameters for each connection object. + * @param AggregatedConnectionInterface $aggregate Aggregate connection instance. + * @param array $parameters List of parameters for each connection. */ - public function aggregate(AggregatedConnectionInterface $cluster, array $parameters); + public function aggregate(AggregatedConnectionInterface $aggregate, array $parameters); } diff --git a/lib/Predis/Connection/ConnectionInterface.php b/lib/Predis/Connection/ConnectionInterface.php index 42f48a8d..fefdc9f5 100644 --- a/lib/Predis/Connection/ConnectionInterface.php +++ b/lib/Predis/Connection/ConnectionInterface.php @@ -22,41 +22,42 @@ use Predis\Command\CommandInterface; interface ConnectionInterface { /** - * Opens the connection. + * Opens the connection to Redis. */ public function connect(); /** - * Closes the connection. + * Closes the connection to Redis. */ public function disconnect(); /** - * Returns if the connection is open. + * Checks if the connection to Redis is considered open. * - * @return Boolean + * @return bool */ public function isConnected(); /** - * Writes the given command over the connection. + * Writes the request for the given command over the connection. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Command instance. */ public function writeRequest(CommandInterface $command); /** - * Reads the response to a command from the connection. + * Reads the response to the given command from the connection. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Command instance. * @return mixed */ public function readResponse(CommandInterface $command); /** - * Writes a command over the connection and reads back the response. + * Writes a request for the given command over the connection and reads back + * the response returned by Redis. * - * @param CommandInterface $command Instance of a Redis command. + * @param CommandInterface $command Command instance. * @return mixed */ public function executeCommand(CommandInterface $command); diff --git a/lib/Predis/Connection/ConnectionParameters.php b/lib/Predis/Connection/ConnectionParameters.php index fdb85352..952535f4 100644 --- a/lib/Predis/Connection/ConnectionParameters.php +++ b/lib/Predis/Connection/ConnectionParameters.php @@ -14,7 +14,7 @@ namespace Predis\Connection; use InvalidArgumentException; /** - * Handles parsing and validation of connection parameters. + * Connection parameters used to initialize connections to Redis. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Connection/MasterSlaveReplication.php b/lib/Predis/Connection/MasterSlaveReplication.php index 24aac493..0defe123 100644 --- a/lib/Predis/Connection/MasterSlaveReplication.php +++ b/lib/Predis/Connection/MasterSlaveReplication.php @@ -17,8 +17,8 @@ use Predis\Command\CommandInterface; use Predis\Replication\ReplicationStrategy; /** - * Aggregated connection class used by to handle replication with a - * group of servers in a master/slave configuration. + * Aggregate connection handling replication of Redis nodes configured in a + * single master / multiple slaves setup. * * @author Daniele Alessandri */ @@ -44,7 +44,9 @@ class MasterSlaveReplication implements ReplicationConnectionInterface protected function check() { if (!isset($this->master) || !$this->slaves) { - throw new RuntimeException('Replication needs a master and at least one slave.'); + throw new RuntimeException( + 'Replication needs a master and at least one slave.' + ); } } @@ -101,7 +103,9 @@ class MasterSlaveReplication implements ReplicationConnectionInterface { if ($this->current === null) { $this->check(); - $this->current = $this->strategy->isReadOperation($command) ? $this->pickSlave() : $this->master; + $this->current = $this->strategy->isReadOperation($command) + ? $this->pickSlave() + : $this->master; return $this->current; } diff --git a/lib/Predis/Connection/PredisCluster.php b/lib/Predis/Connection/PredisCluster.php index c7c4a7f4..fbd9124c 100644 --- a/lib/Predis/Connection/PredisCluster.php +++ b/lib/Predis/Connection/PredisCluster.php @@ -32,7 +32,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co private $distributor; /** - * @param Distributor\DistributorInterface $distributor Distribution strategy used by cluster. + * @param Distributor\DistributorInterface $distributor Distributor instance. */ public function __construct(Distributor\DistributorInterface $distributor = null) { @@ -112,12 +112,12 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * Removes a connection instance using its alias or index. * - * @param string $connectionId Alias or index of a connection. - * @return Boolean Returns true if the connection was in the pool. + * @param string $connectionID Alias or index of a connection. + * @return bool Returns true if the connection was in the pool. */ - public function removeById($connectionId) + public function removeById($connectionID) { - if ($connection = $this->getConnectionById($connectionId)) { + if ($connection = $this->getConnectionById($connectionID)) { return $this->remove($connection); } @@ -145,15 +145,15 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co /** * {@inheritdoc} */ - public function getConnectionById($connectionId) + public function getConnectionById($connectionID) { - return isset($this->pool[$connectionId]) ? $this->pool[$connectionId] : null; + return isset($this->pool[$connectionID]) ? $this->pool[$connectionID] : null; } /** * Retrieves a connection instance from the cluster using a key. * - * @param string $key Key of a Redis value. + * @param string $key Key string. * @return SingleConnectionInterface */ public function getConnectionByKey($key) @@ -165,8 +165,8 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co } /** - * Returns the underlying command hash strategy used to hash - * commands by their keys. + * Returns the underlying command hash strategy used to hash commands by + * using keys found in their arguments. * * @return Cluster\StrategyInterface */ diff --git a/lib/Predis/Connection/RedisCluster.php b/lib/Predis/Connection/RedisCluster.php index 00b20b7d..bf8582d4 100644 --- a/lib/Predis/Connection/RedisCluster.php +++ b/lib/Predis/Connection/RedisCluster.php @@ -463,7 +463,8 @@ class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Cou } /** - * Returns the underlying hash strategy used to hash commands by their keys. + * Returns the underlying command hash strategy used to hash commands by + * using keys found in their arguments. * * @return Cluster\StrategyInterface */ diff --git a/lib/Predis/Connection/ReplicationConnectionInterface.php b/lib/Predis/Connection/ReplicationConnectionInterface.php index 7142dfae..13755c9c 100644 --- a/lib/Predis/Connection/ReplicationConnectionInterface.php +++ b/lib/Predis/Connection/ReplicationConnectionInterface.php @@ -12,35 +12,36 @@ namespace Predis\Connection; /** - * Defines a group of Redis servers in a master/slave replication configuration. + * Defines a group of Redis nodes in a master / slave replication setup. * * @author Daniele Alessandri */ interface ReplicationConnectionInterface extends AggregatedConnectionInterface { /** - * Switches the internal connection object being used. + * Switches the internal connection instance in use. * * @param string $connection Alias of a connection */ public function switchTo($connection); /** - * Retrieves the connection object currently being used. + * Returns the connection instance currently in use by the aggregate + * connection. * * @return SingleConnectionInterface */ public function getCurrent(); /** - * Retrieves the connection object to the master Redis server. + * Returns the connection instance for the master Redis node. * * @return SingleConnectionInterface */ public function getMaster(); /** - * Retrieves a list of connection objects to slaves Redis servers. + * Returns a list of connection instances to slave nodes. * * @return SingleConnectionInterface */ diff --git a/lib/Predis/Connection/SingleConnectionInterface.php b/lib/Predis/Connection/SingleConnectionInterface.php index 3859ad2c..0b68c012 100644 --- a/lib/Predis/Connection/SingleConnectionInterface.php +++ b/lib/Predis/Connection/SingleConnectionInterface.php @@ -14,7 +14,7 @@ namespace Predis\Connection; use Predis\Command\CommandInterface; /** - * Defines a connection object used to communicate with a single Redis server. + * Defines a connection used to communicate with a single Redis node. * * @author Daniele Alessandri */ @@ -28,22 +28,22 @@ interface SingleConnectionInterface extends ConnectionInterface public function __toString(); /** - * Returns the underlying resource used to communicate with a Redis server. + * Returns the underlying resource used to communicate with Redis. * * @return mixed */ public function getResource(); /** - * Gets the parameters used to initialize the connection object. + * Returns the parameters used to initialize the connection. * * @return ConnectionParametersInterface */ public function getParameters(); /** - * Pushes the instance of a Redis command to the queue of commands executed - * when the actual connection to a server is estabilished. + * Pushes the given command into a queue of commands executed when + * establishing the actual connection to Redis. * * @param CommandInterface $command Instance of a Redis command. */ diff --git a/lib/Predis/Connection/StreamConnection.php b/lib/Predis/Connection/StreamConnection.php index f3a581df..b366fc7c 100644 --- a/lib/Predis/Connection/StreamConnection.php +++ b/lib/Predis/Connection/StreamConnection.php @@ -32,9 +32,9 @@ use Predis\Response; class StreamConnection extends AbstractConnection { /** - * Disconnects from the server and destroys the underlying resource when - * PHP's garbage collector kicks in only if the connection has not been - * marked as persistent. + * Disconnects from the server and destroys the underlying resource when the + * garbage collector kicks in only if the connection has not been marked as + * persistent. */ public function __destruct() { @@ -59,7 +59,7 @@ class StreamConnection extends AbstractConnection /** * Initializes a TCP stream resource. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function tcpStreamInitializer(ConnectionParametersInterface $parameters) @@ -99,7 +99,7 @@ class StreamConnection extends AbstractConnection /** * Initializes a UNIX stream resource. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function unixStreamInitializer(ConnectionParametersInterface $parameters) @@ -146,10 +146,10 @@ class StreamConnection extends AbstractConnection } /** - * Performs a write operation on the stream of the buffer containing a + * Performs a write operation over the stream of the buffer containing a * command serialized with the Redis wire protocol. * - * @param string $buffer Redis wire protocol representation of a command. + * @param string $buffer Representation of a command in the Redis wire protocol. */ protected function writeBytes($buffer) { diff --git a/lib/Predis/Connection/WebdisConnection.php b/lib/Predis/Connection/WebdisConnection.php index ab31d7dd..8f32a28d 100644 --- a/lib/Predis/Connection/WebdisConnection.php +++ b/lib/Predis/Connection/WebdisConnection.php @@ -50,7 +50,7 @@ class WebdisConnection implements SingleConnectionInterface private $reader; /** - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. */ public function __construct(ConnectionParametersInterface $parameters) { @@ -66,8 +66,8 @@ class WebdisConnection implements SingleConnectionInterface } /** - * Frees the underlying cURL and protocol reader resources when PHP's - * garbage collector kicks in. + * Frees the underlying cURL and protocol reader resources when the garbage + * collector kicks in. */ public function __destruct() { @@ -105,7 +105,7 @@ class WebdisConnection implements SingleConnectionInterface /** * Initializes cURL. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function createCurl(ConnectionParametersInterface $parameters) @@ -129,9 +129,9 @@ class WebdisConnection implements SingleConnectionInterface } /** - * Initializes phpiredis' protocol reader. + * Initializes the phpiredis protocol reader. * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. + * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. * @return resource */ private function createReader(ConnectionParametersInterface $parameters) @@ -169,10 +169,10 @@ class WebdisConnection implements SingleConnectionInterface } /** - * Feeds phpredis' reader resource with the data read from the network. + * Feeds the phpredis reader resource with the data read from the network. * * @param resource $resource Reader resource. - * @param string $buffer Data read from the network. + * @param string $buffer Buffer of data read from a connection. * @return int */ protected function feedReader($resource, $buffer) @@ -209,7 +209,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 Command instance. * @return string */ protected function getCommandId(CommandInterface $command) diff --git a/lib/Predis/ExecutableContextInterface.php b/lib/Predis/ExecutableContextInterface.php index 9b0017ae..b9411fc8 100644 --- a/lib/Predis/ExecutableContextInterface.php +++ b/lib/Predis/ExecutableContextInterface.php @@ -12,8 +12,8 @@ namespace Predis; /** - * Defines the interface of a basic client object or abstraction that - * can send commands to Redis. + * Defines the interface of a basic client object or abstraction that can send + * commands to Redis. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Monitor/Consumer.php b/lib/Predis/Monitor/Consumer.php index 2d834c30..cfce9301 100644 --- a/lib/Predis/Monitor/Consumer.php +++ b/lib/Predis/Monitor/Consumer.php @@ -32,14 +32,14 @@ class Consumer implements Iterator */ public function __construct(ClientInterface $client) { - $this->checkCapabilities($client); + $this->assertClient($client); $this->client = $client; $this->start(); } /** - * Automatically stops the consumer when PHP's garbage collector kicks in. + * Automatically stops the consumer when the garbage collector kicks in. */ public function __destruct() { @@ -52,7 +52,7 @@ class Consumer implements Iterator * * @param ClientInterface $client Client instance used by the consumer. */ - private function checkCapabilities(ClientInterface $client) + private function assertClient(ClientInterface $client) { if ($client->getConnection() instanceof AggregatedConnectionInterface) { throw new NotSupportedException( @@ -132,8 +132,8 @@ class Consumer implements Iterator } /** - * Waits for a new message from the server generated by MONITOR and - * returns it when available. + * Waits for a new message from the server generated by MONITOR and returns + * it when available. * * @return Object */ diff --git a/lib/Predis/NotSupportedException.php b/lib/Predis/NotSupportedException.php index 631b820a..be82aba7 100644 --- a/lib/Predis/NotSupportedException.php +++ b/lib/Predis/NotSupportedException.php @@ -12,8 +12,8 @@ namespace Predis; /** - * Exception class generated when trying to use features not - * supported by certain classes or abstractions. + * Exception class thrown when trying to use features not supported by certain + * classes or abstractions of Predis. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Pipeline/Pipeline.php b/lib/Predis/Pipeline/Pipeline.php index bab7b3f5..b5b9b6c3 100644 --- a/lib/Predis/Pipeline/Pipeline.php +++ b/lib/Predis/Pipeline/Pipeline.php @@ -64,7 +64,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Queues a command instance into the pipeline buffer. * - * @param CommandInterface $command Command to queue in the buffer. + * @param CommandInterface $command Command to be queued in the buffer. */ protected function recordCommand(CommandInterface $command) { @@ -74,7 +74,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface /** * Queues a command instance into the pipeline buffer. * - * @param CommandInterface $command Command to queue in the buffer. + * @param CommandInterface $command Command to be queued in the buffer. */ public function executeCommand(CommandInterface $command) { @@ -82,10 +82,10 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface } /** - * Throws and exception on -ERR responses returned by Redis. + * Throws an exception on -ERR responses returned by Redis. * - * @param ConnectionInterface $connection The connection that returned the error. - * @param Response\ErrorInterface $response The error response instance. + * @param ConnectionInterface $connection Redis connection that returned the error. + * @param Response\ErrorInterface $response Instance of the error response. */ protected function exception(ConnectionInterface $connection, Response\ErrorInterface $response) { @@ -145,7 +145,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface } /** - * Flushes the buffer that holds the queued commands. + * Flushes the buffer holding all of the commands queued so far. * * @param bool $send Specifies if the commands in the buffer should be sent to Redis. * @return Pipeline diff --git a/lib/Predis/Profile/Factory.php b/lib/Predis/Profile/Factory.php index 24a26bb8..387e718a 100644 --- a/lib/Predis/Profile/Factory.php +++ b/lib/Predis/Profile/Factory.php @@ -16,7 +16,7 @@ use ReflectionClass; use Predis\ClientException; /** - * Base class that implements common functionalities of server profiles. + * Factory class for creating profile instances from strings. * * @author Daniele Alessandri */ @@ -72,7 +72,9 @@ final class Factory $reflection = new ReflectionClass($profileClass); if (!$reflection->isSubclassOf('Predis\Profile\ProfileInterface')) { - throw new InvalidArgumentException("Cannot register '$profileClass' as it is not a valid profile class"); + throw new InvalidArgumentException( + "Cannot register '$profileClass' as it is not a valid profile class" + ); } self::$profiles[$alias] = $profileClass; diff --git a/lib/Predis/Profile/RedisProfile.php b/lib/Predis/Profile/RedisProfile.php index 9a01f92e..62d4d494 100644 --- a/lib/Predis/Profile/RedisProfile.php +++ b/lib/Predis/Profile/RedisProfile.php @@ -17,7 +17,7 @@ use Predis\ClientException; use Predis\Command\Processor\CommandProcessorInterface; /** - * Base class that implements common functionalities of server profiles. + * Base class implementing common functionalities for Redis server profiles. * * @author Daniele Alessandri */ @@ -65,8 +65,8 @@ abstract class RedisProfile implements ProfileInterface } /** - * Returns the FQN of the class that represent the specified command ID - * registered in the current server profile. + * Returns the fully-qualified name of a class representing the specified + * command ID registered in the current server profile. * * @param string $commandID Command ID. * @return string @@ -101,10 +101,10 @@ abstract class RedisProfile implements ProfileInterface } /** - * Defines a new commands in the server profile. + * Defines a new command in the server profile. * * @param string $commandID Command ID. - * @param string $commandClass FQN of a class implementing Predis\Command\CommandInterface. + * @param string $commandClass Fully-qualified name of a Predis\Command\CommandInterface. */ public function defineCommand($commandID, $commandClass) { diff --git a/lib/Predis/Profile/RedisVersion120.php b/lib/Predis/Profile/RedisVersion120.php index 4e066e0f..75d45219 100644 --- a/lib/Predis/Profile/RedisVersion120.php +++ b/lib/Predis/Profile/RedisVersion120.php @@ -12,7 +12,7 @@ namespace Predis\Profile; /** - * Server profile for Redis v1.2.x. + * Server profile for Redis 1.2. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Profile/RedisVersion200.php b/lib/Predis/Profile/RedisVersion200.php index a49d71ed..54093e56 100644 --- a/lib/Predis/Profile/RedisVersion200.php +++ b/lib/Predis/Profile/RedisVersion200.php @@ -12,7 +12,7 @@ namespace Predis\Profile; /** - * Server profile for Redis v2.0.x. + * Server profile for Redis 2.0. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Profile/RedisVersion220.php b/lib/Predis/Profile/RedisVersion220.php index 81e24b1b..a16883b8 100644 --- a/lib/Predis/Profile/RedisVersion220.php +++ b/lib/Predis/Profile/RedisVersion220.php @@ -12,7 +12,7 @@ namespace Predis\Profile; /** - * Server profile for Redis v2.2.x. + * Server profile for Redis 2.2. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Profile/RedisVersion240.php b/lib/Predis/Profile/RedisVersion240.php index 26c05787..2bd088ee 100644 --- a/lib/Predis/Profile/RedisVersion240.php +++ b/lib/Predis/Profile/RedisVersion240.php @@ -12,7 +12,7 @@ namespace Predis\Profile; /** - * Server profile for Redis v2.4.x. + * Server profile for Redis 2.4. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Profile/RedisVersion260.php b/lib/Predis/Profile/RedisVersion260.php index 88b621d1..f3b04994 100644 --- a/lib/Predis/Profile/RedisVersion260.php +++ b/lib/Predis/Profile/RedisVersion260.php @@ -12,7 +12,7 @@ namespace Predis\Profile; /** - * Server profile for Redis v2.6.x. + * Server profile for Redis 2.6. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Profile/RedisVersion280.php b/lib/Predis/Profile/RedisVersion280.php index 70dd14dc..386cb738 100644 --- a/lib/Predis/Profile/RedisVersion280.php +++ b/lib/Predis/Profile/RedisVersion280.php @@ -12,7 +12,7 @@ namespace Predis\Profile; /** - * Server profile for Redis v2.8.x. + * Server profile for Redis 2.8. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Protocol/ProtocolException.php b/lib/Predis/Protocol/ProtocolException.php index 3940d532..6fe5d6d3 100644 --- a/lib/Predis/Protocol/ProtocolException.php +++ b/lib/Predis/Protocol/ProtocolException.php @@ -14,7 +14,8 @@ namespace Predis\Protocol; use Predis\CommunicationException; /** - * Errors encountered while handling the wire protocol. + * Exception used to indentify errors encountered while parsing the Redis wire + * protocol. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Protocol/ProtocolProcessorInterface.php b/lib/Predis/Protocol/ProtocolProcessorInterface.php index a69fd73c..14423f85 100644 --- a/lib/Predis/Protocol/ProtocolProcessorInterface.php +++ b/lib/Predis/Protocol/ProtocolProcessorInterface.php @@ -23,17 +23,17 @@ use Predis\Connection\ComposableConnectionInterface; interface ProtocolProcessorInterface { /** - * Writes a command to the specified connection. + * Writes a request over a connection to Redis. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param CommandInterface $command Redis command. + * @param ComposableConnectionInterface $connection Redis connection. + * @param CommandInterface $command Command instance. */ public function write(ComposableConnectionInterface $connection, CommandInterface $command); /** - * Reads a response from the specified connection. + * Reads a response from a connection to Redis. * - * @param ComposableConnectionInterface $connection Connection to Redis. + * @param ComposableConnectionInterface $connection Redis connection. * @return mixed */ public function read(ComposableConnectionInterface $connection); diff --git a/lib/Predis/Protocol/ResponseReaderInterface.php b/lib/Predis/Protocol/ResponseReaderInterface.php index 9565e4f3..da517ed9 100644 --- a/lib/Predis/Protocol/ResponseReaderInterface.php +++ b/lib/Predis/Protocol/ResponseReaderInterface.php @@ -22,9 +22,9 @@ use Predis\Connection\ComposableConnectionInterface; interface ResponseReaderInterface { /** - * Reads a response from the connection. + * Reads a response from a connection to Redis. * - * @param ComposableConnectionInterface $connection Connection to Redis. + * @param ComposableConnectionInterface $connection Redis connection. * @return mixed */ public function read(ComposableConnectionInterface $connection); diff --git a/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php b/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php index 222f8a67..f50decf6 100644 --- a/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php +++ b/lib/Predis/Protocol/Text/Handler/ResponseHandlerInterface.php @@ -21,11 +21,11 @@ use Predis\Connection\ComposableConnectionInterface; interface ResponseHandlerInterface { /** - * Deserializes the response returned by Redis and reads more data from the - * connection when needed. + * Deserializes a response returned by Redis and reads more data from the + * connection if needed. * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $payload Raw payload. + * @param ComposableConnectionInterface $connection Redis connection. + * @param string $payload String payload. * @return mixed */ function handle(ComposableConnectionInterface $connection, $payload); diff --git a/lib/Predis/Protocol/Text/Handler/StatusResponse.php b/lib/Predis/Protocol/Text/Handler/StatusResponse.php index 7aa8d027..04465923 100644 --- a/lib/Predis/Protocol/Text/Handler/StatusResponse.php +++ b/lib/Predis/Protocol/Text/Handler/StatusResponse.php @@ -15,9 +15,9 @@ use Predis\Connection\ComposableConnectionInterface; use Predis\Response; /** - * Handler for the status response type in the standard Redis wire protocol. - * It translates certain classes of status response to PHP objects or just - * returns the payload as a string. + * Handler for the status response type in the standard Redis wire protocol. It + * translates certain classes of status response to PHP objects or just returns + * the payload as a string. * * @link http://redis.io/topics/protocol * @author Daniele Alessandri diff --git a/lib/Predis/Protocol/Text/ProtocolProcessor.php b/lib/Predis/Protocol/Text/ProtocolProcessor.php index 720855c8..47f28c81 100644 --- a/lib/Predis/Protocol/Text/ProtocolProcessor.php +++ b/lib/Predis/Protocol/Text/ProtocolProcessor.php @@ -105,8 +105,8 @@ class ProtocolProcessor implements ProtocolProcessorInterface * returning a plain array. * * Streamable multibulk responses are not globally supported by the - * abstractions built-in into Predis, such as transactions or pipelines. Use - * them with care! + * abstractions built-in into Predis, such as transactions or pipelines. + * Use them with care! * * @param bool $value Enable or disable streamable multibulk responses. */ diff --git a/lib/Predis/Protocol/Text/ResponseReader.php b/lib/Predis/Protocol/Text/ResponseReader.php index ab490adc..f03ddde8 100644 --- a/lib/Predis/Protocol/Text/ResponseReader.php +++ b/lib/Predis/Protocol/Text/ResponseReader.php @@ -97,10 +97,10 @@ class ResponseReader implements ResponseReaderInterface } /** - * Handles protocol errors generated while reading responses from the + * Handles protocol errors generated while reading responses from a * connection. * - * @param ComposableConnectionInterface $connection Connection to Redis that generated the error. + * @param ComposableConnectionInterface $connection Redis connection that generated the error. * @param string $message Error message. */ protected function onProtocolError(ComposableConnectionInterface $connection, $message) diff --git a/lib/Predis/PubSub/AbstractConsumer.php b/lib/Predis/PubSub/AbstractConsumer.php index 439ece40..e980ff77 100644 --- a/lib/Predis/PubSub/AbstractConsumer.php +++ b/lib/Predis/PubSub/AbstractConsumer.php @@ -14,7 +14,7 @@ namespace Predis\PubSub; use Iterator; /** - * Base implementation of a PUB/SUB consumer abstraction. + * Base implementation of a PUB/SUB consumer abstraction based on PHP iterators. * * @author Daniele Alessandri */ @@ -35,7 +35,7 @@ abstract class AbstractConsumer implements Iterator private $statusFlags = self::STATUS_VALID; /** - * Automatically stops the consumer when PHP's garbage collector kicks in. + * Automatically stops the consumer when the garbage collector kicks in. */ public function __destruct() { @@ -96,12 +96,11 @@ abstract class AbstractConsumer implements Iterator } /** - * Closes the context by unsubscribing from all the subscribed channels. - * Optionally, the context can be forcefully closed by dropping the - * underlying connection. + * Closes the context by unsubscribing from all the subscribed channels. The + * context can be forcefully closed by dropping the underlying connection. * - * @param bool $drop Forcefully close the context by closing the connection. - * @return bool Returns false if there are no pending messages. + * @param bool $drop Indicates if the context should be closed by dropping the connection. + * @return bool Returns false when there are no pending messages. */ public function stop($drop = false) { @@ -125,15 +124,15 @@ abstract class AbstractConsumer implements Iterator } /** - * Closes the underlying connection on forced disconnection. + * Closes the underlying connection when forcing a disconnection. */ protected abstract 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 Command ID. + * @param array $arguments Arguments for the command. */ protected abstract function writeRequest($method, $arguments); diff --git a/lib/Predis/PubSub/Consumer.php b/lib/Predis/PubSub/Consumer.php index a0a83497..99fb2712 100644 --- a/lib/Predis/PubSub/Consumer.php +++ b/lib/Predis/PubSub/Consumer.php @@ -52,8 +52,8 @@ class Consumer extends AbstractConsumer } /** - * Checks if the passed client instance satisfies the required conditions - * needed to initialize a PUB/SUB consumer. + * Checks if the client instance satisfies the required conditions needed to + * initialize a PUB/SUB consumer. * * @param ClientInterface $client Client instance used by the consumer. */ diff --git a/lib/Predis/PubSub/DispatcherLoop.php b/lib/Predis/PubSub/DispatcherLoop.php index b60d7592..5218b924 100644 --- a/lib/Predis/PubSub/DispatcherLoop.php +++ b/lib/Predis/PubSub/DispatcherLoop.php @@ -16,7 +16,7 @@ use Predis\ClientInterface; /** * Method-dispatcher loop built around the client-side abstraction of a Redis - * Publish / Subscribe context. + * PUB / SUB context. * * @author Daniele Alessandri */ @@ -42,7 +42,7 @@ class DispatcherLoop * * @param mixed $callable A callback. */ - protected function validateCallback($callable) + protected function assertCallback($callable) { if (!is_callable($callable)) { throw new InvalidArgumentException("A valid callable object must be provided"); @@ -50,7 +50,7 @@ class DispatcherLoop } /** - * Returns the underlying Publish / Subscribe context. + * Returns the underlying PUB / SUB context. * * @return Consumer */ @@ -67,7 +67,7 @@ class DispatcherLoop public function subscriptionCallback($callable = null) { if (isset($callable)) { - $this->validateCallback($callable); + $this->assertCallback($callable); } $this->subscriptionCallback = $callable; @@ -82,7 +82,7 @@ class DispatcherLoop public function defaultCallback($callable = null) { if (isset($callable)) { - $this->validateCallback($callable); + $this->assertCallback($callable); } $this->subscriptionCallback = $callable; @@ -98,7 +98,7 @@ class DispatcherLoop { $callbackName = $this->getPrefixKeys() . $channel; - $this->validateCallback($callback); + $this->assertCallback($callback); $this->callbacks[$callbackName] = $callback; $this->pubsub->subscribe($channel); } @@ -154,7 +154,7 @@ class DispatcherLoop } /** - * Return the prefix of the keys + * Return the prefix used for keys * * @return string */ diff --git a/lib/Predis/Replication/ReplicationStrategy.php b/lib/Predis/Replication/ReplicationStrategy.php index 7722601c..a37fc1ac 100644 --- a/lib/Predis/Replication/ReplicationStrategy.php +++ b/lib/Predis/Replication/ReplicationStrategy.php @@ -36,16 +36,18 @@ class ReplicationStrategy } /** - * Returns if the specified command performs a read-only operation - * against a key stored on Redis. + * Returns if the specified command will perform a read-only operation + * on Redis or not. * - * @param CommandInterface $command Instance of Redis command. - * @return Boolean + * @param CommandInterface $command Command instance. + * @return bool */ public function isReadOperation(CommandInterface $command) { if (isset($this->disallowed[$id = $command->getId()])) { - throw new NotSupportedException("The command $id is not allowed in replication mode"); + throw new NotSupportedException( + "The command $id is not allowed in replication mode" + ); } if (isset($this->readonly[$id])) { @@ -72,11 +74,11 @@ class ReplicationStrategy } /** - * Returns if the specified command is disallowed in a master/slave - * replication context. + * Returns if the specified command is not allowed for execution in a master + * / slave replication context. * - * @param CommandInterface $command Instance of Redis command. - * @return Boolean + * @param CommandInterface $command Command instance. + * @return bool */ public function isDisallowedOperation(CommandInterface $command) { @@ -87,8 +89,8 @@ 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. - * @return Boolean + * @param CommandInterface $command Command instance. + * @return bool */ protected function isSortReadOnly(CommandInterface $command) { @@ -97,13 +99,14 @@ class ReplicationStrategy } /** - * Marks a command as a read-only operation. When the behaviour of a - * command can be decided only at runtime depending on its arguments, - * a callable object can be provided to dynamically check if the passed - * instance of a command performs write operations or not. + * Marks a command as a read-only operation. * - * @param string $commandID ID of the command. - * @param mixed $readonly A boolean or a callable object. + * When the behavior of a command can be decided only at runtime depending + * on its arguments, a callable object can be provided to dynamically check + * if the specified command performs a read or a write operation. + * + * @param string $commandID Command ID. + * @param mixed $readonly A boolean value or a callable object. */ public function setCommandReadOnly($commandID, $readonly = true) { @@ -124,7 +127,7 @@ class ReplicationStrategy * not. * * @param string $script Body of the Lua script. - * @param mixed $readonly A boolean or a callable object. + * @param mixed $readonly A boolean value or a callable object. */ public function setScriptReadOnly($script, $readonly = true) { diff --git a/lib/Predis/Response/Iterator/MultiBulk.php b/lib/Predis/Response/Iterator/MultiBulk.php index e2581511..bd7df278 100644 --- a/lib/Predis/Response/Iterator/MultiBulk.php +++ b/lib/Predis/Response/Iterator/MultiBulk.php @@ -35,9 +35,9 @@ class MultiBulk extends MultiBulkIterator } /** - * Handles the synchronization of the client with the Redis protocol - * then PHP's garbage collector kicks in (e.g. then the iterator goes - * out of the scope of a foreach). + * Handles the synchronization of the client with the Redis protocol when + * the garbage collector kicks in (e.g. when the iterator goes out of the + * scope of a foreach or it is unset). */ public function __destruct() { diff --git a/lib/Predis/Response/Iterator/MultiBulkTuple.php b/lib/Predis/Response/Iterator/MultiBulkTuple.php index 7f31a12f..c8a3f945 100644 --- a/lib/Predis/Response/Iterator/MultiBulkTuple.php +++ b/lib/Predis/Response/Iterator/MultiBulkTuple.php @@ -49,11 +49,15 @@ class MultiBulkTuple extends MultiBulk implements OuterIterator protected function checkPreconditions(MultiBulk $iterator) { if ($iterator->getPosition() !== 0) { - throw new RuntimeException('Cannot initialize a tuple iterator with an already initiated iterator'); + throw new RuntimeException( + 'Cannot initialize a tuple iterator with an already initiated iterator' + ); } if (($size = count($iterator)) % 2 !== 0) { - throw new UnexpectedValueException("Invalid response size for a tuple iterator [$size]"); + throw new UnexpectedValueException( + "Invalid response size for a tuple iterator [$size]" + ); } } diff --git a/lib/Predis/Response/Status.php b/lib/Predis/Response/Status.php index 487b9fd4..b350349c 100644 --- a/lib/Predis/Response/Status.php +++ b/lib/Predis/Response/Status.php @@ -52,10 +52,10 @@ class Status implements ResponseInterface } /** - * Returns a new instance of a status response object. + * Returns an instance of a status response object. * - * Common status responses such as OK or QUEUED are cached to lower the - * memory usage especially when using pipelines. + * Common status responses such as OK or QUEUED are cached in order to lower + * the global memory usage especially when using pipelines. * * @return string */ diff --git a/lib/Predis/Session/Handler.php b/lib/Predis/Session/Handler.php index fcf399c0..fea6fa79 100644 --- a/lib/Predis/Session/Handler.php +++ b/lib/Predis/Session/Handler.php @@ -18,9 +18,9 @@ use Predis\ClientInterface; * Session handler class that relies on Predis\Client to store PHP's sessions * data into one or multiple Redis servers. * - * This class is mostly intended for PHP 5.4 but it can be used under PHP 5.3 provided - * that a polyfill for `SessionHandlerInterface` is defined by either you or an external - * package such as `symfony/http-foundation`. + * This class is mostly intended for PHP 5.4 but it can be used under PHP 5.3 + * provided that a polyfill for `SessionHandlerInterface` is defined by either + * you or an external package such as `symfony/http-foundation`. * * @author Daniele Alessandri */ @@ -36,11 +36,16 @@ class Handler implements SessionHandlerInterface public function __construct(ClientInterface $client, array $options = array()) { $this->client = $client; - $this->ttl = (int) (isset($options['gc_maxlifetime']) ? $options['gc_maxlifetime'] : ini_get('session.gc_maxlifetime')); + + if (isset($options['gc_maxlifetime'])) { + $this->ttl = (int) $options['gc_maxlifetime']; + } else { + $this->ttl = ini_get('session.gc_maxlifetime'); + } } /** - * Registers the handler instance as the current session handler. + * Registers this instance as the current session handler. */ public function register() { diff --git a/lib/Predis/Transaction/AbortedMultiExecException.php b/lib/Predis/Transaction/AbortedMultiExecException.php index 2365bbf5..f8be4819 100644 --- a/lib/Predis/Transaction/AbortedMultiExecException.php +++ b/lib/Predis/Transaction/AbortedMultiExecException.php @@ -14,7 +14,7 @@ namespace Predis\Transaction; use Predis\PredisException; /** - * Exception class that identifies MULTI / EXEC transactions aborted by Redis. + * Exception class that identifies a MULTI / EXEC transaction aborted by Redis. * * @author Daniele Alessandri */ diff --git a/lib/Predis/Transaction/MultiExec.php b/lib/Predis/Transaction/MultiExec.php index a565cb49..274a30cf 100644 --- a/lib/Predis/Transaction/MultiExec.php +++ b/lib/Predis/Transaction/MultiExec.php @@ -104,7 +104,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Resets the state of a transaction. + * Resets the state of the transaction. */ protected function reset() { @@ -113,7 +113,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Initializes a new transaction. + * Initializes the transaction context. */ protected function initialize() { @@ -160,7 +160,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Sends a Redis command bypassing the transaction logic. + * Executes a Redis command bypassing the transaction logic. * * @param string $method Command ID. * @param array $arguments Arguments for the command. @@ -181,7 +181,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface /** * Executes the specified Redis command. * - * @param CommandInterface $command A Redis command. + * @param CommandInterface $command Command instance. * @return mixed */ public function executeCommand(CommandInterface $command) @@ -203,7 +203,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Executes WATCH on one or more keys. + * Executes WATCH against one or more keys. * * @param string|array $keys One or more keys. * @return mixed @@ -226,7 +226,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Finalizes the transaction on the server by executing MULTI on the server. + * Finalizes the transaction by executing MULTI on the server. * * @return MultiExec */ @@ -260,8 +260,8 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Resets a transaction by UNWATCHing the keys that are being WATCHed and - * DISCARDing the pending commands that have been already sent to the server. + * Resets the transaction by UNWATCH-ing the keys that are being WATCHed and + * DISCARD-ing pending commands that have been already sent to the server. * * @return MultiExec */ @@ -413,15 +413,15 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface } /** - * Helper method that handles protocol errors encountered inside a transaction. + * Helper method for protocol errors encountered inside the transaction. * * @param string $message Error message. */ private function onProtocolError($message) { // Since a MULTI/EXEC block cannot be initialized when using aggregated - // connections, we can safely assume that Predis\Client::getConnection() - // will always return an instance of Predis\Connection\SingleConnectionInterface. + // connections we can safely assume that Predis\Client::getConnection() + // will return a Predis\Connection\SingleConnectionInterface instance. CommunicationException::handle(new ProtocolException( $this->client->getConnection(), $message ));