ソースを参照

Merge branch 'v0.8-backport-fixes' into v0.8

Daniele Alessandri 11 年 前
コミット
9a1884d960
30 ファイル変更148 行追加95 行削除
  1. 6 6
      lib/Predis/Client.php
  2. 1 0
      lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php
  3. 2 2
      lib/Predis/Collection/Iterator/CursorBasedIterator.php
  4. 2 2
      lib/Predis/Collection/Iterator/ListKey.php
  5. 1 3
      lib/Predis/Command/AbstractCommand.php
  6. 2 1
      lib/Predis/Command/CommandInterface.php
  7. 2 3
      lib/Predis/Command/RawCommand.php
  8. 2 1
      lib/Predis/Connection/AbstractConnection.php
  9. 1 1
      lib/Predis/Connection/ConnectionParameters.php
  10. 2 2
      lib/Predis/Connection/ConnectionParametersInterface.php
  11. 7 4
      lib/Predis/Connection/PhpiredisConnection.php
  12. 0 2
      lib/Predis/Connection/PhpiredisStreamConnection.php
  13. 7 5
      lib/Predis/Option/OptionInterface.php
  14. 6 3
      lib/Predis/Pipeline/PipelineContext.php
  15. 1 2
      lib/Predis/Profile/ServerVersion26.php
  16. 1 2
      lib/Predis/Profile/ServerVersion28.php
  17. 8 8
      lib/Predis/PubSub/AbstractPubSubContext.php
  18. 2 0
      lib/Predis/PubSub/PubSubContext.php
  19. 3 3
      lib/Predis/Transaction/MultiExecContext.php
  20. 1 1
      tests/PHPUnit/PredisCommandTestCase.php
  21. 1 0
      tests/PHPUnit/PredisProfileTestCase.php
  22. 16 11
      tests/PHPUnit/PredisTestCase.php
  23. 3 2
      tests/PHPUnit/RedisCommandConstraint.php
  24. 4 4
      tests/Predis/CommunicationExceptionTest.php
  25. 12 0
      tests/Predis/Connection/PhpiredisConnectionTest.php
  26. 1 0
      tests/Predis/Connection/WebdisConnectionTest.php
  27. 29 9
      tests/Predis/Pipeline/PipelineContextTest.php
  28. 2 2
      tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php
  29. 0 2
      tests/Predis/Replication/ReplicationStrategyTest.php
  30. 23 14
      tests/Predis/Transaction/MultiExecContextTest.php

+ 6 - 6
lib/Predis/Client.php

@@ -202,7 +202,7 @@ class Client implements ClientInterface
     /**
      * Retrieves a single connection out of an aggregated connections instance.
      *
-     * @param  string                               $connectionId Index or alias of the connection.
+     * @param  string                               $connectionId Index or alias of the single connection.
      * @return Connection\SingleConnectionInterface
      */
     public function getConnectionById($connectionId)
@@ -319,7 +319,7 @@ class Client implements ClientInterface
      * Creates a new pipeline context and returns it, or returns the results of
      * a pipeline executed inside the optionally provided callable object.
      *
-     * @param  mixed                 $arg,... Options for the context, a callable object, or both.
+     * @param  mixed                 ... Options for the context, a callable object, or both.
      * @return PipelineContext|array
      */
     public function pipeline(/* arguments */)
@@ -368,7 +368,7 @@ class Client implements ClientInterface
      *             as it will replace Client::multiExec() in the next major
      *             version of the library.
      *
-     * @param  mixed                  $arg,... Options for the context, a callable object, or both.
+     * @param  mixed                  ... Options for the context, a callable object, or both.
      * @return MultiExecContext|array
      */
     public function multiExec(/* arguments */)
@@ -380,7 +380,7 @@ class Client implements ClientInterface
      * Creates a new transaction context and returns it, or returns the results of
      * a transaction executed inside the optionally provided callable object.
      *
