Procházet zdrojové kódy

Apply some coding style changes.

Daniele Alessandri před 13 roky
rodič
revize
20d872a306
100 změnil soubory, kde provedl 1011 přidání a 477 odebrání
  1. 8 3
      README.markdown
  2. 8 2
      bin/createPhar.php
  3. 172 75
      bin/createSingleFile.php
  4. 16 7
      examples/CustomDistributionStrategy.php
  5. 10 5
      examples/DispatcherLoop.php
  6. 14 11
      examples/MultiExecTransactionsWithCAS.php
  7. 1 0
      examples/PubSubContext.php
  8. 8 3
      examples/ServerSideScripting.php
  9. 18 7
      examples/SimpleDebuggableConnection.php
  10. 8 4
      lib/Predis/Autoloader.php
  11. 87 48
      lib/Predis/Client.php
  12. 2 1
      lib/Predis/ClientException.php
  13. 25 15
      lib/Predis/ClientOptions.php
  14. 35 14
      lib/Predis/Commands/Command.php
  15. 8 4
      lib/Predis/Commands/ConnectionAuth.php
  16. 8 4
      lib/Predis/Commands/ConnectionEcho.php
  17. 10 5
      lib/Predis/Commands/ConnectionPing.php
  18. 8 4
      lib/Predis/Commands/ConnectionQuit.php
  19. 8 4
      lib/Predis/Commands/ConnectionSelect.php
  20. 8 4
      lib/Predis/Commands/HashDelete.php
  21. 6 3
      lib/Predis/Commands/HashExists.php
  22. 4 2
      lib/Predis/Commands/HashGet.php
  23. 8 3
      lib/Predis/Commands/HashGetAll.php
  24. 6 3
      lib/Predis/Commands/HashGetMultiple.php
  25. 4 2
      lib/Predis/Commands/HashIncrementBy.php
  26. 4 2
      lib/Predis/Commands/HashKeys.php
  27. 4 2
      lib/Predis/Commands/HashLength.php
  28. 4 2
      lib/Predis/Commands/HashSet.php
  29. 9 3
      lib/Predis/Commands/HashSetMultiple.php
  30. 6 3
      lib/Predis/Commands/HashSetPreserve.php
  31. 4 2
      lib/Predis/Commands/HashValues.php
  32. 2 1
      lib/Predis/Commands/ICommand.php
  33. 11 5
      lib/Predis/Commands/KeyDelete.php
  34. 6 3
      lib/Predis/Commands/KeyExists.php
  35. 6 3
      lib/Predis/Commands/KeyExpire.php
  36. 6 3
      lib/Predis/Commands/KeyExpireAt.php
  37. 6 3
      lib/Predis/Commands/KeyKeys.php
  38. 4 2
      lib/Predis/Commands/KeyKeysV12x.php
  39. 8 4
      lib/Predis/Commands/KeyMove.php
  40. 6 3
      lib/Predis/Commands/KeyPersist.php
  41. 8 4
      lib/Predis/Commands/KeyRandom.php
  42. 6 3
      lib/Predis/Commands/KeyRename.php
  43. 6 3
      lib/Predis/Commands/KeyRenamePreserve.php
  44. 17 4
      lib/Predis/Commands/KeySort.php
  45. 4 2
      lib/Predis/Commands/KeyTimeToLive.php
  46. 4 2
      lib/Predis/Commands/KeyType.php
  47. 4 2
      lib/Predis/Commands/ListIndex.php
  48. 4 2
      lib/Predis/Commands/ListInsert.php
  49. 4 2
      lib/Predis/Commands/ListLength.php
  50. 4 2
      lib/Predis/Commands/ListPopFirst.php
  51. 8 4
      lib/Predis/Commands/ListPopFirstBlocking.php
  52. 4 2
      lib/Predis/Commands/ListPopLast.php
  53. 4 2
      lib/Predis/Commands/ListPopLastBlocking.php
  54. 8 4
      lib/Predis/Commands/ListPopLastPushHead.php
  55. 8 4
      lib/Predis/Commands/ListPopLastPushHeadBlocking.php
  56. 4 2
      lib/Predis/Commands/ListPushHead.php
  57. 4 2
      lib/Predis/Commands/ListPushHeadX.php
  58. 6 3
      lib/Predis/Commands/ListPushTail.php
  59. 4 2
      lib/Predis/Commands/ListPushTailX.php
  60. 4 2
      lib/Predis/Commands/ListRange.php
  61. 4 2
      lib/Predis/Commands/ListRemove.php
  62. 4 2
      lib/Predis/Commands/ListSet.php
  63. 4 2
      lib/Predis/Commands/ListTrim.php
  64. 8 3
      lib/Predis/Commands/PrefixHelpers.php
  65. 2 1
      lib/Predis/Commands/Processors/ICommandProcessor.php
  66. 2 2
      lib/Predis/Commands/Processors/ICommandProcessorChain.php
  67. 2 1
      lib/Predis/Commands/Processors/IProcessingSupport.php
  68. 10 5
      lib/Predis/Commands/Processors/KeyPrefixProcessor.php
  69. 26 13
      lib/Predis/Commands/Processors/ProcessorChain.php
  70. 6 3
      lib/Predis/Commands/PubSubPublish.php
  71. 10 5
      lib/Predis/Commands/PubSubSubscribe.php
  72. 4 2
      lib/Predis/Commands/PubSubSubscribeByPattern.php
  73. 8 4
      lib/Predis/Commands/PubSubUnsubscribe.php
  74. 4 2
      lib/Predis/Commands/PubSubUnsubscribeByPattern.php
  75. 8 4
      lib/Predis/Commands/ScriptedCommand.php
  76. 10 5
      lib/Predis/Commands/ServerBackgroundRewriteAOF.php
  77. 11 5
      lib/Predis/Commands/ServerBackgroundSave.php
  78. 15 6
      lib/Predis/Commands/ServerClient.php
  79. 8 4
      lib/Predis/Commands/ServerConfig.php
  80. 8 4
      lib/Predis/Commands/ServerDatabaseSize.php
  81. 10 4
      lib/Predis/Commands/ServerEval.php
  82. 4 2
      lib/Predis/Commands/ServerEvalSHA.php
  83. 8 4
      lib/Predis/Commands/ServerFlushAll.php
  84. 8 4
      lib/Predis/Commands/ServerFlushDatabase.php
  85. 23 7
      lib/Predis/Commands/ServerInfo.php
  86. 11 4
      lib/Predis/Commands/ServerInfoV26x.php
  87. 8 4
      lib/Predis/Commands/ServerLastSave.php
  88. 8 4
      lib/Predis/Commands/ServerMonitor.php
  89. 8 4
      lib/Predis/Commands/ServerObject.php
  90. 8 4
      lib/Predis/Commands/ServerSave.php
  91. 6 3
      lib/Predis/Commands/ServerShutdown.php
  92. 11 5
      lib/Predis/Commands/ServerSlaveOf.php
  93. 8 4
      lib/Predis/Commands/SetAdd.php
  94. 4 2
      lib/Predis/Commands/SetCardinality.php
  95. 6 3
      lib/Predis/Commands/SetDifference.php
  96. 4 2
      lib/Predis/Commands/SetDifferenceStore.php
  97. 10 5
      lib/Predis/Commands/SetIntersection.php
  98. 11 5
      lib/Predis/Commands/SetIntersectionStore.php
  99. 6 3
      lib/Predis/Commands/SetIsMember.php
  100. 4 2
      lib/Predis/Commands/SetMembers.php

+ 8 - 3
README.markdown

@@ -109,7 +109,8 @@ classes. This can be obtained by subclassing the `Predis\Network\IConnectionSing
 
 ``` php
 <?php
