Forráskód Böngészése

Minor code styling changes in Predis\Connection.

Daniele Alessandri 11 éve
szülő
commit
cf70d2f20e

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

@@ -136,7 +136,11 @@ abstract class AbstractConnection implements SingleConnectionInterface
      */
     protected function onConnectionError($message, $code = null)
     {
-        CommunicationException::handle(new ConnectionException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code));
+        CommunicationException::handle(
+            new ConnectionException(
+                $this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code
+            )
+        );
     }
 
     /**
@@ -146,7 +150,11 @@ abstract class AbstractConnection implements SingleConnectionInterface
      */
     protected function onProtocolError($message)
     {
-        CommunicationException::handle(new ProtocolException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]"));
+        CommunicationException::handle(
+            new ProtocolException(
+                $this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]"
+            )
+        );
     }
 
     /**

+ 7 - 5
lib/Predis/Connection/ConnectionFactory.php

@@ -11,6 +11,8 @@
 
 namespace Predis\Connection;
 
+use InvalidArgumentException;
+use ReflectionClass;
 use Predis\Command;
 
 /**
@@ -41,10 +43,10 @@ class ConnectionFactory implements ConnectionFactoryInterface
             return $initializer;
         }
 
-        $initializerReflection = new \ReflectionClass($initializer);
+        $class = new ReflectionClass($initializer);
 
-        if (!$initializerReflection->isSubclassOf('Predis\Connection\SingleConnectionInterface')) {
-            throw new \InvalidArgumentException(
+        if (!$class->isSubclassOf('Predis\Connection\SingleConnectionInterface')) {
+            throw new InvalidArgumentException(
                 'A connection initializer must be a valid connection class or a callable object'
             );
         }
@@ -80,7 +82,7 @@ class ConnectionFactory implements ConnectionFactoryInterface
         $scheme = $parameters->scheme;
 
         if (!isset($this->schemes[$scheme])) {
-            throw new \InvalidArgumentException("Unknown connection scheme: $scheme");
+            throw new InvalidArgumentException("Unknown connection scheme: $scheme");
         }
 
         $initializer = $this->schemes[$scheme];
@@ -93,7 +95,7 @@ class ConnectionFactory implements ConnectionFactoryInterface
         }
 
         if (!$connection instanceof SingleConnectionInterface) {
-            throw new \InvalidArgumentException(
+            throw new InvalidArgumentException(
                 'Objects returned by connection initializers must implement ' .
                 'Predis\Connection\SingleConnectionInterface'
             );

+ 4 - 2
lib/Predis/Connection/MasterSlaveReplication.php

@@ -11,6 +11,8 @@
 
 namespace Predis\Connection;
 
+use InvalidArgumentException;
+use RuntimeException;
 use Predis\Command\CommandInterface;
 use Predis\Replication\ReplicationStrategy;
 
@@ -42,7 +44,7 @@ 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.');
         }
     }
 
@@ -142,7 +144,7 @@ class MasterSlaveReplication implements ReplicationConnectionInterface
             $connection = $this->getConnectionById($connection);
         }
         if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) {
-            throw new \InvalidArgumentException('The specified connection is not valid.');
+            throw new InvalidArgumentException('The specified connection is not valid.');
         }
 
         $this->current = $connection;

+ 4 - 2
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 the cluster.
+     * @param Distributor\DistributorInterface $distributor Distribution strategy used by cluster.
      */
     public function __construct(Distributor\DistributorInterface $distributor = null)
     {
@@ -132,7 +132,9 @@ class PredisCluster implements ClusterConnectionInterface, IteratorAggregate, Co
         $hash = $this->strategy->getHash($command);
 
         if (!isset($hash)) {
-            throw new NotSupportedException("Cannot use {$command->getId()} with a cluster of connections");
+            throw new NotSupportedException(
+                "Cannot use {$command->getId()} with a cluster of connections"
+            );
         }
 
         $node = $this->distributor->get($hash);

+ 4 - 2
lib/Predis/Connection/RedisCluster.php

@@ -11,6 +11,8 @@
 
 namespace Predis\Connection;
 
+use ArrayIterator;
+use OutOfBoundsException;
 use Predis\ClientException;
 use Predis\NotSupportedException;
 use Predis\Cluster;
@@ -178,7 +180,7 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C
     public function setSlots($first, $last, $connection)
     {
         if ($first < 0x0000 || $first > 0x3FFF || $last < 0x0000 || $last > 0x3FFF || $last < $first) {
-            throw new \OutOfBoundsException("Invalid slot values for $connection: [$first-$last]");
+            throw new OutOfBoundsException("Invalid slot values for $connection: [$first-$last]");
         }
 
         $this->slotsMap = $this->getSlotsMap() + array_fill($first, $last - $first + 1, (string) $connection);
@@ -325,7 +327,7 @@ class RedisCluster implements ClusterConnectionInterface, \IteratorAggregate, \C
      */
     public function getIterator()
     {
-        return new \ArrayIterator(array_values($this->pool));
+        return new ArrayIterator(array_values($this->pool));
     }
 
     /**