Browse Source

Run php-cs against source code.

Daniele Alessandri 10 years ago
parent
commit
202c558103

+ 14 - 7
examples/custom_cluster_distributor.php

@@ -19,21 +19,25 @@ use Predis\Connection\Aggregate\PredisCluster;
 use Predis\Cluster\Distributor\DistributorInterface;
 use Predis\Cluster\Hash\HashGeneratorInterface;
 
-class NaiveDistributor implements DistributorInterface, HashGeneratorInterface {
+class NaiveDistributor implements DistributorInterface, HashGeneratorInterface
+{
     private $nodes;
     private $nodesCount;
 
-    public function __construct() {
+    public function __construct()
+    {
         $this->nodes = array();
         $this->nodesCount = 0;
     }
 
-    public function add($node, $weight = null) {
+    public function add($node, $weight = null)
+    {
         $this->nodes[] = $node;
         $this->nodesCount++;
     }
 
-    public function remove($node) {
+    public function remove($node)
+    {
         $this->nodes = array_filter($this->nodes, function ($n) use ($node) {
             return $n !== $node;
         });
@@ -41,7 +45,8 @@ class NaiveDistributor implements DistributorInterface, HashGeneratorInterface {
         $this->nodesCount = count($this->nodes);
     }
 
-    public function get($key) {
+    public function get($key)
+    {
         if (0 === $count = $this->nodesCount) {
             throw new RuntimeException('No connections.');
         }
@@ -49,11 +54,13 @@ class NaiveDistributor implements DistributorInterface, HashGeneratorInterface {
         return $this->nodes[$count > 1 ? abs($key % $count) : 0];
     }
 
-    public function hash($value) {
+    public function hash($value)
+    {
         return crc32($value);
     }
 
-    public function getHashGenerator() {
+    public function getHashGenerator()
+    {
         return $this;
     }
 }

+ 12 - 6
examples/debuggable_connection.php

@@ -19,17 +19,20 @@ require __DIR__.'/shared.php';
 use Predis\Command\CommandInterface;
 use Predis\Connection\StreamConnection;
 
-class SimpleDebuggableConnection extends StreamConnection {
+class SimpleDebuggableConnection extends StreamConnection
+{
     private $tstart = 0;
     private $debugBuffer = array();
 
-    public function connect() {
+    public function connect()
+    {
         $this->tstart = microtime(true);
 
         parent::connect();
     }
 
-    private function storeDebug(CommandInterface $command, $direction) {
+    private function storeDebug(CommandInterface $command, $direction)
+    {
         $firtsArg = $command->getArgument(0);
         $timestamp = round(microtime(true) - $this->tstart, 4);
 
@@ -41,20 +44,23 @@ class SimpleDebuggableConnection extends StreamConnection {
         $this->debugBuffer[] = $debug;
     }
 
-    public function writeRequest(CommandInterface $command) {
+    public function writeRequest(CommandInterface $command)
+    {
         parent::writeRequest($command);
 
         $this->storeDebug($command, '->');
     }
 
-    public function readResponse(CommandInterface $command) {
+    public function readResponse(CommandInterface $command)
+    {
         $response = parent::readResponse($command);
         $this->storeDebug($command, '<-');
 
         return $response;
     }
 
-    public function getDebugBuffer() {
+    public function getDebugBuffer()
+    {
         return $this->debugBuffer;
     }
 }

+ 10 - 5
examples/dispatcher_loop.php

@@ -29,22 +29,27 @@ $client = new Predis\Client($single_server + array('read_write_timeout' => 0));
 $dispatcher = new Predis\PubSub\DispatcherLoop($client);
 
 // Demonstrate how to use a callable class as a callback for Predis\DispatcherLoop.
-class EventsListener implements Countable {
+class EventsListener implements Countable
+{
     private $events;
 
-    public function __construct() {
+    public function __construct()
+    {
         $this->events = array();
     }
 
-    public function count() {
+    public function count()
+    {
         return count($this->events);
     }
 
-    public function getEvents() {
+    public function getEvents()
+    {
         return $this->events;
     }
 
-    public function __invoke($payload) {
+    public function __invoke($payload)
+    {
         $this->events[] = $payload;
     }
 }

+ 4 - 2
examples/replication_complex.php

@@ -27,7 +27,8 @@ use Predis\Replication\ReplicationStrategy;
 // Define a new script command that returns all the fields of a variable number
 // of hashes with a single roundtrip.
 
-class HashMultipleGetAll extends ScriptCommand {
+class HashMultipleGetAll extends ScriptCommand
+{
     const BODY = <<<LUA
 local hashes = {}
 for _, key in pairs(KEYS) do
@@ -37,7 +38,8 @@ end
 return hashes
 LUA;
 
-    public function getScript() {
+    public function getScript()
+    {
         return self::BODY;
     }
 }

+ 1 - 1
examples/shared.php

@@ -15,7 +15,7 @@ function redis_version($info)
 {
     if (isset($info['Server']['redis_version'])) {
         return $info['Server']['redis_version'];
-    } else if (isset($info['redis_version'])) {
+    } elseif (isset($info['redis_version'])) {
         return $info['redis_version'];
     } else {
         return 'unknown version';

+ 0 - 4
src/Cluster/RedisStrategy.php

@@ -11,10 +11,6 @@
 
 namespace Predis\Cluster;
 
-use InvalidArgumentException;
-use Predis\Command\CommandInterface;
-use Predis\Command\ScriptCommand;
-
 /**
  * Default class used by Predis to calculate hashes out of keys of
  * commands supported by redis-cluster.

+ 1 - 1
src/Command/RawCommand.php

@@ -44,7 +44,7 @@ class RawCommand implements CommandInterface
     /**
      * Creates a new raw command using a variadic method.
      *
-     * @param string $commandID Redis command ID.
+     * @param  string           $commandID Redis command ID.
      * @param string ... Arguments list for the command.
      * @return CommandInterface
      */

+ 0 - 1
src/Connection/WebdisConnection.php

@@ -14,7 +14,6 @@ namespace Predis\Connection;
 use InvalidArgumentException;
 use Predis\NotSupportedException;
 use Predis\Command\CommandInterface;
-use Predis\Connection\ConnectionException;
 use Predis\Protocol\ProtocolException;
 use Predis\Response\Error as ErrorResponse;
 use Predis\Response\Status as StatusResponse;

+ 4 - 4
src/Pipeline/Pipeline.php

@@ -51,8 +51,8 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface
     /**
      * Queues a command into the pipeline buffer.
      *
-     * @param string $method    Command ID.
-     * @param array  $arguments Arguments for the command.
+     * @param  string $method    Command ID.
+     * @param  array  $arguments Arguments for the command.
      * @return $this
      */
     public function __call($method, $arguments)
@@ -76,7 +76,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface
     /**
      * Queues a command instance into the pipeline buffer.
      *
-     * @param CommandInterface $command Command instance to be queued in the buffer.
+     * @param  CommandInterface $command Command instance to be queued in the buffer.
      * @return $this
      */
     public function executeCommand(CommandInterface $command)
@@ -152,7 +152,7 @@ class Pipeline implements BasicClientInterface, ExecutableContextInterface
     /**
      * 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.
+     * @param  bool  $send Specifies if the commands in the buffer should be sent to Redis.
      * @return $this
      */
     public function flushPipeline($send = true)

+ 2 - 2
src/Transaction/MultiExec.php

@@ -184,7 +184,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
     /**
      * Executes the specified Redis command.
      *
-     * @param CommandInterface $command Command instance.
+     * @param  CommandInterface $command Command instance.
      * @return $this|mixed
      */
     public function executeCommand(CommandInterface $command)
@@ -199,7 +199,7 @@ class MultiExec implements BasicClientInterface, ExecutableContextInterface
 
         if ($response instanceof StatusResponse && $response == 'QUEUED') {
             $this->commands->enqueue($command);
-        } else if ($response instanceof ErrorResponseInterface) {
+        } elseif ($response instanceof ErrorResponseInterface) {
             throw new AbortedMultiExecException($this, $response->getMessage());
         } else {
             $this->onProtocolError('The server did not return a +QUEUED status response.');

+ 0 - 3
tests/Predis/ClientTest.php

@@ -13,9 +13,6 @@ namespace Predis;
 
 use ReflectionProperty;
 use PredisTestCase;
-use Predis\Connection;
-use Predis\Profile;
-use Predis\Response;
 
 /**
  *

+ 1 - 1
tests/Predis/Collection/Iterator/SortedSetKeyTest.php

@@ -17,7 +17,7 @@ use Predis\Profile;
 /**
  * @group realm-iterators
  */
-class SortedSetTest extends PredisTestCase
+class SortedSetKeyTest extends PredisTestCase
 {
     /**
      * @group disconnected

+ 0 - 1
tests/Predis/CommunicationExceptionTest.php

@@ -12,7 +12,6 @@
 namespace Predis;
 
 use PredisTestCase;
-use Predis\Connection;
 
 /**
  *

+ 0 - 1
tests/Predis/Connection/Aggregate/RedisClusterTest.php

@@ -626,7 +626,6 @@ class RedisClusterTest extends PredisTestCase
             array( 7168,  8191, array('10.1.0.52', 6394), array('10.1.0.51', 6394)),
         );
 
-
         $command = Command\RawCommand::create('CLUSTER', 'SLOTS');
 
         $connection1 = $this->getMockConnection('tcp://10.1.0.51:6384');

+ 0 - 0
tests/Predis/Connection/ComposableStreamConnectionTest.php → tests/Predis/Connection/CompositeStreamConnectionTest.php