Explorar el Código

Apply fixes for consistency.

I know that importing classes and interfaces for the root namespace
using the "use" directive is weird and totally uncommon...
Daniele Alessandri hace 11 años
padre
commit
2aa97e3e61

+ 2 - 1
lib/Predis/Cluster/PredisStrategy.php

@@ -11,6 +11,7 @@
 
 namespace Predis\Cluster;
 
+use InvalidArgumentException;
 use Predis\Cluster\Hash\HashGeneratorInterface;
 use Predis\Command\CommandInterface;
 use Predis\Command\ScriptCommand;
@@ -193,7 +194,7 @@ class PredisStrategy implements StrategyInterface
         }
 
         if (!is_callable($callback)) {
-            throw new \InvalidArgumentException(
+            throw new InvalidArgumentException(
                 "The argument must be a callable object or NULL."
             );
         }

+ 2 - 1
lib/Predis/Cluster/RedisStrategy.php

@@ -11,6 +11,7 @@
 
 namespace Predis\Cluster;
 
+use InvalidArgumentException;
 use Predis\Command\CommandInterface;
 use Predis\Command\ScriptCommand;
 
@@ -178,7 +179,7 @@ class RedisStrategy implements StrategyInterface
         }
 
         if (!is_callable($callback)) {
-            throw new \InvalidArgumentException(
+            throw new InvalidArgumentException(
                 "The argument must be a callable object or NULL."
             );
         }

+ 3 - 2
lib/Predis/CommunicationException.php

@@ -11,6 +11,7 @@
 
 namespace Predis;
 
+use Exception;
 use Predis\Connection\SingleConnectionInterface;
 
 /**
@@ -26,13 +27,13 @@ abstract class CommunicationException extends PredisException
      * @param SingleConnectionInterface $connection     Connection that generated the exception.
      * @param string                    $message        Error message.
      * @param int                       $code           Error code.
-     * @param \Exception                $innerException Inner exception for wrapping the original error.
+     * @param Exception                 $innerException Inner exception for wrapping the original error.
      */
     public function __construct(
         SingleConnectionInterface $connection,
         $message = null,
         $code = null,
-        \Exception $innerException = null
+        Exception $innerException = null
     ) {
         parent::__construct($message, $code, $innerException);
         $this->connection = $connection;

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

@@ -11,6 +11,7 @@
 
 namespace Predis\Connection;
 
+use InvalidArgumentException;
 use Predis\Command\CommandInterface;
 use Predis\Protocol\ProtocolProcessorInterface;
 use Predis\Protocol\Text\ProtocolProcessor as TextProtocolProcessor;
@@ -59,7 +60,7 @@ class ComposableStreamConnection extends StreamConnection implements ComposableC
     public function readBuffer($length)
     {
         if ($length <= 0) {
-            throw new \InvalidArgumentException('Length parameter must be greater than 0.');
+            throw new InvalidArgumentException('Length parameter must be greater than 0.');
         }
 
         $value = '';

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

@@ -11,6 +11,7 @@
 
 namespace Predis\Connection;
 
+use ArrayIterator;
 use Countable;
 use IteratorAggregate;
 use Predis\NotSupportedException;
@@ -190,7 +191,7 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co
      */
     public function getIterator()
     {
-        return new \ArrayIterator($this->pool);
+        return new ArrayIterator($this->pool);
     }
 
     /**

+ 3 - 1
lib/Predis/PredisException.php

@@ -11,11 +11,13 @@
 
 namespace Predis;
 
+use Exception;
+
 /**
  * Base exception class for Predis-related errors.
  *
  * @author Daniele Alessandri <suppakilla@gmail.com>
  */
-abstract class PredisException extends \Exception
+abstract class PredisException extends Exception
 {
 }

+ 4 - 4
tests/PHPUnit/PredisTestCase.php

@@ -162,7 +162,7 @@ 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
+     * @throws PHPUnit_Framework_SkippedTestError  When expected redis version is not met
      */
     protected function executeOnRedisVersion($expectedVersion, $operator, $callback)
     {
@@ -191,7 +191,7 @@ 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
+     * @throws PHPUnit_Framework_SkippedTestError  When expected redis version is not met
      */
     protected function executeOnProfileVersion($expectedVersion, $operator, $callback)
     {
@@ -209,8 +209,8 @@ abstract class PredisTestCase extends PHPUnit_Framework_TestCase
      * @param  string                              $expectedVersion Expected redis version.
      * @param  string                              $message         Optional message.
      * @param  bool                                $remote          Based on local profile or remote redis version.
-     * @throws RuntimeException                    when unable to retrieve server info or redis version
-     * @throws \PHPUnit_Framework_SkippedTestError when expected redis version is not met
+     * @throws RuntimeException                    When unable to retrieve server info or redis version
+     * @throws PHPUnit_Framework_SkippedTestError  When expected redis version is not met
      */
     public function markTestSkippedOnRedisVersionBelow($expectedVersion, $message = '', $remote = true)
     {

+ 4 - 3
tests/Predis/ClientTest.php

@@ -11,6 +11,7 @@
 
 namespace Predis;
 
+use ReflectionProperty;
 use PredisTestCase;
 use Predis\Connection;
 use Predis\Profile;
@@ -690,7 +691,7 @@ class ClientTest extends PredisTestCase
 
         $this->assertInstanceOf('Predis\PubSub\Consumer', $pubsub = $client->pubSubLoop($options));
 
-        $reflection = new \ReflectionProperty($pubsub, 'options');
+        $reflection = new ReflectionProperty($pubsub, 'options');
         $reflection->setAccessible(true);
 
         $this->assertSame($options, $reflection->getValue($pubsub));
@@ -743,11 +744,11 @@ class ClientTest extends PredisTestCase
 
         $this->assertInstanceOf('Predis\Transaction\MultiExec', $tx = $client->transaction($options));
 
-        $property = new \ReflectionProperty($tx, 'modeCAS');
+        $property = new ReflectionProperty($tx, 'modeCAS');
         $property->setAccessible(true);
         $this->assertSame($options['cas'], $property->getValue($tx));
 
-        $property = new \ReflectionProperty($tx, 'attempts');
+        $property = new ReflectionProperty($tx, 'attempts');
         $property->setAccessible(true);
         $this->assertSame($options['retry'], $property->getValue($tx));
     }