-     * @param  mixed                  $arg,... Options for the context, a callable object, or both.
+     * @param  mixed                  ... Options for the context, a callable object, or both.
      * @return MultiExecContext|array
      */
     public function transaction(/* arguments */)
@@ -411,7 +411,7 @@ class Client implements ClientInterface
      *             Client::pubSubLoop() to create Predis\PubSub\PubSubContext
      *             instances from now on.
      *
-     * @param  mixed                   $arg,... Options for the context, a callable object, or both.
+     * @param  mixed                   ... Options for the context, a callable object, or both.
      * @return PubSubExecContext|array
      */
     public function pubSub(/* arguments */)
@@ -423,7 +423,7 @@ class Client implements ClientInterface
      * Creates a new Publish / Subscribe context and returns it, or executes it
      * inside the optionally provided callable object.
      *
-     * @param  mixed                   $arg,... Options for the context, a callable object, or both.
+     * @param  mixed                   ... Options for the context, a callable object, or both.
      * @return PubSubExecContext|array
      */
     public function pubSubLoop(/* arguments */)

+ 1 - 0
lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php

@@ -39,6 +39,7 @@ interface DistributionStrategyInterface
     /**
      * Gets a node from the distributor using the computed hash of a key.
      *
+     * @param  mixed $key
      * @return mixed
      */
     public function get($key);

+ 2 - 2
lib/Predis/Collection/Iterator/CursorBasedIterator.php

@@ -60,8 +60,8 @@ abstract class CursorBasedIterator implements Iterator
      * command required to fetch elements from the server to perform
      * the iteration.
      *