-class MyConnectionClass implements Predis\Network\IConnectionSingle {
+class MyConnectionClass implements Predis\Network\IConnectionSingle
+{
     // implementation goes here
 }
 
@@ -133,8 +134,12 @@ client instance at runtime. Actually, it is easier done than said:
 
 ``` php
 <?php
-class BrandNewRedisCommand extends Predis\Commands\Command {
-    public function getId() { return 'NEWCMD'; }
+class BrandNewRedisCommand extends Predis\Commands\Command
+{
+    public function getId()
+    {
+        return 'NEWCMD';
+    }
 }
 
 $redis = new Predis\Client();

+ 8 - 2
bin/createPhar.php

@@ -12,23 +12,29 @@ $options = array(
     'append_version' => true,
 );
 
-function getPharFilename($options) {
+function getPharFilename($options)
+{
     $filename = $options['name'];
+
     // NOTE: do not consider "append_version" with Phar compression do to a bug in
     // Phar::compress() when renaming phar archives containing dots in their name.
     if ($options['append_version'] && $options['compression'] === Phar::NONE) {
         $versionFile = @fopen(__DIR__ . '/../VERSION', 'r');
+
         if ($versionFile === false) {
             throw new Exception("Could not locate the VERSION file.");
         }
+
         $version = trim(fgets($versionFile));
         fclose($versionFile);
         $filename .= "_$version";
     }
+
     return "$filename.phar";
 }
 
-function getPharStub($options) {
+function getPharStub($options)
+{
     return <<<EOSTUB
 <?php
 Phar::mapPhar('predis.phar');

+ 172 - 75
bin/createSingleFile.php

@@ -13,8 +13,10 @@
 
 /* -------------------------------------------------------------------------- */
 
-class CommandLine {
-    public static function getOptions() {
+class CommandLine
+{
+    public static function getOptions()
+    {
         $parameters = array(
             's:'  => 'source:',
             'o:'  => 'output:',
@@ -23,6 +25,7 @@ class CommandLine {
         );
 
         $getops = getopt(implode(array_keys($parameters)), $parameters);
+
         $options = array(
             'source'  => __DIR__ . "/../lib/",
             'output'  => PredisFile::NS_ROOT . '.php',
@@ -35,14 +38,17 @@ class CommandLine {
                 case 'source':
                     $options['source'] = $value;
                     break;
+
                 case 'o':
                 case 'output':
                     $options['output'] = $value;
                     break;
+
                 case 'E':
                 case 'exclude-classes':
                     $options['exclude'] = @file($value, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: $value;
                     break;
+
                 case 'e':
                 case 'exclude':
                     $options['exclude'] = is_array($value) ? $value : array($value);
@@ -54,120 +60,151 @@ class CommandLine {
     }
 }
 
-class PredisFile {
+class PredisFile
+{
     const NS_ROOT = 'Predis';
+
     private $_namespaces;
 
-    public function __construct() {
+    public function __construct()
+    {
         $this->_namespaces = array();
     }
 
-    public static function from($libraryPath, Array $exclude = array()) {
+    public static function from($libraryPath, Array $exclude = array())
+    {
         $nsroot = self::NS_ROOT;
         $predisFile = new PredisFile();
         $libIterator = new RecursiveDirectoryIterator("$libraryPath$nsroot");
 
-        foreach (new RecursiveIteratorIterator($libIterator) as $classFile) {
+        foreach (new RecursiveIteratorIterator($libIterator) as $classFile)
+        {
             if (!$classFile->isFile()) {
                 continue;
             }
 
             $namespace = strtr(str_replace($libraryPath, '', $classFile->getPath()), '/', '\\');
+
             if (in_array(sprintf('%s\\%s', $namespace, $classFile->getBasename('.php')), $exclude)) {
                 continue;
             }
 
             $phpNamespace = $predisFile->getNamespace($namespace);
+
             if ($phpNamespace === false) {
                 $phpNamespace = new PhpNamespace($namespace);
                 $predisFile->addNamespace($phpNamespace);
             }
+
             $phpClass = new PhpClass($phpNamespace, $classFile);
         }
+
         return $predisFile;
     }
 
-    public function addNamespace(PhpNamespace $namespace) {
+    public function addNamespace(PhpNamespace $namespace)
+    {
         if (isset($this->_namespaces[(string)$namespace])) {
             throw new InvalidArgumentException("Duplicated namespace");
         }
         $this->_namespaces[(string)$namespace] = $namespace;
     }
 
-    public function getNamespaces() {
+    public function getNamespaces()
+    {
         return $this->_namespaces;
     }
 
-    public function getNamespace($namespace) {
+    public function getNamespace($namespace)
+    {
         if (!isset($this->_namespaces[$namespace])) {
             return false;
         }
+
         return $this->_namespaces[$namespace];
     }
 
-    public function getClassByFQN($classFqn) {
+    public function getClassByFQN($classFqn)
+    {
         if (($nsLastPos = strrpos($classFqn, '\\')) !== false) {
             $namespace = $this->getNamespace(substr($classFqn, 0, $nsLastPos));
             if ($namespace === false) {
                 return null;
             }
             $className = substr($classFqn, $nsLastPos + 1);
+
             return $namespace->getClass($className);
         }
+
         return null;
     }
 
-    private function calculateDependencyScores(&$classes, $fqn) {
+    private function calculateDependencyScores(&$classes, $fqn)
+    {
         if (!isset($classes[$fqn])) {
             $classes[$fqn] = 0;
         }
+
         $classes[$fqn] += 1;
+
         if (($phpClass = $this->getClassByFQN($fqn)) === null) {
-            throw new RuntimeException("Cannot found the class $fqn which is required by other subclasses. Are you missing a file?");
+            throw new RuntimeException(
+                "Cannot found the class $fqn which is required by other subclasses. Are you missing a file?"
+            );
         }
+
         foreach ($phpClass->getDependencies() as $fqn) {
             $this->calculateDependencyScores($classes, $fqn);
         }
     }
 
-    private function getDependencyScores() {
+    private function getDependencyScores()
+    {
         $classes = array();
+
         foreach ($this->getNamespaces() as $phpNamespace) {
             foreach ($phpNamespace->getClasses() as $phpClass) {
                 $this->calculateDependencyScores($classes, $phpClass->getFQN());
             }
         }
+
         return $classes;
     }
 
-    private function getOrderedNamespaces($dependencyScores) {
+    private function getOrderedNamespaces($dependencyScores)
+    {
         $namespaces = array_fill_keys(array_unique(
             array_map(
                 function($fqn) { return PhpNamespace::extractName($fqn); },
                 array_keys($dependencyScores)
             )
         ), 0);
+
         foreach ($dependencyScores as $classFqn => $score) {
             $namespaces[PhpNamespace::extractName($classFqn)] += $score;
         }
+
         arsort($namespaces);
+
         return array_keys($namespaces);
     }
 
-    private function getOrderedClasses(PhpNamespace $phpNamespace, $classes) {
-        $nsClassesFQNs = array_map(
-            function($cl) { return $cl->getFQN(); },
-            $phpNamespace->getClasses()
-        );
+    private function getOrderedClasses(PhpNamespace $phpNamespace, $classes)
+    {
+        $nsClassesFQNs = array_map(function($cl) { return $cl->getFQN(); }, $phpNamespace->getClasses());
         $nsOrderedClasses = array();
+
         foreach ($nsClassesFQNs as $nsClassFQN) {
             $nsOrderedClasses[$nsClassFQN] = $classes[$nsClassFQN];
         }
+
         arsort($nsOrderedClasses);
+
         return array_keys($nsOrderedClasses);
     }
 
-    public function getPhpCode() {
+    public function getPhpCode()
+    {
         $buffer = array("<?php\n\n");
         $classes = $this->getDependencyScores();
         $namespaces = $this->getOrderedNamespaces($classes);
@@ -196,10 +233,12 @@ class PredisFile {
             $buffer[] = "/* " . str_repeat("-", 75) . " */";
             $buffer[] = "\n\n";
         }
+
         return implode($buffer);
     }
 
-    public function saveTo($outputFile) {
+    public function saveTo($outputFile)
+    {
         // TODO: add more sanity checks
         if ($outputFile === null || $outputFile === '') {
             throw new InvalidArgumentException('You must specify a valid output file');
@@ -208,127 +247,167 @@ class PredisFile {
     }
 }
 
-class PhpNamespace implements IteratorAggregate {
-    private $_namespace, $_classes;
+class PhpNamespace implements IteratorAggregate
+{
+    private $_namespace;
+    private $_classes;
 
-    public function __construct($namespace) {
+    public function __construct($namespace)
+    {
         $this->_namespace = $namespace;
         $this->_classes = array();
         $this->_useDirectives = new PhpUseDirectives($this);
     }
 
-    public static function extractName($fqn) {
+    public static function extractName($fqn)
+    {
         $nsSepLast = strrpos($fqn, '\\');
         if ($nsSepLast === false) {
             return $fqn;
         }
         $ns = substr($fqn, 0, $nsSepLast);
+
         return $ns !== '' ? $ns : null;
     }
 
-    public function addClass(PhpClass $class) {
+    public function addClass(PhpClass $class)
+    {
         $this->_classes[$class->getName()] = $class;
     }
 
-    public function getClass($className) {
+    public function getClass($className)
+    {
         if (isset($this->_classes[$className])) {
             return $this->_classes[$className];
         }
     }
 
-    public function getClasses() {
+    public function getClasses()
+    {
         return array_values($this->_classes);
     }
 
-    public function getIterator() {
+    public function getIterator()
+    {
         return new \ArrayIterator($this->getClasses());
     }
 
-    public function getUseDirectives() {
+    public function getUseDirectives()
+    {
         return $this->_useDirectives;
     }
 
-    public function getPhpCode() {
+    public function getPhpCode()
+    {
         return "namespace $this->_namespace;\n";
     }
 
-    public function __toString() {
+    public function __toString()
+    {
         return $this->_namespace;
     }
 }
 
-class PhpUseDirectives implements Countable, IteratorAggregate {
-    private $_use, $_aliases, $_namespace;
+class PhpUseDirectives implements Countable, IteratorAggregate
+{
+    private $_use;
+    private $_aliases;
+    private $_namespace;
 
-    public function __construct(PhpNamespace $namespace) {
+    public function __construct(PhpNamespace $namespace)
+    {
         $this->_use = array();
         $this->_aliases = array();
         $this->_namespace = $namespace;
     }
 
-    public function add($use, $as = null) {
-        if (!in_array($use, $this->_use)) {
-            $this->_use[] = $use;
-            $this->_aliases[$as ?: PhpClass::extractName($use)] = $use;
+    public function add($use, $as = null)
+    {
+        if (in_array($use, $this->_use)) {
+            return;
         }
+
+        $this->_use[] = $use;
+        $this->_aliases[$as ?: PhpClass::extractName($use)] = $use;
     }
 
-    public function getList() {
+    public function getList()
+    {
         return $this->_use;
     }
 
-    public function getIterator() {
+    public function getIterator()
+    {
         return new \ArrayIterator($this->getList());
     }
 
-    public function getPhpCode() {
+    public function getPhpCode()
+    {
         $reducer = function($str, $use) { return $str .= "use $use;\n"; };
+
         return array_reduce($this->getList(), $reducer, '');
     }
 
-    public function getNamespace() {
+    public function getNamespace()
+    {
         return $this->_namespace;
     }
 
-    public function getFQN($className) {
+    public function getFQN($className)
+    {
         if (($nsSepFirst = strpos($className, '\\')) === false) {
             if (isset($this->_aliases[$className])) {
                 return $this->_aliases[$className];
             }
+
             return (string)$this->getNamespace() . "\\$className";
         }
+
         if ($nsSepFirst != 0) {
             throw new InvalidArgumentException("Partially qualified names are not supported");
         }
+
         return $className;
     }
 
-    public function count() {
+    public function count()
+    {
         return count($this->_use);
     }
 }
 
-class PhpClass {
-    private $_namespace, $_file, $_body, $_implements, $_extends, $_name;
-
-    public function __construct(PhpNamespace $namespace, SplFileInfo $classFile) {
+class PhpClass
+{
+    private $_namespace;
+    private $_file;
+    private $_body;
+    private $_implements;
+    private $_extends;
+    private $_name;
+
+    public function __construct(PhpNamespace $namespace, SplFileInfo $classFile)
+    {
         $this->_namespace = $namespace;
         $this->_file = $classFile;
         $this->_implements = array();
         $this->_extends = array();
+
         $this->extractData();
         $namespace->addClass($this);
     }
 
-    public static function extractName($fqn) {
+    public static function extractName($fqn)
+    {
         $nsSepLast = strrpos($fqn, '\\');
         if ($nsSepLast === false) {
             return $fqn;
         }
+
         return substr($fqn, $nsSepLast + 1);
     }
 
-    private function extractData() {
+    private function extractData()
+    {
         $useDirectives = $this->getNamespace()->getUseDirectives();
 
         $useExtractor = function($m) use($useDirectives) {
@@ -347,15 +426,18 @@ class PhpClass {
         $this->extractHierarchy();
     }
 
-    private function extractHierarchy() {
+    private function extractHierarchy()
+    {
         $implements = array();
         $extends =  array();
 
         $extractor = function($iterator, $callback) {
             $className = '';
             $iterator->seek($iterator->key() + 1);
+
             while ($iterator->valid()) {
                 $token = $iterator->current();
+
                 if (is_string($token)) {
                     if (preg_match('/\s?,\s?/', $token)) {
                         $callback(trim($className));
@@ -366,26 +448,30 @@ class PhpClass {
                         return;
                     }
                 }
+
                 switch ($token[0]) {
                     case T_NS_SEPARATOR:
                         $className .= '\\';
                         break;
+
                     case T_STRING:
                         $className .= $token[1];
                         break;
+
                     case T_IMPLEMENTS:
                     case T_EXTENDS:
                         $callback(trim($className));
                         $iterator->seek($iterator->key() - 1);
                         return;
                 }
+
                 $iterator->next();
             }
         };
 
         $tokens = token_get_all("<?php\n" . trim($this->getPhpCode()));
-
         $iterator = new ArrayIterator($tokens);
+
         while ($iterator->valid()) {
             $token = $iterator->current();
             if (is_string($token)) {
@@ -400,17 +486,20 @@ class PhpClass {
                     $tk = $iterator->current();
                     $this->_name = $tk[1];
                     break;
+
                 case T_IMPLEMENTS:
                     $extractor($iterator, function($fqn) use (&$implements) {
                         $implements[] = $fqn;
                     });
                     break;
+
                 case T_EXTENDS:
                     $extractor($iterator, function($fqn) use (&$extends) {
                         $extends[] = $fqn;
                     });
                     break;
             }
+
             $iterator->next();
         }
 
@@ -418,63 +507,71 @@ class PhpClass {
         $this->_extends = $this->guessFQN($extends);
     }
 
-    public function guessFQN($classes) {
+    public function guessFQN($classes)
+    {
         $useDirectives = $this->getNamespace()->getUseDirectives();
         return array_map(array($useDirectives, 'getFQN'), $classes);
     }
 
-    public function getImplementedInterfaces($all = false) {
+    public function getImplementedInterfaces($all = false)
+    {
         if ($all) {
             return $this->_implements;
         }
-        else {
-            return array_filter(
-                $this->_implements,
-                function ($cn) { return strpos($cn, 'Predis\\') === 0; }
-            );
-        }
+
+        return array_filter(
+            $this->_implements,
+            function ($cn) { return strpos($cn, 'Predis\\') === 0; }
+        );
     }
 
-    public function getExtendedClasses($all = false) {
+    public function getExtendedClasses($all = false)
+    {
         if ($all) {
             return $this->_extemds;
         }
-        else {
-            return array_filter(
-                $this->_extends,
-                function ($cn) { return strpos($cn, 'Predis\\') === 0; }
-            );
-        }
+
+        return array_filter(
+            $this->_extends,
+            function ($cn) { return strpos($cn, 'Predis\\') === 0; }
+        );
     }
 
-    public function getDependencies($all = false) {
+    public function getDependencies($all = false)
+    {
         return array_merge(
             $this->getImplementedInterfaces($all),
             $this->getExtendedClasses($all)
         );
     }
 
-    public function getNamespace() {
+    public function getNamespace()
+    {
         return $this->_namespace;
     }
 
-    public function getFile() {
+    public function getFile()
+    {
         return $this->_file;
     }
 
-    public function getName() {
+    public function getName()
+    {
         return $this->_name;
     }
 
-    public function getFQN() {
+    public function getFQN()
+    {
         return (string)$this->getNamespace() . '\\' . $this->_name;
     }
 
-    public function getPhpCode() {
+    public function getPhpCode()
+    {
         return $this->_body;
     }
 
-    public function __toString() {
+    public function __toString()
+    {
         return "class " . $this->getName() . '{ ... }';
     }
 }

+ 16 - 7
examples/CustomDistributionStrategy.php

@@ -9,35 +9,44 @@ require 'SharedConfigurations.php';
 use Predis\Distribution\IDistributionStrategy;
 use Predis\Network\PredisCluster;
 
-class NaiveDistributionStrategy implements IDistributionStrategy {
-    private $_nodes, $_nodesCount;
+class NaiveDistributionStrategy implements IDistributionStrategy
+{
+    private $_nodes;
+    private $_nodesCount;
 
-    public function __constructor() {
+    public function __constructor()
+    {
         $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;
         });
+
         $this->_nodesCount = count($this->_nodes);
     }
 
-    public function get($key) {
+    public function get($key)
+    {
         $count = $this->_nodesCount;
         if ($count === 0) {
             throw new RuntimeException('No connections');
         }
+
         return $this->_nodes[$count > 1 ? abs(crc32($key) % $count) : 0];
     }
 
-    public function generateKey($value) {
+    public function generateKey($value)
+    {
         return crc32($value);
     }
 }

+ 10 - 5
examples/DispatcherLoop.php

@@ -22,22 +22,27 @@ $client = new Predis\Client($single_server + array('read_write_timeout' => 0));
 $dispatcher = new Predis\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;
     }
 }

+ 14 - 11
examples/MultiExecTransactionsWithCAS.php

@@ -16,26 +16,29 @@ ZADD zset 2 b
 ZADD zset 3 c
 */
 
-function zpop($client, $zsetKey) {
+function zpop($client, $key)
+{
     $element = null;
+
     $options = array(
-        'cas'   => true,     // Initialize with support for CAS operations
-        'watch' => $zsetKey, // Key that needs to be WATCHed to detect changes
-        'retry' => 3,        // Number of retries on aborted transactions, after
-                             // which the client bails out with an exception.
+        'cas'   => true,    // Initialize with support for CAS operations
+        'watch' => $key,    // Key that needs to be WATCHed to detect changes
+        'retry' => 3,       // Number of retries on aborted transactions, after
+                            // which the client bails out with an exception.
     );
 
-    $txReply = $client->multiExec($options, function($tx)
-        use ($zsetKey, &$element) {
-        @list($element) = $tx->zrange($zsetKey, 0, 0);
+    $txReply = $client->multiExec($options, function($tx) use ($key, &$element) {
+        @list($element) = $tx->zrange($key, 0, 0);
+
         if (isset($element)) {
-            $tx->multi();     // With CAS, MULTI *must* be explicitly invoked.
-            $tx->zrem($zsetKey, $element);
+            $tx->multi();   // With CAS, MULTI *must* be explicitly invoked.
+            $tx->zrem($key, $element);
         }
     });
     return $element;
 }
 
-$redis = new Predis\Client($single_server, 'dev');
+$redis = new Predis\Client($single_server);
 $zpopped = zpop($redis, 'zset');
+
 echo isset($zpopped) ? "ZPOPed $zpopped" : "Nothing to ZPOP!", "\n";

+ 1 - 0
examples/PubSubContext.php

@@ -23,6 +23,7 @@ foreach ($pubsub as $message) {
         case 'subscribe':
             echo "Subscribed to {$message->channel}\n";
             break;
+
         case 'message':
             if ($message->channel == 'control_channel') {
                 if ($message->payload == 'quit_loop') {

+ 8 - 3
examples/ServerSideScripting.php

@@ -9,12 +9,15 @@ require 'SharedConfigurations.php';
 
 use Predis\Commands\ScriptedCommand;
 
-class IncrementExistingKey extends ScriptedCommand {
-    protected function keysCount() {
+class IncrementExistingKey extends ScriptedCommand
+{
+    protected function keysCount()
+    {
         return 1;
     }
 
-    public function getScript() {
+    public function getScript()
+    {
         return
 <<<LUA
     if redis('exists', KEYS[1]) == 1 then
@@ -25,8 +28,10 @@ LUA;
 }
 
 $client = new Predis\Client($single_server, 'dev');
+
 $client->getProfile()->defineCommand('increx', 'IncrementExistingKey');
 
 $client->set('foo', 10);
+
 var_dump($client->increx('foo'));       // int(11)
 var_dump($client->increx('bar'));       // NULL

+ 18 - 7
examples/SimpleDebuggableConnection.php

@@ -6,37 +6,48 @@ use Predis\ConnectionParameters;
 use Predis\Commands\ICommand;
 use Predis\Network\StreamConnection;
 
-class SimpleDebuggableConnection extends StreamConnection {
-    private $_debugBuffer = array();
+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(ICommand $command, $direction) {
+    private function storeDebug(ICommand $command, $direction)
+    {
         $firtsArg  = $command->getArgument(0);
         $timestamp = round(microtime(true) - $this->_tstart, 4);
+
         $debug  = $command->getId();
         $debug .= isset($firtsArg) ? " $firtsArg " : ' ';
         $debug .= "$direction $this";
         $debug .= " [{$timestamp}s]";
+
         $this->_debugBuffer[] = $debug;
     }
 
-    public function writeCommand(ICommand $command) {
+    public function writeCommand(ICommand $command)
+    {
         parent::writeCommand($command);
+
         $this->storeDebug($command, '->');
     }
 
-    public function readResponse(ICommand $command) {
+    public function readResponse(ICommand $command)
+    {
         $reply = parent::readResponse($command);
         $this->storeDebug($command, '<-');
+
         return $reply;
     }
 
-    public function getDebugBuffer() {
+    public function getDebugBuffer()
+    {
         return $this->_debugBuffer;
     }
 }

+ 8 - 4
lib/Predis/Autoloader.php

@@ -2,20 +2,24 @@
 
 namespace Predis;
 
-class Autoloader {
+class Autoloader
+{
     private $base_directory;
     private $prefix;
 
-    public function __construct($base_directory=NULL) {
+    public function __construct($base_directory = null)
+    {
         $this->base_directory = $base_directory ?: dirname(__FILE__);
         $this->prefix = __NAMESPACE__ . '\\';
     }
 
-    public static function register() {
+    public static function register()
+    {
         spl_autoload_register(array(new self, 'autoload'));
     }
 
-    public function autoload($class_name) {
+    public function autoload($class_name)
+    {
         if (0 !== strpos($class_name, $this->prefix)) {
             return;
         }

+ 87 - 48
lib/Predis/Client.php

@@ -15,142 +15,169 @@ class Client {
 
     private $_options;
     private $_profile;
-    private $_connectionFactory;
     private $_connection;
+    private $_connectionFactory;
 
-    public function __construct($parameters = null, $options = null) {
+    public function __construct($parameters = null, $options = null)
+    {
         $options = $this->filterOptions($options);
         $profile = $options->profile;
+
         if (isset($options->prefix)) {
             $profile->setProcessor($options->prefix);
         }
+
         $this->_options = $options;
         $this->_profile = $profile;
         $this->_connectionFactory = $options->connections;
         $this->_connection = $this->initializeConnection($parameters);
     }
 
-    private function filterOptions($options) {
+    private function filterOptions($options)
+    {
         if ($options === null) {
             return new ClientOptions();
         }
+
         if (is_array($options)) {
             return new ClientOptions($options);
         }
+
         if ($options instanceof ClientOptions) {
             return $options;
         }
+
         if ($options instanceof IServerProfile) {
             return new ClientOptions(array('profile' => $options));
         }
+
         if (is_string($options)) {
             return new ClientOptions(array('profile' => ServerProfile::get($options)));
         }
+
         throw new \InvalidArgumentException("Invalid type for client options");
     }
 
-    private function initializeConnection($parameters) {
+    private function initializeConnection($parameters)
+    {
         if ($parameters === null) {
             return $this->createConnection(new ConnectionParameters());
         }
+
         if (is_array($parameters)) {
             if (isset($parameters[0])) {
                 $cluster = $this->_options->cluster;
-                foreach ($parameters as $single) {
-                    $cluster->add($single instanceof IConnectionSingle
-                        ? $single : $this->createConnection($single)
-                    );
+                foreach ($parameters as $node) {
+                    $connection = $node instanceof IConnectionSingle ? $node : $this->createConnection($node);
+                    $cluster->add($connection);
                 }
                 return $cluster;
             }
             return $this->createConnection($parameters);
         }
+
         if ($parameters instanceof IConnection) {
             return $parameters;
         }
+
         return $this->createConnection($parameters);
     }
 
-    protected function createConnection($parameters) {
+    protected function createConnection($parameters)
+    {
         $connection = $this->_connectionFactory->create($parameters);
         $parameters = $connection->getParameters();
+
         if (isset($parameters->password)) {
-            $connection->pushInitCommand(
-                $this->createCommand('auth', array($parameters->password))
-            );
+            $command = $this->createCommand('auth', array($parameters->password));
+            $connection->pushInitCommand($command);
         }
+
         if (isset($parameters->database)) {
-            $connection->pushInitCommand(
-                $this->createCommand('select', array($parameters->database))
-            );
+            $command = $this->createCommand('select', array($parameters->database));
+            $connection->pushInitCommand($command);
         }
+
         return $connection;
     }
 
-    public function getProfile() {
+    public function getProfile()
+    {
         return $this->_profile;
     }
 
-    public function getOptions() {
+    public function getOptions()
+    {
         return $this->_options;
     }
 
-    public function getConnectionFactory() {
+    public function getConnectionFactory()
+    {
         return $this->_connectionFactory;
     }
 
-    public function getClientFor($connectionAlias) {
+    public function getClientFor($connectionAlias)
+    {
         if (($connection = $this->getConnection($connectionAlias)) === null) {
-            throw new \InvalidArgumentException(
-                "Invalid connection alias: '$connectionAlias'"
-            );
+            throw new \InvalidArgumentException("Invalid connection alias: '$connectionAlias'");
         }
+
         return new Client($connection, $this->_options);
     }
 
-    public function connect() {
+    public function connect()
+    {
         $this->_connection->connect();
     }
 
-    public function disconnect() {
+    public function disconnect()
+    {
         $this->_connection->disconnect();
     }
 
-    public function quit() {
+    public function quit()
+    {
         $this->disconnect();
     }
 
-    public function isConnected() {
+    public function isConnected()
+    {
         return $this->_connection->isConnected();
     }
 
-    public function getConnection($id = null) {
+    public function getConnection($id = null)
+    {
         if (isset($id)) {
             if (!Helpers::isCluster($this->_connection)) {
                 throw new ClientException(
-                    'Retrieving connections by alias is supported '.
-                    'only with clustered connections'
+                    'Retrieving connections by alias is supported only with clustered connections'
                 );
             }
+
             return $this->_connection->getConnectionById($id);
         }
+
         return $this->_connection;
     }
 
-    public function __call($method, $arguments) {
+    public function __call($method, $arguments)
+    {
         $command = $this->_profile->createCommand($method, $arguments);
         return $this->_connection->executeCommand($command);
     }
 
-    public function createCommand($method, $arguments = array()) {
+    public function createCommand($method, $arguments = array())
+    {
         return $this->_profile->createCommand($method, $arguments);
     }
 
-    public function executeCommand(ICommand $command) {
+    public function executeCommand(ICommand $command)
+    {
         return $this->_connection->executeCommand($command);
     }
 
-    public function executeCommandOnShards(ICommand $command) {
+    public function executeCommandOnShards(ICommand $command)
+    {
         if (Helpers::isCluster($this->_connection)) {
             $replies = array();
             foreach ($this->_connection as $connection) {
@@ -158,58 +185,69 @@ class Client {
             }
             return $replies;
         }
+
         return array($this->_connection->executeCommand($command));
     }
 
-    private function sharedInitializer($argv, $initializer) {
+    private function sharedInitializer($argv, $initializer)
+    {
         switch (count($argv)) {
             case 0:
                 return $this->$initializer();
+
             case 1:
                 list($arg0) = $argv;
-                return is_array($arg0)
-                    ? $this->$initializer($arg0)
-                    : $this->$initializer(null, $arg0);
+                return is_array($arg0) ? $this->$initializer($arg0) : $this->$initializer(null, $arg0);
+
             case 2:
                 list($arg0, $arg1) = $argv;
                 return $this->$initializer($arg0, $arg1);
+
             default:
                 return $this->$initializer($this, $argv);
         }
     }
 
-    public function pipeline(/* arguments */) {
+    public function pipeline(/* arguments */)
+    {
         return $this->sharedInitializer(func_get_args(), 'initPipeline');
     }
 
-    protected function initPipeline(Array $options = null, $pipelineBlock = null) {
-        return $this->pipelineExecute(
-            new PipelineContext($this, $options), $pipelineBlock
-        );
+    protected function initPipeline(Array $options = null, $pipelineBlock = null)
+    {
+        $pipeline = new PipelineContext($this, $options);
+        return $this->pipelineExecute($pipeline, $pipelineBlock);
     }
 
-    private function pipelineExecute(PipelineContext $pipeline, $block) {
+    private function pipelineExecute(PipelineContext $pipeline, $block)
+    {
         return $block !== null ? $pipeline->execute($block) : $pipeline;
     }
 
-    public function multiExec(/* arguments */) {
+    public function multiExec(/* arguments */)
+    {
         return $this->sharedInitializer(func_get_args(), 'initMultiExec');
     }
 
-    protected function initMultiExec(Array $options = null, $block = null) {
+    protected function initMultiExec(Array $options = null, $block = null)
+    {
         $transaction = new MultiExecContext($this, $options ?: array());
         return isset($block) ? $transaction->execute($block) : $transaction;
     }
 
-    public function pubSub(/* arguments */) {
+    public function pubSub(/* arguments */)
+    {
         return $this->sharedInitializer(func_get_args(), 'initPubSub');
     }
 
-    protected function initPubSub(Array $options = null, $block = null) {
+    protected function initPubSub(Array $options = null, $block = null)
+    {
         $pubsub = new PubSubContext($this, $options);
+
         if (!isset($block)) {
             return $pubsub;
         }
+
         foreach ($pubsub as $message) {
             if ($block($pubsub, $message) === false) {
                 $pubsub->closeContext();
@@ -217,7 +255,8 @@ class Client {
         }
     }
 
-    public function monitor() {
+    public function monitor()
+    {
         return new MonitorContext($this);
     }
 }

+ 2 - 1
lib/Predis/ClientException.php

@@ -2,5 +2,6 @@
 
 namespace Predis;
 
-class ClientException extends PredisException {
+class ClientException extends PredisException
+{
 }

+ 25 - 15
lib/Predis/ClientOptions.php

@@ -8,43 +8,53 @@ use Predis\Options\ClientProfile;
 use Predis\Options\ClientCluster;
 use Predis\Options\ClientConnectionFactory;
 
-class ClientOptions {
+class ClientOptions
+{
     private static $_sharedOptions;
 
-    private $_options = array();
     private $_handlers;
     private $_defined;
 
-    public function __construct(Array $options = array()) {
+    private $_options = array();
+
+    public function __construct(Array $options = array())
+    {
         $this->_handlers = $this->initialize($options);
         $this->_defined = array_keys($options);
     }
 
-    private static function getSharedOptions() {
+    private static function getSharedOptions()
+    {
         if (isset(self::$_sharedOptions)) {
             return self::$_sharedOptions;
         }
+
         self::$_sharedOptions = array(
             'profile' => new ClientProfile(),
             'connections' => new ClientConnectionFactory(),
             'cluster' => new ClientCluster(),
             'prefix' => new ClientPrefix(),
         );
+
         return self::$_sharedOptions;
     }
 
-    public static function define($option, IOption $handler) {
+    public static function define($option, IOption $handler)
+    {
         self::getSharedOptions();
         self::$_sharedOptions[$option] = $handler;
     }
 
-    public static function undefine($option) {
+    public static function undefine($option)
+    {
         self::getSharedOptions();
         unset(self::$_sharedOptions[$option]);
     }
 
-    private function initialize($options) {
+    private function initialize($options)
+    {
         $handlers = self::getSharedOptions();
+
         foreach ($options as $option => $value) {
             if (isset($handlers[$option])) {
                 $handler = $handlers[$option];
@@ -53,26 +63,26 @@ class ClientOptions {
                 };
             }
         }
+
         return $handlers;
     }
 
-    public function __isset($option) {
+    public function __isset($option)
+    {
         return in_array($option, $this->_defined);
     }
 
-    public function __get($option) {
+    public function __get($option)
+    {
         if (isset($this->_options[$option])) {
             return $this->_options[$option];
         }
+
         if (isset($this->_handlers[$option])) {
             $handler = $this->_handlers[$option];
-            if ($handler instanceof IOption) {
-                $value = $handler->getDefault();
-            }
-            else {
-                $value = $handler();
-            }
+            $value = $handler instanceof IOption ? $handler->getDefault() : $handler();
             $this->_options[$option] = $value;
+
             return $value;
         }
     }

+ 35 - 14
lib/Predis/Commands/Command.php

@@ -5,40 +5,48 @@ namespace Predis\Commands;
 use Predis\Helpers;
 use Predis\Distribution\INodeKeyGenerator;
 
-abstract class Command implements ICommand {
+abstract class Command implements ICommand
+{
     private $_hash;
     private $_arguments = array();
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return $arguments;
     }
 
-    public function setArguments(Array $arguments) {
+    public function setArguments(Array $arguments)
+    {
         $this->_arguments = $this->filterArguments($arguments);
         unset($this->_hash);
     }
 
-    public function setRawArguments(Array $arguments) {
+    public function setRawArguments(Array $arguments)
+    {
         $this->_arguments = $arguments;
         unset($this->_hash);
     }
 
-    public function getArguments() {
+    public function getArguments()
+    {
         return $this->_arguments;
     }
 
-    public function getArgument($index = 0) {
+    public function getArgument($index = 0)
+    {
         if (isset($this->_arguments[$index]) === true) {
             return $this->_arguments[$index];
         }
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         $arguments[0] = "$prefix{$arguments[0]}";
         return $arguments;
     }
 
-    public function prefixKeys($prefix) {
+    public function prefixKeys($prefix)
+    {
         $arguments = $this->onPrefixKeys($this->_arguments, $prefix);
         if (isset($arguments)) {
             $this->_arguments = $arguments;
@@ -46,15 +54,19 @@ abstract class Command implements ICommand {
         }
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return isset($this->_arguments[0]);
     }
 
-    protected function checkSameHashForKeys(Array $keys) {
+    protected function checkSameHashForKeys(Array $keys)
+    {
         if (($count = count($keys)) === 0) {
             return false;
         }
+
         $currentKey = Helpers::getKeyHashablePart($keys[0]);
+
         for ($i = 1; $i < $count; $i++) {
             $nextKey = Helpers::getKeyHashablePart($keys[$i]);
             if ($currentKey !== $nextKey) {
@@ -62,34 +74,43 @@ abstract class Command implements ICommand {
             }
             $currentKey = $nextKey;
         }
+
         return true;
     }
 
-    public function getHash(INodeKeyGenerator $distributor) {
+    public function getHash(INodeKeyGenerator $distributor)
+    {
         if (isset($this->_hash)) {
             return $this->_hash;
         }
+
         if ($this->canBeHashed()) {
             $key = Helpers::getKeyHashablePart($this->_arguments[0]);
             $this->_hash = $distributor->generateKey($key);
+
             return $this->_hash;
         }
+
         return null;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return $data;
     }
 
-    protected function toStringArgumentReducer($accumulator, $argument) {
+    protected function toStringArgumentReducer($accumulator, $argument)
+    {
         if (strlen($argument) > 32) {
             $argument = substr($argument, 0, 32) . '[...]';
         }
         $accumulator .= " $argument";
+
         return $accumulator;
     }
 
-    public function __toString() {
+    public function __toString()
+    {
         return array_reduce(
             $this->getArguments(),
             array($this, 'toStringArgumentReducer'),

+ 8 - 4
lib/Predis/Commands/ConnectionAuth.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ConnectionAuth extends Command {
-    public function getId() {
+class ConnectionAuth extends Command
+{
+    public function getId()
+    {
         return 'AUTH';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ConnectionEcho.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ConnectionEcho extends Command {
-    public function getId() {
+class ConnectionEcho extends Command
+{
+    public function getId()
+    {
         return 'ECHO';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 10 - 5
lib/Predis/Commands/ConnectionPing.php

@@ -2,20 +2,25 @@
 
 namespace Predis\Commands;
 
-class ConnectionPing extends Command {
-    public function getId() {
+class ConnectionPing extends Command
+{
+    public function getId()
+    {
         return 'PING';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return $data === 'PONG' ? true : false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ConnectionQuit.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ConnectionQuit extends Command {
-    public function getId() {
+class ConnectionQuit extends Command
+{
+    public function getId()
+    {
         return 'QUIT';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ConnectionSelect.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ConnectionSelect extends Command {
-    public function getId() {
+class ConnectionSelect extends Command
+{
+    public function getId()
+    {
         return 'SELECT';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/HashDelete.php

@@ -4,16 +4,20 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class HashDelete extends Command {
-    public function getId() {
+class HashDelete extends Command
+{
+    public function getId()
+    {
         return 'HDEL';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterVariadicValues($arguments);
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 6 - 3
lib/Predis/Commands/HashExists.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class HashExists extends Command {
-    public function getId() {
+class HashExists extends Command
+{
+    public function getId()
+    {
         return 'HEXISTS';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 4 - 2
lib/Predis/Commands/HashGet.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class HashGet extends Command {
-    public function getId() {
+class HashGet extends Command
+{
+    public function getId()
+    {
         return 'HGET';
     }
 }

+ 8 - 3
lib/Predis/Commands/HashGetAll.php

@@ -4,19 +4,24 @@ namespace Predis\Commands;
 
 use Predis\Iterators\MultiBulkResponseTuple;
 
-class HashGetAll extends Command {
-    public function getId() {
+class HashGetAll extends Command
+{
+    public function getId()
+    {
         return 'HGETALL';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         if ($data instanceof \Iterator) {
             return new MultiBulkResponseTuple($data);
         }
+
         $result = array();
         for ($i = 0; $i < count($data); $i++) {
             $result[$data[$i]] = $data[++$i];
         }
+
         return $result;
     }
 }

+ 6 - 3
lib/Predis/Commands/HashGetMultiple.php

@@ -4,12 +4,15 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class HashGetMultiple extends Command {
-    public function getId() {
+class HashGetMultiple extends Command
+{
+    public function getId()
+    {
         return 'HMGET';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterVariadicValues($arguments);
     }
 }

+ 4 - 2
lib/Predis/Commands/HashIncrementBy.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class HashIncrementBy extends Command {
-    public function getId() {
+class HashIncrementBy extends Command
+{
+    public function getId()
+    {
         return 'HINCRBY';
     }
 }

+ 4 - 2
lib/Predis/Commands/HashKeys.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class HashKeys extends Command {
-    public function getId() {
+class HashKeys extends Command
+{
+    public function getId()
+    {
         return 'HKEYS';
     }
 }

+ 4 - 2
lib/Predis/Commands/HashLength.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class HashLength extends Command {
-    public function getId() {
+class HashLength extends Command
+{
+    public function getId()
+    {
         return 'HLEN';
     }
 }

+ 4 - 2
lib/Predis/Commands/HashSet.php

@@ -3,11 +3,13 @@
 namespace Predis\Commands;
 
 class HashSet extends Command {
-    public function getId() {
+    public function getId()
+    {
         return 'HSET';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 9 - 3
lib/Predis/Commands/HashSetMultiple.php

@@ -2,21 +2,27 @@
 
 namespace Predis\Commands;
 
-class HashSetMultiple extends Command {
-    public function getId() {
+class HashSetMultiple extends Command
+{
+    public function getId()
+    {
         return 'HMSET';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         if (count($arguments) === 2 && is_array($arguments[1])) {
             $flattenedKVs = array($arguments[0]);
             $args = $arguments[1];
+
             foreach ($args as $k => $v) {
                 $flattenedKVs[] = $k;
                 $flattenedKVs[] = $v;
             }
+
             return $flattenedKVs;
         }
+
         return $arguments;
     }
 }

+ 6 - 3
lib/Predis/Commands/HashSetPreserve.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class HashSetPreserve extends Command {
-    public function getId() {
+class HashSetPreserve extends Command
+{
+    public function getId()
+    {
         return 'HSETNX';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 4 - 2
lib/Predis/Commands/HashValues.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class HashValues extends Command {
-    public function getId() {
+class HashValues extends Command
+{
+    public function getId()
+    {
         return 'HVALS';
     }
 }

+ 2 - 1
lib/Predis/Commands/ICommand.php

@@ -4,7 +4,8 @@ namespace Predis\Commands;
 
 use Predis\Distribution\INodeKeyGenerator;
 
-interface ICommand {
+interface ICommand
+{
     public function getId();
     public function getHash(INodeKeyGenerator $distributor);
     public function setArguments(Array $arguments);

+ 11 - 5
lib/Predis/Commands/KeyDelete.php

@@ -4,24 +4,30 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class KeyDelete extends Command {
-    public function getId() {
+class KeyDelete extends Command
+{
+    public function getId()
+    {
         return 'DEL';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterArrayArguments($arguments);
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         $args = $this->getArguments();
         if (count($args) === 1) {
             return true;
         }
+
         return $this->checkSameHashForKeys($args);
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyExists.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeyExists extends Command {
-    public function getId() {
+class KeyExists extends Command
+{
+    public function getId()
+    {
         return 'EXISTS';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyExpire.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeyExpire extends Command {
-    public function getId() {
+class KeyExpire extends Command
+{
+    public function getId()
+    {
         return 'EXPIRE';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyExpireAt.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeyExpireAt extends Command {
-    public function getId() {
+class KeyExpireAt extends Command
+{
+    public function getId()
+    {
         return 'EXPIREAT';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyKeys.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeyKeys extends Command {
-    public function getId() {
+class KeyKeys extends Command
+{
+    public function getId()
+    {
         return 'KEYS';
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 4 - 2
lib/Predis/Commands/KeyKeysV12x.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class KeyKeysV12x extends KeyKeys {
-    public function parseResponse($data) {
+class KeyKeysV12x extends KeyKeys
+{
+    public function parseResponse($data)
+    {
         return explode(' ', $data);
     }
 }

+ 8 - 4
lib/Predis/Commands/KeyMove.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class KeyMove extends Command {
-    public function getId() {
+class KeyMove extends Command
+{
+    public function getId()
+    {
         return 'MOVE';
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyPersist.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeyPersist extends Command {
-    public function getId() {
+class KeyPersist extends Command
+{
+    public function getId()
+    {
         return 'PERSIST';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 8 - 4
lib/Predis/Commands/KeyRandom.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class KeyRandom extends Command {
-    public function getId() {
+class KeyRandom extends Command
+{
+    public function getId()
+    {
         return 'RANDOMKEY';
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return $data !== '' ? $data : null;
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyRename.php

@@ -3,15 +3,18 @@
 namespace Predis\Commands;
 
 class KeyRename extends Command {
-    public function getId() {
+    public function getId()
+    {
         return 'RENAME';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 6 - 3
lib/Predis/Commands/KeyRenamePreserve.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeyRenamePreserve extends KeyRename {
-    public function getId() {
+class KeyRenamePreserve extends KeyRename
+{
+    public function getId()
+    {
         return 'RENAMENX';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 17 - 4
lib/Predis/Commands/KeySort.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class KeySort extends Command {
-    public function getId() {
+class KeySort extends Command
+{
+    public function getId()
+    {
         return 'SORT';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         if (count($arguments) === 1) {
             return $arguments;
         }
@@ -19,6 +22,7 @@ class KeySort extends Command {
             $query[] = 'BY';
             $query[] = $sortParams['BY'];
         }
+
         if (isset($sortParams['GET'])) {
             $getargs = $sortParams['GET'];
             if (is_array($getargs)) {
@@ -32,6 +36,7 @@ class KeySort extends Command {
                 $query[] = $getargs;
             }
         }
+
         if (isset($sortParams['LIMIT']) && is_array($sortParams['LIMIT'])
             && count($sortParams['LIMIT']) == 2) {
 
@@ -39,12 +44,15 @@ class KeySort extends Command {
             $query[] = $sortParams['LIMIT'][0];
             $query[] = $sortParams['LIMIT'][1];
         }
+
         if (isset($sortParams['SORT'])) {
             $query[] = strtoupper($sortParams['SORT']);
         }
+
         if (isset($sortParams['ALPHA']) && $sortParams['ALPHA'] == true) {
             $query[] = 'ALPHA';
         }
+
         if (isset($sortParams['STORE'])) {
             $query[] = 'STORE';
             $query[] = $sortParams['STORE'];
@@ -53,8 +61,10 @@ class KeySort extends Command {
         return $query;
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         $arguments[0] = "$prefix{$arguments[0]}";
+
         if (($count = count($arguments)) > 1) {
             for ($i = 1; $i < $count; $i++) {
                 switch ($arguments[$i]) {
@@ -62,18 +72,21 @@ class KeySort extends Command {
                     case 'STORE':
                         $arguments[$i] = "$prefix{$arguments[++$i]}";
                         break;
+
                     case 'GET':
                         $value = $arguments[++$i];
                         if ($value !== '#') {
                             $arguments[$i] = "$prefix$value";
                         }
                         break;
+
                     case 'LIMIT';
                         $i += 2;
                         break;
                 }
             }
         }
+
         return $arguments;
     }
 }

+ 4 - 2
lib/Predis/Commands/KeyTimeToLive.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class KeyTimeToLive extends Command {
-    public function getId() {
+class KeyTimeToLive extends Command
+{
+    public function getId()
+    {
         return 'TTL';
     }
 }

+ 4 - 2
lib/Predis/Commands/KeyType.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class KeyType extends Command {
-    public function getId() {
+class KeyType extends Command
+{
+    public function getId()
+    {
         return 'TYPE';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListIndex.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListIndex extends Command {
-    public function getId() {
+class ListIndex extends Command
+{
+    public function getId()
+    {
         return 'LINDEX';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListInsert.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListInsert extends Command {
-    public function getId() {
+class ListInsert extends Command
+{
+    public function getId()
+    {
         return 'LINSERT';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListLength.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListLength extends Command {
-    public function getId() {
+class ListLength extends Command
+{
+    public function getId()
+    {
         return 'LLEN';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListPopFirst.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListPopFirst extends Command {
-    public function getId() {
+class ListPopFirst extends Command
+{
+    public function getId()
+    {
         return 'LPOP';
     }
 }

+ 8 - 4
lib/Predis/Commands/ListPopFirstBlocking.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ListPopFirstBlocking extends Command {
-    public function getId() {
+class ListPopFirstBlocking extends Command
+{
+    public function getId()
+    {
         return 'BLPOP';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::skipLastArgument($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return $this->checkSameHashForKeys(
             array_slice(($args = $this->getArguments()), 0, count($args) - 1)
         );

+ 4 - 2
lib/Predis/Commands/ListPopLast.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListPopLast extends Command {
-    public function getId() {
+class ListPopLast extends Command
+{
+    public function getId()
+    {
         return 'RPOP';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListPopLastBlocking.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListPopLastBlocking extends ListPopFirstBlocking {
-    public function getId() {
+class ListPopLastBlocking extends ListPopFirstBlocking
+{
+    public function getId()
+    {
         return 'BRPOP';
     }
 }

+ 8 - 4
lib/Predis/Commands/ListPopLastPushHead.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ListPopLastPushHead extends Command {
-    public function getId() {
+class ListPopLastPushHead extends Command
+{
+    public function getId()
+    {
         return 'RPOPLPUSH';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return $this->checkSameHashForKeys($this->getArguments());
     }
 }

+ 8 - 4
lib/Predis/Commands/ListPopLastPushHeadBlocking.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ListPopLastPushHeadBlocking extends Command {
-    public function getId() {
+class ListPopLastPushHeadBlocking extends Command
+{
+    public function getId()
+    {
         return 'BRPOPLPUSH';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::skipLastArgument($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return $this->checkSameHashForKeys(
             array_slice($args = $this->getArguments(), 0, count($args) - 1)
         );

+ 4 - 2
lib/Predis/Commands/ListPushHead.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListPushHead extends ListPushTail {
-    public function getId() {
+class ListPushHead extends ListPushTail
+{
+    public function getId()
+    {
         return 'LPUSH';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListPushHeadX.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListPushHeadX extends Command {
-    public function getId() {
+class ListPushHeadX extends Command
+{
+    public function getId()
+    {
         return 'LPUSHX';
     }
 }

+ 6 - 3
lib/Predis/Commands/ListPushTail.php

@@ -4,12 +4,15 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class ListPushTail extends Command {
-    public function getId() {
+class ListPushTail extends Command
+{
+    public function getId()
+    {
         return 'RPUSH';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterVariadicValues($arguments);
     }
 }

+ 4 - 2
lib/Predis/Commands/ListPushTailX.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListPushTailX extends Command {
-    public function getId() {
+class ListPushTailX extends Command
+{
+    public function getId()
+    {
         return 'RPUSHX';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListRange.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListRange extends Command {
-    public function getId() {
+class ListRange extends Command
+{
+    public function getId()
+    {
         return 'LRANGE';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListRemove.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListRemove extends Command {
-    public function getId() {
+class ListRemove extends Command
+{
+    public function getId()
+    {
         return 'LREM';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListSet.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListSet extends Command {
-    public function getId() {
+class ListSet extends Command
+{
+    public function getId()
+    {
         return 'LSET';
     }
 }

+ 4 - 2
lib/Predis/Commands/ListTrim.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ListTrim extends Command {
-    public function getId() {
+class ListTrim extends Command
+{
+    public function getId()
+    {
         return 'LTRIM';
     }
 }

+ 8 - 3
lib/Predis/Commands/PrefixHelpers.php

@@ -2,19 +2,24 @@
 
 namespace Predis\Commands;
 
-class PrefixHelpers {
-    public static function multipleKeys(Array $arguments, $prefix) {
+class PrefixHelpers
+{
+    public static function multipleKeys(Array $arguments, $prefix)
+    {
         foreach ($arguments as &$key) {
             $key = "$prefix$key";
         }
+
         return $arguments;
     }
 
-    public static function skipLastArgument(Array $arguments, $prefix) {
+    public static function skipLastArgument(Array $arguments, $prefix)
+    {
         $length = count($arguments);
         for ($i = 0; $i < $length - 1; $i++) {
             $arguments[$i] = "$prefix{$arguments[$i]}";
         }
+
         return $arguments;
     }
 }

+ 2 - 1
lib/Predis/Commands/Processors/ICommandProcessor.php

@@ -4,6 +4,7 @@ namespace Predis\Commands\Processors;
 
 use Predis\Commands\ICommand;
 
-interface ICommandProcessor {
+interface ICommandProcessor
+{
     public function process(ICommand $command);
 }

+ 2 - 2
lib/Predis/Commands/Processors/ICommandProcessorChain.php

@@ -2,8 +2,8 @@
 
 namespace Predis\Commands\Processors;
 
-interface ICommandProcessorChain
-    extends ICommandProcessor, \IteratorAggregate, \Countable {
+interface ICommandProcessorChain extends ICommandProcessor, \IteratorAggregate, \Countable
+{
 
     public function add(ICommandProcessor $preprocessor);
     public function remove(ICommandProcessor $preprocessor);

+ 2 - 1
lib/Predis/Commands/Processors/IProcessingSupport.php

@@ -2,7 +2,8 @@
 
 namespace Predis\Commands\Processors;
 
-interface IProcessingSupport {
+interface IProcessingSupport
+{
     public function setProcessor(ICommandProcessor $processor);
     public function getProcessor();
 }

+ 10 - 5
lib/Predis/Commands/Processors/KeyPrefixProcessor.php

@@ -4,22 +4,27 @@ namespace Predis\Commands\Processors;
 
 use Predis\Commands\ICommand;
 
-class KeyPrefixProcessor implements ICommandProcessor {
+class KeyPrefixProcessor implements ICommandProcessor
+{
     private $_prefix;
 
-    public function __construct($prefix) {
+    public function __construct($prefix)
+    {
         $this->setPrefix($prefix);
     }
 
-    public function setPrefix($prefix) {
+    public function setPrefix($prefix)
+    {
         $this->_prefix = $prefix;
     }
 
-    public function getPrefix() {
+    public function getPrefix()
+    {
         return $this->_prefix;
     }
 
-    public function process(ICommand $command) {
+    public function process(ICommand $command)
+    {
         $command->prefixKeys($this->_prefix);
     }
 }

+ 26 - 13
lib/Predis/Commands/Processors/ProcessorChain.php

@@ -4,64 +4,77 @@ namespace Predis\Commands\Processors;
 
 use Predis\Commands\ICommand;
 
-class ProcessorChain implements ICommandProcessorChain, \ArrayAccess {
+class ProcessorChain implements ICommandProcessorChain, \ArrayAccess
+{
     private $_processors;
 
-    public function __construct($processors = array()) {
+    public function __construct($processors = array())
+    {
         foreach ($processors as $processor) {
             $this->add($processor);
         }
     }
 
-    public function add(ICommandProcessor $processor) {
+    public function add(ICommandProcessor $processor)
+    {
         $this->_processors[] = $processor;
     }
 
-    public function remove(ICommandProcessor $processor) {
+    public function remove(ICommandProcessor $processor)
+    {
         $index = array_search($processor, $this->_processors, true);
         if ($index !== false) {
-            unset($this->_processors);
+            unset($this[$index]);
         }
     }
 
-    public function process(ICommand $command) {
+    public function process(ICommand $command)
+    {
         $count = count($this->_processors);
         for ($i = 0; $i < $count; $i++) {
             $this->_processors[$i]->process($command);
         }
     }
 
-    public function getProcessors() {
+    public function getProcessors() 
+    {
         return $this->_processors;
     }
 
-    public function getIterator() {
+    public function getIterator()
+    {
         return new \ArrayIterator($this->_processors);
     }
 
-    public function count() {
+    public function count()
+    {
         return count($this->_processors);
     }
 
-    public function offsetExists($index) {
+    public function offsetExists($index)
+    {
         return isset($this->_processors[$index]);
     }
 
-    public function offsetGet($index) {
+    public function offsetGet($index)
+    {
         return $this->_processors[$index];
     }
 
-    public function offsetSet($index, $processor) {
+    public function offsetSet($index, $processor)
+    {
         if (!$processor instanceof ICommandProcessor) {
             throw new \InvalidArgumentException(
                 'A processor chain can hold only instances of classes implementing '.
                 'the Predis\Commands\Preprocessors\ICommandProcessor interface'
             );
         }
+
         $this->_processors[$index] = $processor;
     }
 
-    public function offsetUnset($index) {
+    public function offsetUnset($index)
+    {
         unset($this->_processors[$index]);
     }
 }

+ 6 - 3
lib/Predis/Commands/PubSubPublish.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class PubSubPublish extends Command {
-    public function getId() {
+class PubSubPublish extends Command
+{
+    public function getId()
+    {
         return 'PUBLISH';
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 10 - 5
lib/Predis/Commands/PubSubSubscribe.php

@@ -4,20 +4,25 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class PubSubSubscribe extends Command {
-    public function getId() {
+class PubSubSubscribe extends Command
+{
+    public function getId()
+    {
         return 'SUBSCRIBE';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterArrayArguments($arguments);
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 4 - 2
lib/Predis/Commands/PubSubSubscribeByPattern.php

@@ -4,8 +4,10 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class PubSubSubscribeByPattern extends PubSubSubscribe {
-    public function getId() {
+class PubSubSubscribeByPattern extends PubSubSubscribe
+{
+    public function getId()
+    {
         return 'PSUBSCRIBE';
     }
 }

+ 8 - 4
lib/Predis/Commands/PubSubUnsubscribe.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class PubSubUnsubscribe extends Command {
-    public function getId() {
+class PubSubUnsubscribe extends Command
+{
+    public function getId()
+    {
         return 'UNSUBSCRIBE';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 4 - 2
lib/Predis/Commands/PubSubUnsubscribeByPattern.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class PubSubUnsubscribeByPattern extends PubSubUnsubscribe {
-    public function getId() {
+class PubSubUnsubscribeByPattern extends PubSubUnsubscribe
+{
+    public function getId()
+    {
         return 'PUNSUBSCRIBE';
     }
 }

+ 8 - 4
lib/Predis/Commands/ScriptedCommand.php

@@ -2,20 +2,24 @@
 
 namespace Predis\Commands;
 
-abstract class ScriptedCommand extends ServerEval {
+abstract class ScriptedCommand extends ServerEval
+{
     public abstract function getScript();
 
-    protected function keysCount() {
+    protected function keysCount()
+    {
         // The default behaviour for the base class is to use all the arguments
         // passed to a scripted command to populate the KEYS table in Lua.
         return count($this->getArguments());
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return array_merge(array($this->getScript(), $this->keysCount()), $arguments);
     }
 
-    protected function getKeys() {
+    protected function getKeys()
+    {
         return array_slice($this->getArguments(), 2, $this->keysCount());
     }
 }

+ 10 - 5
lib/Predis/Commands/ServerBackgroundRewriteAOF.php

@@ -2,20 +2,25 @@
 
 namespace Predis\Commands;
 
-class ServerBackgroundRewriteAOF extends Command {
-    public function getId() {
+class ServerBackgroundRewriteAOF extends Command
+{
+    public function getId()
+    {
         return 'BGREWRITEAOF';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return $data == 'Background append only file rewriting started';
     }
 }

+ 11 - 5
lib/Predis/Commands/ServerBackgroundSave.php

@@ -2,23 +2,29 @@
 
 namespace Predis\Commands;
 
-class ServerBackgroundSave extends Command {
-    public function getId() {
+class ServerBackgroundSave extends Command
+{
+    public function getId()
+    {
         return 'BGSAVE';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         if ($data == 'Background saving started') {
             return true;
         }
+
         return $data;
     }
 }

+ 15 - 6
lib/Predis/Commands/ServerClient.php

@@ -2,32 +2,40 @@
 
 namespace Predis\Commands;
 
-class ServerClient extends Command {
-    public function getId() {
+class ServerClient extends Command
+{
+    public function getId()
+    {
         return 'CLIENT';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         $args = array_change_key_case($this->getArguments(), CASE_UPPER);
         switch (strtoupper($args[0])) {
             case 'LIST':
                 return $this->parseClientList($data);
+
             case 'KILL':
             default:
                 return $data;
         }
     }
 
-    protected function parseClientList($data) {
+    protected function parseClientList($data)
+    {
         $clients = array();
+
         foreach (explode("\n", $data, -1) as $clientData) {
             $client = array();
             foreach (explode(' ', $clientData) as $kv) {
@@ -36,6 +44,7 @@ class ServerClient extends Command {
             }
             $clients[] = $client;
         }
+
         return $clients;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerConfig.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerConfig extends Command {
-    public function getId() {
+class ServerConfig extends Command
+{
+    public function getId()
+    {
         return 'CONFIG';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerDatabaseSize.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerDatabaseSize extends Command {
-    public function getId() {
+class ServerDatabaseSize extends Command
+{
+    public function getId()
+    {
         return 'DBSIZE';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 10 - 4
lib/Predis/Commands/ServerEval.php

@@ -2,20 +2,26 @@
 
 namespace Predis\Commands;
 
-class ServerEval extends Command {
-    public function getId() {
+class ServerEval extends Command
+{
+    public function getId()
+    {
         return 'EVAL';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         $arguments = $this->getArguments();
+
         for ($i = 2; $i < $arguments[1] + 2; $i++) {
             $arguments[$i] = "$prefix{$arguments[$i]}";
         }
+
         return $arguments;
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 4 - 2
lib/Predis/Commands/ServerEvalSHA.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class ServerEvalSHA extends ServerEval {
-    public function getId() {
+class ServerEvalSHA extends ServerEval
+{
+    public function getId()
+    {
         return 'EVALSHA';
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerFlushAll.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerFlushAll extends Command {
-    public function getId() {
+class ServerFlushAll extends Command
+{
+    public function getId()
+    {
         return 'FLUSHALL';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerFlushDatabase.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerFlushDatabase extends Command {
-    public function getId() {
+class ServerFlushDatabase extends Command
+{
+    public function getId()
+    {
         return 'FLUSHDB';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 23 - 7
lib/Predis/Commands/ServerInfo.php

@@ -2,27 +2,35 @@
 
 namespace Predis\Commands;
 
-class ServerInfo extends Command {
-    public function getId() {
+class ServerInfo extends Command
+{
+    public function getId()
+    {
         return 'INFO';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         $info      = array();
         $infoLines = explode("\r\n", $data, -1);
+
         foreach ($infoLines as $row) {
             @list($k, $v) = explode(':', $row);
+
             if ($row === '' || !isset($v)) {
                 continue;
             }
+
             if (!preg_match('/^db\d+$/', $k)) {
                 if ($k === 'allocation_stats') {
                     $info[$k] = $this->parseAllocationStats($v);
@@ -34,22 +42,29 @@ class ServerInfo extends Command {
                 $info[$k] = $this->parseDatabaseStats($v);
             }
         }
+
         return $info;
     }
 
-    protected function parseDatabaseStats($str) {
+    protected function parseDatabaseStats($str)
+    {
         $db = array();
+
         foreach (explode(',', $str) as $dbvar) {
             list($dbvk, $dbvv) = explode('=', $dbvar);
             $db[trim($dbvk)] = $dbvv;
         }
+
         return $db;
     }
 
-    protected function parseAllocationStats($str) {
+    protected function parseAllocationStats($str)
+    {
         $stats = array();
+
         foreach (explode(',', $str) as $kv) {
             @list($size, $objects, $extra) = explode('=', $kv);
+
             // hack to prevent incorrect values when parsing the >=256 key
             if (isset($extra)) {
                 $size = ">=$objects";
@@ -57,6 +72,7 @@ class ServerInfo extends Command {
             }
             $stats[$size] = $objects;
         }
+
         return $stats;
     }
 }

+ 11 - 4
lib/Predis/Commands/ServerInfoV26x.php

@@ -2,21 +2,27 @@
 
 namespace Predis\Commands;
 
-class ServerInfoV26x extends ServerInfo {
-    public function parseResponse($data) {
-        $info      = array();
-        $current   = null;
+class ServerInfoV26x extends ServerInfo
+{
+    public function parseResponse($data)
+    {
+        $info = array();
+        $current = null;
         $infoLines = explode("\r\n", $data, -1);
+
         foreach ($infoLines as $row) {
             if ($row === '') {
                 continue;
             }
+
             if (preg_match('/^# (\w+)$/', $row, $matches)) {
                 $info[$matches[1]] = array();
                 $current = &$info[$matches[1]];
                 continue;
             }
+
             list($k, $v) = explode(':', $row);
+
             if (!preg_match('/^db\d+$/', $k)) {
                 if ($k === 'allocation_stats') {
                     $current[$k] = $this->parseAllocationStats($v);
@@ -28,6 +34,7 @@ class ServerInfoV26x extends ServerInfo {
                 $current[$k] = $this->parseDatabaseStats($v);
             }
         }
+
         return $info;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerLastSave.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerLastSave extends Command {
-    public function getId() {
+class ServerLastSave extends Command
+{
+    public function getId()
+    {
         return 'LASTSAVE';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerMonitor.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerMonitor extends Command {
-    public function getId() {
+class ServerMonitor extends Command
+{
+    public function getId()
+    {
         return 'MONITOR';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerObject.php

@@ -4,16 +4,20 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class ServerObject extends Command {
-    public function getId() {
+class ServerObject extends Command
+{
+    public function getId()
+    {
         return 'OBJECT';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/ServerSave.php

@@ -2,16 +2,20 @@
 
 namespace Predis\Commands;
 
-class ServerSave extends Command {
-    public function getId() {
+class ServerSave extends Command
+{
+    public function getId()
+    {
         return 'SAVE';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 6 - 3
lib/Predis/Commands/ServerShutdown.php

@@ -2,16 +2,19 @@
 
 namespace Predis\Commands;
 
-class ServerShutdown extends Command {
+class ServerShutdown extends Command
+{
     public function getId() {
         return 'SHUTDOWN';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 11 - 5
lib/Predis/Commands/ServerSlaveOf.php

@@ -2,23 +2,29 @@
 
 namespace Predis\Commands;
 
-class ServerSlaveOf extends Command {
-    public function getId() {
+class ServerSlaveOf extends Command
+{
+    public function getId()
+    {
         return 'SLAVEOF';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         if (count($arguments) === 0 || $arguments[0] === 'NO ONE') {
             return array('NO', 'ONE');
         }
+
         return $arguments;
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         /* NOOP */
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return false;
     }
 }

+ 8 - 4
lib/Predis/Commands/SetAdd.php

@@ -4,16 +4,20 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class SetAdd extends Command {
-    public function getId() {
+class SetAdd extends Command
+{
+    public function getId()
+    {
         return 'SADD';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterVariadicValues($arguments);
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 4 - 2
lib/Predis/Commands/SetCardinality.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class SetCardinality extends Command {
-    public function getId() {
+class SetCardinality extends Command
+{
+    public function getId()
+    {
         return 'SCARD';
     }
 }

+ 6 - 3
lib/Predis/Commands/SetDifference.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class SetDifference extends SetIntersection {
-    public function getId() {
+class SetDifference extends SetIntersection
+{
+    public function getId()
+    {
         return 'SDIFF';
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 }

+ 4 - 2
lib/Predis/Commands/SetDifferenceStore.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class SetDifferenceStore extends SetIntersectionStore {
-    public function getId() {
+class SetDifferenceStore extends SetIntersectionStore
+{
+    public function getId()
+    {
         return 'SDIFFSTORE';
     }
 }

+ 10 - 5
lib/Predis/Commands/SetIntersection.php

@@ -4,20 +4,25 @@ namespace Predis\Commands;
 
 use Predis\Helpers;
 
-class SetIntersection extends Command {
-    public function getId() {
+class SetIntersection extends Command
+{
+    public function getId()
+    {
         return 'SINTER';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         return Helpers::filterArrayArguments($arguments);
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return $this->checkSameHashForKeys($this->getArguments());
     }
 }

+ 11 - 5
lib/Predis/Commands/SetIntersectionStore.php

@@ -2,23 +2,29 @@
 
 namespace Predis\Commands;
 
-class SetIntersectionStore extends Command {
-    public function getId() {
+class SetIntersectionStore extends Command
+{
+    public function getId()
+    {
         return 'SINTERSTORE';
     }
 
-    protected function filterArguments(Array $arguments) {
+    protected function filterArguments(Array $arguments)
+    {
         if (count($arguments) === 2 && is_array($arguments[1])) {
             return array_merge(array($arguments[0]), $arguments[1]);
         }
+
         return $arguments;
     }
 
-    protected function onPrefixKeys(Array $arguments, $prefix) {
+    protected function onPrefixKeys(Array $arguments, $prefix)
+    {
         return PrefixHelpers::multipleKeys($arguments, $prefix);
     }
 
-    protected function canBeHashed() {
+    protected function canBeHashed()
+    {
         return $this->checkSameHashForKeys($this->getArguments());
     }
 }

+ 6 - 3
lib/Predis/Commands/SetIsMember.php

@@ -2,12 +2,15 @@
 
 namespace Predis\Commands;
 
-class SetIsMember extends Command {
-    public function getId() {
+class SetIsMember extends Command
+{
+    public function getId()
+    {
         return 'SISMEMBER';
     }
 
-    public function parseResponse($data) {
+    public function parseResponse($data)
+    {
         return (bool) $data;
     }
 }

+ 4 - 2
lib/Predis/Commands/SetMembers.php

@@ -2,8 +2,10 @@
 
 namespace Predis\Commands;
 
-class SetMembers extends Command {
-    public function getId() {
+class SetMembers extends Command
+{
+    public function getId()
+    {
         return 'SMEMBERS';
     }
 }

Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů