Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpredis/phpredis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichael-grunder <michael.grunder@gmail.com>2019-02-10 01:10:52 +0300
committermichael-grunder <michael.grunder@gmail.com>2019-02-10 01:12:52 +0300
commit9440f05e19a1ab7c06563e59dc0c54db94d6d9c8 (patch)
tree900a1b6535e770f3da78f13f46a6286dd91353b2
parentfa130a4bd46200d799f0659b709c8062c87f692b (diff)
Switch everything to new array syntax
-rw-r--r--README.markdown126
-rw-r--r--tests/RedisArrayTest.php6
-rw-r--r--tests/RedisClusterTest.php72
-rw-r--r--tests/RedisTest.php834
-rw-r--r--tests/TestRedis.php6
-rw-r--r--tests/TestSuite.php4
6 files changed, 522 insertions, 526 deletions
diff --git a/README.markdown b/README.markdown
index 7f92fbe5..1240a86e 100644
--- a/README.markdown
+++ b/README.markdown
@@ -709,10 +709,10 @@ $redis->set('key', 'value');
$redis->set('key','value', 10);
// Will set the key, if it doesn't exist, with a ttl of 10 seconds
-$redis->set('key', 'value', Array('nx', 'ex'=>10));
+$redis->set('key', 'value', ['nx', 'ex'=>10]);
// Will set a key, if it does exist, with a ttl of 1000 miliseconds
-$redis->set('key', 'value', Array('xx', 'px'=>1000));
+$redis->set('key', 'value', ['xx', 'px'=>1000]);
~~~
@@ -772,11 +772,11 @@ $redis->set('key3', 'val3');
$redis->set('key4', 'val4');
$redis->delete('key1', 'key2'); /* return 2 */
-$redis->delete(array('key3', 'key4')); /* return 2 */
+$redis->delete(['key3', 'key4']); /* return 2 */
/* If using Redis >= 4.0.0 you can call unlink */
$redis->unlink('key1', 'key2');
-$redis->unlink(Array('key1', 'key2'));
+$redis->unlink(['key1', 'key2']);
~~~
@@ -890,8 +890,8 @@ _**Description**_: Get the values of all the specified keys. If one or more keys
$redis->set('key1', 'value1');
$redis->set('key2', 'value2');
$redis->set('key3', 'value3');
-$redis->mGet(array('key1', 'key2', 'key3')); /* array('value1', 'value2', 'value3');
-$redis->mGet(array('key0', 'key1', 'key5')); /* array(`FALSE`, 'value1', `FALSE`);
+$redis->mGet(['key1', 'key2', 'key3']); /* ['value1', 'value2', 'value3'];
+$redis->mGet(['key0', 'key1', 'key5']); /* [`FALSE`, 'value1', `FALSE`];
~~~
### getSet
@@ -1252,10 +1252,10 @@ _**Description**_: Sort the elements in a list, set or sorted set.
##### *Parameters*
*Key*: key
-*Options*: array(key => value, ...) - optional, with the following keys and values:
+*Options*: [key => value, ...] - optional, with the following keys and values:
~~~
'by' => 'some_pattern_*',
- 'limit' => array(0, 1),
+ 'limit' => [0, 1],
'get' => 'some_other_pattern_*' or an array of patterns,
'sort' => 'asc' or 'desc',
'alpha' => TRUE,
@@ -1274,8 +1274,8 @@ $redis->sAdd('s', 1);
$redis->sAdd('s', 3);
var_dump($redis->sort('s')); // 1,2,3,4,5
-var_dump($redis->sort('s', array('sort' => 'desc'))); // 5,4,3,2,1
-var_dump($redis->sort('s', array('sort' => 'desc', 'store' => 'out'))); // (int)5
+var_dump($redis->sort('s', ['sort' => 'desc'])); // 5,4,3,2,1
+var_dump($redis->sort('s', ['sort' => 'desc', 'store' => 'out'])); // (int)5
~~~
@@ -1316,7 +1316,7 @@ $redis->persist('key');
_**Description**_: Sets multiple key-value pairs in one atomic command. MSETNX only returns TRUE if all the keys were set (see SETNX).
##### *Parameters*
-*Pairs*: array(key => value, ...)
+*Pairs*: [key => value, ...]
##### *Return value*
*Bool* `TRUE` in case of success, `FALSE` in case of failure.
@@ -1324,7 +1324,7 @@ _**Description**_: Sets multiple key-value pairs in one atomic command. MSETNX o
##### *Example*
~~~php
-$redis->mSet(array('key0' => 'value0', 'key1' => 'value1'));
+$redis->mSet(['key0' => 'value0', 'key1' => 'value1']);
var_dump($redis->get('key0'));
var_dump($redis->get('key1'));
@@ -1650,7 +1650,7 @@ _**Description**_: Fills in a whole hash. Non-string values are converted to str
##### *Examples*
~~~php
$redis->delete('user:1');
-$redis->hMSet('user:1', array('name' => 'Joe', 'salary' => 2000));
+$redis->hMSet('user:1', ['name' => 'Joe', 'salary' => 2000]);
$redis->hIncrBy('user:1', 'salary', 100); // Joe earns 100 more now.
~~~
@@ -1667,7 +1667,7 @@ _**Description**_: Retrieve the values associated to the specified fields in the
$redis->delete('h');
$redis->hSet('h', 'field1', 'value1');
$redis->hSet('h', 'field2', 'value2');
-$redis->hMGet('h', array('field1', 'field2')); /* returns array('field1' => 'value1', 'field2' => 'value2') */
+$redis->hMGet('h', ['field1', 'field2']); /* returns ['field1' => 'value1', 'field2' => 'value2'] */
~~~
### hScan
@@ -1738,7 +1738,7 @@ Or
*INTEGER* Timeout
##### *Return value*
-*ARRAY* array('listName', 'element')
+*ARRAY* ['listName', 'element']
##### *Example*
~~~php
@@ -1746,13 +1746,13 @@ Or
$redis->lPush('key1', 'A');
$redis->delete('key2');
-$redis->blPop('key1', 'key2', 10); /* array('key1', 'A') */
+$redis->blPop('key1', 'key2', 10); /* ['key1', 'A'] */
/* OR */
-$redis->blPop(array('key1', 'key2'), 10); /* array('key1', 'A') */
+$redis->blPop(['key1', 'key2'], 10); /* ['key1', 'A'] */
-$redis->brPop('key1', 'key2', 10); /* array('key1', 'A') */
+$redis->brPop('key1', 'key2', 10); /* ['key1', 'A'] */
/* OR */
-$redis->brPop(array('key1', 'key2'), 10); /* array('key1', 'A') */
+$redis->brPop(['key1', 'key2'], 10); /* ['key1', 'A'] */
/* Blocking feature */
@@ -1765,7 +1765,7 @@ $redis->blPop('key1', 10);
$redis->lPush('key1', 'A');
/* process 1 */
-/* array('key1', 'A') is returned*/
+/* ['key1', 'A'] is returned*/
~~~
### bRPopLPush
@@ -1833,10 +1833,10 @@ $redis->lPush('key1', 'B');
$redis->lPush('key1', 'C');
$redis->lInsert('key1', Redis::BEFORE, 'C', 'X'); /* 4 */
-$redis->lRange('key1', 0, -1); /* array('A', 'B', 'X', 'C') */
+$redis->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C'] */
$redis->lInsert('key1', Redis::AFTER, 'C', 'Y'); /* 5 */
-$redis->lRange('key1', 0, -1); /* array('A', 'B', 'X', 'C', 'Y') */
+$redis->lRange('key1', 0, -1); /* ['A', 'B', 'X', 'C', 'Y'] */
$redis->lInsert('key1', Redis::AFTER, 'W', 'value'); /* -1 */
~~~
@@ -1920,7 +1920,7 @@ _**Description**_: Returns the specified elements of the list stored at the spec
$redis->rPush('key1', 'A');
$redis->rPush('key1', 'B');
$redis->rPush('key1', 'C');
-$redis->lRange('key1', 0, -1); /* array('A', 'B', 'C') */
+$redis->lRange('key1', 0, -1); /* ['A', 'B', 'C'] */
~~~
### lRem, lRemove
@@ -1946,9 +1946,9 @@ $redis->lPush('key1', 'C');
$redis->lPush('key1', 'A');
$redis->lPush('key1', 'A');
-$redis->lRange('key1', 0, -1); /* array('A', 'A', 'C', 'B', 'A') */
+$redis->lRange('key1', 0, -1); /* ['A', 'A', 'C', 'B', 'A'] */
$redis->lRem('key1', 'A', 2); /* 2 */
-$redis->lRange('key1', 0, -1); /* array('C', 'B', 'A') */
+$redis->lRange('key1', 0, -1); /* ['C', 'B', 'A'] */
~~~
### lSet
@@ -1991,9 +1991,9 @@ _**Description**_: Trims an existing list so that it will contain only a specifi
$redis->rPush('key1', 'A');
$redis->rPush('key1', 'B');
$redis->rPush('key1', 'C');
-$redis->lRange('key1', 0, -1); /* array('A', 'B', 'C') */
+$redis->lRange('key1', 0, -1); /* ['A', 'B', 'C'] */
$redis->lTrim('key1', 0, 1);
-$redis->lRange('key1', 0, -1); /* array('A', 'B') */
+$redis->lRange('key1', 0, -1); /* ['A', 'B'] */
~~~
### rPop
@@ -2619,7 +2619,7 @@ _**Description**_: Add one or more members to a sorted set or update its score i
$redis->zAdd('key', 1, 'val1');
$redis->zAdd('key', 0, 'val0');
$redis->zAdd('key', 5, 'val5');
-$redis->zRange('key', 0, -1); // array(val0, val1, val5)
+$redis->zRange('key', 0, -1); // [val0, val1, val5]
~~~
### zCard, zSize
@@ -2657,7 +2657,7 @@ _**Description**_: Returns the *number* of elements of the sorted set stored at
$redis->zAdd('key', 0, 'val0');
$redis->zAdd('key', 2, 'val2');
$redis->zAdd('key', 10, 'val10');
-$redis->zCount('key', 0, 3); /* 2, corresponding to array('val0', 'val2') */
+$redis->zCount('key', 0, 3); /* 2, corresponding to ['val0', 'val2'] */
~~~
### zIncrBy
@@ -2714,12 +2714,12 @@ $redis->zAdd('k1', 3, 'val3');
$redis->zAdd('k2', 2, 'val1');
$redis->zAdd('k2', 3, 'val3');
-$redis->zInter('ko1', array('k1', 'k2')); /* 2, 'ko1' => array('val1', 'val3') */
-$redis->zInter('ko2', array('k1', 'k2'), array(1, 1)); /* 2, 'ko2' => array('val1', 'val3') */
+$redis->zInter('ko1', ['k1', 'k2']); /* 2, 'ko1' => ['val1', 'val3'] */
+$redis->zInter('ko2', ['k1', 'k2'], [1, 1]); /* 2, 'ko2' => ['val1', 'val3'] */
/* Weighted zInter */
-$redis->zInter('ko3', array('k1', 'k2'), array(1, 5), 'min'); /* 2, 'ko3' => array('val1', 'val3') */
-$redis->zInter('ko4', array('k1', 'k2'), array(1, 5), 'max'); /* 2, 'ko4' => array('val3', 'val1') */
+$redis->zInter('ko3', ['k1', 'k2'], [1, 5], 'min'); /* 2, 'ko3' => ['val1', 'val3'] */
+$redis->zInter('ko4', ['k1', 'k2'], [1, 5], 'max'); /* 2, 'ko4' => ['val3', 'val1'] */
~~~
### zRange
@@ -2744,10 +2744,10 @@ Start and stop are interpreted as zero-based indices:
$redis->zAdd('key1', 0, 'val0');
$redis->zAdd('key1', 2, 'val2');
$redis->zAdd('key1', 10, 'val10');
-$redis->zRange('key1', 0, -1); /* array('val0', 'val2', 'val10') */
+$redis->zRange('key1', 0, -1); /* ['val0', 'val2', 'val10'] */
// with scores
-$redis->zRange('key1', 0, -1, true); /* array('val0' => 0, 'val2' => 2, 'val10' => 10) */
+$redis->zRange('key1', 0, -1, true); /* ['val0' => 0, 'val2' => 2, 'val10' => 10] */
~~~
### zRangeByScore, zRevRangeByScore
@@ -2760,7 +2760,7 @@ _**Description**_: Returns the elements of the sorted set stored at the specifie
*end*: string
*options*: array
-Two options are available: `withscores => TRUE`, and `limit => array($offset, $count)`
+Two options are available: `withscores => TRUE`, and `limit => [$offset, $count]`
##### *Return value*
*Array* containing the values in specified range.
@@ -2770,10 +2770,10 @@ Two options are available: `withscores => TRUE`, and `limit => array($offset, $c
$redis->zAdd('key', 0, 'val0');
$redis->zAdd('key', 2, 'val2');
$redis->zAdd('key', 10, 'val10');
-$redis->zRangeByScore('key', 0, 3); /* array('val0', 'val2') */
-$redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE)); /* array('val0' => 0, 'val2' => 2) */
-$redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 1))); /* array('val2') */
-$redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE, 'limit' => array(1, 1))); /* array('val2' => 2) */
+$redis->zRangeByScore('key', 0, 3); /* ['val0', 'val2'] */
+$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE]); /* ['val0' => 0, 'val2' => 2] */
+$redis->zRangeByScore('key', 0, 3, ['limit' => [1, 1]]); /* ['val2'] */
+$redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE, 'limit' => [1, 1]]); /* ['val2' => 2] */
~~~
### zRangeByLex
@@ -2792,12 +2792,12 @@ _**Description**_: Returns a lexicographical range of members in a sorted set,
##### *Example*
~~~php
-foreach(Array('a','b','c','d','e','f','g') as $c)
+foreach(['a','b','c','d','e','f','g'] as $c)
$redis->zAdd('key',0,$c);
-$redis->zRangeByLex('key','-','[c') /* Array('a','b','c'); */
-$redis->zRangeByLex('key','-','(c') /* Array('a','b') */
-$redis->zRangeByLex('key','-','[c',1,2) /* Array('b','c') */
+$redis->zRangeByLex('key','-','[c') /* ['a','b','c']; */
+$redis->zRangeByLex('key','-','(c') /* ['a','b'] */
+$redis->zRangeByLex('key','-','[c',1,2) /* ['b','c'] */
~~~
### zRank, zRevRank
@@ -2839,7 +2839,7 @@ $redis->zAdd('key', 0, 'val0');
$redis->zAdd('key', 2, 'val2');
$redis->zAdd('key', 10, 'val10');
$redis->zDelete('key', 'val2');
-$redis->zRange('key', 0, -1); /* array('val0', 'val10') */
+$redis->zRange('key', 0, -1); /* ['val0', 'val10'] */
~~~
### zRemRangeByRank, zDeleteRangeByRank
@@ -2860,7 +2860,7 @@ $redis->zAdd('key', 1, 'one');
$redis->zAdd('key', 2, 'two');
$redis->zAdd('key', 3, 'three');
$redis->zRemRangeByRank('key', 0, 1); /* 2 */
-$redis->zRange('key', 0, -1, array('withscores' => TRUE)); /* array('three' => 3) */
+$redis->zRange('key', 0, -1, ['withscores' => TRUE]); /* ['three' => 3] */
~~~
### zRemRangeByScore, zDeleteRangeByScore
@@ -2903,10 +2903,10 @@ _**Description**_: Returns the elements of the sorted set stored at the specifie
$redis->zAdd('key', 0, 'val0');
$redis->zAdd('key', 2, 'val2');
$redis->zAdd('key', 10, 'val10');
-$redis->zRevRange('key', 0, -1); /* array('val10', 'val2', 'val0') */
+$redis->zRevRange('key', 0, -1); /* ['val10', 'val2', 'val0'] */
// with scores
-$redis->zRevRange('key', 0, -1, true); /* array('val10' => 10, 'val2' => 2, 'val0' => 0) */
+$redis->zRevRange('key', 0, -1, true); /* ['val10' => 10, 'val2' => 2, 'val0' => 0] */
~~~
### zScore
@@ -2957,11 +2957,11 @@ $redis->zAdd('k1', 1, 'val1');
$redis->zAdd('k2', 2, 'val2');
$redis->zAdd('k2', 3, 'val3');
-$redis->zUnion('ko1', array('k1', 'k2')); /* 4, 'ko1' => array('val0', 'val1', 'val2', 'val3') */
+$redis->zUnion('ko1', ['k1', 'k2']); /* 4, 'ko1' => ['val0', 'val1', 'val2', 'val3'] */
/* Weighted zUnion */
-$redis->zUnion('ko2', array('k1', 'k2'), array(1, 1)); /* 4, 'ko2' => array('val0', 'val1', 'val2', 'val3') */
-$redis->zUnion('ko3', array('k1', 'k2'), array(5, 1)); /* 4, 'ko3' => array('val0', 'val2', 'val3', 'val1') */
+$redis->zUnion('ko2', ['k1', 'k2'], [1, 1]); /* 4, 'ko2' => ['val0', 'val1', 'val2', 'val3'] */
+$redis->zUnion('ko3', ['k1', 'k2'], [5, 1]); /* 4, 'ko3' => ['val0', 'val2', 'val3', 'val1'] */
~~~
### zScan
@@ -3261,7 +3261,7 @@ echo "Within 300 miles of Honolulu:\n";
var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi'));
echo "\nFirst match within 300 miles of Honolulu:\n";
-var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi', Array('count' => 1)));
+var_dump($redis->geoRadiusByMember("hawaii", "Honolulu", 300, 'mi', ['count' => 1]));
~~~
##### *Output*
@@ -3654,7 +3654,7 @@ _**Description**_: Subscribe to channels. Warning: this function will probably c
##### *Parameters*
*channels*: an array of channels to subscribe to
-*callback*: either a string or an array($instance, 'method_name'). The callback function receives 3 parameters: the redis instance, the channel name, and the message.
+*callback*: either a string or an Array($instance, 'method_name'). The callback function receives 3 parameters: the redis instance, the channel name, and the message.
*return value*: Mixed. Any non-null return value in the callback will be returned to the caller.
##### *Example*
~~~php
@@ -3674,7 +3674,7 @@ function f($redis, $chan, $msg) {
}
}
-$redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f'); // subscribe to 3 chans
+$redis->subscribe(['chan-1', 'chan-2', 'chan-3'], 'f'); // subscribe to 3 chans
~~~
### pubSub
@@ -3694,7 +3694,7 @@ _**Description**_: A command allowing you to get information on the Redis pub/su
~~~php
$redis->pubSub("channels"); /*All channels */
$redis->pubSub("channels", "*pattern*"); /* Just channels matching your pattern */
-$redis->pubSub("numsub", Array("chan1", "chan2")); /*Get subscriber counts for 'chan1' and 'chan2'*/
+$redis->pubSub("numsub", ["chan1", "chan2"]); /*Get subscriber counts for 'chan1' and 'chan2'*/
$redis->pubSub("numpat"); /* Get the number of pattern subscribers */
@@ -3753,11 +3753,7 @@ $ret = $redis->multi()
->exec();
/*
-$ret == array(
- 0 => TRUE,
- 1 => 'val1',
- 2 => TRUE,
- 3 => 'val2');
+$ret == Array(0 => TRUE, 1 => 'val1', 2 => TRUE, 3 => 'val2');
*/
~~~
@@ -3772,7 +3768,7 @@ If the key is modified between `WATCH` and `EXEC`, the MULTI/EXEC transaction wi
##### *Example*
~~~php
-$redis->watch('x'); // or for a list of keys: $redis->watch(array('x','another key'));
+$redis->watch('x'); // or for a list of keys: $redis->watch(['x','another key']);
/* long code here during the execution of which other clients could well modify `x` */
$ret = $redis->multi()
->incr('x')
@@ -3812,12 +3808,12 @@ executing the LUA script, the getLastError() function can tell you the message t
##### *Examples*
~~~php
$redis->eval("return 1"); // Returns an integer: 1
-$redis->eval("return {1,2,3}"); // Returns Array(1,2,3)
+$redis->eval("return {1,2,3}"); // Returns [1,2,3]
$redis->del('mylist');
$redis->rpush('mylist','a');
$redis->rpush('mylist','b');
$redis->rpush('mylist','c');
-// Nested response: Array(1,2,3,Array('a','b','c'));
+// Nested response: [1,2,3,['a','b','c']];
$redis->eval("return {1,2,3,redis.call('lrange','mylist',0,-1)}");
~~~
@@ -3959,7 +3955,7 @@ will change Array values to 'Array', and Objects to 'Object'.
~~~php
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);
$redis->_serialize("foo"); // returns "foo"
-$redis->_serialize(Array()); // Returns "Array"
+$redis->_serialize([]); // Returns "Array"
$redis->_serialize(new stdClass()); // Returns "Object"
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
@@ -3980,7 +3976,7 @@ serializing values, and you return something from redis in a LUA script that is
##### *Examples*
~~~php
$redis->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);
-$redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return Array(1,2,3)
+$redis->_unserialize('a:3:{i:0;i:1;i:1;i:2;i:2;i:3;}'); // Will return [1,2,3]
~~~
diff --git a/tests/RedisArrayTest.php b/tests/RedisArrayTest.php
index 49c71a98..b46a06ee 100644
--- a/tests/RedisArrayTest.php
+++ b/tests/RedisArrayTest.php
@@ -591,9 +591,9 @@ function run_tests($className, $str_filter, $str_host) {
// reset rings
global $newRing, $oldRing, $serverList;
- $newRing = Array("$str_host:6379", "$str_host:6380", "$str_host:6381");
- $oldRing = Array();
- $serverList = Array("$str_host:6379", "$str_host:6380", "$str_host:6381", "$str_host:6382");
+ $newRing = ["$str_host:6379", "$str_host:6380", "$str_host:6381"];
+ $oldRing = [];
+ $serverList = ["$str_host:6379", "$str_host:6380", "$str_host:6381", "$str_host:6382"];
// run
return TestSuite::run($className, $str_filter);
diff --git a/tests/RedisClusterTest.php b/tests/RedisClusterTest.php
index ccd8927a..02e78209 100644
--- a/tests/RedisClusterTest.php
+++ b/tests/RedisClusterTest.php
@@ -7,21 +7,21 @@ require_once(dirname($_SERVER['PHP_SELF'])."/RedisTest.php");
* where we're validating specific cluster mechanisms
*/
class Redis_Cluster_Test extends Redis_Test {
- private static $_arr_node_map = Array();
+ private static $_arr_node_map = [];
- private $_arr_redis_types = Array(
+ private $_arr_redis_types = [
Redis::REDIS_STRING,
Redis::REDIS_SET,
Redis::REDIS_LIST,
Redis::REDIS_ZSET,
Redis::REDIS_HASH
- );
+ ];
- private $_arr_failover_types = Array(
+ private $_arr_failover_types = [
RedisCluster::FAILOVER_NONE,
RedisCluster::FAILOVER_ERROR,
RedisCluster::FAILOVER_DISTRIBUTE
- );
+ ];
/**
* @var string
@@ -144,12 +144,12 @@ class Redis_Cluster_Test extends Redis_Test {
}
public function testInfo() {
- $arr_check_keys = Array(
+ $arr_check_keys = [
"redis_version", "arch_bits", "uptime_in_seconds", "uptime_in_days",
"connected_clients", "connected_slaves", "used_memory",
"total_connections_received", "total_commands_processed",
"role"
- );
+ ];
for ($i = 0; $i < 3; $i++) {
$arr_info = $this->redis->info("k:$i");
@@ -233,14 +233,14 @@ class Redis_Cluster_Test extends Redis_Test {
$this->assertTrue(is_array($result));
$this->assertEquals(count($result), 4);
- $arr_zipped = Array();
+ $arr_zipped = [];
for ($i = 0; $i <= count($result) / 2; $i+=2) {
$arr_zipped[$result[$i]] = $result[$i+1];
}
$result = $arr_zipped;
// Make sure the elements are correct, and have zero counts
- foreach(Array($c1,$c2) as $channel) {
+ foreach([$c1,$c2] as $channel) {
$this->assertTrue(isset($result[$channel]));
$this->assertEquals($result[$channel], 0);
}
@@ -258,20 +258,20 @@ class Redis_Cluster_Test extends Redis_Test {
public function testMSetNX() {
/* All of these keys should get set */
$this->redis->del('x','y','z');
- $ret = $this->redis->msetnx(Array('x'=>'a','y'=>'b','z'=>'c'));
+ $ret = $this->redis->msetnx(['x'=>'a','y'=>'b','z'=>'c']);
$this->assertTrue(is_array($ret));
$this->assertEquals(array_sum($ret),count($ret));
/* Delete one key */
$this->redis->del('x');
- $ret = $this->redis->msetnx(Array('x'=>'a','y'=>'b','z'=>'c'));
+ $ret = $this->redis->msetnx(['x'=>'a','y'=>'b','z'=>'c']);
$this->assertTrue(is_array($ret));
$this->assertEquals(array_sum($ret),1);
$this->assertFalse($this->redis->msetnx(array())); // set ø → FALSE
}
- /* Slowlog needs to take a key or Array(ip, port), to direct it to a node */
+ /* Slowlog needs to take a key or [ip, port], to direct it to a node */
public function testSlowlog() {
$str_key = uniqid() . '-' . rand(1, 1000);
@@ -308,7 +308,7 @@ class Redis_Cluster_Test extends Redis_Test {
// This transaction should fail because the other client changed 'x'
$ret = $this->redis->multi()->get('x')->exec();
- $this->assertTrue($ret === Array(FALSE));
+ $this->assertTrue($ret === [false]);
// watch and unwatch
$this->redis->watch('x');
$r->incr('x'); // other instance
@@ -370,8 +370,8 @@ class Redis_Cluster_Test extends Redis_Test {
$this->redis->script($str_key, 'flush');
// Non existant script (but proper sha1), and a random (not) sha1 string
- $this->assertFalse($this->redis->evalsha(sha1(uniqid()),Array($str_key), 1));
- $this->assertFalse($this->redis->evalsha('some-random-data'),Array($str_key), 1);
+ $this->assertFalse($this->redis->evalsha(sha1(uniqid()),[$str_key], 1));
+ $this->assertFalse($this->redis->evalsha('some-random-data'),[$str_key], 1);
// Load a script
$cb = uniqid(); // To ensure the script is new
@@ -379,9 +379,9 @@ class Redis_Cluster_Test extends Redis_Test {
$sha = sha1($scr);
// Run it when it doesn't exist, run it with eval, and then run it with sha1
- $this->assertTrue(false === $this->redis->evalsha($scr,Array($str_key), 1));
- $this->assertTrue(1 === $this->redis->eval($scr,Array($str_key), 1));
- $this->assertTrue(1 === $this->redis->evalsha($sha,Array($str_key), 1));
+ $this->assertTrue(false === $this->redis->evalsha($scr,[$str_key], 1));
+ $this->assertTrue(1 === $this->redis->eval($scr,[$str_key], 1));
+ $this->assertTrue(1 === $this->redis->evalsha($sha,[$str_key], 1));
}
public function testEvalBulkResponse() {
@@ -393,7 +393,7 @@ class Redis_Cluster_Test extends Redis_Test {
$scr = "return {KEYS[1],KEYS[2]}";
- $result = $this->redis->eval($scr,Array($str_key1, $str_key2), 2);
+ $result = $this->redis->eval($scr,[$str_key1, $str_key2], 2);
$this->assertTrue($str_key1 === $result[0]);
$this->assertTrue($str_key2 === $result[1]);
@@ -409,7 +409,7 @@ class Redis_Cluster_Test extends Redis_Test {
$scr = "return {KEYS[1],KEYS[2]}";
$this->redis->multi();
- $this->redis->eval($scr,Array($str_key1, $str_key2), 2);
+ $this->redis->eval($scr, [$str_key1, $str_key2], 2);
$result = $this->redis->exec();
@@ -426,7 +426,7 @@ class Redis_Cluster_Test extends Redis_Test {
$scr = "for _,key in ipairs(KEYS) do redis.call('SET', key, 'value') end";
- $result = $this->redis->eval($scr,Array($str_key1, $str_key2), 2);
+ $result = $this->redis->eval($scr, [$str_key1, $str_key2], 2);
$this->assertTrue(null === $result);
}
@@ -441,7 +441,7 @@ class Redis_Cluster_Test extends Redis_Test {
$scr = "for _,key in ipairs(KEYS) do redis.call('SET', key, 'value') end";
$this->redis->multi();
- $this->redis->eval($scr,Array($str_key1, $str_key2), 2);
+ $this->redis->eval($scr, [$str_key1, $str_key2], 2);
$result = $this->redis->exec();
$this->assertTrue(null === $result[0]);
@@ -487,37 +487,37 @@ class Redis_Cluster_Test extends Redis_Test {
$this->redis->set($str_key, $value);
break;
case Redis::REDIS_SET:
- $value = Array(
+ $value = [
$str_key . '-mem1', $str_key . '-mem2', $str_key . '-mem3',
$str_key . '-mem4', $str_key . '-mem5', $str_key . '-mem6'
- );
+ ];
$arr_args = $value;
array_unshift($arr_args, $str_key);
- call_user_func_array(Array($this->redis, 'sadd'), $arr_args);
+ call_user_func_array([$this->redis, 'sadd'], $arr_args);
break;
case Redis::REDIS_HASH:
- $value = Array(
+ $value = [
$str_key . '-mem1' => $str_key . '-val1',
$str_key . '-mem2' => $str_key . '-val2',
$str_key . '-mem3' => $str_key . '-val3'
- );
+ ];
$this->redis->hmset($str_key, $value);
break;
case Redis::REDIS_LIST:
- $value = Array(
+ $value = [
$str_key . '-ele1', $str_key . '-ele2', $str_key . '-ele3',
$str_key . '-ele4', $str_key . '-ele5', $str_key . '-ele6'
- );
+ ];
$arr_args = $value;
array_unshift($arr_args, $str_key);
- call_user_func_array(Array($this->redis, 'rpush'), $arr_args);
+ call_user_func_array([$this->redis, 'rpush'], $arr_args);
break;
case Redis::REDIS_ZSET:
$i_score = 1;
- $value = Array(
+ $value = [
$str_key . '-mem1' => 1, $str_key . '-mem2' => 2,
$str_key . '-mem3' => 3, $str_key . '-mem3' => 3
- );
+ ];
foreach ($value as $str_mem => $i_score) {
$this->redis->zadd($str_key, $i_score, $str_mem);
}
@@ -571,8 +571,8 @@ class Redis_Cluster_Test extends Redis_Test {
/* Test automatic load distributor */
public function testFailOver() {
- $arr_value_ref = Array();
- $arr_type_ref = Array();
+ $arr_value_ref = [];
+ $arr_type_ref = [];
/* Set a bunch of keys of various redis types*/
for ($i = 0; $i < 200; $i++) {
@@ -601,12 +601,12 @@ class Redis_Cluster_Test extends Redis_Test {
$this->redis->del('mylist');
$this->redis->rpush('mylist', 'A','B','C','D');
- $this->assertEquals($this->redis->lrange('mylist', 0, -1), Array('A','B','C','D'));
+ $this->assertEquals($this->redis->lrange('mylist', 0, -1), ['A','B','C','D']);
}
protected function rawCommandArray($key, $args) {
array_unshift($args, $key);
- return call_user_func_array(Array($this->redis, 'rawCommand'), $args);
+ return call_user_func_array([$this->redis, 'rawCommand'], $args);
}
public function testSession()
diff --git a/tests/RedisTest.php b/tests/RedisTest.php
index 9887daac..03f6e0e8 100644
--- a/tests/RedisTest.php
+++ b/tests/RedisTest.php
@@ -8,18 +8,18 @@ class Redis_Test extends TestSuite
const AUTH = NULL; //replace with a string to use Redis authentication
/* City lat/long */
- protected $cities = Array(
- 'Chico' => Array(-121.837478, 39.728494),
- 'Sacramento' => Array(-121.494400, 38.581572),
- 'Gridley' => Array(-121.693583, 39.363777),
- 'Marysville' => Array(-121.591355, 39.145725),
- 'Cupertino' => Array(-122.032182, 37.322998)
- );
-
- protected $serializers = Array(
+ protected $cities = [
+ 'Chico' => [-121.837478, 39.728494],
+ 'Sacramento' => [-121.494400, 38.581572],
+ 'Gridley' => [-121.693583, 39.363777],
+ 'Marysville' => [-121.591355, 39.145725],
+ 'Cupertino' => [-122.032182, 37.322998]
+ ];
+
+ protected $serializers = [
Redis::SERIALIZER_NONE,
Redis::SERIALIZER_PHP,
- );
+ ];
/**
* @var Redis
@@ -131,14 +131,14 @@ class Redis_Test extends TestSuite
$c1 = uniqid() . '-' . rand(1,100);
$c2 = uniqid() . '-' . rand(1,100);
- $result = $this->redis->pubsub("numsub", Array($c1, $c2));
+ $result = $this->redis->pubsub("numsub", [$c1, $c2]);
// Should get an array back, with two elements
$this->assertTrue(is_array($result));
$this->assertEquals(count($result), 2);
// Make sure the elements are correct, and have zero counts
- foreach(Array($c1,$c2) as $channel) {
+ foreach([$c1,$c2] as $channel) {
$this->assertTrue(isset($result[$channel]));
$this->assertEquals($result[$channel], 0);
}
@@ -324,39 +324,39 @@ class Redis_Test extends TestSuite
/* Set if not exist */
$this->redis->del('foo');
- $this->assertTrue($this->redis->set('foo','bar',Array('nx')));
+ $this->assertTrue($this->redis->set('foo','bar', ['nx']));
$this->assertEquals($this->redis->get('foo'), 'bar');
- $this->assertFalse($this->redis->set('foo','bar',Array('nx')));
+ $this->assertFalse($this->redis->set('foo','bar', ['nx']));
/* Set if exists */
- $this->assertTrue($this->redis->set('foo','bar',Array('xx')));
+ $this->assertTrue($this->redis->set('foo','bar', ['xx']));
$this->assertEquals($this->redis->get('foo'), 'bar');
$this->redis->del('foo');
- $this->assertFalse($this->redis->set('foo','bar',Array('xx')));
+ $this->assertFalse($this->redis->set('foo','bar', ['xx']));
/* Set with a TTL */
- $this->assertTrue($this->redis->set('foo','bar',Array('ex'=>100)));
+ $this->assertTrue($this->redis->set('foo','bar', ['ex'=>100]));
$this->assertEquals($this->redis->ttl('foo'), 100);
/* Set with a PTTL */
- $this->assertTrue($this->redis->set('foo','bar',Array('px'=>100000)));
+ $this->assertTrue($this->redis->set('foo','bar',['px'=>100000]));
$this->assertTrue(100000 - $this->redis->pttl('foo') < 1000);
/* Set if exists, with a TTL */
- $this->assertTrue($this->redis->set('foo','bar',Array('xx','ex'=>105)));
+ $this->assertTrue($this->redis->set('foo','bar',['xx','ex'=>105]));
$this->assertEquals($this->redis->ttl('foo'), 105);
$this->assertEquals($this->redis->get('foo'), 'bar');
/* Set if not exists, with a TTL */
$this->redis->del('foo');
- $this->assertTrue($this->redis->set('foo','bar', Array('nx', 'ex'=>110)));
+ $this->assertTrue($this->redis->set('foo','bar', ['nx', 'ex'=>110]));
$this->assertEquals($this->redis->ttl('foo'), 110);
$this->assertEquals($this->redis->get('foo'), 'bar');
- $this->assertFalse($this->redis->set('foo','bar', Array('nx', 'ex'=>110)));
+ $this->assertFalse($this->redis->set('foo','bar', ['nx', 'ex'=>110]));
/* Throw some nonsense into the array, and check that the TTL came through */
$this->redis->del('foo');
- $this->assertTrue($this->redis->set('foo','barbaz', Array('not-valid','nx','invalid','ex'=>200)));
+ $this->assertTrue($this->redis->set('foo','barbaz', ['not-valid','nx','invalid','ex'=>200]));
$this->assertEquals($this->redis->ttl('foo'), 200);
$this->assertEquals($this->redis->get('foo'), 'barbaz');
@@ -407,13 +407,13 @@ class Redis_Test extends TestSuite
$this->redis->lPush('{key}1', 'val1-0');
$this->redis->lPush('{key}1', 'val1-1');
$this->assertTrue($this->redis->renameNx('{key}0', '{key}1') === FALSE);
- $this->assertTrue($this->redis->lRange('{key}0', 0, -1) === array('val1', 'val0'));
- $this->assertTrue($this->redis->lRange('{key}1', 0, -1) === array('val1-1', 'val1-0'));
+ $this->assertTrue($this->redis->lRange('{key}0', 0, -1) === ['val1', 'val0']);
+ $this->assertTrue($this->redis->lRange('{key}1', 0, -1) === ['val1-1', 'val1-0']);
$this->redis->del('{key}2');
$this->assertTrue($this->redis->renameNx('{key}0', '{key}2') === TRUE);
- $this->assertTrue($this->redis->lRange('{key}0', 0, -1) === array());
- $this->assertTrue($this->redis->lRange('{key}2', 0, -1) === array('val1', 'val0'));
+ $this->assertTrue($this->redis->lRange('{key}0', 0, -1) === []);
+ $this->assertTrue($this->redis->lRange('{key}2', 0, -1) === ['val1', 'val0']);
}
public function testMultiple() {
@@ -426,15 +426,15 @@ class Redis_Test extends TestSuite
$this->redis->set('k3', 'v3');
$this->redis->set(1, 'test');
- $this->assertEquals(array('v1'), $this->redis->mget(array('k1')));
- $this->assertEquals(array('v1', 'v3', false), $this->redis->mget(array('k1', 'k3', 'NoKey')));
- $this->assertEquals(array('v1', 'v2', 'v3'), $this->redis->mget(array('k1', 'k2', 'k3')));
- $this->assertEquals(array('v1', 'v2', 'v3'), $this->redis->mget(array('k1', 'k2', 'k3')));
+ $this->assertEquals(['v1'], $this->redis->mget(['k1']));
+ $this->assertEquals(['v1', 'v3', false], $this->redis->mget(['k1', 'k3', 'NoKey']));
+ $this->assertEquals(['v1', 'v2', 'v3'], $this->redis->mget(['k1', 'k2', 'k3']));
+ $this->assertEquals(['v1', 'v2', 'v3'], $this->redis->mget(['k1', 'k2', 'k3']));
$this->redis->set('k5', '$1111111111');
- $this->assertEquals(array(0 => '$1111111111'), $this->redis->mget(array('k5')));
+ $this->assertEquals([0 => '$1111111111'], $this->redis->mget(['k5']));
- $this->assertEquals(array(0 => 'test'), $this->redis->mget(array(1))); // non-string
+ $this->assertEquals([0 => 'test'], $this->redis->mget([1])); // non-string
}
public function testMultipleBin() {
@@ -447,8 +447,8 @@ class Redis_Test extends TestSuite
$this->redis->set('k2', gzcompress('v2'));
$this->redis->set('k3', gzcompress('v3'));
- $this->assertEquals(array(gzcompress('v1'), gzcompress('v2'), gzcompress('v3')), $this->redis->mget(array('k1', 'k2', 'k3')));
- $this->assertEquals(array(gzcompress('v1'), gzcompress('v2'), gzcompress('v3')), $this->redis->mget(array('k1', 'k2', 'k3')));
+ $this->assertEquals([gzcompress('v1'), gzcompress('v2'), gzcompress('v3')], $this->redis->mget(['k1', 'k2', 'k3']));
+ $this->assertEquals([gzcompress('v1'), gzcompress('v2'), gzcompress('v3')], $this->redis->mget(['k1', 'k2', 'k3']));
}
@@ -616,7 +616,7 @@ class Redis_Test extends TestSuite
$this->assertEquals(1, $this->redis->exists('key'));
/* Add multiple keys */
- $mkeys = Array();
+ $mkeys = [];
for ($i = 0; $i < 10; $i++) {
if (rand(1, 2) == 1) {
$mkey = "{exists}key:$i";
@@ -627,7 +627,7 @@ class Redis_Test extends TestSuite
/* Test passing an array as well as the keys variadic */
$this->assertEquals(count($mkeys), $this->redis->exists($mkeys));
- $this->assertEquals(count($mkeys), call_user_func_array(Array($this->redis, 'exists'), $mkeys));
+ $this->assertEquals(count($mkeys), call_user_func_array([$this->redis, 'exists'], $mkeys));
}
public function testGetKeys()
@@ -646,7 +646,7 @@ class Redis_Test extends TestSuite
$this->assertEquals((count($keys) + 1), count($keys2));
// empty array when no key matches
- $this->assertEquals(array(), $this->redis->keys(rand().rand().rand().'*'));
+ $this->assertEquals([], $this->redis->keys(rand().rand().rand().'*'));
}
protected function genericDelUnlink($cmd) {
@@ -678,7 +678,7 @@ class Redis_Test extends TestSuite
$this->redis->set('x', 0);
$this->redis->set('y', 1);
- $this->assertEquals(2, $this->redis->$cmd(array('x', 'y')));
+ $this->assertEquals(2, $this->redis->$cmd(['x', 'y']));
}
public function testDelete() {
@@ -721,7 +721,7 @@ class Redis_Test extends TestSuite
// sadd with numeric key
$this->redis->del(123);
$this->assertTrue(1 === $this->redis->sAdd(123, 'val0'));
- $this->assertTrue(array('val0') === $this->redis->sMembers(123));
+ $this->assertTrue(['val0'] === $this->redis->sMembers(123));
// zset
$this->redis->del('keyZSet');
@@ -837,19 +837,19 @@ class Redis_Test extends TestSuite
$this->redis->del('list');
$this->redis->lPush('list', 'val1');
$this->redis->lPush('list', 'val2');
- $this->assertTrue($this->redis->blPop(array('list'), 2) === array('list', 'val2'));
- $this->assertTrue($this->redis->blPop(array('list'), 2) === array('list', 'val1'));
+ $this->assertTrue($this->redis->blPop(['list'], 2) === ['list', 'val2']);
+ $this->assertTrue($this->redis->blPop(['list'], 2) === ['list', 'val1']);
$this->redis->del('list');
$this->redis->lPush('list', 'val1');
$this->redis->lPush('list', 'val2');
- $this->assertTrue($this->redis->brPop(array('list'), 1) === array('list', 'val1'));
- $this->assertTrue($this->redis->brPop(array('list'), 1) === array('list', 'val2'));
+ $this->assertTrue($this->redis->brPop(['list'], 1) === ['list', 'val1']);
+ $this->assertTrue($this->redis->brPop(['list'], 1) === ['list', 'val2']);
// blocking blpop, brpop
$this->redis->del('list');
- $this->assertTrue($this->redis->blPop(array('list'), 1) === array());
- $this->assertTrue($this->redis->brPop(array('list'), 1) === array());
+ $this->assertTrue($this->redis->blPop(['list'], 1) === []);
+ $this->assertTrue($this->redis->brPop(['list'], 1) === []);
}
public function testllen()
@@ -889,7 +889,7 @@ class Redis_Test extends TestSuite
$this->redis->lPush('key', 'val0');
$this->assertTrue($this->redis->lPushx('key', 'val1') === 2);
$this->assertTrue($this->redis->rPushx('key', 'val2') === 3);
- $this->assertTrue($this->redis->lrange('key', 0, -1) === array('val1', 'val0', 'val2'));
+ $this->assertTrue($this->redis->lrange('key', 0, -1) === ['val1', 'val0', 'val2']);
//test linsert
$this->redis->del('key');
@@ -899,7 +899,7 @@ class Redis_Test extends TestSuite
$this->assertTrue($this->redis->lInsert('key', Redis::AFTER, 'val0', 'val1') === 2);
$this->assertTrue($this->redis->lInsert('key', Redis::BEFORE, 'val0', 'val2') === 3);
- $this->assertTrue($this->redis->lrange('key', 0, -1) === array('val2', 'val0', 'val1'));
+ $this->assertTrue($this->redis->lrange('key', 0, -1) === ['val2', 'val0', 'val1']);
}
// ltrim, lsize, lpop
@@ -949,7 +949,7 @@ class Redis_Test extends TestSuite
// set-up
$this->redis->del('person:id');
- foreach(array(1,2,3,4) as $id) {
+ foreach([1,2,3,4] as $id) {
$this->redis->lPush('person:id', $id);
}
}
@@ -962,9 +962,9 @@ class Redis_Test extends TestSuite
$this->redis->sadd('some-item', 2);
$this->redis->sadd('some-item', 3);
- $this->assertEquals(array('1','2','3'), $this->redis->sortAsc('some-item'));
- $this->assertEquals(array('3','2','1'), $this->redis->sortDesc('some-item'));
- $this->assertEquals(array('1','2','3'), $this->redis->sort('some-item'));
+ $this->assertEquals(['1','2','3'], $this->redis->sortAsc('some-item'));
+ $this->assertEquals(['3','2','1'], $this->redis->sortDesc('some-item'));
+ $this->assertEquals(['1','2','3'], $this->redis->sort('some-item'));
// Kill our set/prefix
$this->redis->del('some-item');
@@ -976,41 +976,41 @@ class Redis_Test extends TestSuite
$this->assertTrue(FALSE === $this->redis->sortAsc(NULL));
// sort by age and get IDs
- $byAgeAsc = array('3','1','2','4');
+ $byAgeAsc = ['3','1','2','4'];
$this->assertEquals($byAgeAsc, $this->redis->sortAsc('person:id', 'person:age_*'));
- $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', array('by' => 'person:age_*', 'sort' => 'asc')));
- $this->assertEquals(array('1', '2', '3', '4'), $this->redis->sortAsc('person:id', NULL)); // check that NULL works.
- $this->assertEquals(array('1', '2', '3', '4'), $this->redis->sortAsc('person:id', NULL, NULL)); // for all fields.
- $this->assertEquals(array('1', '2', '3', '4'), $this->redis->sort('person:id', array('sort' => 'asc')));
+ $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', ['by' => 'person:age_*', 'sort' => 'asc']));
+ $this->assertEquals(['1', '2', '3', '4'], $this->redis->sortAsc('person:id', NULL)); // check that NULL works.
+ $this->assertEquals(['1', '2', '3', '4'], $this->redis->sortAsc('person:id', NULL, NULL)); // for all fields.
+ $this->assertEquals(['1', '2', '3', '4'], $this->redis->sort('person:id', ['sort' => 'asc']));
// sort by age and get names
- $byAgeAsc = array('Carol','Alice','Bob','Dave');
+ $byAgeAsc = ['Carol','Alice','Bob','Dave'];
$this->assertEquals($byAgeAsc, $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*'));
- $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', array('by' => 'person:age_*', 'get' => 'person:name_*', 'sort' => 'asc')));
+ $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', ['by' => 'person:age_*', 'get' => 'person:name_*', 'sort' => 'asc']));
$this->assertEquals(array_slice($byAgeAsc, 0, 2), $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*', 0, 2));
- $this->assertEquals(array_slice($byAgeAsc, 0, 2), $this->redis->sort('person:id', array('by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => array(0, 2), 'sort' => 'asc')));
+ $this->assertEquals(array_slice($byAgeAsc, 0, 2), $this->redis->sort('person:id', ['by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => [0, 2], 'sort' => 'asc']));
$this->assertEquals(array_slice($byAgeAsc, 1, 2), $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*', 1, 2));
- $this->assertEquals(array_slice($byAgeAsc, 1, 2), $this->redis->sort('person:id', array('by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => array(1, 2), 'sort' => 'asc')));
+ $this->assertEquals(array_slice($byAgeAsc, 1, 2), $this->redis->sort('person:id', ['by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => [1, 2], 'sort' => 'asc']));
$this->assertEquals(array_slice($byAgeAsc, 0, 3), $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*', NULL, 3)); // NULL is transformed to 0 if there is something after it.
$this->assertEquals($byAgeAsc, $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*', 0, 4));
- $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', array('by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => array(0, 4))));
- $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', array('by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => array(0, "4")))); // with strings
- $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', array('by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => array("0", 4))));
- $this->assertEquals(array(), $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*', NULL, NULL)); // NULL, NULL is the same as (0,0). That returns no element.
+ $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', ['by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => [0, 4]]));
+ $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', ['by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => [0, "4"]])); // with strings
+ $this->assertEquals($byAgeAsc, $this->redis->sort('person:id', ['by' => 'person:age_*', 'get' => 'person:name_*', 'limit' => ["0", 4]]));
+ $this->assertEquals([], $this->redis->sortAsc('person:id', 'person:age_*', 'person:name_*', NULL, NULL)); // NULL, NULL is the same as (0,0). That returns no element.
// sort by salary and get ages
- $agesBySalaryAsc = array('34', '27', '25', '41');
+ $agesBySalaryAsc = ['34', '27', '25', '41'];
$this->assertEquals($agesBySalaryAsc, $this->redis->sortAsc('person:id', 'person:salary_*', 'person:age_*'));
- $this->assertEquals($agesBySalaryAsc, $this->redis->sort('person:id', array('by' => 'person:salary_*', 'get' => 'person:age_*', 'sort' => 'asc')));
+ $this->assertEquals($agesBySalaryAsc, $this->redis->sort('person:id', ['by' => 'person:salary_*', 'get' => 'person:age_*', 'sort' => 'asc']));
- $agesAndSalaries = $this->redis->sort('person:id', array('by' => 'person:salary_*', 'get' => array('person:age_*', 'person:salary_*'), 'sort' => 'asc'));
- $this->assertEquals(array('34', '2000', '27', '2500', '25', '2800', '41', '3100'), $agesAndSalaries);
+ $agesAndSalaries = $this->redis->sort('person:id', ['by' => 'person:salary_*', 'get' => ['person:age_*', 'person:salary_*'], 'sort' => 'asc']);
+ $this->assertEquals(['34', '2000', '27', '2500', '25', '2800', '41', '3100'], $agesAndSalaries);
// sort non-alpha doesn't change all-string lists
// list → [ghi, def, abc]
- $list = array('abc', 'def', 'ghi');
+ $list = ['abc', 'def', 'ghi'];
$this->redis->del('list');
foreach($list as $i) {
$this->redis->lPush('list', $i);
@@ -1019,7 +1019,7 @@ class Redis_Test extends TestSuite
// SORT list → [ghi, def, abc]
if (version_compare($this->version, "2.5.0", "lt")) {
$this->assertEquals(array_reverse($list), $this->redis->sortAsc('list'));
- $this->assertEquals(array_reverse($list), $this->redis->sort('list', array('sort' => 'asc')));
+ $this->assertEquals(array_reverse($list), $this->redis->sort('list', ['sort' => 'asc']));
} else {
// TODO rewrite, from 2.6.0 release notes:
// SORT now will refuse to sort in numerical mode elements that can't be parsed
@@ -1028,7 +1028,7 @@ class Redis_Test extends TestSuite
// SORT list ALPHA → [abc, def, ghi]
$this->assertEquals($list, $this->redis->sortAscAlpha('list'));
- $this->assertEquals($list, $this->redis->sort('list', array('sort' => 'asc', 'alpha' => TRUE)));
+ $this->assertEquals($list, $this->redis->sort('list', ['sort' => 'asc', 'alpha' => TRUE]));
}
public function testSortDesc() {
@@ -1036,22 +1036,22 @@ class Redis_Test extends TestSuite
$this->setupSort();
// sort by age and get IDs
- $byAgeDesc = array('4','2','1','3');
+ $byAgeDesc = ['4','2','1','3'];
$this->assertEquals($byAgeDesc, $this->redis->sortDesc('person:id', 'person:age_*'));
// sort by age and get names
- $byAgeDesc = array('Dave', 'Bob', 'Alice', 'Carol');
+ $byAgeDesc = ['Dave', 'Bob', 'Alice', 'Carol'];
$this->assertEquals($byAgeDesc, $this->redis->sortDesc('person:id', 'person:age_*', 'person:name_*'));
$this->assertEquals(array_slice($byAgeDesc, 0, 2), $this->redis->sortDesc('person:id', 'person:age_*', 'person:name_*', 0, 2));
$this->assertEquals(array_slice($byAgeDesc, 1, 2), $this->redis->sortDesc('person:id', 'person:age_*', 'person:name_*', 1, 2));
// sort by salary and get ages
- $agesBySalaryDesc = array('41', '25', '27', '34');
+ $agesBySalaryDesc = ['41', '25', '27', '34'];
$this->assertEquals($agesBySalaryDesc, $this->redis->sortDesc('person:id', 'person:salary_*', 'person:age_*'));
// sort non-alpha doesn't change all-string lists
- $list = array('def', 'abc', 'ghi');
+ $list = ['def', 'abc', 'ghi'];
$this->redis->del('list');
foreach($list as $i) {
$this->redis->lPush('list', $i);
@@ -1067,7 +1067,7 @@ class Redis_Test extends TestSuite
}
// SORT list ALPHA → [abc, def, ghi]
- $this->assertEquals(array('ghi', 'def', 'abc'), $this->redis->sortDescAlpha('list'));
+ $this->assertEquals(['ghi', 'def', 'abc'], $this->redis->sortDescAlpha('list'));
}
// LINDEX
@@ -1196,8 +1196,8 @@ class Redis_Test extends TestSuite
$this->assertEquals(1, $this->redis->scard('{set}0'));
$this->assertEquals(1, $this->redis->scard('{set}1'));
- $this->assertEquals(array('val2'), $this->redis->smembers('{set}0'));
- $this->assertEquals(array('val'), $this->redis->smembers('{set}1'));
+ $this->assertEquals(['val2'], $this->redis->smembers('{set}0'));
+ $this->assertEquals(['val'], $this->redis->smembers('{set}1'));
}
public function testsPop()
@@ -1252,7 +1252,7 @@ class Redis_Test extends TestSuite
$this->redis->sAdd('set0', 'val');
$this->redis->sAdd('set0', 'val2');
- $got = array();
+ $got = [];
while(true) {
$v = $this->redis->sRandMember('set0');
$this->assertTrue(2 === $this->redis->scard('set0')); // no change.
@@ -1362,7 +1362,7 @@ class Redis_Test extends TestSuite
$this->redis->sAdd('set', 'val2');
$this->redis->sAdd('set', 'val3');
- $array = array('val', 'val2', 'val3');
+ $array = ['val', 'val2', 'val3'];
$smembers = $this->redis->smembers('set');
sort($smembers);
@@ -1398,22 +1398,22 @@ class Redis_Test extends TestSuite
$this->redis->del('{set}square'); // set of squares
$this->redis->del('{set}seq'); // set of numbers of the form n^2 - 1
- $x = array(1,3,5,7,9,11,13,15,17,19,21,23,25);
+ $x = [1,3,5,7,9,11,13,15,17,19,21,23,25];
foreach($x as $i) {
$this->redis->sAdd('{set}odd', $i);
}
- $y = array(1,2,3,5,7,11,13,17,19,23);
+ $y = [1,2,3,5,7,11,13,17,19,23];
foreach($y as $i) {
$this->redis->sAdd('{set}prime', $i);
}
- $z = array(1,4,9,16,25);
+ $z = [1,4,9,16,25];
foreach($z as $i) {
$this->redis->sAdd('{set}square', $i);
}
- $t = array(2,5,10,17,26);
+ $t = [2,5,10,17,26];
foreach($t as $i) {
$this->redis->sAdd('{set}seq', $i);
}
@@ -1424,7 +1424,7 @@ class Redis_Test extends TestSuite
$this->assertTrue(in_array($i, array_intersect($x, $y)));
}
- $xy = $this->redis->sInter(array('{set}odd', '{set}prime')); // odd prime numbers, as array.
+ $xy = $this->redis->sInter(['{set}odd', '{set}prime']); // odd prime numbers, as array.
foreach($xy as $i) {
$i = (int)$i;
$this->assertTrue(in_array($i, array_intersect($x, $y)));
@@ -1436,24 +1436,24 @@ class Redis_Test extends TestSuite
$this->assertTrue(in_array($i, array_intersect($y, $z)));
}
- $yz = $this->redis->sInter(array('{set}prime', '{set}square')); // set of odd squares, as array
+ $yz = $this->redis->sInter(['{set}prime', '{set}square']); // set of odd squares, as array
foreach($yz as $i) {
$i = (int)$i;
$this->assertTrue(in_array($i, array_intersect($y, $z)));
}
$zt = $this->redis->sInter('{set}square', '{set}seq'); // prime squares
- $this->assertTrue($zt === array());
- $zt = $this->redis->sInter(array('{set}square', '{set}seq')); // prime squares, as array
- $this->assertTrue($zt === array());
+ $this->assertTrue($zt === []);
+ $zt = $this->redis->sInter(['{set}square', '{set}seq']); // prime squares, as array
+ $this->assertTrue($zt === []);
$xyz = $this->redis->sInter('{set}odd', '{set}prime', '{set}square');// odd prime squares
- $this->assertTrue($xyz === array('1'));
+ $this->assertTrue($xyz === ['1']);
- $xyz = $this->redis->sInter(array('{set}odd', '{set}prime', '{set}square'));// odd prime squares, with an array as a parameter
- $this->assertTrue($xyz === array('1'));
+ $xyz = $this->redis->sInter(['{set}odd', '{set}prime', '{set}square']);// odd prime squares, with an array as a parameter
+ $this->assertTrue($xyz === ['1']);
- $nil = $this->redis->sInter(array());
+ $nil = $this->redis->sInter([]);
$this->assertTrue($nil === FALSE);
}
@@ -1463,28 +1463,28 @@ class Redis_Test extends TestSuite
$this->redis->del('{set}z'); // set of squares
$this->redis->del('{set}t'); // set of numbers of the form n^2 - 1
- $x = array(1,3,5,7,9,11,13,15,17,19,21,23,25);
+ $x = [1,3,5,7,9,11,13,15,17,19,21,23,25];
foreach($x as $i) {
$this->redis->sAdd('{set}x', $i);
}
- $y = array(1,2,3,5,7,11,13,17,19,23);
+ $y = [1,2,3,5,7,11,13,17,19,23];
foreach($y as $i) {
$this->redis->sAdd('{set}y', $i);
}
- $z = array(1,4,9,16,25);
+ $z = [1,4,9,16,25];
foreach($z as $i) {
$this->redis->sAdd('{set}z', $i);
}
- $t = array(2,5,10,17,26);
+ $t = [2,5,10,17,26];
foreach($t as $i) {
$this->redis->sAdd('{set}t', $i);
}
/* Regression test for passing a single array */
- $this->assertEquals($this->redis->sInterStore(Array('{set}k', '{set}x', '{set}y')), count(array_intersect($x,$y)));
+ $this->assertEquals($this->redis->sInterStore(['{set}k', '{set}x', '{set}y']), count(array_intersect($x,$y)));
$count = $this->redis->sInterStore('{set}k', '{set}x', '{set}y'); // odd prime numbers
$this->assertEquals($count, $this->redis->scard('{set}k'));
@@ -1521,22 +1521,22 @@ class Redis_Test extends TestSuite
$this->redis->del('{set}z'); // set of squares
$this->redis->del('{set}t'); // set of numbers of the form n^2 - 1
- $x = array(1,3,5,7,9,11,13,15,17,19,21,23,25);
+ $x = [1,3,5,7,9,11,13,15,17,19,21,23,25];
foreach($x as $i) {
$this->redis->sAdd('{set}x', $i);
}
- $y = array(1,2,3,5,7,11,13,17,19,23);
+ $y = [1,2,3,5,7,11,13,17,19,23];
foreach($y as $i) {
$this->redis->sAdd('{set}y', $i);
}
- $z = array(1,4,9,16,25);
+ $z = [1,4,9,16,25];
foreach($z as $i) {
$this->redis->sAdd('{set}z', $i);
}
- $t = array(2,5,10,17,26);
+ $t = [2,5,10,17,26];
foreach($t as $i) {
$this->redis->sAdd('{set}t', $i);
}
@@ -1572,22 +1572,22 @@ class Redis_Test extends TestSuite
$this->redis->del('{set}z'); // set of squares
$this->redis->del('{set}t'); // set of numbers of the form n^2 - 1
- $x = array(1,3,5,7,9,11,13,15,17,19,21,23,25);
+ $x = [1,3,5,7,9,11,13,15,17,19,21,23,25];
foreach($x as $i) {
$this->redis->sAdd('{set}x', $i);
}
- $y = array(1,2,3,5,7,11,13,17,19,23);
+ $y = [1,2,3,5,7,11,13,17,19,23];
foreach($y as $i) {
$this->redis->sAdd('{set}y', $i);
}
- $z = array(1,4,9,16,25);
+ $z = [1,4,9,16,25];
foreach($z as $i) {
$this->redis->sAdd('{set}z', $i);
}
- $t = array(2,5,10,17,26);
+ $t = [2,5,10,17,26];
foreach($t as $i) {
$this->redis->sAdd('{set}t', $i);
}
@@ -1643,22 +1643,22 @@ class Redis_Test extends TestSuite
$this->redis->del('{set}z'); // set of squares
$this->redis->del('{set}t'); // set of numbers of the form n^2 - 1
- $x = array(1,3,5,7,9,11,13,15,17,19,21,23,25);
+ $x = [1,3,5,7,9,11,13,15,17,19,21,23,25];
foreach($x as $i) {
$this->redis->sAdd('{set}x', $i);
}
- $y = array(1,2,3,5,7,11,13,17,19,23);
+ $y = [1,2,3,5,7,11,13,17,19,23];
foreach($y as $i) {
$this->redis->sAdd('{set}y', $i);
}
- $z = array(1,4,9,16,25);
+ $z = [1,4,9,16,25];
foreach($z as $i) {
$this->redis->sAdd('{set}z', $i);
}
- $t = array(2,5,10,17,26);
+ $t = [2,5,10,17,26];
foreach($t as $i) {
$this->redis->sAdd('{set}t', $i);
}
@@ -1694,22 +1694,22 @@ class Redis_Test extends TestSuite
$this->redis->del('{set}z'); // set of squares
$this->redis->del('{set}t'); // set of numbers of the form n^2 - 1
- $x = array(1,3,5,7,9,11,13,15,17,19,21,23,25);
+ $x = [1,3,5,7,9,11,13,15,17,19,21,23,25];
foreach($x as $i) {
$this->redis->sAdd('{set}x', $i);
}
- $y = array(1,2,3,5,7,11,13,17,19,23);
+ $y = [1,2,3,5,7,11,13,17,19,23];
foreach($y as $i) {
$this->redis->sAdd('{set}y', $i);
}
- $z = array(1,4,9,16,25);
+ $z = [1,4,9,16,25];
foreach($z as $i) {
$this->redis->sAdd('{set}z', $i);
}
- $t = array(2,5,10,17,26);
+ $t = [2,5,10,17,26];
foreach($t as $i) {
$this->redis->sAdd('{set}t', $i);
}
@@ -1769,17 +1769,17 @@ class Redis_Test extends TestSuite
// pos : -3 -2 -1
// list: [val3, val2, val]
- $this->assertEquals($this->redis->lrange('list', 0, 0), array('val3'));
- $this->assertEquals($this->redis->lrange('list', 0, 1), array('val3', 'val2'));
- $this->assertEquals($this->redis->lrange('list', 0, 2), array('val3', 'val2', 'val'));
- $this->assertEquals($this->redis->lrange('list', 0, 3), array('val3', 'val2', 'val'));
+ $this->assertEquals($this->redis->lrange('list', 0, 0), ['val3']);
+ $this->assertEquals($this->redis->lrange('list', 0, 1), ['val3', 'val2']);
+ $this->assertEquals($this->redis->lrange('list', 0, 2), ['val3', 'val2', 'val']);
+ $this->assertEquals($this->redis->lrange('list', 0, 3), ['val3', 'val2', 'val']);
- $this->assertEquals($this->redis->lrange('list', 0, -1), array('val3', 'val2', 'val'));
- $this->assertEquals($this->redis->lrange('list', 0, -2), array('val3', 'val2'));
- $this->assertEquals($this->redis->lrange('list', -2, -1), array('val2', 'val'));
+ $this->assertEquals($this->redis->lrange('list', 0, -1), ['val3', 'val2', 'val']);
+ $this->assertEquals($this->redis->lrange('list', 0, -2), ['val3', 'val2']);
+ $this->assertEquals($this->redis->lrange('list', -2, -1), ['val2', 'val']);
$this->redis->del('list');
- $this->assertEquals($this->redis->lrange('list', 0, -1), array());
+ $this->assertEquals($this->redis->lrange('list', 0, -1), []);
}
public function testdbSize() {
@@ -1882,7 +1882,7 @@ class Redis_Test extends TestSuite
}
public function testInfo() {
- foreach (Array(false, true) as $boo_multi) {
+ foreach ([false, true] as $boo_multi) {
if ($boo_multi) {
$this->redis->multi();
$this->redis->info();
@@ -1892,7 +1892,7 @@ class Redis_Test extends TestSuite
$info = $this->redis->info();
}
- $keys = array(
+ $keys = [
"redis_version",
"arch_bits",
"uptime_in_seconds",
@@ -1903,7 +1903,7 @@ class Redis_Test extends TestSuite
"total_connections_received",
"total_commands_processed",
"role"
- );
+ ];
if (version_compare($this->version, "2.5.0", "lt")) {
array_push($keys,
"changes_since_last_save",
@@ -1957,15 +1957,15 @@ class Redis_Test extends TestSuite
public function testMset() {
$this->redis->del('x', 'y', 'z'); // remove x y z
- $this->assertTrue($this->redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'))); // set x y z
+ $this->assertTrue($this->redis->mset(['x' => 'a', 'y' => 'b', 'z' => 'c'])); // set x y z
- $this->assertEquals($this->redis->mget(array('x', 'y', 'z')), array('a', 'b', 'c')); // check x y z
+ $this->assertEquals($this->redis->mget(['x', 'y', 'z']), ['a', 'b', 'c']); // check x y z
$this->redis->del('x'); // delete just x
- $this->assertTrue($this->redis->mset(array('x' => 'a', 'y' => 'b', 'z' => 'c'))); // set x y z
- $this->assertEquals($this->redis->mget(array('x', 'y', 'z')), array('a', 'b', 'c')); // check x y z
+ $this->assertTrue($this->redis->mset(['x' => 'a', 'y' => 'b', 'z' => 'c'])); // set x y z
+ $this->assertEquals($this->redis->mget(['x', 'y', 'z']), ['a', 'b', 'c']); // check x y z
- $this->assertFalse($this->redis->mset(array())); // set ø → FALSE
+ $this->assertFalse($this->redis->mset([])); // set ø → FALSE
/*
@@ -1973,7 +1973,7 @@ class Redis_Test extends TestSuite
*/
// No prefix
- $set_array = Array(-1 => 'neg1', -2 => 'neg2', -3 => 'neg3', 1 => 'one', 2 => 'two', '3' => 'three');
+ $set_array = [-1 => 'neg1', -2 => 'neg2', -3 => 'neg3', 1 => 'one', 2 => 'two', '3' => 'three'];
$this->redis->del(array_keys($set_array));
$this->assertTrue($this->redis->mset($set_array));
$this->assertEquals($this->redis->mget(array_keys($set_array)), array_values($set_array));
@@ -1990,15 +1990,15 @@ class Redis_Test extends TestSuite
public function testMsetNX() {
$this->redis->del('x', 'y', 'z'); // remove x y z
- $this->assertTrue(TRUE === $this->redis->msetnx(array('x' => 'a', 'y' => 'b', 'z' => 'c'))); // set x y z
+ $this->assertTrue(TRUE === $this->redis->msetnx(['x' => 'a', 'y' => 'b', 'z' => 'c'])); // set x y z
- $this->assertEquals($this->redis->mget(array('x', 'y', 'z')), array('a', 'b', 'c')); // check x y z
+ $this->assertEquals($this->redis->mget(['x', 'y', 'z']), ['a', 'b', 'c']); // check x y z
$this->redis->del('x'); // delete just x
- $this->assertTrue(FALSE === $this->redis->msetnx(array('x' => 'A', 'y' => 'B', 'z' => 'C'))); // set x y z
- $this->assertEquals($this->redis->mget(array('x', 'y', 'z')), array(FALSE, 'b', 'c')); // check x y z
+ $this->assertTrue(FALSE === $this->redis->msetnx(['x' => 'A', 'y' => 'B', 'z' => 'C'])); // set x y z
+ $this->assertEquals($this->redis->mget(['x', 'y', 'z']), [FALSE, 'b', 'c']); // check x y z
- $this->assertFalse($this->redis->msetnx(array())); // set ø → FALSE
+ $this->assertFalse($this->redis->msetnx([])); // set ø → FALSE
}
public function testRpopLpush() {
@@ -2011,14 +2011,14 @@ class Redis_Test extends TestSuite
$this->redis->lpush('{list}y', '456'); // y = [456, 123]
$this->assertEquals($this->redis->rpoplpush('{list}x', '{list}y'), 'abc'); // we RPOP x, yielding abc.
- $this->assertEquals($this->redis->lrange('{list}x', 0, -1), array('def')); // only def remains in x.
- $this->assertEquals($this->redis->lrange('{list}y', 0, -1), array('abc', '456', '123')); // abc has been lpushed to y.
+ $this->assertEquals($this->redis->lrange('{list}x', 0, -1), ['def']); // only def remains in x.
+ $this->assertEquals($this->redis->lrange('{list}y', 0, -1), ['abc', '456', '123']); // abc has been lpushed to y.
// with an empty source, expecting no change.
$this->redis->del('{list}x', '{list}y');
$this->assertTrue(FALSE === $this->redis->rpoplpush('{list}x', '{list}y'));
- $this->assertTrue(array() === $this->redis->lrange('{list}x', 0, -1));
- $this->assertTrue(array() === $this->redis->lrange('{list}y', 0, -1));
+ $this->assertTrue([] === $this->redis->lrange('{list}x', 0, -1));
+ $this->assertTrue([] === $this->redis->lrange('{list}y', 0, -1));
}
public function testBRpopLpush() {
@@ -2031,14 +2031,14 @@ class Redis_Test extends TestSuite
$this->redis->lpush('{list}y', '456'); // y = [456, 123]
$this->assertEquals($this->redis->brpoplpush('{list}x', '{list}y', 1), 'abc'); // we RPOP x, yielding abc.
- $this->assertEquals($this->redis->lrange('{list}x', 0, -1), array('def')); // only def remains in x.
- $this->assertEquals($this->redis->lrange('{list}y', 0, -1), array('abc', '456', '123')); // abc has been lpushed to y.
+ $this->assertEquals($this->redis->lrange('{list}x', 0, -1), ['def']); // only def remains in x.
+ $this->assertEquals($this->redis->lrange('{list}y', 0, -1), ['abc', '456', '123']); // abc has been lpushed to y.
// with an empty source, expecting no change.
$this->redis->del('{list}x', '{list}y');
$this->assertTrue(FALSE === $this->redis->brpoplpush('{list}x', '{list}y', 1));
- $this->assertTrue(array() === $this->redis->lrange('{list}x', 0, -1));
- $this->assertTrue(array() === $this->redis->lrange('{list}y', 0, -1));
+ $this->assertTrue([] === $this->redis->lrange('{list}x', 0, -1));
+ $this->assertTrue([] === $this->redis->lrange('{list}y', 0, -1));
}
public function testZAddFirstArg() {
@@ -2049,14 +2049,14 @@ class Redis_Test extends TestSuite
$this->assertTrue(1 === $this->redis->zAdd($zsetName, 0, 'val0'));
$this->assertTrue(1 === $this->redis->zAdd($zsetName, 1, 'val1'));
- $this->assertTrue(array('val0', 'val1') === $this->redis->zRange($zsetName, 0, -1));
+ $this->assertTrue(['val0', 'val1'] === $this->redis->zRange($zsetName, 0, -1));
}
public function testZX() {
$this->redis->del('key');
- $this->assertTrue(array() === $this->redis->zRange('key', 0, -1));
- $this->assertTrue(array() === $this->redis->zRange('key', 0, -1, true));
+ $this->assertTrue([] === $this->redis->zRange('key', 0, -1));
+ $this->assertTrue([] === $this->redis->zRange('key', 0, -1, true));
$this->assertTrue(1 === $this->redis->zAdd('key', 0, 'val0'));
$this->assertTrue(1 === $this->redis->zAdd('key', 2, 'val2'));
@@ -2065,12 +2065,12 @@ class Redis_Test extends TestSuite
$this->assertTrue(1 === $this->redis->zAdd('key', 1, 'val1'));
$this->assertTrue(1 === $this->redis->zAdd('key', 3, 'val3'));
} else {
- $this->assertTrue(1 === $this->redis->zAdd('key', array(), 1, 'val1')); // empty options
- $this->assertTrue(1 === $this->redis->zAdd('key', array('nx'), 3, 'val3')); // nx option
- $this->assertTrue(0 === $this->redis->zAdd('key', array('xx'), 3, 'val3')); // xx option
+ $this->assertTrue(1 === $this->redis->zAdd('key', [], 1, 'val1')); // empty options
+ $this->assertTrue(1 === $this->redis->zAdd('key', ['nx'], 3, 'val3')); // nx option
+ $this->assertTrue(0 === $this->redis->zAdd('key', ['xx'], 3, 'val3')); // xx option
}
- $this->assertTrue(array('val0', 'val1', 'val2', 'val3', 'val4', 'val5') === $this->redis->zRange('key', 0, -1));
+ $this->assertTrue(['val0', 'val1', 'val2', 'val3', 'val4', 'val5'] === $this->redis->zRange('key', 0, -1));
// withscores
$ret = $this->redis->zRange('key', 0, -1, true);
@@ -2087,7 +2087,7 @@ class Redis_Test extends TestSuite
$this->assertTrue(1 === $this->redis->zRem('key', 'val4'));
$this->assertTrue(1 === $this->redis->zRem('key', 'val5'));
- $this->assertTrue(array('val0', 'val1', 'val2') === $this->redis->zRange('key', 0, -1));
+ $this->assertTrue(['val0', 'val1', 'val2'] === $this->redis->zRange('key', 0, -1));
// zGetReverseRange
@@ -2095,34 +2095,34 @@ class Redis_Test extends TestSuite
$this->assertTrue(1 === $this->redis->zAdd('key', 3, 'aal3'));
$zero_to_three = $this->redis->zRangeByScore('key', 0, 3);
- $this->assertTrue(array('val0', 'val1', 'val2', 'aal3', 'val3') === $zero_to_three || array('val0', 'val1', 'val2', 'val3', 'aal3') === $zero_to_three);
+ $this->assertTrue(['val0', 'val1', 'val2', 'aal3', 'val3'] === $zero_to_three || ['val0', 'val1', 'val2', 'val3', 'aal3'] === $zero_to_three);
$three_to_zero = $this->redis->zRevRangeByScore('key', 3, 0);
- $this->assertTrue(array_reverse(array('val0', 'val1', 'val2', 'aal3', 'val3')) === $three_to_zero || array_reverse(array('val0', 'val1', 'val2', 'val3', 'aal3')) === $three_to_zero);
+ $this->assertTrue(array_reverse(['val0', 'val1', 'val2', 'aal3', 'val3']) === $three_to_zero || array_reverse(['val0', 'val1', 'val2', 'val3', 'aal3']) === $three_to_zero);
$this->assertTrue(5 === $this->redis->zCount('key', 0, 3));
// withscores
$this->redis->zRem('key', 'aal3');
- $zero_to_three = $this->redis->zRangeByScore('key', 0, 3, array('withscores' => TRUE));
- $this->assertTrue(array('val0' => 0, 'val1' => 1, 'val2' => 2, 'val3' => 3) == $zero_to_three);
+ $zero_to_three = $this->redis->zRangeByScore('key', 0, 3, ['withscores' => TRUE]);
+ $this->assertTrue(['val0' => 0, 'val1' => 1, 'val2' => 2, 'val3' => 3] == $zero_to_three);
$this->assertTrue(4 === $this->redis->zCount('key', 0, 3));
// limit
- $this->assertTrue(array('val0') === $this->redis->zRangeByScore('key', 0, 3, array('limit' => array(0, 1))));
- $this->assertTrue(array('val0', 'val1') === $this->redis->zRangeByScore('key', 0, 3, array('limit' => array(0, 2))));
- $this->assertTrue(array('val1', 'val2') === $this->redis->zRangeByScore('key', 0, 3, array('limit' => array(1, 2))));
- $this->assertTrue(array('val0', 'val1') === $this->redis->zRangeByScore('key', 0, 1, array('limit' => array(0, 100))));
+ $this->assertTrue(['val0'] === $this->redis->zRangeByScore('key', 0, 3, ['limit' => [0, 1]]));
+ $this->assertTrue(['val0', 'val1'] === $this->redis->zRangeByScore('key', 0, 3, ['limit' => [0, 2]]));
+ $this->assertTrue(['val1', 'val2'] === $this->redis->zRangeByScore('key', 0, 3, ['limit' => [1, 2]]));
+ $this->assertTrue(['val0', 'val1'] === $this->redis->zRangeByScore('key', 0, 1, ['limit' => [0, 100]]));
// limits as references
- $limit = array(0, 100);
+ $limit = [0, 100];
foreach ($limit as &$val) {}
- $this->assertTrue(array('val0', 'val1') === $this->redis->zRangeByScore('key', 0, 1, array('limit' => $limit)));
+ $this->assertTrue(['val0', 'val1'] === $this->redis->zRangeByScore('key', 0, 1, ['limit' => $limit]));
- $this->assertTrue(array('val3') === $this->redis->zRevRangeByScore('key', 3, 0, array('limit' => array(0, 1))));
- $this->assertTrue(array('val3', 'val2') === $this->redis->zRevRangeByScore('key', 3, 0, array('limit' => array(0, 2))));
- $this->assertTrue(array('val2', 'val1') === $this->redis->zRevRangeByScore('key', 3, 0, array('limit' => array(1, 2))));
- $this->assertTrue(array('val1', 'val0') === $this->redis->zRevRangeByScore('key', 1, 0, array('limit' => array(0, 100))));
+ $this->assertTrue(['val3'] === $this->redis->zRevRangeByScore('key', 3, 0, ['limit' => [0, 1]]));
+ $this->assertTrue(['val3', 'val2'] === $this->redis->zRevRangeByScore('key', 3, 0, ['limit' => [0, 2]]));
+ $this->assertTrue(['val2', 'val1'] === $this->redis->zRevRangeByScore('key', 3, 0, ['limit' => [1, 2]]));
+ $this->assertTrue(['val1', 'val0'] === $this->redis->zRevRangeByScore('key', 1, 0, ['limit' => [0, 100]]));
$this->assertTrue(4 === $this->redis->zCard('key'));
$this->assertTrue(1.0 === $this->redis->zScore('key', 'val1'));
@@ -2135,10 +2135,10 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('zset', 2, 'bar');
$this->redis->zAdd('zset', 3, 'biz');
$this->redis->zAdd('zset', 4, 'foz');
- $this->assertTrue(array('foo' => 1, 'bar' => 2, 'biz' => 3, 'foz' => 4) == $this->redis->zRangeByScore('zset', '-inf', '+inf', array('withscores' => TRUE)));
- $this->assertTrue(array('foo' => 1, 'bar' => 2) == $this->redis->zRangeByScore('zset', 1, 2, array('withscores' => TRUE)));
- $this->assertTrue(array('bar' => 2) == $this->redis->zRangeByScore('zset', '(1', 2, array('withscores' => TRUE)));
- $this->assertTrue(array() == $this->redis->zRangeByScore('zset', '(1', '(2', array('withscores' => TRUE)));
+ $this->assertTrue(['foo' => 1, 'bar' => 2, 'biz' => 3, 'foz' => 4] == $this->redis->zRangeByScore('zset', '-inf', '+inf', ['withscores' => TRUE]));
+ $this->assertTrue(['foo' => 1, 'bar' => 2] == $this->redis->zRangeByScore('zset', 1, 2, ['withscores' => TRUE]));
+ $this->assertTrue(['bar' => 2] == $this->redis->zRangeByScore('zset', '(1', 2, ['withscores' => TRUE]));
+ $this->assertTrue([] == $this->redis->zRangeByScore('zset', '(1', '(2', ['withscores' => TRUE]));
$this->assertTrue(4 == $this->redis->zCount('zset', '-inf', '+inf'));
$this->assertTrue(2 == $this->redis->zCount('zset', 1, 2));
@@ -2168,26 +2168,26 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('{zset}3', 4, 'val4');
$this->redis->zAdd('{zset}3', 5, 'val5');
- $this->assertTrue(4 === $this->redis->zUnionStore('{zset}U', array('{zset}1', '{zset}3')));
- $this->assertTrue(array('val0', 'val1', 'val4', 'val5') === $this->redis->zRange('{zset}U', 0, -1));
+ $this->assertTrue(4 === $this->redis->zUnionStore('{zset}U', ['{zset}1', '{zset}3']));
+ $this->assertTrue(['val0', 'val1', 'val4', 'val5'] === $this->redis->zRange('{zset}U', 0, -1));
// Union on non existing keys
$this->redis->del('{zset}U');
- $this->assertTrue(0 === $this->redis->zUnionStore('{zset}U', array('{zset}X', '{zset}Y')));
- $this->assertTrue(array() === $this->redis->zRange('{zset}U', 0, -1));
+ $this->assertTrue(0 === $this->redis->zUnionStore('{zset}U', ['{zset}X', '{zset}Y']));
+ $this->assertTrue([] === $this->redis->zRange('{zset}U', 0, -1));
// !Exist U Exist → copy of existing zset.
$this->redis->del('{zset}U', 'X');
- $this->assertTrue(2 === $this->redis->zUnionStore('{zset}U', array('{zset}1', '{zset}X')));
+ $this->assertTrue(2 === $this->redis->zUnionStore('{zset}U', ['{zset}1', '{zset}X']));
// test weighted zUnion
$this->redis->del('{zset}Z');
- $this->assertTrue(4 === $this->redis->zUnionStore('{zset}Z', array('{zset}1', '{zset}2'), array(1, 1)));
- $this->assertTrue(array('val0', 'val1', 'val2', 'val3') === $this->redis->zRange('{zset}Z', 0, -1));
+ $this->assertTrue(4 === $this->redis->zUnionStore('{zset}Z', ['{zset}1', '{zset}2'], [1, 1]));
+ $this->assertTrue(['val0', 'val1', 'val2', 'val3'] === $this->redis->zRange('{zset}Z', 0, -1));
$this->redis->zRemRangeByScore('{zset}Z', 0, 10);
- $this->assertTrue(4 === $this->redis->zUnionStore('{zset}Z', array('{zset}1', '{zset}2'), array(5, 1)));
- $this->assertTrue(array('val0', 'val2', 'val3', 'val1') === $this->redis->zRange('{zset}Z', 0, -1));
+ $this->assertTrue(4 === $this->redis->zUnionStore('{zset}Z', ['{zset}1', '{zset}2'], [5, 1]));
+ $this->assertTrue(['val0', 'val2', 'val3', 'val1'] === $this->redis->zRange('{zset}Z', 0, -1));
$this->redis->del('{zset}1');
$this->redis->del('{zset}2');
@@ -2196,12 +2196,12 @@ class Redis_Test extends TestSuite
//test zUnion with weights and aggegration function
$this->redis->zadd('{zset}1', 1, 'duplicate');
$this->redis->zadd('{zset}2', 2, 'duplicate');
- $this->redis->zUnionStore('{zset}U', array('{zset}1','{zset}2'), array(1,1), 'MIN');
+ $this->redis->zUnionStore('{zset}U', ['{zset}1','{zset}2'], [1,1], 'MIN');
$this->assertTrue($this->redis->zScore('{zset}U', 'duplicate')===1.0);
$this->redis->del('{zset}U');
//now test zUnion *without* weights but with aggregrate function
- $this->redis->zUnionStore('{zset}U', array('{zset}1','{zset}2'), null, 'MIN');
+ $this->redis->zUnionStore('{zset}U', ['{zset}1','{zset}2'], null, 'MIN');
$this->assertTrue($this->redis->zScore('{zset}U', 'duplicate')===1.0);
$this->redis->del('{zset}U', '{zset}1', '{zset}2');
@@ -2214,7 +2214,7 @@ class Redis_Test extends TestSuite
$this->redis->zadd('{zset}2', 2, 'two');
$this->redis->zadd('{zset}2', 3, 'three');
- $this->assertTrue($this->redis->zUnionStore('{zset}3', array('{zset}1', '{zset}2'), array(2, 3.0)) === 3);
+ $this->assertTrue($this->redis->zUnionStore('{zset}3', ['{zset}1', '{zset}2'], [2, 3.0]) === 3);
$this->redis->del('{zset}1');
$this->redis->del('{zset}2');
@@ -2225,17 +2225,17 @@ class Redis_Test extends TestSuite
$this->redis->zadd('{zset}2', 3, 'three', 4, 'four', 5, 'five');
// Make sure phpredis handles these weights
- $this->assertTrue($this->redis->zUnionStore('{zset}3', array('{zset}1','{zset}2'), array(1, 'inf')) === 5);
- $this->assertTrue($this->redis->zUnionStore('{zset}3', array('{zset}1','{zset}2'), array(1, '-inf')) === 5);
- $this->assertTrue($this->redis->zUnionStore('{zset}3', array('{zset}1','{zset}2'), array(1, '+inf')) === 5);
+ $this->assertTrue($this->redis->zUnionStore('{zset}3', ['{zset}1','{zset}2'], [1, 'inf']) === 5);
+ $this->assertTrue($this->redis->zUnionStore('{zset}3', ['{zset}1','{zset}2'], [1, '-inf']) === 5);
+ $this->assertTrue($this->redis->zUnionStore('{zset}3', ['{zset}1','{zset}2'], [1, '+inf']) === 5);
// Now, confirm that they're being sent, and that it works
- $arr_weights = Array('inf','-inf','+inf');
+ $arr_weights = ['inf','-inf','+inf'];
foreach($arr_weights as $str_weight) {
- $r = $this->redis->zUnionStore('{zset}3', array('{zset}1','{zset}2'), array(1,$str_weight));
+ $r = $this->redis->zUnionStore('{zset}3', ['{zset}1','{zset}2'], [1,$str_weight]);
$this->assertTrue($r===5);
- $r = $this->redis->zrangebyscore('{zset}3', '(-inf', '(inf',array('withscores'=>true));
+ $r = $this->redis->zrangebyscore('{zset}3', '(-inf', '(inf',['withscores'=>true]);
$this->assertTrue(count($r)===2);
$this->assertTrue(isset($r['one']));
$this->assertTrue(isset($r['two']));
@@ -2251,7 +2251,7 @@ class Redis_Test extends TestSuite
$this->assertTrue(count($ret) === 3);
$retValues = array_keys($ret);
- $this->assertTrue(array('one', 'two', 'three') === $retValues);
+ $this->assertTrue(['one', 'two', 'three'] === $retValues);
// + 0 converts from string to float OR integer
$this->assertTrue(is_float($ret['one'] + 0));
@@ -2265,7 +2265,7 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('{zset}1', 2, 'two');
$this->redis->zAdd('{zset}1', 3, 'three');
$this->assertTrue(2 === $this->redis->zremrangebyrank('{zset}1', 0, 1));
- $this->assertTrue(array('three' => 3) == $this->redis->zRange('{zset}1', 0, -1, TRUE));
+ $this->assertTrue(['three' => 3] == $this->redis->zRange('{zset}1', 0, -1, TRUE));
$this->redis->del('{zset}1');
@@ -2282,16 +2282,16 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('{zset}3', 5, 'val5');
$this->redis->del('{zset}I');
- $this->assertTrue(2 === $this->redis->zInterStore('{zset}I', array('{zset}1', '{zset}2')));
- $this->assertTrue(array('val1', 'val3') === $this->redis->zRange('{zset}I', 0, -1));
+ $this->assertTrue(2 === $this->redis->zInterStore('{zset}I', ['{zset}1', '{zset}2']));
+ $this->assertTrue(['val1', 'val3'] === $this->redis->zRange('{zset}I', 0, -1));
// Union on non existing keys
- $this->assertTrue(0 === $this->redis->zInterStore('{zset}X', array('{zset}X', '{zset}Y')));
- $this->assertTrue(array() === $this->redis->zRange('{zset}X', 0, -1));
+ $this->assertTrue(0 === $this->redis->zInterStore('{zset}X', ['{zset}X', '{zset}Y']));
+ $this->assertTrue([] === $this->redis->zRange('{zset}X', 0, -1));
// !Exist U Exist
- $this->assertTrue(0 === $this->redis->zInterStore('{zset}Y', array('{zset}1', '{zset}X')));
- $this->assertTrue(array() === $this->redis->zRange('keyY', 0, -1));
+ $this->assertTrue(0 === $this->redis->zInterStore('{zset}Y', ['{zset}1', '{zset}X']));
+ $this->assertTrue([] === $this->redis->zRange('keyY', 0, -1));
// test weighted zInter
@@ -2311,18 +2311,18 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('{zset}3', 3, 'val3');
$this->redis->del('{zset}I');
- $this->assertTrue(2 === $this->redis->zInterStore('{zset}I', array('{zset}1', '{zset}2'), array(1, 1)));
- $this->assertTrue(array('val1', 'val3') === $this->redis->zRange('{zset}I', 0, -1));
+ $this->assertTrue(2 === $this->redis->zInterStore('{zset}I', ['{zset}1', '{zset}2'], [1, 1]));
+ $this->assertTrue(['val1', 'val3'] === $this->redis->zRange('{zset}I', 0, -1));
$this->redis->del('{zset}I');
- $this->assertTrue( 2 === $this->redis->zInterStore('{zset}I', array('{zset}1', '{zset}2', '{zset}3'), array(1, 5, 1), 'min'));
- $this->assertTrue(array('val1', 'val3') === $this->redis->zRange('{zset}I', 0, -1));
+ $this->assertTrue( 2 === $this->redis->zInterStore('{zset}I', ['{zset}1', '{zset}2', '{zset}3'], [1, 5, 1], 'min'));
+ $this->assertTrue(['val1', 'val3'] === $this->redis->zRange('{zset}I', 0, -1));
$this->redis->del('{zset}I');
- $this->assertTrue( 2 === $this->redis->zInterStore('{zset}I', array('{zset}1', '{zset}2', '{zset}3'), array(1, 5, 1), 'max'));
- $this->assertTrue(array('val3', 'val1') === $this->redis->zRange('{zset}I', 0, -1));
+ $this->assertTrue( 2 === $this->redis->zInterStore('{zset}I', ['{zset}1', '{zset}2', '{zset}3'], [1, 5, 1], 'max'));
+ $this->assertTrue(['val3', 'val1'] === $this->redis->zRange('{zset}I', 0, -1));
$this->redis->del('{zset}I');
- $this->assertTrue(2 === $this->redis->zInterStore('{zset}I', array('{zset}1', '{zset}2', '{zset}3'), null, 'max'));
+ $this->assertTrue(2 === $this->redis->zInterStore('{zset}I', ['{zset}1', '{zset}2', '{zset}3'], null, 'max'));
$this->assertTrue($this->redis->zScore('{zset}I', 'val1') === floatval(7));
// zrank, zrevrank
@@ -2352,12 +2352,12 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('key', 0, $c);
}
- $this->assertEquals($this->redis->zRangeByLex('key', '-', '[c'), Array('a', 'b', 'c'));
- $this->assertEquals($this->redis->zRangeByLex('key', '(e', '+'), Array('f', 'g'));
+ $this->assertEquals($this->redis->zRangeByLex('key', '-', '[c'), ['a', 'b', 'c']);
+ $this->assertEquals($this->redis->zRangeByLex('key', '(e', '+'), ['f', 'g']);
// with limit offset
- $this->assertEquals($this->redis->zRangeByLex('key', '-', '[c', 1, 2), Array('b', 'c') );
- $this->assertEquals($this->redis->zRangeByLex('key', '-', '(c', 1, 2), Array('b'));
+ $this->assertEquals($this->redis->zRangeByLex('key', '-', '[c', 1, 2), ['b', 'c'] );
+ $this->assertEquals($this->redis->zRangeByLex('key', '-', '(c', 1, 2), ['b']);
}
public function testZLexCount() {
@@ -2447,15 +2447,15 @@ class Redis_Test extends TestSuite
// keys
$keys = $this->redis->hKeys('h');
- $this->assertTrue($keys === array('x', 'y') || $keys === array('y', 'x'));
+ $this->assertTrue($keys === ['x', 'y'] || $keys === ['y', 'x']);
// values
$values = $this->redis->hVals('h');
- $this->assertTrue($values === array('a', 'b') || $values === array('b', 'a'));
+ $this->assertTrue($values === ['a', 'b'] || $values === ['b', 'a']);
// keys + values
$all = $this->redis->hGetAll('h');
- $this->assertTrue($all === array('x' => 'a', 'y' => 'b') || $all === array('y' => 'b', 'x' => 'a'));
+ $this->assertTrue($all === ['x' => 'a', 'y' => 'b'] || $all === ['y' => 'b', 'x' => 'a']);
// hExists
$this->assertTrue(TRUE === $this->redis->hExists('h', 'x'));
@@ -2490,41 +2490,41 @@ class Redis_Test extends TestSuite
// hmset
$this->redis->del('h');
- $this->assertTrue(TRUE === $this->redis->hMset('h', array('x' => 123, 'y' => 456, 'z' => 'abc')));
+ $this->assertTrue(TRUE === $this->redis->hMset('h', ['x' => 123, 'y' => 456, 'z' => 'abc']));
$this->assertTrue('123' === $this->redis->hGet('h', 'x'));
$this->assertTrue('456' === $this->redis->hGet('h', 'y'));
$this->assertTrue('abc' === $this->redis->hGet('h', 'z'));
$this->assertTrue(FALSE === $this->redis->hGet('h', 't'));
// hmget
- $this->assertTrue(array('x' => '123', 'y' => '456') === $this->redis->hMget('h', array('x', 'y')));
- $this->assertTrue(array('z' => 'abc') === $this->redis->hMget('h', array('z')));
- $this->assertTrue(array('x' => '123', 't' => FALSE, 'y' => '456') === $this->redis->hMget('h', array('x', 't', 'y')));
- $this->assertFalse(array(123 => 'x') === $this->redis->hMget('h', array(123)));
- $this->assertTrue(array(123 => FALSE) === $this->redis->hMget('h', array(123)));
+ $this->assertTrue(['x' => '123', 'y' => '456'] === $this->redis->hMget('h', ['x', 'y']));
+ $this->assertTrue(['z' => 'abc'] === $this->redis->hMget('h', ['z']));
+ $this->assertTrue(['x' => '123', 't' => FALSE, 'y' => '456'] === $this->redis->hMget('h', ['x', 't', 'y']));
+ $this->assertFalse([123 => 'x'] === $this->redis->hMget('h', [123]));
+ $this->assertTrue([123 => FALSE] === $this->redis->hMget('h', [123]));
// Test with an array populated with things we can't use as keys
- $this->assertTrue($this->redis->hmget('h', Array(false,NULL,false)) === FALSE);
+ $this->assertTrue($this->redis->hmget('h', [false,NULL,false]) === FALSE);
// Test with some invalid keys mixed in (which should just be ignored)
- $this->assertTrue(array('x'=>'123','y'=>'456','z'=>'abc') === $this->redis->hMget('h',Array('x',null,'y','','z',false)));
+ $this->assertTrue(['x'=>'123','y'=>'456','z'=>'abc'] === $this->redis->hMget('h',['x',null,'y','','z',false]));
// hmget/hmset with numeric fields
$this->redis->del('h');
- $this->assertTrue(TRUE === $this->redis->hMset('h', array(123 => 'x', 'y' => 456)));
+ $this->assertTrue(TRUE === $this->redis->hMset('h', [123 => 'x', 'y' => 456]));
$this->assertTrue('x' === $this->redis->hGet('h', 123));
$this->assertTrue('x' === $this->redis->hGet('h', '123'));
$this->assertTrue('456' === $this->redis->hGet('h', 'y'));
- $this->assertTrue(array(123 => 'x', 'y' => '456') === $this->redis->hMget('h', array('123', 'y')));
+ $this->assertTrue([123 => 'x', 'y' => '456'] === $this->redis->hMget('h', ['123', 'y']));
// references
- $keys = array(123, 'y');
+ $keys = [123, 'y'];
foreach ($keys as &$key) {}
- $this->assertTrue(array(123 => 'x', 'y' => '456') === $this->redis->hMget('h', $keys));
+ $this->assertTrue([123 => 'x', 'y' => '456'] === $this->redis->hMget('h', $keys));
// check non-string types.
$this->redis->del('h1');
- $this->assertTrue(TRUE === $this->redis->hMSet('h1', array('x' => 0, 'y' => array(), 'z' => new stdclass(), 't' => NULL)));
+ $this->assertTrue(TRUE === $this->redis->hMSet('h1', ['x' => 0, 'y' => [], 'z' => new stdclass(), 't' => NULL]));
$h1 = $this->redis->hGetAll('h1');
$this->assertTrue('0' === $h1['x']);
$this->assertTrue('Array' === $h1['y']);
@@ -2629,7 +2629,7 @@ class Redis_Test extends TestSuite
$ret = $this->redis->multi()->get('x')->exec();
// successful transaction
- $this->assertTrue($ret === array('42'));
+ $this->assertTrue($ret === ['42']);
}
public function testFailedTransactions() {
@@ -2651,7 +2651,7 @@ class Redis_Test extends TestSuite
$ret = $this->redis->multi()->get('x')->exec();
- $this->assertTrue($ret === array('44')); // succeeded since we've cancel the WATCH command.
+ $this->assertTrue($ret === ['44']); // succeeded since we've cancel the WATCH command.
}
public function testPipeline() {
@@ -2701,7 +2701,7 @@ class Redis_Test extends TestSuite
$this->redis->set('pipecount','over9000')->get('pipecount');
$data = $this->redis->exec();
- $this->assertEquals(Array(true,'over9000'), $data);
+ $this->assertEquals([true,'over9000'], $data);
/* Only the first MULTI should be honored */
for ($i = 0; $i < 6; $i++) {
@@ -2712,12 +2712,12 @@ class Redis_Test extends TestSuite
$this->redis->set('multicount', 'over9000')->get('multicount');
$data = $this->redis->exec();
- $this->assertEquals(Array(true, 'over9000'), $data);
+ $this->assertEquals([true, 'over9000'], $data);
}
public function testDiscard()
{
- foreach (Array(Redis::PIPELINE, Redis::MULTI) as $mode) {
+ foreach ([Redis::PIPELINE, Redis::MULTI] as $mode) {
/* start transaction */
$this->redis->multi($mode);
@@ -2815,8 +2815,8 @@ class Redis_Test extends TestSuite
$this->redis->del('key');
$ret = $this->redis->multi($mode)
->ttl('key')
- ->mget(array('{key}1', '{key}2', '{key}3'))
- ->mset(array('{key}3' => 'value3', 'key4' => 'value4'))
+ ->mget(['{key}1', '{key}2', '{key}3'])
+ ->mset(['{key}3' => 'value3', 'key4' => 'value4'])
->set('key', 'value')
->expire('key', 5)
->ttl('key')
@@ -2827,7 +2827,7 @@ class Redis_Test extends TestSuite
$i = 0;
$ttl = $ret[$i++];
$this->assertTrue($ttl === -1 || $ttl === -2);
- $this->assertTrue($ret[$i++] === array('val1', 'valX', FALSE)); // mget
+ $this->assertTrue($ret[$i++] === ['val1', 'valX', FALSE]); // mget
$this->assertTrue($ret[$i++] === TRUE); // mset
$this->assertTrue($ret[$i++] === TRUE); // set
$this->assertTrue($ret[$i++] === TRUE); // expire
@@ -2870,15 +2870,15 @@ class Redis_Test extends TestSuite
$this->assertTrue($ret[$i++] === 5); // lpush, now 5 elements
$this->assertTrue($ret[$i++] === 6); // lpush, now 6 elements
$this->assertTrue($ret[$i++] === 'lvalue'); // rpoplpush returns the element: "lvalue"
- $this->assertTrue($ret[$i++] === array('lvalue')); // lDest contains only that one element.
+ $this->assertTrue($ret[$i++] === ['lvalue']); // lDest contains only that one element.
$this->assertTrue($ret[$i++] === 'lvalue'); // removing a second element from lkey, now 4 elements left ↓
$this->assertTrue($ret[$i++] === 4); // 4 elements left, after 2 pops.
$this->assertTrue($ret[$i++] === 3); // removing 3 elements, now 1 left.
$this->assertTrue($ret[$i++] === 1); // 1 element left
$this->assertTrue($ret[$i++] === "lvalue"); // this is the current head.
- $this->assertTrue($ret[$i++] === array("lvalue")); // this is the current list.
+ $this->assertTrue($ret[$i++] === ["lvalue"]); // this is the current list.
$this->assertTrue($ret[$i++] === FALSE); // updating a non-existent element fails.
- $this->assertTrue($ret[$i++] === array("lvalue")); // this is the current list.
+ $this->assertTrue($ret[$i++] === ["lvalue"]); // this is the current list.
$this->assertTrue($ret[$i++] === 1); // 1 element left
$this->assertTrue(count($ret) == $i);
@@ -2899,7 +2899,7 @@ class Redis_Test extends TestSuite
$this->assertTrue($ret[$i++] === 2); // 2 elements in the list
$this->assertTrue($ret[$i++] === 3); // 3 elements in the list
$this->assertTrue($ret[$i++] === 'lvalue'); // rpoplpush returns the element: "lvalue"
- $this->assertTrue($ret[$i++] === array('lvalue')); // rpoplpush returns the element: "lvalue"
+ $this->assertTrue($ret[$i++] === ['lvalue']); // rpoplpush returns the element: "lvalue"
$this->assertTrue($ret[$i++] === 'lvalue'); // pop returns the front element: "lvalue"
$this->assertTrue(count($ret) == $i);
@@ -2975,8 +2975,8 @@ class Redis_Test extends TestSuite
// ttl, mget, mset, msetnx, expire, expireAt
$ret = $this->redis->multi($mode)
->ttl('key')
- ->mget(array('{key}1', '{key}2', '{key}3'))
- ->mset(array('{key}3' => 'value3', '{key}4' => 'value4'))
+ ->mget(['{key}1', '{key}2', '{key}3'])
+ ->mset(['{key}3' => 'value3', '{key}4' => 'value4'])
->set('key', 'value')
->expire('key', 5)
->ttl('key')
@@ -3027,15 +3027,15 @@ class Redis_Test extends TestSuite
$this->assertTrue($ret[$i++] === 5); // 5 values
$this->assertTrue($ret[$i++] === 6); // 6 values
$this->assertTrue($ret[$i++] === 'lvalue');
- $this->assertTrue($ret[$i++] === array('lvalue')); // 1 value only in lDest
+ $this->assertTrue($ret[$i++] === ['lvalue']); // 1 value only in lDest
$this->assertTrue($ret[$i++] === 'lvalue'); // now 4 values left
$this->assertTrue($ret[$i++] === 4);
$this->assertTrue($ret[$i++] === 3); // removing 3 elements.
$this->assertTrue($ret[$i++] === 1); // length is now 1
$this->assertTrue($ret[$i++] === 'lvalue'); // this is the head
- $this->assertTrue($ret[$i++] === array('lvalue')); // 1 value only in lkey
+ $this->assertTrue($ret[$i++] === ['lvalue']); // 1 value only in lkey
$this->assertTrue($ret[$i++] === FALSE); // can't set list[1] if we only have a single value in it.
- $this->assertTrue($ret[$i++] === array('lvalue')); // the previous error didn't touch anything.
+ $this->assertTrue($ret[$i++] === ['lvalue']); // the previous error didn't touch anything.
$this->assertTrue($ret[$i++] === 1); // the previous error didn't change the length
$this->assertTrue(count($ret) === $i);
@@ -3089,34 +3089,34 @@ class Redis_Test extends TestSuite
$this->assertTrue($ret[$i++] === TRUE); // the move did succeed.
$this->assertTrue($ret[$i++] === 3); // sKey2 now has 3 values.
$this->assertTrue($ret[$i++] === TRUE); // sKey2 does contain sValue4.
- foreach(array('sValue1', 'sValue3') as $k) { // sKey1 contains sValue1 and sValue3.
+ foreach(['sValue1', 'sValue3'] as $k) { // sKey1 contains sValue1 and sValue3.
$this->assertTrue(in_array($k, $ret[$i]));
}
$this->assertTrue(count($ret[$i++]) === 2);
- foreach(array('sValue1', 'sValue2', 'sValue4') as $k) { // sKey2 contains sValue1, sValue2, and sValue4.
+ foreach(['sValue1', 'sValue2', 'sValue4'] as $k) { // sKey2 contains sValue1, sValue2, and sValue4.
$this->assertTrue(in_array($k, $ret[$i]));
}
$this->assertTrue(count($ret[$i++]) === 3);
- $this->assertTrue($ret[$i++] === array('sValue1')); // intersection
+ $this->assertTrue($ret[$i++] === ['sValue1']); // intersection
$this->assertTrue($ret[$i++] === 1); // intersection + store → 1 value in the destination set.
- $this->assertTrue($ret[$i++] === array('sValue1')); // sinterstore destination contents
+ $this->assertTrue($ret[$i++] === ['sValue1']); // sinterstore destination contents
- foreach(array('sValue1', 'sValue2', 'sValue4') as $k) { // (skeydest U sKey2) contains sValue1, sValue2, and sValue4.
+ foreach(['sValue1', 'sValue2', 'sValue4'] as $k) { // (skeydest U sKey2) contains sValue1, sValue2, and sValue4.
$this->assertTrue(in_array($k, $ret[$i]));
}
$this->assertTrue(count($ret[$i++]) === 3); // union size
$this->assertTrue($ret[$i++] === 3); // unionstore size
- foreach(array('sValue1', 'sValue2', 'sValue4') as $k) { // (skeyUnion) contains sValue1, sValue2, and sValue4.
+ foreach(['sValue1', 'sValue2', 'sValue4'] as $k) { // (skeyUnion) contains sValue1, sValue2, and sValue4.
$this->assertTrue(in_array($k, $ret[$i]));
}
$this->assertTrue(count($ret[$i++]) === 3); // skeyUnion size
- $this->assertTrue($ret[$i++] === array('sValue3')); // diff skey1, skey2 : only sValue3 is not shared.
+ $this->assertTrue($ret[$i++] === ['sValue3']); // diff skey1, skey2 : only sValue3 is not shared.
$this->assertTrue($ret[$i++] === 1); // sdiffstore size == 1
- $this->assertTrue($ret[$i++] === array('sValue3')); // contents of sDiffDest
+ $this->assertTrue($ret[$i++] === ['sValue3']); // contents of sDiffDest
- $this->assertTrue(in_array($ret[$i++], array('sValue1', 'sValue2', 'sValue4'))); // we removed an element from sKey2
+ $this->assertTrue(in_array($ret[$i++], ['sValue1', 'sValue2', 'sValue4'])); // we removed an element from sKey2
$this->assertTrue($ret[$i++] === 2); // sKey2 now has 2 elements only.
$this->assertTrue(count($ret) === $i);
@@ -3143,11 +3143,11 @@ class Redis_Test extends TestSuite
->zScore('{z}key1', 'zValue15')
->zadd('{z}key2', 5, 'zValue5')
->zadd('{z}key2', 2, 'zValue2')
- ->zInterStore('{z}Inter', array('{z}key1', '{z}key2'))
+ ->zInterStore('{z}Inter', ['{z}key1', '{z}key2'])
->zRange('{z}key1', 0, -1)
->zRange('{z}key2', 0, -1)
->zRange('{z}Inter', 0, -1)
- ->zUnionStore('{z}Union', array('{z}key1', '{z}key2'))
+ ->zUnionStore('{z}Union', ['{z}key1', '{z}key2'])
->zRange('{z}Union', 0, -1)
->zadd('{z}key5', 5, 'zValue5')
->zIncrBy('{z}key5', 3, 'zValue5') // fix this
@@ -3161,28 +3161,28 @@ class Redis_Test extends TestSuite
$this->assertTrue($ret[$i++] === 1);
$this->assertTrue($ret[$i++] === 1);
$this->assertTrue($ret[$i++] === 1);
- $this->assertTrue($ret[$i++] === array('zValue1', 'zValue2', 'zValue5'));
+ $this->assertTrue($ret[$i++] === ['zValue1', 'zValue2', 'zValue5']);
$this->assertTrue($ret[$i++] === 1);
- $this->assertTrue($ret[$i++] === array('zValue1', 'zValue5'));
+ $this->assertTrue($ret[$i++] === ['zValue1', 'zValue5']);
$this->assertTrue($ret[$i++] === 1); // adding zValue11
$this->assertTrue($ret[$i++] === 1); // adding zValue12
$this->assertTrue($ret[$i++] === 1); // adding zValue13
$this->assertTrue($ret[$i++] === 1); // adding zValue14
$this->assertTrue($ret[$i++] === 1); // adding zValue15
$this->assertTrue($ret[$i++] === 3); // deleted zValue11, zValue12, zValue13
- $this->assertTrue($ret[$i++] === array('zValue1', 'zValue5', 'zValue14', 'zValue15'));
- $this->assertTrue($ret[$i++] === array('zValue15', 'zValue14', 'zValue5', 'zValue1'));
- $this->assertTrue($ret[$i++] === array('zValue1', 'zValue5'));
+ $this->assertTrue($ret[$i++] === ['zValue1', 'zValue5', 'zValue14', 'zValue15']);
+ $this->assertTrue($ret[$i++] === ['zValue15', 'zValue14', 'zValue5', 'zValue1']);
+ $this->assertTrue($ret[$i++] === ['zValue1', 'zValue5']);
$this->assertTrue($ret[$i++] === 4); // 4 elements
$this->assertTrue($ret[$i++] === 15.0);
$this->assertTrue($ret[$i++] === 1); // added value
$this->assertTrue($ret[$i++] === 1); // added value
$this->assertTrue($ret[$i++] === 1); // zinter only has 1 value
- $this->assertTrue($ret[$i++] === array('zValue1', 'zValue5', 'zValue14', 'zValue15')); // {z}key1 contents
- $this->assertTrue($ret[$i++] === array('zValue2', 'zValue5')); // {z}key2 contents
- $this->assertTrue($ret[$i++] === array('zValue5')); // {z}inter contents
+ $this->assertTrue($ret[$i++] === ['zValue1', 'zValue5', 'zValue14', 'zValue15']); // {z}key1 contents
+ $this->assertTrue($ret[$i++] === ['zValue2', 'zValue5']); // {z}key2 contents
+ $this->assertTrue($ret[$i++] === ['zValue5']); // {z}inter contents
$this->assertTrue($ret[$i++] === 5); // {z}Union has 5 values (1,2,5,14,15)
- $this->assertTrue($ret[$i++] === array('zValue1', 'zValue2', 'zValue5', 'zValue14', 'zValue15')); // {z}Union contents
+ $this->assertTrue($ret[$i++] === ['zValue1', 'zValue2', 'zValue5', 'zValue14', 'zValue15']); // {z}Union contents
$this->assertTrue($ret[$i++] === 1); // added value to {z}key5, with score 5
$this->assertTrue($ret[$i++] === 8.0); // incremented score by 3 → it is now 8.
$this->assertTrue($ret[$i++] === 8.0); // current score is 8.
@@ -3196,7 +3196,7 @@ class Redis_Test extends TestSuite
->hset('hkey1', 'key1', 'value1')
->hset('hkey1', 'key2', 'value2')
->hset('hkey1', 'key3', 'value3')
- ->hmget('hkey1', array('key1', 'key2', 'key3'))
+ ->hmget('hkey1', ['key1', 'key2', 'key3'])
->hget('hkey1', 'key1')
->hlen('hkey1')
->hdel('hkey1', 'key2')
@@ -3216,15 +3216,15 @@ class Redis_Test extends TestSuite
$this->assertTrue($ret[$i++] === 1); // added 1 element
$this->assertTrue($ret[$i++] === 1); // added 1 element
$this->assertTrue($ret[$i++] === 1); // added 1 element
- $this->assertTrue($ret[$i++] === array('key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3')); // hmget, 3 elements
+ $this->assertTrue($ret[$i++] === ['key1' => 'value1', 'key2' => 'value2', 'key3' => 'value3']); // hmget, 3 elements
$this->assertTrue($ret[$i++] === 'value1'); // hget
$this->assertTrue($ret[$i++] === 3); // hlen
$this->assertTrue($ret[$i++] === 1); // hdel succeeded
$this->assertTrue($ret[$i++] === 0); // hdel failed
$this->assertTrue($ret[$i++] === FALSE); // hexists didn't find the deleted key
- $this->assertTrue($ret[$i] === array('key1', 'key3') || $ret[$i] === array('key3', 'key1')); $i++; // hkeys
- $this->assertTrue($ret[$i] === array('value1', 'value3') || $ret[$i] === array('value3', 'value1')); $i++; // hvals
- $this->assertTrue($ret[$i] === array('key1' => 'value1', 'key3' => 'value3') || $ret[$i] === array('key3' => 'value3', 'key1' => 'value1')); $i++; // hgetall
+ $this->assertTrue($ret[$i] === ['key1', 'key3'] || $ret[$i] === ['key3', 'key1']); $i++; // hkeys
+ $this->assertTrue($ret[$i] === ['value1', 'value3'] || $ret[$i] === ['value3', 'value1']); $i++; // hvals
+ $this->assertTrue($ret[$i] === ['key1' => 'value1', 'key3' => 'value3'] || $ret[$i] === ['key3' => 'value3', 'key1' => 'value1']); $i++; // hgetall
$this->assertTrue($ret[$i++] === 1); // added 1 element
$this->assertTrue($ret[$i++] === 1); // added the element, so 1.
$this->assertTrue($ret[$i++] === 'non-string'); // hset succeeded
@@ -3254,7 +3254,7 @@ class Redis_Test extends TestSuite
->zscore('test', "2")
->exec();
- $this->assertTrue($result === array(1.0, FALSE, FALSE, 2.0));
+ $this->assertTrue($result === [1.0, FALSE, FALSE, 2.0]);
}
protected function differentType($mode) {
@@ -3314,8 +3314,8 @@ class Redis_Test extends TestSuite
// hash I/F
->hSet($key, 'key1', 'value1')
->hGet($key, 'key1')
- ->hMGet($key, array('key1'))
- ->hMSet($key, array('key1' => 'value1'))
+ ->hMGet($key, ['key1'])
+ ->hMSet($key, ['key1' => 'value1'])
->hIncrBy($key, 'key2', 1)
->hExists($key, 'key2')
->hDel($key, 'key2')
@@ -3396,7 +3396,7 @@ class Redis_Test extends TestSuite
->getset($key, 'value2')
->append($key, 'append')
->getRange($key, 0, 8)
- ->mget(array($key))
+ ->mget([$key])
->incr($key)
->incrBy($key, 1)
->decr($key)
@@ -3433,8 +3433,8 @@ class Redis_Test extends TestSuite
// hash I/F
->hSet($key, 'key1', 'value1')
->hGet($key, 'key1')
- ->hMGet($key, array('key1'))
- ->hMSet($key, array('key1' => 'value1'))
+ ->hMGet($key, ['key1'])
+ ->hMSet($key, ['key1' => 'value1'])
->hIncrBy($key, 'key2', 1)
->hExists($key, 'key2')
->hDel($key, 'key2')
@@ -3513,7 +3513,7 @@ class Redis_Test extends TestSuite
->getset($key, 'value2')
->append($key, 'append')
->getRange($key, 0, 8)
- ->mget(array($key))
+ ->mget([$key])
->incr($key)
->incrBy($key, 1)
->decr($key)
@@ -3551,8 +3551,8 @@ class Redis_Test extends TestSuite
// hash I/F
->hSet($key, 'key1', 'value1')
->hGet($key, 'key1')
- ->hMGet($key, array('key1'))
- ->hMSet($key, array('key1' => 'value1'))
+ ->hMGet($key, ['key1'])
+ ->hMSet($key, ['key1' => 'value1'])
->hIncrBy($key, 'key2', 1)
->hExists($key, 'key2')
->hDel($key, 'key2')
@@ -3632,7 +3632,7 @@ class Redis_Test extends TestSuite
->getset($key, 'value2')
->append($key, 'append')
->getRange($key, 0, 8)
- ->mget(array($key))
+ ->mget([$key])
->incr($key)
->incrBy($key, 1)
->decr($key)
@@ -3668,8 +3668,8 @@ class Redis_Test extends TestSuite
// hash I/F
->hSet($key, 'key1', 'value1')
->hGet($key, 'key1')
- ->hMGet($key, array('key1'))
- ->hMSet($key, array('key1' => 'value1'))
+ ->hMGet($key, ['key1'])
+ ->hMSet($key, ['key1' => 'value1'])
->hIncrBy($key, 'key2', 1)
->hExists($key, 'key2')
->hDel($key, 'key2')
@@ -3747,7 +3747,7 @@ class Redis_Test extends TestSuite
->getset($key, 'value2')
->append($key, 'append')
->getRange($key, 0, 8)
- ->mget(array($key))
+ ->mget([$key])
->incr($key)
->incrBy($key, 1)
->decr($key)
@@ -3907,8 +3907,8 @@ class Redis_Test extends TestSuite
// hash I/F
$this->assertEquals(FALSE, $this->redis->hSet($key, 'key1', 'value1'));
$this->assertEquals(FALSE, $this->redis->hGet($key, 'key1'));
- $this->assertEquals(FALSE, $this->redis->hMGet($key, array('key1')));
- $this->assertEquals(FALSE, $this->redis->hMSet($key, array('key1' => 'value1')));
+ $this->assertEquals(FALSE, $this->redis->hMGet($key, ['key1']));
+ $this->assertEquals(FALSE, $this->redis->hMSet($key, ['key1' => 'value1']));
$this->assertEquals(FALSE, $this->redis->hIncrBy($key, 'key2', 1));
$this->assertEquals(FALSE, $this->redis->hExists($key, 'key2'));
$this->assertEquals(FALSE, $this->redis->hDel($key, 'key2'));
@@ -3930,7 +3930,7 @@ class Redis_Test extends TestSuite
$this->assertEquals(FALSE, $this->redis->getset($key, 'value2'));
$this->assertEquals(FALSE, $this->redis->append($key, 'append'));
$this->assertEquals(FALSE, $this->redis->getRange($key, 0, 8));
- $this->assertEquals(array(FALSE), $this->redis->mget(array($key)));
+ $this->assertEquals([FALSE], $this->redis->mget([$key]));
$this->assertEquals(FALSE, $this->redis->incr($key));
$this->assertEquals(FALSE, $this->redis->incrBy($key, 1));
$this->assertEquals(FALSE, $this->redis->decr($key));
@@ -3967,8 +3967,8 @@ class Redis_Test extends TestSuite
// hash I/F
$this->assertEquals(FALSE, $this->redis->hSet($key, 'key1', 'value1'));
$this->assertEquals(FALSE, $this->redis->hGet($key, 'key1'));
- $this->assertEquals(FALSE, $this->redis->hMGet($key, array('key1')));
- $this->assertEquals(FALSE, $this->redis->hMSet($key, array('key1' => 'value1')));
+ $this->assertEquals(FALSE, $this->redis->hMGet($key, ['key1']));
+ $this->assertEquals(FALSE, $this->redis->hMSet($key, ['key1' => 'value1']));
$this->assertEquals(FALSE, $this->redis->hIncrBy($key, 'key2', 1));
$this->assertEquals(FALSE, $this->redis->hExists($key, 'key2'));
$this->assertEquals(FALSE, $this->redis->hDel($key, 'key2'));
@@ -3989,7 +3989,7 @@ class Redis_Test extends TestSuite
$this->assertEquals(FALSE, $this->redis->getset($key, 'value2'));
$this->assertEquals(FALSE, $this->redis->append($key, 'append'));
$this->assertEquals(FALSE, $this->redis->getRange($key, 0, 8));
- $this->assertEquals(array(FALSE), $this->redis->mget(array($key)));
+ $this->assertEquals([FALSE], $this->redis->mget([$key]));
$this->assertEquals(FALSE, $this->redis->incr($key));
$this->assertEquals(FALSE, $this->redis->incrBy($key, 1));
$this->assertEquals(FALSE, $this->redis->decr($key));
@@ -4027,8 +4027,8 @@ class Redis_Test extends TestSuite
// hash I/F
$this->assertEquals(FALSE, $this->redis->hSet($key, 'key1', 'value1'));
$this->assertEquals(FALSE, $this->redis->hGet($key, 'key1'));
- $this->assertEquals(FALSE, $this->redis->hMGet($key, array('key1')));
- $this->assertEquals(FALSE, $this->redis->hMSet($key, array('key1' => 'value1')));
+ $this->assertEquals(FALSE, $this->redis->hMGet($key, ['key1']));
+ $this->assertEquals(FALSE, $this->redis->hMSet($key, ['key1' => 'value1']));
$this->assertEquals(FALSE, $this->redis->hIncrBy($key, 'key2', 1));
$this->assertEquals(FALSE, $this->redis->hExists($key, 'key2'));
$this->assertEquals(FALSE, $this->redis->hDel($key, 'key2'));
@@ -4050,7 +4050,7 @@ class Redis_Test extends TestSuite
$this->assertEquals(FALSE, $this->redis->getset($key, 'value2'));
$this->assertEquals(FALSE, $this->redis->append($key, 'append'));
$this->assertEquals(FALSE, $this->redis->getRange($key, 0, 8));
- $this->assertEquals(array(FALSE), $this->redis->mget(array($key)));
+ $this->assertEquals([FALSE], $this->redis->mget([$key]));
$this->assertEquals(FALSE, $this->redis->incr($key));
$this->assertEquals(FALSE, $this->redis->incrBy($key, 1));
$this->assertEquals(FALSE, $this->redis->decr($key));
@@ -4086,8 +4086,8 @@ class Redis_Test extends TestSuite
// hash I/F
$this->assertEquals(FALSE, $this->redis->hSet($key, 'key1', 'value1'));
$this->assertEquals(FALSE, $this->redis->hGet($key, 'key1'));
- $this->assertEquals(FALSE, $this->redis->hMGet($key, array('key1')));
- $this->assertEquals(FALSE, $this->redis->hMSet($key, array('key1' => 'value1')));
+ $this->assertEquals(FALSE, $this->redis->hMGet($key, ['key1']));
+ $this->assertEquals(FALSE, $this->redis->hMSet($key, ['key1' => 'value1']));
$this->assertEquals(FALSE, $this->redis->hIncrBy($key, 'key2', 1));
$this->assertEquals(FALSE, $this->redis->hExists($key, 'key2'));
$this->assertEquals(FALSE, $this->redis->hDel($key, 'key2'));
@@ -4109,7 +4109,7 @@ class Redis_Test extends TestSuite
$this->assertEquals(FALSE, $this->redis->getset($key, 'value2'));
$this->assertEquals(FALSE, $this->redis->append($key, 'append'));
$this->assertEquals(FALSE, $this->redis->getRange($key, 0, 8));
- $this->assertEquals(array(FALSE), $this->redis->mget(array($key)));
+ $this->assertEquals([FALSE], $this->redis->mget([$key]));
$this->assertEquals(FALSE, $this->redis->incr($key));
$this->assertEquals(FALSE, $this->redis->incrBy($key, 1));
$this->assertEquals(FALSE, $this->redis->decr($key));
@@ -4187,7 +4187,7 @@ class Redis_Test extends TestSuite
$this->assertTrue($this->redis->getOption(Redis::OPT_SERIALIZER) === $mode); // get ok
// lPush, rPush
- $a = array('hello world', 42, TRUE, array('<tag>' => 1729));
+ $a = ['hello world', 42, TRUE, ['<tag>' => 1729]];
$this->redis->del('key');
$this->redis->lPush('key', $a[0]);
$this->redis->rPush('key', $a[1]);
@@ -4208,20 +4208,20 @@ class Redis_Test extends TestSuite
$this->assertTrue(array_slice($a, 0, 3) === $this->redis->lrange('key', 0, -1));
// lSet
- $a[0] = array('k' => 'v'); // update
+ $a[0] = ['k' => 'v']; // update
$this->assertTrue(TRUE === $this->redis->lSet('key', 0, $a[0]));
$this->assertTrue($a[0] === $this->redis->lGet('key', 0));
// lInsert
- $this->assertTrue($this->redis->lInsert('key', Redis::BEFORE, $a[0], array(1,2,3)) === 4);
- $this->assertTrue($this->redis->lInsert('key', Redis::AFTER, $a[0], array(4,5,6)) === 5);
+ $this->assertTrue($this->redis->lInsert('key', Redis::BEFORE, $a[0], [1,2,3]) === 4);
+ $this->assertTrue($this->redis->lInsert('key', Redis::AFTER, $a[0], [4,5,6]) === 5);
- $a = array(array(1,2,3), $a[0], array(4,5,6), $a[1], $a[2]);
+ $a = [[1,2,3], $a[0], [4,5,6], $a[1], $a[2]];
$this->assertTrue($a === $this->redis->lrange('key', 0, -1));
// sAdd
$this->redis->del('{set}key');
- $s = array(1,'a', array(1,2,3), array('k' => 'v'));
+ $s = [1,'a', [1,2,3], ['k' => 'v']];
$this->assertTrue(1 === $this->redis->sAdd('{set}key', $s[0]));
$this->assertTrue(1 === $this->redis->sAdd('{set}key', $s[1]));
@@ -4259,7 +4259,7 @@ class Redis_Test extends TestSuite
unset($s[0]);
// sorted sets
- $z = array('z0', array('k' => 'v'), FALSE, NULL);
+ $z = ['z0', ['k' => 'v'], FALSE, NULL];
$this->redis->del('key');
// zAdd
@@ -4283,7 +4283,7 @@ class Redis_Test extends TestSuite
$this->redis->zAdd('k', 2, 'c');
$this->assertTrue(2 === $this->redis->zRem('k', 'a', 'c'));
$this->assertTrue(1.0 === $this->redis->zScore('k', 'b'));
- $this->assertTrue($this->redis->zRange('k', 0, -1, true) == array('b' => 1.0));
+ $this->assertTrue($this->redis->zRange('k', 0, -1, true) == ['b' => 1.0]);
// zRange
$this->assertTrue($z === $this->redis->zRange('key', 0, -1));
@@ -4314,13 +4314,13 @@ class Redis_Test extends TestSuite
$this->assertTrue(2.0 === $this->redis->zScore('key', $z[2]));
// mset
- $a = array('k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => array('a' => 'b'));
+ $a = ['k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => ['a' => 'b']];
$this->assertTrue(TRUE === $this->redis->mset($a));
foreach($a as $k => $v) {
$this->assertTrue($this->redis->get($k) === $v);
}
- $a = array('k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => array('a' => 'b'));
+ $a = ['k0' => 1, 'k1' => 42, 'k2' => NULL, 'k3' => FALSE, 'k4' => ['a' => 'b']];
// hSet
$this->redis->del('key');
@@ -4358,9 +4358,9 @@ class Redis_Test extends TestSuite
$this->redis->set('a', NULL);
$this->redis->set('b', FALSE);
$this->redis->set('c', 42);
- $this->redis->set('d', array('x' => 'y'));
+ $this->redis->set('d', ['x' => 'y']);
- $this->assertTrue(array(NULL, FALSE, 42, array('x' => 'y')) === $this->redis->mGet(array('a', 'b', 'c', 'd')));
+ $this->assertTrue([NULL, FALSE, 42, ['x' => 'y']] === $this->redis->mGet(['a', 'b', 'c', 'd']));
// pipeline
if ($this->havePipeline()) {
@@ -4383,7 +4383,7 @@ class Redis_Test extends TestSuite
$this->assertTrue($data['session_id'] === 'test 2');
// issue #145, serializer with objects.
- $this->redis->set('x', array(new stdClass, new stdClass));
+ $this->redis->set('x', [new stdClass, new stdClass]);
$x = $this->redis->get('x');
$this->assertTrue(is_array($x));
$this->assertTrue(is_object($x[0]) && get_class($x[0]) === 'stdClass');
@@ -4459,7 +4459,7 @@ class Redis_Test extends TestSuite
// Helper function to compare nested results -- from the php.net array_diff page, I believe
private function array_diff_recursive($aArray1, $aArray2) {
- $aReturn = array();
+ $aReturn = [];
foreach ($aArray1 as $mKey => $mValue) {
if (array_key_exists($mKey, $aArray2)) {
@@ -4544,17 +4544,17 @@ class Redis_Test extends TestSuite
$this->redis->set('{eval-key}-str2', 'hello again!');
// Use a script to return our list, and verify its response
- $list = $this->redis->eval("return redis.call('lrange', KEYS[1], 0, -1)", Array('{eval-key}-list'), 1);
- $this->assertTrue($list === Array('a','b','c'));
+ $list = $this->redis->eval("return redis.call('lrange', KEYS[1], 0, -1)", ['{eval-key}-list'], 1);
+ $this->assertTrue($list === ['a','b','c']);
// Use a script to return our zset
- $zset = $this->redis->eval("return redis.call('zrange', KEYS[1], 0, -1)", Array('{eval-key}-zset'), 1);
- $this->assertTrue($zset == Array('d','e','f'));
+ $zset = $this->redis->eval("return redis.call('zrange', KEYS[1], 0, -1)", ['{eval-key}-zset'], 1);
+ $this->assertTrue($zset == ['d','e','f']);
// Test an empty MULTI BULK response
$this->redis->del('{eval-key}-nolist');
$empty_resp = $this->redis->eval("return redis.call('lrange', '{eval-key}-nolist', 0, -1)",
- Array('{eval-key}-nolist'), 1);
+ ['{eval-key}-nolist'], 1);
$this->assertTrue(is_array($empty_resp) && empty($empty_resp));
// Now test a nested reply
@@ -4572,20 +4572,20 @@ class Redis_Test extends TestSuite
}
";
- $expected = Array(
- 1, 2, 3, Array(
+ $expected = [
+ 1, 2, 3, [
'hello, world',
'hello again!',
- Array(),
- Array(
- Array('d','e','f'),
- Array('a','b','c')
- )
- )
- );
+ [],
+ [
+ ['d','e','f'],
+ ['a','b','c']
+ ]
+ ]
+ ];
// Now run our script, and check our values against each other
- $eval_result = $this->redis->eval($nested_script, Array('{eval-key}-str1', '{eval-key}-str2', '{eval-key}-zset', '{eval-key}-list'), 4);
+ $eval_result = $this->redis->eval($nested_script, ['{eval-key}-str1', '{eval-key}-str2', '{eval-key}-zset', '{eval-key}-list'], 4);
$this->assertTrue(is_array($eval_result) && count($this->array_diff_recursive($eval_result, $expected)) == 0);
/*
@@ -4594,13 +4594,13 @@ class Redis_Test extends TestSuite
$num_scripts = 10;
- $arr_modes = Array(Redis::MULTI);
+ $arr_modes = [Redis::MULTI];
if ($this->havePipeline()) $arr_modes[] = Redis::PIPELINE;
foreach($arr_modes as $mode) {
$this->redis->multi($mode);
for($i=0;$i<$num_scripts;$i++) {
- $this->redis->eval($nested_script, Array('{eval-key}-dummy'), 1);
+ $this->redis->eval($nested_script, ['{eval-key}-dummy'], 1);
}
$replies = $this->redis->exec();
@@ -4614,7 +4614,7 @@ class Redis_Test extends TestSuite
*/
$args_script = "return {KEYS[1],KEYS[2],KEYS[3],ARGV[1],ARGV[2],ARGV[3]}";
- $args_args = Array('{k}1','{k}2','{k}3','v1','v2','v3');
+ $args_args = ['{k}1','{k}2','{k}3','v1','v2','v3'];
$args_result = $this->redis->eval($args_script, $args_args, 3);
$this->assertTrue($args_result === $args_args);
@@ -4658,22 +4658,22 @@ class Redis_Test extends TestSuite
}
public function testSerialize() {
- $vals = Array(1, 1.5, 'one', Array('here','is','an','array'));
+ $vals = [1, 1.5, 'one', ['here','is','an','array']];
// Test with no serialization at all
$this->assertTrue($this->redis->_serialize('test') === 'test');
$this->assertTrue($this->redis->_serialize(1) === '1');
- $this->assertTrue($this->redis->_serialize(Array()) === 'Array');
+ $this->assertTrue($this->redis->_serialize([]) === 'Array');
$this->assertTrue($this->redis->_serialize(new stdClass) === 'Object');
- $arr_serializers = Array(Redis::SERIALIZER_PHP);
+ $arr_serializers = [Redis::SERIALIZER_PHP];
if(defined('Redis::SERIALIZER_IGBINARY')) {
$arr_serializers[] = Redis::SERIALIZER_IGBINARY;
}
foreach($arr_serializers as $mode) {
- $arr_enc = Array();
- $arr_dec = Array();
+ $arr_enc = [];
+ $arr_dec = [];
foreach($vals as $k => $v) {
$enc = $this->redis->_serialize($v);
@@ -4686,17 +4686,17 @@ class Redis_Test extends TestSuite
}
public function testUnserialize() {
- $vals = Array(
- 1,1.5,'one',Array('this','is','an','array')
- );
+ $vals = [
+ 1,1.5,'one',['this','is','an','array']
+ ];
- $serializers = Array(Redis::SERIALIZER_PHP);
+ $serializers = [Redis::SERIALIZER_PHP];
if(defined('Redis::SERIALIZER_IGBINARY')) {
$serializers[] = Redis::SERIALIZER_IGBINARY;
}
foreach($serializers as $mode) {
- $vals_enc = Array();
+ $vals_enc = [];
// Pass them through redis so they're serialized
foreach($vals as $key => $val) {
@@ -4982,7 +4982,7 @@ class Redis_Test extends TestSuite
//
protected function createPFKey($str_key, $i_count) {
- $arr_mems = Array();
+ $arr_mems = [];
for($i=0;$i<$i_count;$i++) {
$arr_mems[] = uniqid() . '-' . $i;
}
@@ -4999,7 +4999,7 @@ class Redis_Test extends TestSuite
}
$str_uniq = uniqid();
- $arr_mems = Array();
+ $arr_mems = [];
for($i=0;$i<1000;$i++) {
if($i%2 == 0) {
@@ -5013,9 +5013,9 @@ class Redis_Test extends TestSuite
$i_keys = 10;
// Iterate prefixing/serialization options
- foreach(Array(Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP) as $str_ser) {
- foreach(Array('', 'hl-key-prefix:') as $str_prefix) {
- $arr_keys = Array();
+ foreach([Redis::SERIALIZER_NONE, Redis::SERIALIZER_PHP] as $str_ser) {
+ foreach(['', 'hl-key-prefix:'] as $str_prefix) {
+ $arr_keys = [];
// Now add for each key
for($i=0;$i<$i_keys;$i++) {
@@ -5062,7 +5062,7 @@ class Redis_Test extends TestSuite
//
protected function rawCommandArray($key, $args) {
- return call_user_func_array(Array($this->redis, 'rawCommand'), $args);
+ return call_user_func_array([$this->redis, 'rawCommand'], $args);
}
protected function addCities($key) {
@@ -5086,13 +5086,13 @@ class Redis_Test extends TestSuite
}
/* Add them again, all at once */
- $args = Array('geokey');
+ $args = ['geokey'];
foreach ($this->cities as $city => $longlat) {
- $args = array_merge($args, Array($longlat[0], $longlat[1], $city));
+ $args = array_merge($args, [$longlat[0], $longlat[1], $city]);
}
/* They all exist, should be nothing added */
- $this->assertEquals(call_user_func_array(Array($this->redis, 'geoadd'), $args), 0);
+ $this->assertEquals(call_user_func_array([$this->redis, 'geoadd'], $args), 0);
}
/* GEORADIUS */
@@ -5110,35 +5110,35 @@ class Redis_Test extends TestSuite
/* Pre tested with redis-cli. We're just verifying proper delivery of distance and unit */
if ($cmd == 'georadius') {
- $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 10, 'mi'), Array('Chico'));
- $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 30, 'mi'), Array('Gridley','Chico'));
- $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 50, 'km'), Array('Gridley','Chico'));
- $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 50000, 'm'), Array('Gridley','Chico'));
- $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 150000, 'ft'), Array('Gridley', 'Chico'));
- $args = Array('georadius', '{gk}', $lng, $lat, 500, 'mi');
+ $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 10, 'mi'), ['Chico']);
+ $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 30, 'mi'), ['Gridley','Chico']);
+ $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 50, 'km'), ['Gridley','Chico']);
+ $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 50000, 'm'), ['Gridley','Chico']);
+ $this->assertEquals($this->redis->georadius('{gk}', $lng, $lat, 150000, 'ft'), ['Gridley', 'Chico']);
+ $args = ['georadius', '{gk}', $lng, $lat, 500, 'mi'];
/* Test a bad COUNT argument */
- foreach (Array(-1, 0, 'notanumber') as $count) {
- $this->assertFalse(@$this->redis->georadius('{gk}', $lng, $lat, 10, 'mi', Array('count' => $count)));
+ foreach ([-1, 0, 'notanumber'] as $count) {
+ $this->assertFalse(@$this->redis->georadius('{gk}', $lng, $lat, 10, 'mi', ['count' => $count]));
}
} else {
- $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 10, 'mi'), Array('Chico'));
- $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 30, 'mi'), Array('Gridley','Chico'));
- $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 50, 'km'), Array('Gridley','Chico'));
- $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 50000, 'm'), Array('Gridley','Chico'));
- $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 150000, 'ft'), Array('Gridley', 'Chico'));
- $args = Array('georadiusbymember', '{gk}', $city, 500, 'mi');
+ $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 10, 'mi'), ['Chico']);
+ $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 30, 'mi'), ['Gridley','Chico']);
+ $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 50, 'km'), ['Gridley','Chico']);
+ $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 50000, 'm'), ['Gridley','Chico']);
+ $this->assertEquals($this->redis->georadiusbymember('{gk}', $city, 150000, 'ft'), ['Gridley', 'Chico']);
+ $args = ['georadiusbymember', '{gk}', $city, 500, 'mi'];
/* Test a bad COUNT argument */
- foreach (Array(-1, 0, 'notanumber') as $count) {
- $this->assertFalse(@$this->redis->georadiusbymember('{gk}', $city, 10, 'mi', Array('count' => $count)));
+ foreach ([-1, 0, 'notanumber'] as $count) {
+ $this->assertFalse(@$this->redis->georadiusbymember('{gk}', $city, 10, 'mi', ['count' => $count]));
}
}
/* Options */
- $opts = Array('WITHCOORD', 'WITHDIST', 'WITHHASH');
- $sortopts = Array('', 'ASC', 'DESC');
- $storeopts = Array('', 'STORE', 'STOREDIST');
+ $opts = ['WITHCOORD', 'WITHDIST', 'WITHHASH'];
+ $sortopts = ['', 'ASC', 'DESC'];
+ $storeopts = ['', 'STORE', 'STOREDIST'];
for ($i = 0; $i < count($opts); $i++) {
$subopts = array_slice($opts, 0, $i);
@@ -5150,7 +5150,7 @@ class Redis_Test extends TestSuite
}
/* Cannot mix STORE[DIST] with the WITH* arguments */
- $realstoreopts = count($subopts) == 0 ? $storeopts : Array();
+ $realstoreopts = count($subopts) == 0 ? $storeopts : [];
$base_subargs = $subargs;
$base_subopts = $subopts;
@@ -5221,8 +5221,8 @@ class Redis_Test extends TestSuite
}
$this->addCities('gk');
- $this->assertEquals($this->redis->geopos('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', Array('geopos', 'gk', 'Chico', 'Sacramento')));
- $this->assertEquals($this->redis->geopos('gk', 'Cupertino'), $this->rawCommandArray('gk', Array('geopos', 'gk', 'Cupertino')));
+ $this->assertEquals($this->redis->geopos('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', ['geopos', 'gk', 'Chico', 'Sacramento']));
+ $this->assertEquals($this->redis->geopos('gk', 'Cupertino'), $this->rawCommandArray('gk', ['geopos', 'gk', 'Cupertino']));
}
public function testGeoHash() {
@@ -5231,8 +5231,8 @@ class Redis_Test extends TestSuite
}
$this->addCities('gk');
- $this->assertEquals($this->redis->geohash('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', Array('geohash', 'gk', 'Chico', 'Sacramento')));
- $this->assertEquals($this->redis->geohash('gk', 'Chico'), $this->rawCommandArray('gk', Array('geohash', 'gk', 'Chico')));
+ $this->assertEquals($this->redis->geohash('gk', 'Chico', 'Sacramento'), $this->rawCommandArray('gk', ['geohash', 'gk', 'Chico', 'Sacramento']));
+ $this->assertEquals($this->redis->geohash('gk', 'Chico'), $this->rawCommandArray('gk', ['geohash', 'gk', 'Chico']));
}
public function testGeoDist() {
@@ -5243,11 +5243,11 @@ class Redis_Test extends TestSuite
$this->addCities('gk');
$r1 = $this->redis->geodist('gk', 'Chico', 'Cupertino');
- $r2 = $this->rawCommandArray('gk', Array('geodist', 'gk', 'Chico', 'Cupertino'));
+ $r2 = $this->rawCommandArray('gk', ['geodist', 'gk', 'Chico', 'Cupertino']);
$this->assertEquals(round($r1, 8), round($r2, 8));
$r1 = $this->redis->geodist('gk', 'Chico', 'Cupertino', 'km');
- $r2 = $this->rawCommandArray('gk', Array('geodist', 'gk', 'Chico', 'Cupertino', 'km'));
+ $r2 = $this->rawCommandArray('gk', ['geodist', 'gk', 'Chico', 'Cupertino', 'km']);
$this->assertEquals(round($r1, 8), round($r2, 8));
}
@@ -5259,25 +5259,25 @@ class Redis_Test extends TestSuite
$this->redis->del('mylist');
$this->redis->rpush('mylist', 'A', 'B', 'C', 'D');
- $this->assertEquals($this->redis->lrange('mylist', 0, -1), Array('A','B','C','D'));
+ $this->assertEquals($this->redis->lrange('mylist', 0, -1), ['A','B','C','D']);
}
/* STREAMS */
protected function addStreamEntries($key, $count) {
- $ids = Array();
+ $ids = [];
$this->redis->del($key);
for ($i = 0; $i < $count; $i++) {
- $ids[] = $this->redis->xAdd($key, '*', Array('field' => "value:$i"));
+ $ids[] = $this->redis->xAdd($key, '*', ['field' => "value:$i"]);
}
return $ids;
}
protected function addStreamsAndGroups($arr_streams, $count, $arr_groups) {
- $ids = Array();
+ $ids = [];
foreach ($arr_streams as $str_stream) {
$ids[$str_stream] = $this->addStreamEntries($str_stream, $count);
@@ -5295,7 +5295,7 @@ class Redis_Test extends TestSuite
$this->redis->del('stream');
for ($i = 0; $i < 5; $i++) {
- $id = $this->redis->xAdd("stream", '*', Array('k1' => 'v1', 'k2' => 'v2'));
+ $id = $this->redis->xAdd("stream", '*', ['k1' => 'v1', 'k2' => 'v2']);
$this->assertEquals($this->redis->xLen('stream'), $i+1);
/* Redis should return <timestamp>-<sequence> */
@@ -5307,32 +5307,32 @@ class Redis_Test extends TestSuite
/* Test an absolute maximum length */
for ($i = 0; $i < 100; $i++) {
- $this->redis->xAdd('stream', '*', Array('k' => 'v'), 10);
+ $this->redis->xAdd('stream', '*', ['k' => 'v'], 10);
}
$this->assertEquals($this->redis->xLen('stream'), 10);
/* Not the greatest test but I'm unsure if approximate trimming is
* totally deterministic, so just make sure we are able to add with
* an approximate maxlen argument structure */
- $id = $this->redis->xAdd('stream', '*', Array('k' => 'v'), 10, true);
+ $id = $this->redis->xAdd('stream', '*', ['k' => 'v'], 10, true);
$this->assertEquals(count(explode('-', $id)), 2);
/* Empty message should fail */
- $this->redis->xAdd('stream', '*', Array());
+ $this->redis->xAdd('stream', '*', []);
}
protected function doXRangeTest($reverse) {
$key = '{stream}';
if ($reverse) {
- list($cmd,$a1,$a2) = Array('xRevRange', '+', 0);
+ list($cmd,$a1,$a2) = ['xRevRange', '+', 0];
} else {
- list($cmd,$a1,$a2) = Array('xRange', 0, '+');
+ list($cmd,$a1,$a2) = ['xRange', 0, '+'];
}
$this->redis->del($key);
for ($i = 0; $i < 3; $i++) {
- $msg = Array('field' => "value:$i");
+ $msg = ['field' => "value:$i"];
$id = $this->redis->xAdd($key, '*', $msg);
$rows[$id] = $msg;
}
@@ -5343,7 +5343,7 @@ class Redis_Test extends TestSuite
$i = $reverse ? 2 : 0;
foreach ($messages as $seq => $v) {
$this->assertEquals(count(explode('-', $seq)), 2);
- $this->assertEquals($v, Array('field' => "value:$i"));
+ $this->assertEquals($v, ['field' => "value:$i"]);
$i += $reverse ? -1 : 1;
}
@@ -5358,9 +5358,9 @@ class Redis_Test extends TestSuite
if (!$this->minVersionCheck("5.0"))
return $this->markTestSkipped();
- foreach (Array(false, true) as $reverse) {
+ foreach ([false, true] as $reverse) {
foreach ($this->serializers as $serializer) {
- foreach (Array(NULL, 'prefix:') as $prefix) {
+ foreach ([NULL, 'prefix:'] as $prefix) {
$this->redis->setOption(Redis::OPT_PREFIX, $prefix);
$this->redis->setOption(Redis::OPT_SERIALIZER, $serializer);
$this->doXRangeTest($reverse);
@@ -5375,7 +5375,7 @@ class Redis_Test extends TestSuite
$this->redis->del('{stream}');
for ($i = 0; $i < 5; $i++) {
- $this->redis->xadd('{stream}', '*', Array('foo' => 'bar'));
+ $this->redis->xadd('{stream}', '*', ['foo' => 'bar']);
$this->assertEquals($this->redis->xLen('{stream}'), $i+1);
}
}
@@ -5415,8 +5415,8 @@ class Redis_Test extends TestSuite
return $this->markTestSkipped();
for ($n = 1; $n <= 3; $n++) {
- $this->addStreamsAndGroups(Array('{s}'), 3, Array('g1' => 0));
- $msg = $this->redis->xReadGroup('g1', 'c1', Array('{s}' => '>'));
+ $this->addStreamsAndGroups(['{s}'], 3, ['g1' => 0]);
+ $msg = $this->redis->xReadGroup('g1', 'c1', ['{s}' => '>']);
/* Extract IDs */
$smsg = array_shift($msg);
@@ -5428,18 +5428,18 @@ class Redis_Test extends TestSuite
}
/* Verify sending no IDs is a failure */
- $this->assertFalse($this->redis->xAck('{s}', 'g1', Array()));
+ $this->assertFalse($this->redis->xAck('{s}', 'g1', []));
}
protected function doXReadTest() {
if (!$this->minVersionCheck("5.0"))
return $this->markTestSkipped();
- $row = Array('f1' => 'v1', 'f2' => 'v2');
- $msgdata = Array(
+ $row = ['f1' => 'v1', 'f2' => 'v2'];
+ $msgdata = [
'{stream}-1' => $row,
'{stream}-2' => $row,
- );
+ ];
/* Append a bit of data and populate STREAM queries */
$this->redis->del(array_keys($msgdata));
@@ -5470,15 +5470,15 @@ class Redis_Test extends TestSuite
/* Test against a specific ID */
$id = $this->redis->xAdd('{stream}-1', '*', $row);
- $new_id = $this->redis->xAdd('{stream}-1', '*', Array('final' => 'row'));
- $rmsg = $this->redis->xRead(Array('{stream}-1' => $id));
+ $new_id = $this->redis->xAdd('{stream}-1', '*', ['final' => 'row']);
+ $rmsg = $this->redis->xRead(['{stream}-1' => $id]);
$this->assertEquals(
- $this->redis->xRead(Array('{stream}-1' => $id)),
- Array('{stream}-1' => Array($new_id => Array('final' => 'row')))
+ $this->redis->xRead(['{stream}-1' => $id]),
+ ['{stream}-1' => [$new_id => ['final' => 'row']]]
);
/* Emtpy query should fail */
- $this->assertFalse($this->redis->xRead(Array()));
+ $this->assertFalse($this->redis->xRead([]));
}
public function testXRead() {
@@ -5492,7 +5492,7 @@ class Redis_Test extends TestSuite
/* Don't need to test BLOCK multiple times */
$m1 = round(microtime(true)*1000);
- $this->redis->xRead(Array('somestream' => '$'), -1, 100);
+ $this->redis->xRead(['somestream' => '$'], -1, 100);
$m2 = round(microtime(true)*1000);
$this->assertTrue($m2 - $m1 >= 100);
}
@@ -5517,21 +5517,21 @@ class Redis_Test extends TestSuite
return $this->markTestSkipped();
/* Create some streams and groups */
- $streams = Array('{s}-1', '{s}-2');
- $groups = Array('g1' => 0, 'g2' => 0);
+ $streams = ['{s}-1', '{s}-2'];
+ $groups = ['g1' => 0, 'g2' => 0];
/* I'm not totally sure why Redis behaves this way, but we have to
* send '>' first and then send ID '0' for subsequent xReadGroup calls
* or Redis will not return any messages. This behavior changed from
* redis 5.0.1 and 5.0.2 but doing it this way works for both versions. */
$qcount = 0;
- $query1 = Array('{s}-1' => '>', '{s}-2' => '>');
- $query2 = Array('{s}-1' => '0', '{s}-2' => '0');
+ $query1 = ['{s}-1' => '>', '{s}-2' => '>'];
+ $query2 = ['{s}-1' => '0', '{s}-2' => '0'];
$ids = $this->addStreamsAndGroups($streams, 1, $groups);
/* Test that we get get the IDs we should */
- foreach (Array('g1', 'g2') as $group) {
+ foreach (['g1', 'g2'] as $group) {
foreach ($ids as $stream => $messages) {
while ($ids[$stream]) {
/* Read more messages */
@@ -5543,7 +5543,7 @@ class Redis_Test extends TestSuite
/* Remove a message from our control *and* XACK it in Redis */
$id = array_shift($ids[$stream]);
- $this->redis->xAck($stream, $group, Array($id));
+ $this->redis->xAck($stream, $group, [$id]);
}
}
}
@@ -5560,7 +5560,7 @@ class Redis_Test extends TestSuite
/* Finally test BLOCK with a sloppy timing test */
$t1 = $this->mstime();
- $qnew = Array('{s}-1' => '>', '{s}-2' => '>');
+ $qnew = ['{s}-1' => '>', '{s}-2' => '>'];
$this->redis->xReadGroup('g1', 'c1', $qnew, -1, 100);
$t2 = $this->mstime();
$this->assertTrue($t2 - $t1 >= 100);
@@ -5572,9 +5572,9 @@ class Redis_Test extends TestSuite
}
$rows = 5;
- $this->addStreamsAndGroups(Array('s'), $rows, Array('group' => 0));
+ $this->addStreamsAndGroups(['s'], $rows, ['group' => 0]);
- $msg = $this->redis->xReadGroup('group', 'consumer', Array('s' => 0));
+ $msg = $this->redis->xReadGroup('group', 'consumer', ['s' => 0]);
$ids = array_keys($msg['s']);
for ($n = count($ids); $n >= 0; $n--) {
@@ -5590,7 +5590,7 @@ class Redis_Test extends TestSuite
if ($ids) {
$id = array_shift($ids);
- $this->redis->xAck('s', 'group', Array($id));
+ $this->redis->xAck('s', 'group', [$id]);
}
}
}
@@ -5606,7 +5606,7 @@ class Redis_Test extends TestSuite
}
/* Empty array should fail */
- $this->assertFalse($this->redis->xDel('s', Array()));
+ $this->assertFalse($this->redis->xDel('s', []));
}
public function testXTrim() {
@@ -5631,14 +5631,14 @@ class Redis_Test extends TestSuite
if (!$this->minVersionCheck("5.0"))
return $this->markTestSkipped();
- foreach (Array(0, 100) as $min_idle_time) {
- foreach (Array(false, true) as $justid) {
- foreach (Array(0, 10) as $retrycount) {
+ foreach ([0, 100] as $min_idle_time) {
+ foreach ([false, true] as $justid) {
+ foreach ([0, 10] as $retrycount) {
/* We need to test not passing TIME/IDLE as well as passing either */
if ($min_idle_time == 0) {
- $topts = Array(Array(), Array('IDLE', 1000000), Array('TIME', time() * 1000));
+ $topts = [[], ['IDLE', 1000000], ['TIME', time() * 1000]];
} else {
- $topts = Array(NULL);
+ $topts = [NULL];
}
foreach ($topts as $tinfo) {
@@ -5649,18 +5649,18 @@ class Redis_Test extends TestSuite
}
/* Add some messages and create a group */
- $this->addStreamsAndGroups(Array('s'), 10, Array('group1' => 0));
+ $this->addStreamsAndGroups(['s'], 10, ['group1' => 0]);
/* Create a second stream we can FORCE ownership on */
- $fids = $this->addStreamsAndGroups(Array('f'), 10, Array('group1' => 0));
+ $fids = $this->addStreamsAndGroups(['f'], 10, ['group1' => 0]);
$fids = $fids['f'];
/* Have consumer 'Mike' read the messages */
- $oids = $this->redis->xReadGroup('group1', 'Mike', Array('s' => '>'));
+ $oids = $this->redis->xReadGroup('group1', 'Mike', ['s' => '>']);
$oids = array_keys($oids['s']); /* We're only dealing with stream 's' */
/* Construct our options array */
- $opts = Array();
+ $opts = [];
if ($justid) $opts[] = 'JUSTID';
if ($retrycount) $opts['RETRYCOUNT'] = $retrycount;
if ($tvalue !== NULL) $opts[$ttype] = $tvalue;
@@ -5700,7 +5700,7 @@ class Redis_Test extends TestSuite
} else {
/* We're verifying that we get no messages when we've set 100 seconds
* as our idle time, which should match nothing */
- $this->assertEquals($cids, Array());
+ $this->assertEquals($cids, []);
}
}
}
@@ -6084,7 +6084,7 @@ class Redis_Test extends TestSuite
$this->markTestSkipped();
return true;
} else {
- $commandParameters = array($this->getFullHostPath(), $this->sessionSaveHandler, $sessionId, $sleepTime, $maxExecutionTime, $lock_retries, $lock_expires, $sessionData, $sessionLifetime);
+ $commandParameters = [$this->getFullHostPath(), $this->sessionSaveHandler, $sessionId, $sleepTime, $maxExecutionTime, $lock_retries, $lock_expires, $sessionData, $sessionLifetime];
if ($locking_enabled) {
$commandParameters[] = '1';
@@ -6125,7 +6125,7 @@ class Redis_Test extends TestSuite
*/
private function regenerateSessionId($sessionId, $locking = false, $destroyPrevious = false, $sessionProxy = false)
{
- $args = array_map('escapeshellarg', array($sessionId, $locking, $destroyPrevious, $sessionProxy));
+ $args = array_map('escapeshellarg', [$sessionId, $locking, $destroyPrevious, $sessionProxy]);
$command = self::getPhpCommand('regenerateSessionId.php') . escapeshellarg($this->getFullHostPath()) . ' ' . $this->sessionSaveHandler . ' ' . implode(' ', $args);
diff --git a/tests/TestRedis.php b/tests/TestRedis.php
index 4348c7d8..9da9ab86 100644
--- a/tests/TestRedis.php
+++ b/tests/TestRedis.php
@@ -10,10 +10,10 @@ error_reporting(E_ALL);
ini_set( 'display_errors','1');
/* Grab options */
-$arr_args = getopt('', Array('host:', 'class:', 'test:', 'nocolors'));
+$arr_args = getopt('', ['host:', 'class:', 'test:', 'nocolors']);
/* Grab the test the user is trying to run */
-$arr_valid_classes = Array('redis', 'redisarray', 'rediscluster');
+$arr_valid_classes = ['redis', 'redisarray', 'rediscluster'];
$str_class = isset($arr_args['class']) ? strtolower($arr_args['class']) : 'redis';
$boo_colorize = !isset($arr_args['nocolors']);
@@ -48,7 +48,7 @@ if ($str_class == 'redis') {
echo "\n".($useIndex?"WITH":"WITHOUT"). " per-node index:\n";
/* The various RedisArray subtests we can run */
- $arr_ra_tests = Array('Redis_Array_Test', 'Redis_Rehashing_Test', 'Redis_Auto_Rehashing_Test', 'Redis_Multi_Exec_Test', 'Redis_Distributor_Test');
+ $arr_ra_tests = ['Redis_Array_Test', 'Redis_Rehashing_Test', 'Redis_Auto_Rehashing_Test', 'Redis_Multi_Exec_Test', 'Redis_Distributor_Test'];
foreach ($arr_ra_tests as $str_test) {
/* Run until we encounter a failure */
if (run_tests($str_test, $str_filter, $str_host) != 0) {
diff --git a/tests/TestSuite.php b/tests/TestSuite.php
index c2d68259..78fc8729 100644
--- a/tests/TestSuite.php
+++ b/tests/TestSuite.php
@@ -18,8 +18,8 @@ class TestSuite {
private static $YELLOW = "\033[0;33m";
private static $RED = "\033[0;31m";
- public static $errors = array();
- public static $warnings = array();
+ public static $errors = [];
+ public static $warnings = [];
public function __construct($str_host) {
$this->str_host = $str_host;