-     * @param ClientInterface Client connected to Redis.
-     * @param string $commandID Command ID.
+     * @param ClientInterface $client    Client connected to Redis.
+     * @param string          $commandID Command ID.
      */
     protected function requiredCommand(ClientInterface $client, $commandID)
     {

+ 2 - 2
lib/Predis/Collection/Iterator/ListKey.php

@@ -66,8 +66,8 @@ class ListKey implements Iterator
      * command required to fetch elements from the server to perform
      * the iteration.
      *
-     * @param ClientInterface Client connected to Redis.
-     * @param string $commandID Command ID.
+     * @param ClientInterface $client    Client connected to Redis.
+     * @param string          $commandID Command ID.
      */
     protected function requiredCommand(ClientInterface $client, $commandID)
     {

+ 1 - 3
lib/Predis/Command/AbstractCommand.php

@@ -59,9 +59,7 @@ abstract class AbstractCommand implements CommandInterface
     }
 
     /**
-     * Gets the argument from the arguments list at the specified index.
-     *
-     * @param array $arguments Position of the argument.
+     * {@inheritdoc}
      */
     public function getArgument($index)
     {

+ 2 - 1
lib/Predis/Command/CommandInterface.php

@@ -62,7 +62,8 @@ interface CommandInterface
     /**
      * Gets the argument of the command at the specified index.
      *
-     * @return array
+     * @param  int   $index Index of the desired argument.
+     * @return mixed
      */
     public function getArgument($index);
 

+ 2 - 3
lib/Predis/Command/RawCommand.php

@@ -44,6 +44,7 @@ class RawCommand implements CommandInterface
      *
      * @param string $commandID Redis command ID.
      * @param string ... Arguments list for the command.
+     * @return CommandInterface
      */
     public static function create($commandID /* [ $arg, ... */)
     {
@@ -87,9 +88,7 @@ class RawCommand implements CommandInterface
     }
 
     /**
-     * Gets the argument from the arguments list at the specified index.
-     *
-     * @param array $arguments Position of the argument.
+     * {@inheritdoc}
      */
     public function getArgument($index)
     {

+ 2 - 1
lib/Predis/Connection/AbstractConnection.php

@@ -50,7 +50,8 @@ 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.
+     * @return ConnectionParametersInterface
      */
     protected function checkParameters(ConnectionParametersInterface $parameters)
     {

+ 1 - 1
lib/Predis/Connection/ConnectionParameters.php

@@ -30,7 +30,7 @@ class ConnectionParameters implements ConnectionParametersInterface
     );
 
     /**
-     * @param string|array Connection parameters in the form of an URI string or a named array.
+     * @param string|array $parameters Connection parameters in the form of an URI string or a named array.
      */
     public function __construct($parameters = array())
     {

+ 2 - 2
lib/Predis/Connection/ConnectionParametersInterface.php

@@ -22,8 +22,8 @@ interface ConnectionParametersInterface
     /**
      * Checks if the specified parameters is set.
      *
-     * @param  string  $property Name of the property.
-     * @return Boolean
+     * @param  string $parameter Name of the parameter.
+     * @return bool
      */
     public function __isset($parameter);
 

+ 7 - 4
lib/Predis/Connection/PhpiredisConnection.php

@@ -227,7 +227,7 @@ class PhpiredisConnection extends AbstractConnection
      * @param  ConnectionParametersInterface $parameters Parameters used to initialize the connection.
      * @return string
      */
-    private function getAddress(ConnectionParametersInterface $parameters)
+    protected static function getAddress(ConnectionParametersInterface $parameters)
     {
         if ($parameters->scheme === 'unix') {
             return $parameters->path;
@@ -236,8 +236,8 @@ class PhpiredisConnection extends AbstractConnection
         $host = $parameters->host;
 
         if (ip2long($host) === false) {
-            if (($addresses = gethostbynamel($host)) === false) {
-                $this->onConnectionError("Cannot resolve the address of $host");
+            if (false === $addresses = gethostbynamel($host)) {
+                return false;
             }
 
             return $addresses[array_rand($addresses)];
@@ -254,7 +254,10 @@ class PhpiredisConnection extends AbstractConnection
      */
     private function connectWithTimeout(ConnectionParametersInterface $parameters)
     {
-        $host = self::getAddress($parameters);
+        if (false === $host = self::getAddress($parameters)) {
+            $this->onConnectionError("Cannot resolve the address of '$parameters->host'.");
+        }
+
         $socket = $this->getResource();
 
         socket_set_nonblock($socket);

+ 0 - 2
lib/Predis/Connection/PhpiredisStreamConnection.php

@@ -156,8 +156,6 @@ class PhpiredisStreamConnection extends StreamConnection
 
             if ($buffer === false || $buffer === '') {
                 $this->onConnectionError('Error while reading bytes from the server');
-
-                return;
             }
 
             phpiredis_reader_feed($reader, $buffer);

+ 7 - 5
lib/Predis/Option/OptionInterface.php

@@ -21,7 +21,8 @@ interface OptionInterface
     /**
      * Filters (and optionally converts) the passed value.
      *
-     * @param  mixed $value Input value.
+     * @param  ClientOptionsInterface $options Options container.
+     * @param  mixed                  $value   Input value.
      * @return mixed
      */
     public function filter(ClientOptionsInterface $options, $value);
@@ -29,16 +30,17 @@ interface OptionInterface
     /**
      * Returns a default value for the option.
      *
-     * @param  mixed $value Input value.
+     * @param  ClientOptionsInterface $options Options container.
      * @return mixed
      */
     public function getDefault(ClientOptionsInterface $options);
 
     /**
-     * Filters a value and, if no value is specified, returns
-     * the default one defined by the option.
+     * Filters a value and, if no value is specified, returns the default one
+     * defined by the option.
      *
-     * @param  mixed $value Input value.
+     * @param  ClientOptionsInterface $options Options container.
+     * @param  mixed                  $value   Input value.
      * @return mixed
      */
     public function __invoke(ClientOptionsInterface $options, $value);

+ 6 - 3
lib/Predis/Pipeline/PipelineContext.php

@@ -65,9 +65,9 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac
     /**
      * Queues a command into the pipeline buffer.
      *
-     * @param  string          $method    Command ID.
-     * @param  array           $arguments Arguments for the command.
-     * @return PipelineContext
+     * @param string $method    Command ID.
+     * @param array  $arguments Arguments for the command.
+     * @return $this
      */
     public function __call($method, $arguments)
     {
@@ -91,10 +91,13 @@ class PipelineContext implements BasicClientInterface, ExecutableContextInterfac
      * Queues a command instance into the pipeline buffer.
      *
      * @param CommandInterface $command Command to queue in the buffer.
+     * @return $this
      */
     public function executeCommand(CommandInterface $command)
     {
         $this->recordCommand($command);
+
+        return $this;
     }
 
     /**

+ 1 - 2
lib/Predis/Profile/ServerVersion26.php

@@ -111,7 +111,7 @@ class ServerVersion26 extends ServerProfile
             'quit'                      => 'Predis\Command\ConnectionQuit',
 
             /* remote server control commands */
-            'info'                      => 'Predis\Command\ServerInfo',
+            'info'                      => 'Predis\Command\ServerInfoV26x',
             'slaveof'                   => 'Predis\Command\ServerSlaveOf',
             'monitor'                   => 'Predis\Command\ServerMonitor',
             'dbsize'                    => 'Predis\Command\ServerDatabaseSize',
@@ -227,7 +227,6 @@ class ServerVersion26 extends ServerProfile
             'script'                    => 'Predis\Command\ServerScript',
 
             /* remote server control commands */
-            'info'                      => 'Predis\Command\ServerInfoV26x',
             'time'                      => 'Predis\Command\ServerTime',
         );
     }

+ 1 - 2
lib/Predis/Profile/ServerVersion28.php

@@ -111,7 +111,7 @@ class ServerVersion28 extends ServerProfile
             'quit'                      => 'Predis\Command\ConnectionQuit',
 
             /* remote server control commands */
-            'info'                      => 'Predis\Command\ServerInfo',
+            'info'                      => 'Predis\Command\ServerInfoV26x',
             'slaveof'                   => 'Predis\Command\ServerSlaveOf',
             'monitor'                   => 'Predis\Command\ServerMonitor',
             'dbsize'                    => 'Predis\Command\ServerDatabaseSize',
@@ -227,7 +227,6 @@ class ServerVersion28 extends ServerProfile
             'script'                    => 'Predis\Command\ServerScript',
 
             /* remote server control commands */
-            'info'                      => 'Predis\Command\ServerInfoV26x',
             'time'                      => 'Predis\Command\ServerTime',
 
             /* ---------------- Redis 2.8 ---------------- */

+ 8 - 8
lib/Predis/PubSub/AbstractPubSubContext.php

@@ -54,9 +54,9 @@ abstract class AbstractPubSubContext implements \Iterator
     /**
      * Subscribes to the specified channels.
      *
-     * @param mixed $arg,... One or more channel names.
+     * @param mixed $channel,... One or more channel names.
      */
-    public function subscribe(/* arguments */)
+    public function subscribe($channel /*, ... */)
     {
         $this->writeCommand(self::SUBSCRIBE, func_get_args());
         $this->statusFlags |= self::STATUS_SUBSCRIBED;
@@ -65,9 +65,9 @@ abstract class AbstractPubSubContext implements \Iterator
     /**
      * Unsubscribes from the specified channels.
      *
-     * @param mixed $arg,... One or more channel names.
+     * @param string ... One or more channel names.
      */
-    public function unsubscribe(/* arguments */)
+    public function unsubscribe(/* ... */)
     {
         $this->writeCommand(self::UNSUBSCRIBE, func_get_args());
     }
@@ -75,9 +75,9 @@ abstract class AbstractPubSubContext implements \Iterator
     /**
      * Subscribes to the specified channels using a pattern.
      *
-     * @param mixed $arg,... One or more channel name patterns.
+     * @param mixed $pattern,... One or more channel name patterns.
      */
-    public function psubscribe(/* arguments */)
+    public function psubscribe($pattern /* ... */)
     {
         $this->writeCommand(self::PSUBSCRIBE, func_get_args());
         $this->statusFlags |= self::STATUS_PSUBSCRIBED;
@@ -86,9 +86,9 @@ abstract class AbstractPubSubContext implements \Iterator
     /**
      * Unsubscribes from the specified channels using a pattern.
      *
-     * @param mixed $arg,... One or more channel name patterns.
+     * @param string ... One or more channel name patterns.
      */
-    public function punsubscribe(/* arguments */)
+    public function punsubscribe(/* ... */)
     {
         $this->writeCommand(self::PUNSUBSCRIBE, func_get_args());
     }

+ 2 - 0
lib/Predis/PubSub/PubSubContext.php

@@ -115,6 +115,8 @@ class PubSubContext extends AbstractPubSubContext
                 if ($response[2] === 0) {
                     $this->invalidate();
                 }
+                // The missing break here is intentional as we must process
+                // subscriptions and unsubscriptions as standard messages.
 
             case self::MESSAGE:
                 return (object) array(

+ 3 - 3
lib/Predis/Transaction/MultiExecContext.php

@@ -200,8 +200,8 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa
     /**
      * Executes the specified Redis command.
      *
-     * @param  CommandInterface $command A Redis command.
-     * @return mixed
+     * @param CommandInterface $command Command instance.
+     * @return $this|mixed
      */
     public function executeCommand(CommandInterface $command)
     {
@@ -352,7 +352,7 @@ class MultiExecContext implements BasicClientInterface, ExecutableContextInterfa
                     $this->discard();
                 }
 
-                return;
+                return null;
             }
 
             $reply = $this->client->exec();

+ 1 - 1
tests/PHPUnit/PredisCommandTestCase.php

@@ -48,7 +48,7 @@ abstract class PredisCommandTestCase extends PredisTestCase
     /**
      * Returns a new client instance.
      *
-     * @param  bool   $connect Flush selected database before returning the client.
+     * @param  bool   $flushdb Flush selected database before returning the client.
      * @return Client
      */
     public function getClient($flushdb = true)

+ 1 - 0
tests/PHPUnit/PredisProfileTestCase.php

@@ -21,6 +21,7 @@ abstract class PredisProfileTestCase extends PredisTestCase
     /**
      * Returns a new instance of the tested profile.
      *
+     * @param  string                 $version Version of Redis.
      * @return ServerProfileInterface
      */
     protected function getProfile($version = null)

+ 16 - 11
tests/PHPUnit/PredisTestCase.php

@@ -24,8 +24,9 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
      * Verifies that a Redis command is a valid Predis\Command\CommandInterface
      * instance with the specified ID and command arguments.
      *
-     * @param string|CommandInterface $command   Expected command or command ID.
-     * @param array                   $arguments Expected command arguments.
+     * @param  string|CommandInterface $command   Expected command or command ID.
+     * @param  array                   $arguments Expected command arguments.
+     * @return RedisCommandConstraint
      */
     public function isRedisCommand($command = null, array $arguments = null)
     {
@@ -122,7 +123,7 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
     /**
      * Returns a new instance of server profile.
      *
-     * @param  array                  $additional Additional connection parameters.
+     * @param  string                 $version Redis profile.
      * @return ServerProfileInterface
      */
     protected function getProfile($version = null)
@@ -133,7 +134,9 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
     /**
      * Returns a new client instance.
      *
-     * @param  bool   $connect Flush selected database before returning the client.
+     * @param  array  $parameters Additional connection parameters.
+     * @param  array  $options    Additional client options.
+     * @param  bool   $flushdb    Flush selected database before returning the client.
      * @return Client
      */
     protected function createClient(array $parameters = null, array $options = null, $flushdb = true)
@@ -161,9 +164,10 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * @param  string                              $expectedVersion Expected redis version
-     * @param  string                              $operator        Comparison operator.
-     * @throws \PHPUnit_Framework_SkippedTestError when expected redis version is not met
+     * @param  string                             $expectedVersion Expected redis version.
+     * @param  string                             $operator        Comparison operator.
+     * @param  callable                           $callback        Callback for matching version.
+     * @throws PHPUnit_Framework_SkippedTestError When expected redis version is not met.
      */
     protected function executeOnRedisVersion($expectedVersion, $operator, $callback)
     {
@@ -190,14 +194,15 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * @param  string                              $expectedVersion Expected redis version
-     * @param  string                              $operator        Comparison operator.
-     * @throws \PHPUnit_Framework_SkippedTestError when expected redis version is not met
+     * @param  string                             $expectedVersion Expected redis version.
+     * @param  string                             $operator        Comparison operator.
+     * @param  callable                           $callback        Callback for matching version.
+     * @throws PHPUnit_Framework_SkippedTestError When expected redis version is not met.
      */
     protected function executeOnProfileVersion($expectedVersion, $operator, $callback)
     {
         $profile = $this->getProfile();
-        $comparation = version_compare($profile->getVersion(), $expectedVersion);
+        $comparation = version_compare($version = $profile->getVersion(), $expectedVersion);
 
         if ($match = eval("return $comparation $operator 0;")) {
             call_user_func($callback, $this, $version);

+ 3 - 2
tests/PHPUnit/RedisCommandConstraint.php

@@ -20,13 +20,14 @@ class RedisCommandConstraint extends PHPUnit_Framework_Constraint
     protected $arguments;
 
     /**
-     * @param array $array
+     * @param string|CommandInterface $command   Expected command ID or instance.
+     * @param array                   $arguments Expected command arguments.
      */
     public function __construct($command = null, array $arguments = null)
     {
         if ($command instanceof CommandInterface) {
             $this->commandID = strtoupper($command->getId());
-            $this->arguments = $arguments ?: $commant->getArguments();
+            $this->arguments = $arguments ?: $command->getArguments();
         } else {
             $this->commandID = strtoupper($command);
             $this->arguments = $arguments;

+ 4 - 4
tests/Predis/CommunicationExceptionTest.php

@@ -97,10 +97,10 @@ class CommunicationExceptionTest extends PredisTestCase
     /**
      * Returns a connection exception instance.
      *
-     * @param  SingleConnectionInterface $message Connection instance.
-     * @param  string                    $message Exception message.
-     * @param  int                       $code    Exception code.
-     * @param  \Exception                $inner   Inner exception.
+     * @param  Connection\SingleConnectionInterface $connection Connection instance.
+     * @param  string                               $message    Exception message.
+     * @param  int                                  $code       Exception code.
+     * @param  \Exception                           $inner      Inner exception.
      * @return \Exception
      */
     protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null)

+ 12 - 0
tests/Predis/Connection/PhpiredisConnectionTest.php

@@ -86,6 +86,18 @@ class PhpiredisConnectionTest extends PredisConnectionTestCase
         $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange));
     }
 
+     /**
+      * @group connected
+      * @expectedException Predis\Connection\ConnectionException
+      * @expectedExceptionMessage Cannot resolve the address of 'bogus.tld'.
+      */
+     public function testThrowsExceptionOnUnresolvableHostname()
+     {
+         $parameters = $this->getParameters(array('host' => 'bogus.tld'));
+         $connection = new PhpiredisConnection($parameters);
+         $connection->connect();
+     }
+
     /**
      * @group connected
      * @expectedException Predis\Protocol\ProtocolException

+ 1 - 0
tests/Predis/Connection/WebdisConnectionTest.php

@@ -169,6 +169,7 @@ class WebdisConnectionTest extends PredisTestCase
     /**
      * Returns a new instance of a connection instance.
      *
+     * @param  mixed            $profile    Redis profile.
      * @param  array            $parameters Additional connection parameters.
      * @return WebdisConnection
      */

+ 29 - 9
tests/Predis/Pipeline/PipelineContextTest.php

@@ -74,6 +74,20 @@ class PipelineContextTest extends PredisTestCase
         $this->assertSame($pipeline, $pipeline->echo('one')->echo('two')->echo('three'));
     }
 
+    /**
+     * @group disconnected
+     */
+     public function testExecuteReturnsPipelineForFluentInterface()
+     {
+        $profile = ServerProfile::getDefault();
+        $connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
+
+        $pipeline = new PipelineContext(new Client($connection));
+        $command = $profile->createCommand('echo', array('one'));
+
+        $this->assertSame($pipeline, $pipeline->executeCommand($command));
+     }
+
     /**
      * @group disconnected
      */
@@ -239,6 +253,8 @@ class PipelineContextTest extends PredisTestCase
      */
     public function testExecuteWithCallableArgumentHandlesExceptions()
     {
+        $exception = null;
+
         $connection = $this->getMock('Predis\Connection\SingleConnectionInterface');
         $connection->expects($this->never())->method('writeCommand');
         $connection->expects($this->never())->method('readResponse');
@@ -254,8 +270,8 @@ class PipelineContextTest extends PredisTestCase
                 throw new ClientException('TEST');
                 $pipe->echo('two');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ClientException', $exception);
@@ -322,6 +338,8 @@ class PipelineContextTest extends PredisTestCase
      */
     public function testIntegrationWithClientExceptionInCallableBlock()
     {
+        $exception = null;
+
         $client = $this->getClient();
 
         try {
@@ -329,8 +347,8 @@ class PipelineContextTest extends PredisTestCase
                 $pipe->set('foo', 'bar');
                 throw new ClientException('TEST');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ClientException', $exception);
@@ -343,6 +361,8 @@ class PipelineContextTest extends PredisTestCase
      */
     public function testIntegrationWithServerExceptionInCallableBlock()
     {
+        $exception = null;
+
         $client = $this->getClient();
 
         try {
@@ -353,8 +373,8 @@ class PipelineContextTest extends PredisTestCase
                 $pipe->lpush('foo', 'bar');
                 $pipe->set('hoge', 'piyo');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ServerException', $exception);
@@ -388,9 +408,9 @@ class PipelineContextTest extends PredisTestCase
      * Returns a client instance connected to the specified Redis
      * server instance to perform integration tests.
      *
-     * @return array  Additional connection parameters.
-     * @return array  Additional client options.
-     * @return Client New client instance.
+     * @param  array  $parameters Additional connection parameters.
+     * @param  array  $options    Additional client options.
+     * @return Client
      */
     protected function getClient(array $parameters = array(), array $options = array())
     {

+ 2 - 2
tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php

@@ -42,7 +42,7 @@ class ResponseBulkHandlerTest extends PredisTestCase
     public function testBulk()
     {
         $bulk = "This is a bulk string.";
-        $bulkLengh = (string) strlen($bulk);
+        $bulkLengh = strlen($bulk);
 
         $handler = new ResponseBulkHandler();
 
@@ -54,7 +54,7 @@ class ResponseBulkHandlerTest extends PredisTestCase
                    ->with($this->equalTo($bulkLengh + 2))
                    ->will($this->returnValue("$bulk\r\n"));
 
-        $this->assertSame($bulk, $handler->handle($connection, $bulkLengh));
+        $this->assertSame($bulk, $handler->handle($connection, (string) $bulkLengh));
     }
 
     /**

+ 0 - 2
tests/Predis/Replication/ReplicationStrategyTest.php

@@ -12,7 +12,6 @@
 namespace Predis\Replication;
 
 use PredisTestCase;
-use Predis\Command\CommandInterface;
 use Predis\Profile\ServerProfile;
 
 /**
@@ -240,7 +239,6 @@ class ReplicationStrategyTest extends PredisTestCase
     {
         $commands = array(
             /* commands operating on the connection */
-            'EXISTS'                => 'read',
             'AUTH'                  => 'read',
             'SELECT'                => 'read',
             'ECHO'                  => 'read',

+ 23 - 14
tests/Predis/Transaction/MultiExecContextTest.php

@@ -89,6 +89,8 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testCannotMixExecutionWithFluentInterfaceAndCallable()
     {
+        $exception = null;
+
         $commands = array();
 
         $callback = $this->getExecuteCallback(null, $commands);
@@ -100,8 +102,8 @@ class MultiExecContextTest extends PredisTestCase
             $tx->echo('foo')->execute(function ($tx) {
                 $tx->echo('bar');
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ClientException', $exception);
@@ -419,6 +421,8 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testHandlesStandardExceptionsInBlock()
     {
+        $exception = null;
+
         $commands = array();
         $expected = array('foobar', true);
 
@@ -434,7 +438,7 @@ class MultiExecContextTest extends PredisTestCase
 
                 throw new \RuntimeException('TEST');
             });
-        } catch (\Exception $ex) {
+        } catch (\Exception $exception) {
             // NOOP
         }
 
@@ -461,7 +465,7 @@ class MultiExecContextTest extends PredisTestCase
                 $tx->echo('ERR Invalid operation');
                 $tx->get('foo');
             });
-        } catch (ServerException $ex) {
+        } catch (ServerException $exception) {
             $tx->discard();
         }
 
@@ -478,16 +482,17 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testIntegrationHandlesStandardExceptionsInBlock()
     {
-        $client = $this->getClient();
         $exception = null;
 
+        $client = $this->getClient();
+
         try {
             $client->multiExec(function ($tx) {
                 $tx->set('foo', 'bar');
                 throw new \RuntimeException("TEST");
             });
-        } catch (\Exception $ex) {
-            $exception = $ex;
+        } catch (\Exception $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('RuntimeException', $exception);
@@ -499,8 +504,9 @@ class MultiExecContextTest extends PredisTestCase
      */
     public function testIntegrationThrowsExceptionOnRedisErrorInBlock()
     {
-        $client = $this->getClient();
         $exception = null;
+
+        $client = $this->getClient();
         $value = (string) rand();
 
         try {
@@ -509,8 +515,8 @@ class MultiExecContextTest extends PredisTestCase
                 $tx->lpush('foo', 'bar');
                 $tx->set('foo', $value);
             });
-        } catch (ServerException $ex) {
-            $exception = $ex;
+        } catch (ServerException $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\ResponseErrorInterface', $exception);
@@ -559,6 +565,7 @@ class MultiExecContextTest extends PredisTestCase
     public function testIntegrationWritesOnWatchedKeysAbortTransaction()
     {
         $exception = null;
+
         $client1 = $this->getClient();
         $client2 = $this->getClient();
 
@@ -568,8 +575,8 @@ class MultiExecContextTest extends PredisTestCase
                 $tx->get('sentinel');
                 $client2->set('sentinel', 'client2');
             });
-        } catch (AbortedMultiExecException $ex) {
-            $exception = $ex;
+        } catch (AbortedMultiExecException $exception) {
+            // NOOP
         }
 
         $this->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $exception);
@@ -650,6 +657,7 @@ class MultiExecContextTest extends PredisTestCase
      * of the underlying connection.
      *
      * @param  \Closure         $executeCallback
+     * @param  array            $options
      * @return MultiExecContext
      */
     protected function getMockedTransaction($executeCallback, $options = array())
@@ -664,8 +672,9 @@ class MultiExecContextTest extends PredisTestCase
     /**
      * Returns a callback that emulates a server-side MULTI/EXEC transaction context.
      *
-     * @param  array    $expected Expected replies.
-     * @param  array    $commands Reference to an array that stores the whole flow of commands.
+     * @param  array    $expected Expected responses.
+     * @param  array    $commands Reference to an array storing the whole flow of commands.
+     * @param  array    $cas      Check and set operations performed by the transaction.
      * @return \Closure
      */
     protected function getExecuteCallback($expected = array(), &$commands = array(), &$cas = array())