diff --git a/src/Client.php b/src/Client.php index e78213ea..edce9788 100644 --- a/src/Client.php +++ b/src/Client.php @@ -477,7 +477,7 @@ class Client implements ClientInterface * * @param mixed ... Array of options, a callable for execution, or both. * - * @return PubSubConsumer|NULL + * @return PubSubConsumer|null */ public function pubSubLoop(/* arguments */) { @@ -490,7 +490,7 @@ class Client implements ClientInterface * @param array $options Options for the context. * @param mixed $callable Optional callable used to execute the context. * - * @return PubSubConsumer|NULL + * @return PubSubConsumer|null */ protected function createPubSub(array $options = null, $callable = null) { @@ -505,8 +505,6 @@ class Client implements ClientInterface $pubsub->stop(); } } - - return null; } /** diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index 8e7351f7..2369a569 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -225,7 +225,7 @@ abstract class ClusterStrategy implements StrategyInterface * * @param CommandInterface $command Command instance. * - * @return string + * @return string|null */ protected function getKeyFromAllArguments(CommandInterface $command) { @@ -234,8 +234,6 @@ abstract class ClusterStrategy implements StrategyInterface if ($this->checkSameSlotForKeys($arguments)) { return $arguments[0]; } - - return null; } /** @@ -244,7 +242,7 @@ abstract class ClusterStrategy implements StrategyInterface * * @param CommandInterface $command Command instance. * - * @return string + * @return string|null */ protected function getKeyFromInterleavedArguments(CommandInterface $command) { @@ -258,8 +256,6 @@ abstract class ClusterStrategy implements StrategyInterface if ($this->checkSameSlotForKeys($keys)) { return $arguments[0]; } - - return null; } /** @@ -267,7 +263,7 @@ abstract class ClusterStrategy implements StrategyInterface * * @param CommandInterface $command Command instance. * - * @return string + * @return string|null */ protected function getKeyFromBlockingListCommands(CommandInterface $command) { @@ -276,8 +272,6 @@ abstract class ClusterStrategy implements StrategyInterface if ($this->checkSameSlotForKeys(array_slice($arguments, 0, count($arguments) - 1))) { return $arguments[0]; } - - return null; } /** @@ -285,7 +279,7 @@ abstract class ClusterStrategy implements StrategyInterface * * @param CommandInterface $command Command instance. * - * @return string + * @return string|null */ protected function getKeyFromBitOp(CommandInterface $command) { @@ -294,8 +288,6 @@ abstract class ClusterStrategy implements StrategyInterface if ($this->checkSameSlotForKeys(array_slice($arguments, 1, count($arguments)))) { return $arguments[1]; } - - return null; } /** @@ -303,7 +295,7 @@ abstract class ClusterStrategy implements StrategyInterface * * @param CommandInterface $command Command instance. * - * @return string + * @return string|null */ protected function getKeyFromZsetAggregationCommands(CommandInterface $command) { @@ -313,8 +305,6 @@ abstract class ClusterStrategy implements StrategyInterface if ($this->checkSameSlotForKeys($keys)) { return $arguments[0]; } - - return null; } /** @@ -322,7 +312,7 @@ abstract class ClusterStrategy implements StrategyInterface * * @param CommandInterface $command Command instance. * - * @return string + * @return string|null */ protected function getKeyFromScriptingCommands(CommandInterface $command) { @@ -335,8 +325,6 @@ abstract class ClusterStrategy implements StrategyInterface if ($keys && $this->checkSameSlotForKeys($keys)) { return $keys[0]; } - - return null; } /** diff --git a/src/Cluster/Distributor/DistributorInterface.php b/src/Cluster/Distributor/DistributorInterface.php index a5c8198b..831f52c5 100644 --- a/src/Cluster/Distributor/DistributorInterface.php +++ b/src/Cluster/Distributor/DistributorInterface.php @@ -51,7 +51,7 @@ interface DistributorInterface * * @param mixed $slot * - * @return mixed + * @return mixed|null */ public function getBySlot($slot); diff --git a/src/Cluster/Distributor/HashRing.php b/src/Cluster/Distributor/HashRing.php index 38792442..a2c14db7 100644 --- a/src/Cluster/Distributor/HashRing.php +++ b/src/Cluster/Distributor/HashRing.php @@ -204,8 +204,6 @@ class HashRing implements DistributorInterface, HashGeneratorInterface if (isset($this->ring[$slot])) { return $this->ring[$slot]; } - - return null; } /** diff --git a/src/Command/Command.php b/src/Command/Command.php index 7cc14230..bb538e7c 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -67,8 +67,6 @@ abstract class Command implements CommandInterface if (isset($this->arguments[$index])) { return $this->arguments[$index]; } - - return null; } /** @@ -87,8 +85,6 @@ abstract class Command implements CommandInterface if (isset($this->slot)) { return $this->slot; } - - return null; } /** diff --git a/src/Command/CommandInterface.php b/src/Command/CommandInterface.php index a0deb70d..9f349e1d 100644 --- a/src/Command/CommandInterface.php +++ b/src/Command/CommandInterface.php @@ -36,7 +36,7 @@ interface CommandInterface /** * Returns the assigned slot of the command for clustering distribution. * - * @return int + * @return int|null */ public function getSlot(); @@ -66,7 +66,7 @@ interface CommandInterface * * @param int $index Index of the desired argument. * - * @return mixed + * @return mixed|null */ public function getArgument($index); diff --git a/src/Command/RawCommand.php b/src/Command/RawCommand.php index dc5d0eaf..a7f17894 100644 --- a/src/Command/RawCommand.php +++ b/src/Command/RawCommand.php @@ -101,8 +101,6 @@ class RawCommand implements CommandInterface if (isset($this->arguments[$index])) { return $this->arguments[$index]; } - - return null; } /** @@ -121,8 +119,6 @@ class RawCommand implements CommandInterface if (isset($this->slot)) { return $this->slot; } - - return null; } /** diff --git a/src/Configuration/ClusterOption.php b/src/Configuration/ClusterOption.php index d7ff9834..62f03231 100644 --- a/src/Configuration/ClusterOption.php +++ b/src/Configuration/ClusterOption.php @@ -31,7 +31,7 @@ class ClusterOption implements OptionInterface * @param OptionsInterface $options Instance of the client options. * @param string $id Descriptive identifier of the cluster type (`predis`, `redis-cluster`) * - * @return ClusterInterface + * @return ClusterInterface|null */ protected function createByDescription(OptionsInterface $options, $id) { @@ -44,9 +44,9 @@ class ClusterOption implements OptionInterface case 'redis-cluster': return new RedisCluster($options->connections); + default: + return; } - - return null; } /** diff --git a/src/Configuration/Options.php b/src/Configuration/Options.php index 04556258..1bf3f09b 100644 --- a/src/Configuration/Options.php +++ b/src/Configuration/Options.php @@ -63,8 +63,6 @@ class Options implements OptionsInterface return $handler->getDefault($this); } - - return null; } /** diff --git a/src/Configuration/OptionsInterface.php b/src/Configuration/OptionsInterface.php index f3051156..f8116470 100644 --- a/src/Configuration/OptionsInterface.php +++ b/src/Configuration/OptionsInterface.php @@ -31,7 +31,7 @@ interface OptionsInterface * * @param string $option Name of the option. * - * @return mixed + * @return mixed|null */ public function getDefault($option); @@ -58,7 +58,7 @@ interface OptionsInterface * * @param string $option Name of the option. * - * @return mixed + * @return mixed|null */ public function __get($option); } diff --git a/src/Connection/Aggregate/RedisCluster.php b/src/Connection/Aggregate/RedisCluster.php index 15395edb..3d3b84f4 100644 --- a/src/Connection/Aggregate/RedisCluster.php +++ b/src/Connection/Aggregate/RedisCluster.php @@ -345,22 +345,18 @@ class RedisCluster implements ClusterInterface, IteratorAggregate, Countable if (isset($this->pool[$connectionID])) { return $this->pool[$connectionID]; } - - return null; } /** * Returns a random connection from the pool. * - * @return NodeConnectionInterface + * @return NodeConnectionInterface|null */ protected function getRandomConnection() { if ($this->pool) { return $this->pool[array_rand($this->pool)]; } - - return null; } /** diff --git a/src/Connection/AggregateConnectionInterface.php b/src/Connection/AggregateConnectionInterface.php index 670f8240..7eeaede7 100644 --- a/src/Connection/AggregateConnectionInterface.php +++ b/src/Connection/AggregateConnectionInterface.php @@ -51,7 +51,7 @@ interface AggregateConnectionInterface extends ConnectionInterface * * @param string $connectionID Connection alias. * - * @return NodeConnectionInterface + * @return NodeConnectionInterface|null */ public function getConnectionById($connectionID); } diff --git a/src/Connection/Parameters.php b/src/Connection/Parameters.php index 8062f354..45a7be17 100644 --- a/src/Connection/Parameters.php +++ b/src/Connection/Parameters.php @@ -114,8 +114,6 @@ class Parameters implements ParametersInterface if (isset($this->parameters[$parameter])) { return $this->parameters[$parameter]; } - - return null; } /** diff --git a/src/Connection/ParametersInterface.php b/src/Connection/ParametersInterface.php index 5ed0ab67..fd8a908e 100644 --- a/src/Connection/ParametersInterface.php +++ b/src/Connection/ParametersInterface.php @@ -49,7 +49,7 @@ interface ParametersInterface * * @param string $parameter Name of the parameter. * - * @return mixed + * @return mixed|null */ public function __get($parameter); diff --git a/src/Connection/PhpiredisSocketConnection.php b/src/Connection/PhpiredisSocketConnection.php index daf58545..1cd31aa0 100644 --- a/src/Connection/PhpiredisSocketConnection.php +++ b/src/Connection/PhpiredisSocketConnection.php @@ -365,9 +365,9 @@ class PhpiredisSocketConnection extends AbstractConnection return phpiredis_reader_get_reply($reader); } else { $this->onProtocolError(phpiredis_reader_get_error($reader)); - } - return null; + return; + } } /** diff --git a/src/Connection/PhpiredisStreamConnection.php b/src/Connection/PhpiredisStreamConnection.php index 692e31fe..36f3dfce 100644 --- a/src/Connection/PhpiredisStreamConnection.php +++ b/src/Connection/PhpiredisStreamConnection.php @@ -200,9 +200,9 @@ class PhpiredisStreamConnection extends StreamConnection return phpiredis_reader_get_reply($reader); } else { $this->onProtocolError(phpiredis_reader_get_error($reader)); - } - return null; + return; + } } /** diff --git a/src/Connection/StreamConnection.php b/src/Connection/StreamConnection.php index 087b8d68..d74bd6d1 100644 --- a/src/Connection/StreamConnection.php +++ b/src/Connection/StreamConnection.php @@ -239,9 +239,9 @@ class StreamConnection extends AbstractConnection default: $this->onProtocolError("Unknown response prefix: '$prefix'."); - } - return null; + return; + } } /** diff --git a/src/Profile/RedisProfile.php b/src/Profile/RedisProfile.php index 1e68f447..659ce42b 100644 --- a/src/Profile/RedisProfile.php +++ b/src/Profile/RedisProfile.php @@ -70,15 +70,13 @@ abstract class RedisProfile implements ProfileInterface * * @param string $commandID Command ID. * - * @return string + * @return string|null */ public function getCommandClass($commandID) { if (isset($this->commands[$commandID = strtoupper($commandID)])) { return $this->commands[$commandID]; } - - return null; } /** diff --git a/src/Protocol/Text/Handler/BulkResponse.php b/src/Protocol/Text/Handler/BulkResponse.php index 708573e7..f9f9a299 100644 --- a/src/Protocol/Text/Handler/BulkResponse.php +++ b/src/Protocol/Text/Handler/BulkResponse.php @@ -45,7 +45,10 @@ class BulkResponse implements ResponseHandlerInterface return null; } - // TODO: we should probably check if < -1, just to make sure. - return null; + CommunicationException::handle(new ProtocolException( + $connection, "Value '$payload' is not a valid length for a bulk response." + )); + + return; } } diff --git a/src/Protocol/Text/ProtocolProcessor.php b/src/Protocol/Text/ProtocolProcessor.php index 99af643c..59a192d3 100644 --- a/src/Protocol/Text/ProtocolProcessor.php +++ b/src/Protocol/Text/ProtocolProcessor.php @@ -99,7 +99,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface $connection, "Unknown response prefix: '$prefix'." )); - return null; + return; } } diff --git a/src/Protocol/Text/ResponseReader.php b/src/Protocol/Text/ResponseReader.php index 1543aa03..1d6875bf 100644 --- a/src/Protocol/Text/ResponseReader.php +++ b/src/Protocol/Text/ResponseReader.php @@ -94,9 +94,9 @@ class ResponseReader implements ResponseReaderInterface $this->onProtocolError($connection, "Unknown response prefix: '$prefix'."); } - $handler = $this->handlers[$prefix]; + $payload = $this->handlers[$prefix]->handle($connection, substr($header, 1)); - return $handler->handle($connection, substr($header, 1)); + return $payload; } /**