diff --git a/lib/Predis/Commands/Append.php b/lib/Predis/Commands/Append.php index 006ef067..cd4256c4 100644 --- a/lib/Predis/Commands/Append.php +++ b/lib/Predis/Commands/Append.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Append extends Command { - public function getId() { return 'APPEND'; } + public function getId() { + return 'APPEND'; + } } diff --git a/lib/Predis/Commands/Auth.php b/lib/Predis/Commands/Auth.php index 966382d2..ad9ea3f6 100644 --- a/lib/Predis/Commands/Auth.php +++ b/lib/Predis/Commands/Auth.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Auth extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'AUTH'; } + public function getId() { + return 'AUTH'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php b/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php index 61c10ad0..07b4c3e4 100644 --- a/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php +++ b/lib/Predis/Commands/BackgroundRewriteAppendOnlyFile.php @@ -3,8 +3,14 @@ namespace Predis\Commands; class BackgroundRewriteAppendOnlyFile extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'BGREWRITEAOF'; } + public function getId() { + return 'BGREWRITEAOF'; + } + + protected function canBeHashed() { + return false; + } + public function parseResponse($data) { return $data == 'Background append only file rewriting started'; } diff --git a/lib/Predis/Commands/BackgroundSave.php b/lib/Predis/Commands/BackgroundSave.php index c65eb9f5..7c1e0ef1 100644 --- a/lib/Predis/Commands/BackgroundSave.php +++ b/lib/Predis/Commands/BackgroundSave.php @@ -3,8 +3,14 @@ namespace Predis\Commands; class BackgroundSave extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'BGSAVE'; } + public function getId() { + return 'BGSAVE'; + } + + protected function canBeHashed() { + return false; + } + public function parseResponse($data) { if ($data == 'Background saving started') { return true; diff --git a/lib/Predis/Commands/Command.php b/lib/Predis/Commands/Command.php index 5c607280..42eee048 100644 --- a/lib/Predis/Commands/Command.php +++ b/lib/Predis/Commands/Command.php @@ -8,6 +8,30 @@ abstract class Command implements ICommand { private $_hash; private $_arguments = array(); + protected function filterArguments(Array $arguments) { + return $arguments; + } + + public function setArguments(/* arguments */) { + $this->_arguments = $this->filterArguments(func_get_args()); + unset($this->_hash); + } + + public function setArgumentsArray(Array $arguments) { + $this->_arguments = $this->filterArguments($arguments); + unset($this->_hash); + } + + public function getArguments() { + return $this->_arguments; + } + + public function getArgument($index = 0) { + if (isset($this->_arguments[$index]) === true) { + return $this->_arguments[$index]; + } + } + protected function canBeHashed() { return isset($this->_arguments[0]); } @@ -50,30 +74,6 @@ abstract class Command implements ICommand { return null; } - protected function filterArguments(Array $arguments) { - return $arguments; - } - - public function setArguments(/* arguments */) { - $this->_arguments = $this->filterArguments(func_get_args()); - unset($this->_hash); - } - - public function setArgumentsArray(Array $arguments) { - $this->_arguments = $this->filterArguments($arguments); - unset($this->_hash); - } - - public function getArguments() { - return $this->_arguments; - } - - public function getArgument($index = 0) { - if (isset($this->_arguments[$index]) === true) { - return $this->_arguments[$index]; - } - } - public function parseResponse($data) { return $data; } diff --git a/lib/Predis/Commands/Config.php b/lib/Predis/Commands/Config.php index 2dde0c25..2faa9bee 100644 --- a/lib/Predis/Commands/Config.php +++ b/lib/Predis/Commands/Config.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Config extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'CONFIG'; } + public function getId() { + return 'CONFIG'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/DatabaseSize.php b/lib/Predis/Commands/DatabaseSize.php index b2c404c6..0768ea89 100644 --- a/lib/Predis/Commands/DatabaseSize.php +++ b/lib/Predis/Commands/DatabaseSize.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class DatabaseSize extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'DBSIZE'; } + public function getId() { + return 'DBSIZE'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Decrement.php b/lib/Predis/Commands/Decrement.php index e0dabac3..8c6f8e45 100644 --- a/lib/Predis/Commands/Decrement.php +++ b/lib/Predis/Commands/Decrement.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Decrement extends Command { - public function getId() { return 'DECR'; } + public function getId() { + return 'DECR'; + } } diff --git a/lib/Predis/Commands/DecrementBy.php b/lib/Predis/Commands/DecrementBy.php index a2784ba1..1b5df1c2 100644 --- a/lib/Predis/Commands/DecrementBy.php +++ b/lib/Predis/Commands/DecrementBy.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class DecrementBy extends Command { - public function getId() { return 'DECRBY'; } + public function getId() { + return 'DECRBY'; + } } diff --git a/lib/Predis/Commands/Delete.php b/lib/Predis/Commands/Delete.php index a844acdf..82cbb1da 100644 --- a/lib/Predis/Commands/Delete.php +++ b/lib/Predis/Commands/Delete.php @@ -5,6 +5,14 @@ namespace Predis\Commands; use Predis\Utils; class Delete extends Command { + public function getId() { + return 'DEL'; + } + + public function filterArguments(Array $arguments) { + return Utils::filterArrayArguments($arguments); + } + protected function canBeHashed() { $args = $this->getArguments(); if (count($args) === 1) { @@ -12,8 +20,4 @@ class Delete extends Command { } return $this->checkSameHashForKeys($args); } - public function getId() { return 'DEL'; } - public function filterArguments(Array $arguments) { - return Utils::filterArrayArguments($arguments); - } } diff --git a/lib/Predis/Commands/Discard.php b/lib/Predis/Commands/Discard.php index d0177cfd..c3e53f1d 100644 --- a/lib/Predis/Commands/Discard.php +++ b/lib/Predis/Commands/Discard.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Discard extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'DISCARD'; } + public function getId() { + return 'DISCARD'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/DoEcho.php b/lib/Predis/Commands/DoEcho.php index 5caa4ec8..aeeef8a4 100644 --- a/lib/Predis/Commands/DoEcho.php +++ b/lib/Predis/Commands/DoEcho.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class DoEcho extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'ECHO'; } + public function getId() { + return 'ECHO'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Exec.php b/lib/Predis/Commands/Exec.php index 99e6a851..bf641bdf 100644 --- a/lib/Predis/Commands/Exec.php +++ b/lib/Predis/Commands/Exec.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Exec extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'EXEC'; } + public function getId() { + return 'EXEC'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Exists.php b/lib/Predis/Commands/Exists.php index 4b2c840c..43bba57e 100644 --- a/lib/Predis/Commands/Exists.php +++ b/lib/Predis/Commands/Exists.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Exists extends Command { - public function getId() { return 'EXISTS'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'EXISTS'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/Expire.php b/lib/Predis/Commands/Expire.php index 3172b168..ec0cc674 100644 --- a/lib/Predis/Commands/Expire.php +++ b/lib/Predis/Commands/Expire.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Expire extends Command { - public function getId() { return 'EXPIRE'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'EXPIRE'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/ExpireAt.php b/lib/Predis/Commands/ExpireAt.php index 19af372f..3c7984b2 100644 --- a/lib/Predis/Commands/ExpireAt.php +++ b/lib/Predis/Commands/ExpireAt.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class ExpireAt extends Command { - public function getId() { return 'EXPIREAT'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'EXPIREAT'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/FlushAll.php b/lib/Predis/Commands/FlushAll.php index 1eb6bd61..953e4409 100644 --- a/lib/Predis/Commands/FlushAll.php +++ b/lib/Predis/Commands/FlushAll.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class FlushAll extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'FLUSHALL'; } + public function getId() { + return 'FLUSHALL'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/FlushDatabase.php b/lib/Predis/Commands/FlushDatabase.php index 448efb08..d9f05294 100644 --- a/lib/Predis/Commands/FlushDatabase.php +++ b/lib/Predis/Commands/FlushDatabase.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class FlushDatabase extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'FLUSHDB'; } + public function getId() { + return 'FLUSHDB'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Get.php b/lib/Predis/Commands/Get.php index 4a7bde63..c32b221e 100644 --- a/lib/Predis/Commands/Get.php +++ b/lib/Predis/Commands/Get.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Get extends Command { - public function getId() { return 'GET'; } + public function getId() { + return 'GET'; + } } diff --git a/lib/Predis/Commands/GetBit.php b/lib/Predis/Commands/GetBit.php index 8dd5f5e9..b064f4b9 100644 --- a/lib/Predis/Commands/GetBit.php +++ b/lib/Predis/Commands/GetBit.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class GetBit extends Command { - public function getId() { return 'GETBIT'; } + public function getId() { + return 'GETBIT'; + } } diff --git a/lib/Predis/Commands/GetMultiple.php b/lib/Predis/Commands/GetMultiple.php index 1c652c13..03a23966 100644 --- a/lib/Predis/Commands/GetMultiple.php +++ b/lib/Predis/Commands/GetMultiple.php @@ -5,11 +5,15 @@ namespace Predis\Commands; use Predis\Utils; class GetMultiple extends Command { - protected function canBeHashed() { - return $this->checkSameHashForKeys($this->getArguments()); + public function getId() { + return 'MGET'; } - public function getId() { return 'MGET'; } + public function filterArguments(Array $arguments) { return Utils::filterArrayArguments($arguments); } + + protected function canBeHashed() { + return $this->checkSameHashForKeys($this->getArguments()); + } } diff --git a/lib/Predis/Commands/GetRange.php b/lib/Predis/Commands/GetRange.php index e6b71b38..0be9e8a6 100644 --- a/lib/Predis/Commands/GetRange.php +++ b/lib/Predis/Commands/GetRange.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class GetRange extends Command { - public function getId() { return 'GETRANGE'; } + public function getId() { + return 'GETRANGE'; + } } diff --git a/lib/Predis/Commands/GetSet.php b/lib/Predis/Commands/GetSet.php index 36f5b611..816aba9a 100644 --- a/lib/Predis/Commands/GetSet.php +++ b/lib/Predis/Commands/GetSet.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class GetSet extends Command { - public function getId() { return 'GETSET'; } + public function getId() { + return 'GETSET'; + } } diff --git a/lib/Predis/Commands/HashDelete.php b/lib/Predis/Commands/HashDelete.php index 70af036e..b5b9cd2a 100644 --- a/lib/Predis/Commands/HashDelete.php +++ b/lib/Predis/Commands/HashDelete.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class HashDelete extends Command { - public function getId() { return 'HDEL'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'HDEL'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/HashExists.php b/lib/Predis/Commands/HashExists.php index fc4b6ba8..5f834d7c 100644 --- a/lib/Predis/Commands/HashExists.php +++ b/lib/Predis/Commands/HashExists.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class HashExists extends Command { - public function getId() { return 'HEXISTS'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'HEXISTS'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/HashGet.php b/lib/Predis/Commands/HashGet.php index 668db489..7b2bb7ca 100644 --- a/lib/Predis/Commands/HashGet.php +++ b/lib/Predis/Commands/HashGet.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class HashGet extends Command { - public function getId() { return 'HGET'; } + public function getId() { + return 'HGET'; + } } diff --git a/lib/Predis/Commands/HashGetAll.php b/lib/Predis/Commands/HashGetAll.php index f0d9c3a6..45992a0d 100644 --- a/lib/Predis/Commands/HashGetAll.php +++ b/lib/Predis/Commands/HashGetAll.php @@ -5,7 +5,10 @@ namespace Predis\Commands; use Predis\Iterators\MultiBulkResponseTuple; class HashGetAll extends Command { - public function getId() { return 'HGETALL'; } + public function getId() { + return 'HGETALL'; + } + public function parseResponse($data) { if ($data instanceof \Iterator) { return new MultiBulkResponseTuple($data); diff --git a/lib/Predis/Commands/HashGetMultiple.php b/lib/Predis/Commands/HashGetMultiple.php index 70bc8968..0cea1c17 100644 --- a/lib/Predis/Commands/HashGetMultiple.php +++ b/lib/Predis/Commands/HashGetMultiple.php @@ -3,7 +3,10 @@ namespace Predis\Commands; class HashGetMultiple extends Command { - public function getId() { return 'HMGET'; } + public function getId() { + return 'HMGET'; + } + public function filterArguments(Array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { $flattenedKVs = array($arguments[0]); diff --git a/lib/Predis/Commands/HashIncrementBy.php b/lib/Predis/Commands/HashIncrementBy.php index 910c4248..7f8570c1 100644 --- a/lib/Predis/Commands/HashIncrementBy.php +++ b/lib/Predis/Commands/HashIncrementBy.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class HashIncrementBy extends Command { - public function getId() { return 'HINCRBY'; } + public function getId() { + return 'HINCRBY'; + } } diff --git a/lib/Predis/Commands/HashKeys.php b/lib/Predis/Commands/HashKeys.php index 3d117d2d..23fcd18a 100644 --- a/lib/Predis/Commands/HashKeys.php +++ b/lib/Predis/Commands/HashKeys.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class HashKeys extends Command { - public function getId() { return 'HKEYS'; } + public function getId() { + return 'HKEYS'; + } } diff --git a/lib/Predis/Commands/HashLength.php b/lib/Predis/Commands/HashLength.php index 12b7b208..1da170a3 100644 --- a/lib/Predis/Commands/HashLength.php +++ b/lib/Predis/Commands/HashLength.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class HashLength extends Command { - public function getId() { return 'HLEN'; } + public function getId() { + return 'HLEN'; + } } diff --git a/lib/Predis/Commands/HashSet.php b/lib/Predis/Commands/HashSet.php index 12ce8926..0436f710 100644 --- a/lib/Predis/Commands/HashSet.php +++ b/lib/Predis/Commands/HashSet.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class HashSet extends Command { - public function getId() { return 'HSET'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'HSET'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/HashSetMultiple.php b/lib/Predis/Commands/HashSetMultiple.php index 1093b5a1..aaf75b61 100644 --- a/lib/Predis/Commands/HashSetMultiple.php +++ b/lib/Predis/Commands/HashSetMultiple.php @@ -3,7 +3,10 @@ namespace Predis\Commands; class HashSetMultiple extends Command { - public function getId() { return 'HMSET'; } + public function getId() { + return 'HMSET'; + } + public function filterArguments(Array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { $flattenedKVs = array($arguments[0]); diff --git a/lib/Predis/Commands/HashSetPreserve.php b/lib/Predis/Commands/HashSetPreserve.php index 3325f366..5f0cfb01 100644 --- a/lib/Predis/Commands/HashSetPreserve.php +++ b/lib/Predis/Commands/HashSetPreserve.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class HashSetPreserve extends Command { - public function getId() { return 'HSETNX'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'HSETNX'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/HashValues.php b/lib/Predis/Commands/HashValues.php index 4ced5eb2..03e16a68 100644 --- a/lib/Predis/Commands/HashValues.php +++ b/lib/Predis/Commands/HashValues.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class HashValues extends Command { - public function getId() { return 'HVALS'; } + public function getId() { + return 'HVALS'; + } } diff --git a/lib/Predis/Commands/Increment.php b/lib/Predis/Commands/Increment.php index dc21a817..35319f6a 100644 --- a/lib/Predis/Commands/Increment.php +++ b/lib/Predis/Commands/Increment.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Increment extends Command { - public function getId() { return 'INCR'; } + public function getId() { + return 'INCR'; + } } diff --git a/lib/Predis/Commands/IncrementBy.php b/lib/Predis/Commands/IncrementBy.php index e0345e3c..33cb41a8 100644 --- a/lib/Predis/Commands/IncrementBy.php +++ b/lib/Predis/Commands/IncrementBy.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class IncrementBy extends Command { - public function getId() { return 'INCRBY'; } + public function getId() { + return 'INCRBY'; + } } diff --git a/lib/Predis/Commands/Info.php b/lib/Predis/Commands/Info.php index a300e5a3..c6d244ad 100644 --- a/lib/Predis/Commands/Info.php +++ b/lib/Predis/Commands/Info.php @@ -3,8 +3,14 @@ namespace Predis\Commands; class Info extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'INFO'; } + public function getId() { + return 'INFO'; + } + + protected function canBeHashed() { + return false; + } + public function parseResponse($data) { $info = array(); $infoLines = explode("\r\n", $data, -1); @@ -26,6 +32,7 @@ class Info extends Command { } return $info; } + protected function parseDatabaseStats($str) { $db = array(); foreach (explode(',', $str) as $dbvar) { @@ -34,6 +41,7 @@ class Info extends Command { } return $db; } + protected function parseAllocationStats($str) { $stats = array(); foreach (explode(',', $str) as $kv) { diff --git a/lib/Predis/Commands/Keys.php b/lib/Predis/Commands/Keys.php index 339ba662..2510f903 100644 --- a/lib/Predis/Commands/Keys.php +++ b/lib/Predis/Commands/Keys.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Keys extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'KEYS'; } + public function getId() { + return 'KEYS'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/LastSave.php b/lib/Predis/Commands/LastSave.php index 4f8a6638..49768e8f 100644 --- a/lib/Predis/Commands/LastSave.php +++ b/lib/Predis/Commands/LastSave.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class LastSave extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'LASTSAVE'; } + public function getId() { + return 'LASTSAVE'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/ListIndex.php b/lib/Predis/Commands/ListIndex.php index 436d40c6..177a3009 100644 --- a/lib/Predis/Commands/ListIndex.php +++ b/lib/Predis/Commands/ListIndex.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListIndex extends Command { - public function getId() { return 'LINDEX'; } + public function getId() { + return 'LINDEX'; + } } diff --git a/lib/Predis/Commands/ListInsert.php b/lib/Predis/Commands/ListInsert.php index ee4a884f..c5420bba 100644 --- a/lib/Predis/Commands/ListInsert.php +++ b/lib/Predis/Commands/ListInsert.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListInsert extends Command { - public function getId() { return 'LINSERT'; } + public function getId() { + return 'LINSERT'; + } } diff --git a/lib/Predis/Commands/ListLength.php b/lib/Predis/Commands/ListLength.php index 53c882e1..28fa647e 100644 --- a/lib/Predis/Commands/ListLength.php +++ b/lib/Predis/Commands/ListLength.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListLength extends Command { - public function getId() { return 'LLEN'; } + public function getId() { + return 'LLEN'; + } } diff --git a/lib/Predis/Commands/ListPopFirst.php b/lib/Predis/Commands/ListPopFirst.php index 58c1f2d2..4399d38d 100644 --- a/lib/Predis/Commands/ListPopFirst.php +++ b/lib/Predis/Commands/ListPopFirst.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPopFirst extends Command { - public function getId() { return 'LPOP'; } + public function getId() { + return 'LPOP'; + } } diff --git a/lib/Predis/Commands/ListPopFirstBlocking.php b/lib/Predis/Commands/ListPopFirstBlocking.php index ee48a269..31c9b9ce 100644 --- a/lib/Predis/Commands/ListPopFirstBlocking.php +++ b/lib/Predis/Commands/ListPopFirstBlocking.php @@ -3,10 +3,13 @@ namespace Predis\Commands; class ListPopFirstBlocking extends Command { + public function getId() { + return 'BLPOP'; + } + protected function canBeHashed() { return $this->checkSameHashForKeys( array_slice(($args = $this->getArguments()), 0, count($args) - 1) ); } - public function getId() { return 'BLPOP'; } } diff --git a/lib/Predis/Commands/ListPopLast.php b/lib/Predis/Commands/ListPopLast.php index e13532c7..792df506 100644 --- a/lib/Predis/Commands/ListPopLast.php +++ b/lib/Predis/Commands/ListPopLast.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPopLast extends Command { - public function getId() { return 'RPOP'; } + public function getId() { + return 'RPOP'; + } } diff --git a/lib/Predis/Commands/ListPopLastBlocking.php b/lib/Predis/Commands/ListPopLastBlocking.php index 3e0372d5..22b148cd 100644 --- a/lib/Predis/Commands/ListPopLastBlocking.php +++ b/lib/Predis/Commands/ListPopLastBlocking.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPopLastBlocking extends ListPopFirstBlocking { - public function getId() { return 'BRPOP'; } + public function getId() { + return 'BRPOP'; + } } diff --git a/lib/Predis/Commands/ListPopLastPushHead.php b/lib/Predis/Commands/ListPopLastPushHead.php index a5b934f6..390d7213 100644 --- a/lib/Predis/Commands/ListPopLastPushHead.php +++ b/lib/Predis/Commands/ListPopLastPushHead.php @@ -3,8 +3,11 @@ namespace Predis\Commands; class ListPopLastPushHead extends Command { + public function getId() { + return 'RPOPLPUSH'; + } + protected function canBeHashed() { return $this->checkSameHashForKeys($this->getArguments()); } - public function getId() { return 'RPOPLPUSH'; } } diff --git a/lib/Predis/Commands/ListPopLastPushHeadBlocking.php b/lib/Predis/Commands/ListPopLastPushHeadBlocking.php index 02152170..0e0088fa 100644 --- a/lib/Predis/Commands/ListPopLastPushHeadBlocking.php +++ b/lib/Predis/Commands/ListPopLastPushHeadBlocking.php @@ -3,10 +3,13 @@ namespace Predis\Commands; class ListPopLastPushHeadBlocking extends Command { + public function getId() { + return 'BRPOPLPUSH'; + } + protected function canBeHashed() { return $this->checkSameHashForKeys( array_slice($args = $this->getArguments(), 0, count($args) - 1) ); } - public function getId() { return 'BRPOPLPUSH'; } } diff --git a/lib/Predis/Commands/ListPushHead.php b/lib/Predis/Commands/ListPushHead.php index 26b6f9a4..9620975a 100644 --- a/lib/Predis/Commands/ListPushHead.php +++ b/lib/Predis/Commands/ListPushHead.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPushHead extends Command { - public function getId() { return 'LPUSH'; } + public function getId() { + return 'LPUSH'; + } } diff --git a/lib/Predis/Commands/ListPushHeadX.php b/lib/Predis/Commands/ListPushHeadX.php index ce592a8f..55ad1689 100644 --- a/lib/Predis/Commands/ListPushHeadX.php +++ b/lib/Predis/Commands/ListPushHeadX.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPushHeadX extends Command { - public function getId() { return 'LPUSHX'; } + public function getId() { + return 'LPUSHX'; + } } diff --git a/lib/Predis/Commands/ListPushTail.php b/lib/Predis/Commands/ListPushTail.php index b09e5c02..eb472bf4 100644 --- a/lib/Predis/Commands/ListPushTail.php +++ b/lib/Predis/Commands/ListPushTail.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPushTail extends Command { - public function getId() { return 'RPUSH'; } + public function getId() { + return 'RPUSH'; + } } diff --git a/lib/Predis/Commands/ListPushTailX.php b/lib/Predis/Commands/ListPushTailX.php index badddb72..55225ac2 100644 --- a/lib/Predis/Commands/ListPushTailX.php +++ b/lib/Predis/Commands/ListPushTailX.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListPushTailX extends Command { - public function getId() { return 'RPUSHX'; } + public function getId() { + return 'RPUSHX'; + } } diff --git a/lib/Predis/Commands/ListRange.php b/lib/Predis/Commands/ListRange.php index 55034a1b..5f2a14cd 100644 --- a/lib/Predis/Commands/ListRange.php +++ b/lib/Predis/Commands/ListRange.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListRange extends Command { - public function getId() { return 'LRANGE'; } + public function getId() { + return 'LRANGE'; + } } diff --git a/lib/Predis/Commands/ListRemove.php b/lib/Predis/Commands/ListRemove.php index 296b5213..c28ccaa4 100644 --- a/lib/Predis/Commands/ListRemove.php +++ b/lib/Predis/Commands/ListRemove.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListRemove extends Command { - public function getId() { return 'LREM'; } + public function getId() { + return 'LREM'; + } } diff --git a/lib/Predis/Commands/ListSet.php b/lib/Predis/Commands/ListSet.php index 98ab7852..e39a4c47 100644 --- a/lib/Predis/Commands/ListSet.php +++ b/lib/Predis/Commands/ListSet.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListSet extends Command { - public function getId() { return 'LSET'; } + public function getId() { + return 'LSET'; + } } diff --git a/lib/Predis/Commands/ListTrim.php b/lib/Predis/Commands/ListTrim.php index a5189e34..b7bb4d75 100644 --- a/lib/Predis/Commands/ListTrim.php +++ b/lib/Predis/Commands/ListTrim.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ListTrim extends Command { - public function getId() { return 'LTRIM'; } + public function getId() { + return 'LTRIM'; + } } diff --git a/lib/Predis/Commands/MoveKey.php b/lib/Predis/Commands/MoveKey.php index b343dbc5..67089dde 100644 --- a/lib/Predis/Commands/MoveKey.php +++ b/lib/Predis/Commands/MoveKey.php @@ -3,7 +3,15 @@ namespace Predis\Commands; class MoveKey extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'MOVE'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'MOVE'; + } + + protected function canBeHashed() { + return false; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/Multi.php b/lib/Predis/Commands/Multi.php index 4a4383e5..8322cf4a 100644 --- a/lib/Predis/Commands/Multi.php +++ b/lib/Predis/Commands/Multi.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Multi extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'MULTI'; } + public function getId() { + return 'MULTI'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Persist.php b/lib/Predis/Commands/Persist.php index ff0f5175..8a56d431 100644 --- a/lib/Predis/Commands/Persist.php +++ b/lib/Predis/Commands/Persist.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Persist extends Command { - public function getId() { return 'PERSIST'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'PERSIST'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/Ping.php b/lib/Predis/Commands/Ping.php index e6efd65e..f5025307 100644 --- a/lib/Predis/Commands/Ping.php +++ b/lib/Predis/Commands/Ping.php @@ -3,8 +3,14 @@ namespace Predis\Commands; class Ping extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'PING'; } + public function getId() { + return 'PING'; + } + + protected function canBeHashed() { + return false; + } + public function parseResponse($data) { return $data === 'PONG' ? true : false; } diff --git a/lib/Predis/Commands/Publish.php b/lib/Predis/Commands/Publish.php index 74f35639..b29025c6 100644 --- a/lib/Predis/Commands/Publish.php +++ b/lib/Predis/Commands/Publish.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Publish extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'PUBLISH'; } + public function getId() { + return 'PUBLISH'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Quit.php b/lib/Predis/Commands/Quit.php index a53faa9f..1f80a862 100644 --- a/lib/Predis/Commands/Quit.php +++ b/lib/Predis/Commands/Quit.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Quit extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'QUIT'; } + public function getId() { + return 'QUIT'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/RandomKey.php b/lib/Predis/Commands/RandomKey.php index a8ec603c..0eea5e0b 100644 --- a/lib/Predis/Commands/RandomKey.php +++ b/lib/Predis/Commands/RandomKey.php @@ -3,7 +3,15 @@ namespace Predis\Commands; class RandomKey extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'RANDOMKEY'; } - public function parseResponse($data) { return $data !== '' ? $data : null; } + public function getId() { + return 'RANDOMKEY'; + } + + protected function canBeHashed() { + return false; + } + + public function parseResponse($data) { + return $data !== '' ? $data : null; + } } diff --git a/lib/Predis/Commands/Rename.php b/lib/Predis/Commands/Rename.php index f6a973cd..b7ff7e46 100644 --- a/lib/Predis/Commands/Rename.php +++ b/lib/Predis/Commands/Rename.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Rename extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'RENAME'; } + public function getId() { + return 'RENAME'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/RenamePreserve.php b/lib/Predis/Commands/RenamePreserve.php index f88e4190..725421b9 100644 --- a/lib/Predis/Commands/RenamePreserve.php +++ b/lib/Predis/Commands/RenamePreserve.php @@ -3,7 +3,15 @@ namespace Predis\Commands; class RenamePreserve extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'RENAMENX'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'RENAMENX'; + } + + protected function canBeHashed() { + return false; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/Save.php b/lib/Predis/Commands/Save.php index 6d8f675f..b8f7b5e5 100644 --- a/lib/Predis/Commands/Save.php +++ b/lib/Predis/Commands/Save.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Save extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'SAVE'; } + public function getId() { + return 'SAVE'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/SelectDatabase.php b/lib/Predis/Commands/SelectDatabase.php index fa3b6785..d831ddd4 100644 --- a/lib/Predis/Commands/SelectDatabase.php +++ b/lib/Predis/Commands/SelectDatabase.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class SelectDatabase extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'SELECT'; } + public function getId() { + return 'SELECT'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Set.php b/lib/Predis/Commands/Set.php index a2fe3580..1dbf148a 100644 --- a/lib/Predis/Commands/Set.php +++ b/lib/Predis/Commands/Set.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Set extends Command { - public function getId() { return 'SET'; } + public function getId() { + return 'SET'; + } } diff --git a/lib/Predis/Commands/SetAdd.php b/lib/Predis/Commands/SetAdd.php index b4c9ca98..fd159146 100644 --- a/lib/Predis/Commands/SetAdd.php +++ b/lib/Predis/Commands/SetAdd.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class SetAdd extends Command { - public function getId() { return 'SADD'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'SADD'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/SetBit.php b/lib/Predis/Commands/SetBit.php index 69c97807..cefd1707 100644 --- a/lib/Predis/Commands/SetBit.php +++ b/lib/Predis/Commands/SetBit.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetBit extends Command { - public function getId() { return 'SETBIT'; } + public function getId() { + return 'SETBIT'; + } } diff --git a/lib/Predis/Commands/SetCardinality.php b/lib/Predis/Commands/SetCardinality.php index 755ce039..49f5c138 100644 --- a/lib/Predis/Commands/SetCardinality.php +++ b/lib/Predis/Commands/SetCardinality.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetCardinality extends Command { - public function getId() { return 'SCARD'; } + public function getId() { + return 'SCARD'; + } } diff --git a/lib/Predis/Commands/SetDifference.php b/lib/Predis/Commands/SetDifference.php index a83ad6fc..e509d61c 100644 --- a/lib/Predis/Commands/SetDifference.php +++ b/lib/Predis/Commands/SetDifference.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetDifference extends SetIntersection { - public function getId() { return 'SDIFF'; } + public function getId() { + return 'SDIFF'; + } } diff --git a/lib/Predis/Commands/SetDifferenceStore.php b/lib/Predis/Commands/SetDifferenceStore.php index 6675650f..8677110d 100644 --- a/lib/Predis/Commands/SetDifferenceStore.php +++ b/lib/Predis/Commands/SetDifferenceStore.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetDifferenceStore extends SetIntersectionStore { - public function getId() { return 'SDIFFSTORE'; } + public function getId() { + return 'SDIFFSTORE'; + } } diff --git a/lib/Predis/Commands/SetExpire.php b/lib/Predis/Commands/SetExpire.php index 4d056dcb..93dd6a31 100644 --- a/lib/Predis/Commands/SetExpire.php +++ b/lib/Predis/Commands/SetExpire.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetExpire extends Command { - public function getId() { return 'SETEX'; } + public function getId() { + return 'SETEX'; + } } diff --git a/lib/Predis/Commands/SetIntersection.php b/lib/Predis/Commands/SetIntersection.php index 0fd86d6c..6040d88f 100644 --- a/lib/Predis/Commands/SetIntersection.php +++ b/lib/Predis/Commands/SetIntersection.php @@ -5,11 +5,15 @@ namespace Predis\Commands; use Predis\Utils; class SetIntersection extends Command { - protected function canBeHashed() { - return $this->checkSameHashForKeys($this->getArguments()); + public function getId() { + return 'SINTER'; } - public function getId() { return 'SINTER'; } + public function filterArguments(Array $arguments) { return Utils::filterArrayArguments($arguments); } + + protected function canBeHashed() { + return $this->checkSameHashForKeys($this->getArguments()); + } } diff --git a/lib/Predis/Commands/SetIntersectionStore.php b/lib/Predis/Commands/SetIntersectionStore.php index 07ae61af..84ad5544 100644 --- a/lib/Predis/Commands/SetIntersectionStore.php +++ b/lib/Predis/Commands/SetIntersectionStore.php @@ -5,14 +5,18 @@ namespace Predis\Commands; use Predis\Utils; class SetIntersectionStore extends Command { - protected function canBeHashed() { - return $this->checkSameHashForKeys($this->getArguments()); + public function getId() { + return 'SINTERSTORE'; } - public function getId() { return 'SINTERSTORE'; } + public function filterArguments(Array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { return array_merge(array($arguments[0]), $arguments[1]); } return $arguments; } + + protected function canBeHashed() { + return $this->checkSameHashForKeys($this->getArguments()); + } } diff --git a/lib/Predis/Commands/SetIsMember.php b/lib/Predis/Commands/SetIsMember.php index a2f7981b..d1e3557e 100644 --- a/lib/Predis/Commands/SetIsMember.php +++ b/lib/Predis/Commands/SetIsMember.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class SetIsMember extends Command { - public function getId() { return 'SISMEMBER'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'SISMEMBER'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/SetMembers.php b/lib/Predis/Commands/SetMembers.php index 842d55d6..ea5383c9 100644 --- a/lib/Predis/Commands/SetMembers.php +++ b/lib/Predis/Commands/SetMembers.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetMembers extends Command { - public function getId() { return 'SMEMBERS'; } + public function getId() { + return 'SMEMBERS'; + } } diff --git a/lib/Predis/Commands/SetMove.php b/lib/Predis/Commands/SetMove.php index e5ed7748..0d5de8e3 100644 --- a/lib/Predis/Commands/SetMove.php +++ b/lib/Predis/Commands/SetMove.php @@ -3,7 +3,15 @@ namespace Predis\Commands; class SetMove extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'SMOVE'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'SMOVE'; + } + + protected function canBeHashed() { + return false; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/SetMultiple.php b/lib/Predis/Commands/SetMultiple.php index a0e14e5d..38bea8bd 100644 --- a/lib/Predis/Commands/SetMultiple.php +++ b/lib/Predis/Commands/SetMultiple.php @@ -3,15 +3,10 @@ namespace Predis\Commands; class SetMultiple extends Command { - protected function canBeHashed() { - $args = $this->getArguments(); - $keys = array(); - for ($i = 0; $i < count($args); $i += 2) { - $keys[] = $args[$i]; - } - return $this->checkSameHashForKeys($keys); + public function getId() { + return 'MSET'; } - public function getId() { return 'MSET'; } + public function filterArguments(Array $arguments) { if (count($arguments) === 1 && is_array($arguments[0])) { $flattenedKVs = array(); @@ -24,4 +19,13 @@ class SetMultiple extends Command { } return $arguments; } + + protected function canBeHashed() { + $args = $this->getArguments(); + $keys = array(); + for ($i = 0; $i < count($args); $i += 2) { + $keys[] = $args[$i]; + } + return $this->checkSameHashForKeys($keys); + } } diff --git a/lib/Predis/Commands/SetMultiplePreserve.php b/lib/Predis/Commands/SetMultiplePreserve.php index d2d93677..c568b0a0 100644 --- a/lib/Predis/Commands/SetMultiplePreserve.php +++ b/lib/Predis/Commands/SetMultiplePreserve.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class SetMultiplePreserve extends SetMultiple { - public function getId() { return 'MSETNX'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'MSETNX'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/SetPop.php b/lib/Predis/Commands/SetPop.php index 953963d2..1bef449a 100644 --- a/lib/Predis/Commands/SetPop.php +++ b/lib/Predis/Commands/SetPop.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetPop extends Command { - public function getId() { return 'SPOP'; } + public function getId() { + return 'SPOP'; + } } diff --git a/lib/Predis/Commands/SetPreserve.php b/lib/Predis/Commands/SetPreserve.php index d0e13c36..5643da19 100644 --- a/lib/Predis/Commands/SetPreserve.php +++ b/lib/Predis/Commands/SetPreserve.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class SetPreserve extends Command { - public function getId() { return 'SETNX'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'SETNX'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/SetRandomMember.php b/lib/Predis/Commands/SetRandomMember.php index 67b5773b..06fe2d77 100644 --- a/lib/Predis/Commands/SetRandomMember.php +++ b/lib/Predis/Commands/SetRandomMember.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetRandomMember extends Command { - public function getId() { return 'SRANDMEMBER'; } + public function getId() { + return 'SRANDMEMBER'; + } } diff --git a/lib/Predis/Commands/SetRange.php b/lib/Predis/Commands/SetRange.php index ddf88d19..7e6ee3e6 100644 --- a/lib/Predis/Commands/SetRange.php +++ b/lib/Predis/Commands/SetRange.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetRange extends Command { - public function getId() { return 'SETRANGE'; } + public function getId() { + return 'SETRANGE'; + } } diff --git a/lib/Predis/Commands/SetRemove.php b/lib/Predis/Commands/SetRemove.php index 3b143234..9a683b7b 100644 --- a/lib/Predis/Commands/SetRemove.php +++ b/lib/Predis/Commands/SetRemove.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class SetRemove extends Command { - public function getId() { return 'SREM'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'SREM'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/SetUnion.php b/lib/Predis/Commands/SetUnion.php index e317ca7d..b1cab8e0 100644 --- a/lib/Predis/Commands/SetUnion.php +++ b/lib/Predis/Commands/SetUnion.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetUnion extends SetIntersection { - public function getId() { return 'SUNION'; } + public function getId() { + return 'SUNION'; + } } diff --git a/lib/Predis/Commands/SetUnionStore.php b/lib/Predis/Commands/SetUnionStore.php index e136f917..b154532b 100644 --- a/lib/Predis/Commands/SetUnionStore.php +++ b/lib/Predis/Commands/SetUnionStore.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class SetUnionStore extends SetIntersectionStore { - public function getId() { return 'SUNIONSTORE'; } + public function getId() { + return 'SUNIONSTORE'; + } } diff --git a/lib/Predis/Commands/Shutdown.php b/lib/Predis/Commands/Shutdown.php index 33e48807..75afb267 100644 --- a/lib/Predis/Commands/Shutdown.php +++ b/lib/Predis/Commands/Shutdown.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Shutdown extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'SHUTDOWN'; } + public function getId() { + return 'SHUTDOWN'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/SlaveOf.php b/lib/Predis/Commands/SlaveOf.php index 2067baac..eecad75f 100644 --- a/lib/Predis/Commands/SlaveOf.php +++ b/lib/Predis/Commands/SlaveOf.php @@ -3,12 +3,18 @@ namespace Predis\Commands; class SlaveOf extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'SLAVEOF'; } + public function getId() { + return 'SLAVEOF'; + } + public function filterArguments(Array $arguments) { if (count($arguments) === 0 || $arguments[0] === 'NO ONE') { return array('NO', 'ONE'); } return $arguments; } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Sort.php b/lib/Predis/Commands/Sort.php index 8f61aaac..e127ac8a 100644 --- a/lib/Predis/Commands/Sort.php +++ b/lib/Predis/Commands/Sort.php @@ -3,7 +3,10 @@ namespace Predis\Commands; class Sort extends Command { - public function getId() { return 'SORT'; } + public function getId() { + return 'SORT'; + } + public function filterArguments(Array $arguments) { if (count($arguments) === 1) { return $arguments; diff --git a/lib/Predis/Commands/Strlen.php b/lib/Predis/Commands/Strlen.php index 313eef06..bbdd6831 100644 --- a/lib/Predis/Commands/Strlen.php +++ b/lib/Predis/Commands/Strlen.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Strlen extends Command { - public function getId() { return 'STRLEN'; } + public function getId() { + return 'STRLEN'; + } } diff --git a/lib/Predis/Commands/Subscribe.php b/lib/Predis/Commands/Subscribe.php index 698f3366..572db17b 100644 --- a/lib/Predis/Commands/Subscribe.php +++ b/lib/Predis/Commands/Subscribe.php @@ -5,9 +5,15 @@ namespace Predis\Commands; use Predis\Utils; class Subscribe extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'SUBSCRIBE'; } + public function getId() { + return 'SUBSCRIBE'; + } + public function filterArguments(Array $arguments) { return Utils::filterArrayArguments($arguments); } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/SubscribeByPattern.php b/lib/Predis/Commands/SubscribeByPattern.php index b0cf30ce..fa6b4e81 100644 --- a/lib/Predis/Commands/SubscribeByPattern.php +++ b/lib/Predis/Commands/SubscribeByPattern.php @@ -3,9 +3,15 @@ namespace Predis\Commands; class SubscribeByPattern extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'PSUBSCRIBE'; } + public function getId() { + return 'PSUBSCRIBE'; + } + public function filterArguments(Array $arguments) { return Utils::filterArrayArguments($arguments); } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Substr.php b/lib/Predis/Commands/Substr.php index aeb676be..af9b8151 100644 --- a/lib/Predis/Commands/Substr.php +++ b/lib/Predis/Commands/Substr.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Substr extends Command { - public function getId() { return 'SUBSTR'; } + public function getId() { + return 'SUBSTR'; + } } diff --git a/lib/Predis/Commands/TimeToLive.php b/lib/Predis/Commands/TimeToLive.php index c2f0575e..4ca394e8 100644 --- a/lib/Predis/Commands/TimeToLive.php +++ b/lib/Predis/Commands/TimeToLive.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class TimeToLive extends Command { - public function getId() { return 'TTL'; } + public function getId() { + return 'TTL'; + } } diff --git a/lib/Predis/Commands/Type.php b/lib/Predis/Commands/Type.php index 3ff3f42e..425d1928 100644 --- a/lib/Predis/Commands/Type.php +++ b/lib/Predis/Commands/Type.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class Type extends Command { - public function getId() { return 'TYPE'; } + public function getId() { + return 'TYPE'; + } } diff --git a/lib/Predis/Commands/Unsubscribe.php b/lib/Predis/Commands/Unsubscribe.php index ac854212..42ad1862 100644 --- a/lib/Predis/Commands/Unsubscribe.php +++ b/lib/Predis/Commands/Unsubscribe.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class Unsubscribe extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'UNSUBSCRIBE'; } + public function getId() { + return 'UNSUBSCRIBE'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/UnsubscribeByPattern.php b/lib/Predis/Commands/UnsubscribeByPattern.php index bc02da47..47b106d8 100644 --- a/lib/Predis/Commands/UnsubscribeByPattern.php +++ b/lib/Predis/Commands/UnsubscribeByPattern.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class UnsubscribeByPattern extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'PUNSUBSCRIBE'; } + public function getId() { + return 'PUNSUBSCRIBE'; + } + + protected function canBeHashed() { + return false; + } } diff --git a/lib/Predis/Commands/Unwatch.php b/lib/Predis/Commands/Unwatch.php index a476a169..0c8cfb06 100644 --- a/lib/Predis/Commands/Unwatch.php +++ b/lib/Predis/Commands/Unwatch.php @@ -3,7 +3,15 @@ namespace Predis\Commands; class Unwatch extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'UNWATCH'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'UNWATCH'; + } + + protected function canBeHashed() { + return false; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/Watch.php b/lib/Predis/Commands/Watch.php index a8c57c4c..daef71f9 100644 --- a/lib/Predis/Commands/Watch.php +++ b/lib/Predis/Commands/Watch.php @@ -3,13 +3,22 @@ namespace Predis\Commands; class Watch extends Command { - protected function canBeHashed() { return false; } - public function getId() { return 'WATCH'; } + public function getId() { + return 'WATCH'; + } + public function filterArguments(Array $arguments) { if (isset($arguments[0]) && is_array($arguments[0])) { return $arguments[0]; } return $arguments; } - public function parseResponse($data) { return (bool) $data; } + + protected function canBeHashed() { + return false; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/ZSetAdd.php b/lib/Predis/Commands/ZSetAdd.php index e9a9c050..1c68c535 100644 --- a/lib/Predis/Commands/ZSetAdd.php +++ b/lib/Predis/Commands/ZSetAdd.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class ZSetAdd extends Command { - public function getId() { return 'ZADD'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'ZADD'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/ZSetCardinality.php b/lib/Predis/Commands/ZSetCardinality.php index 88d100da..9b2f3524 100644 --- a/lib/Predis/Commands/ZSetCardinality.php +++ b/lib/Predis/Commands/ZSetCardinality.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetCardinality extends Command { - public function getId() { return 'ZCARD'; } + public function getId() { + return 'ZCARD'; + } } diff --git a/lib/Predis/Commands/ZSetCount.php b/lib/Predis/Commands/ZSetCount.php index 7904af0f..f7b581ce 100644 --- a/lib/Predis/Commands/ZSetCount.php +++ b/lib/Predis/Commands/ZSetCount.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetCount extends Command { - public function getId() { return 'ZCOUNT'; } + public function getId() { + return 'ZCOUNT'; + } } diff --git a/lib/Predis/Commands/ZSetIncrementBy.php b/lib/Predis/Commands/ZSetIncrementBy.php index 7e9ecd21..dfa7e791 100644 --- a/lib/Predis/Commands/ZSetIncrementBy.php +++ b/lib/Predis/Commands/ZSetIncrementBy.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetIncrementBy extends Command { - public function getId() { return 'ZINCRBY'; } + public function getId() { + return 'ZINCRBY'; + } } diff --git a/lib/Predis/Commands/ZSetIntersectionStore.php b/lib/Predis/Commands/ZSetIntersectionStore.php index 11bc9e91..98afd4db 100644 --- a/lib/Predis/Commands/ZSetIntersectionStore.php +++ b/lib/Predis/Commands/ZSetIntersectionStore.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetIntersectionStore extends ZSetUnionStore { - public function getId() { return 'ZINTERSTORE'; } + public function getId() { + return 'ZINTERSTORE'; + } } diff --git a/lib/Predis/Commands/ZSetRange.php b/lib/Predis/Commands/ZSetRange.php index 3d3826e8..69d97ef1 100644 --- a/lib/Predis/Commands/ZSetRange.php +++ b/lib/Predis/Commands/ZSetRange.php @@ -6,7 +6,11 @@ use Predis\Iterators\MultiBulkResponseTuple; class ZSetRange extends Command { private $_withScores = false; - public function getId() { return 'ZRANGE'; } + + public function getId() { + return 'ZRANGE'; + } + public function filterArguments(Array $arguments) { if (count($arguments) === 4) { $lastType = gettype($arguments[3]); @@ -22,6 +26,7 @@ class ZSetRange extends Command { } return $arguments; } + protected function prepareOptions($options) { $opts = array_change_key_case($options, CASE_UPPER); $finalizedOpts = array(); @@ -31,6 +36,7 @@ class ZSetRange extends Command { } return $finalizedOpts; } + public function parseResponse($data) { if ($this->_withScores) { if ($data instanceof \Iterator) { diff --git a/lib/Predis/Commands/ZSetRangeByScore.php b/lib/Predis/Commands/ZSetRangeByScore.php index 8bdb2d85..07c566a5 100644 --- a/lib/Predis/Commands/ZSetRangeByScore.php +++ b/lib/Predis/Commands/ZSetRangeByScore.php @@ -3,7 +3,10 @@ namespace Predis\Commands; class ZSetRangeByScore extends ZSetRange { - public function getId() { return 'ZRANGEBYSCORE'; } + public function getId() { + return 'ZRANGEBYSCORE'; + } + protected function prepareOptions($options) { $opts = array_change_key_case($options, CASE_UPPER); $finalizedOpts = array(); diff --git a/lib/Predis/Commands/ZSetRank.php b/lib/Predis/Commands/ZSetRank.php index 73adfa65..813518ec 100644 --- a/lib/Predis/Commands/ZSetRank.php +++ b/lib/Predis/Commands/ZSetRank.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetRank extends Command { - public function getId() { return 'ZRANK'; } + public function getId() { + return 'ZRANK'; + } } diff --git a/lib/Predis/Commands/ZSetRemove.php b/lib/Predis/Commands/ZSetRemove.php index 7f9398d4..c549567c 100644 --- a/lib/Predis/Commands/ZSetRemove.php +++ b/lib/Predis/Commands/ZSetRemove.php @@ -3,6 +3,11 @@ namespace Predis\Commands; class ZSetRemove extends Command { - public function getId() { return 'ZREM'; } - public function parseResponse($data) { return (bool) $data; } + public function getId() { + return 'ZREM'; + } + + public function parseResponse($data) { + return (bool) $data; + } } diff --git a/lib/Predis/Commands/ZSetRemoveRangeByRank.php b/lib/Predis/Commands/ZSetRemoveRangeByRank.php index 19713597..8f17a111 100644 --- a/lib/Predis/Commands/ZSetRemoveRangeByRank.php +++ b/lib/Predis/Commands/ZSetRemoveRangeByRank.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetRemoveRangeByRank extends Command { - public function getId() { return 'ZREMRANGEBYRANK'; } + public function getId() { + return 'ZREMRANGEBYRANK'; + } } diff --git a/lib/Predis/Commands/ZSetRemoveRangeByScore.php b/lib/Predis/Commands/ZSetRemoveRangeByScore.php index 41229f51..b589c9f3 100644 --- a/lib/Predis/Commands/ZSetRemoveRangeByScore.php +++ b/lib/Predis/Commands/ZSetRemoveRangeByScore.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetRemoveRangeByScore extends Command { - public function getId() { return 'ZREMRANGEBYSCORE'; } + public function getId() { + return 'ZREMRANGEBYSCORE'; + } } diff --git a/lib/Predis/Commands/ZSetReverseRange.php b/lib/Predis/Commands/ZSetReverseRange.php index 0e50639b..588ce192 100644 --- a/lib/Predis/Commands/ZSetReverseRange.php +++ b/lib/Predis/Commands/ZSetReverseRange.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetReverseRange extends ZSetRange { - public function getId() { return 'ZREVRANGE'; } + public function getId() { + return 'ZREVRANGE'; + } } diff --git a/lib/Predis/Commands/ZSetReverseRangeByScore.php b/lib/Predis/Commands/ZSetReverseRangeByScore.php index fe9d5382..bc3ebdc1 100644 --- a/lib/Predis/Commands/ZSetReverseRangeByScore.php +++ b/lib/Predis/Commands/ZSetReverseRangeByScore.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetReverseRangeByScore extends ZSetRangeByScore { - public function getId() { return 'ZREVRANGEBYSCORE'; } + public function getId() { + return 'ZREVRANGEBYSCORE'; + } } diff --git a/lib/Predis/Commands/ZSetReverseRank.php b/lib/Predis/Commands/ZSetReverseRank.php index 0e91a5eb..603bbf1e 100644 --- a/lib/Predis/Commands/ZSetReverseRank.php +++ b/lib/Predis/Commands/ZSetReverseRank.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetReverseRank extends Command { - public function getId() { return 'ZREVRANK'; } + public function getId() { + return 'ZREVRANK'; + } } diff --git a/lib/Predis/Commands/ZSetScore.php b/lib/Predis/Commands/ZSetScore.php index d486afeb..7bbda282 100644 --- a/lib/Predis/Commands/ZSetScore.php +++ b/lib/Predis/Commands/ZSetScore.php @@ -3,5 +3,7 @@ namespace Predis\Commands; class ZSetScore extends Command { - public function getId() { return 'ZSCORE'; } + public function getId() { + return 'ZSCORE'; + } } diff --git a/lib/Predis/Commands/ZSetUnionStore.php b/lib/Predis/Commands/ZSetUnionStore.php index 658c50cf..ff81680b 100644 --- a/lib/Predis/Commands/ZSetUnionStore.php +++ b/lib/Predis/Commands/ZSetUnionStore.php @@ -3,13 +3,10 @@ namespace Predis\Commands; class ZSetUnionStore extends Command { - protected function canBeHashed() { - $args = $this->getArguments(); - return $this->checkSameHashForKeys( - array_merge(array($args[0]), array_slice($args, 2, $args[1])) - ); + public function getId() { + return 'ZUNIONSTORE'; } - public function getId() { return 'ZUNIONSTORE'; } + public function filterArguments(Array $arguments) { $options = array(); $argc = count($arguments); @@ -24,6 +21,7 @@ class ZSetUnionStore extends Command { } return array_merge($arguments, $options); } + private function prepareOptions($options) { $opts = array_change_key_case($options, CASE_UPPER); $finalizedOpts = array(); @@ -39,4 +37,11 @@ class ZSetUnionStore extends Command { } return $finalizedOpts; } + + protected function canBeHashed() { + $args = $this->getArguments(); + return $this->checkSameHashForKeys( + array_merge(array($args[0]), array_slice($args, 2, $args[1])) + ); + } }