diff --git a/examples/custom_cluster_distributor.php b/examples/custom_cluster_distributor.php index 085d2826..c45331d1 100644 --- a/examples/custom_cluster_distributor.php +++ b/examples/custom_cluster_distributor.php @@ -28,7 +28,7 @@ class NaiveDistributor implements DistributorInterface, HashGeneratorInterface public function __construct() { - $this->nodes = array(); + $this->nodes = []; $this->nodesCount = 0; } @@ -88,7 +88,7 @@ class NaiveDistributor implements DistributorInterface, HashGeneratorInterface } } -$options = array( +$options = [ 'cluster' => function () { $distributor = new NaiveDistributor(); $strategy = new PredisStrategy($distributor); @@ -96,7 +96,7 @@ $options = array( return $cluster; }, -); +]; $client = new Predis\Client($multiple_servers, $options); diff --git a/examples/debuggable_connection.php b/examples/debuggable_connection.php index d82d747d..a9452549 100644 --- a/examples/debuggable_connection.php +++ b/examples/debuggable_connection.php @@ -23,7 +23,7 @@ use Predis\Connection\StreamConnection; class SimpleDebuggableConnection extends StreamConnection { private $tstart = 0; - private $debugBuffer = array(); + private $debugBuffer = []; public function connect() { @@ -66,11 +66,11 @@ class SimpleDebuggableConnection extends StreamConnection } } -$options = array( - 'connections' => array( +$options = [ + 'connections' => [ 'tcp' => 'SimpleDebuggableConnection', - ), -); + ], +]; $client = new Predis\Client($single_server, $options); $client->set('foo', 'bar'); diff --git a/examples/dispatcher_loop.php b/examples/dispatcher_loop.php index 42e059df..9e68d51b 100644 --- a/examples/dispatcher_loop.php +++ b/examples/dispatcher_loop.php @@ -24,7 +24,7 @@ require __DIR__.'/shared.php'; // PUBLISH control terminate_dispatcher // Create a client and disable r/w timeout on the socket -$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); +$client = new Predis\Client($single_server + ['read_write_timeout' => 0]); // Return an initialized PubSub consumer instance from the client. $pubsub = $client->pubSubLoop(); @@ -39,7 +39,7 @@ class EventsListener implements Countable public function __construct() { - $this->events = array(); + $this->events = []; } public function count() diff --git a/examples/executing_redis_commands.php b/examples/executing_redis_commands.php index 2c51a19a..0625b86c 100644 --- a/examples/executing_redis_commands.php +++ b/examples/executing_redis_commands.php @@ -24,11 +24,11 @@ var_export($response); echo PHP_EOL; // Redis has the MSET and MGET commands to set or get multiple keys in one go, // cases like this Predis accepts arguments for variadic commands both as a list // of arguments or an array containing all of the keys and/or values. -$mkv = array( +$mkv = [ 'uid:0001' => '1st user', 'uid:0002' => '2nd user', 'uid:0003' => '3rd user', -); +]; $client->mset($mkv); $response = $client->mget(array_keys($mkv)); @@ -45,9 +45,9 @@ array ( // commands to Redis the usual way and the "raw" way is that in the latter case // their arguments are not filtered nor responses coming from Redis are parsed. -$response = $client->executeRaw(array( +$response = $client->executeRaw([ 'MGET', 'uid:0001', 'uid:0002', 'uid:0003', -)); +]); var_export($response); echo PHP_EOL; /* OUTPUT: diff --git a/examples/key_prefixing.php b/examples/key_prefixing.php index 66abde7b..d5e0a794 100644 --- a/examples/key_prefixing.php +++ b/examples/key_prefixing.php @@ -17,9 +17,9 @@ require __DIR__.'/shared.php'; // Prefixing keys can be useful to create user-level namespaces for you keyspace // thus reducing the need for separate logical databases in certain scenarios. -$client = new Predis\Client($single_server, array('prefix' => 'nrk:')); +$client = new Predis\Client($single_server, ['prefix' => 'nrk:']); -$client->mset(array('foo' => 'bar', 'lol' => 'wut')); +$client->mset(['foo' => 'bar', 'lol' => 'wut']); var_export($client->mget('foo', 'lol')); /* array ( diff --git a/examples/lua_scripting_abstraction.php b/examples/lua_scripting_abstraction.php index eced4c17..6cce407d 100644 --- a/examples/lua_scripting_abstraction.php +++ b/examples/lua_scripting_abstraction.php @@ -49,11 +49,11 @@ LUA; } } -$client = new Predis\Client($single_server, array( - 'commands' => array( +$client = new Predis\Client($single_server, [ + 'commands' => [ 'increxby' => 'IncrementExistingKeysBy', - ), -)); + ], +]); $client->mset('foo', 10, 'foobar', 100); diff --git a/examples/monitor_consumer.php b/examples/monitor_consumer.php index 4e69eaf5..712489aa 100644 --- a/examples/monitor_consumer.php +++ b/examples/monitor_consumer.php @@ -18,7 +18,7 @@ require __DIR__.'/shared.php'; // exit the monitor loop and terminate this script in a graceful way. // Create a client and disable r/w timeout on the socket. -$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); +$client = new Predis\Client($single_server + ['read_write_timeout' => 0]); // Use only one instance of DateTime, we will update the timestamp later. $timestamp = new DateTime(); diff --git a/examples/pubsub_consumer.php b/examples/pubsub_consumer.php index 806f4207..a94d75df 100644 --- a/examples/pubsub_consumer.php +++ b/examples/pubsub_consumer.php @@ -16,7 +16,7 @@ require __DIR__.'/shared.php'; // on certain channels using a Publish/Subscribe (PUB/SUB) approach. // Create a client and disable r/w timeout on the socket -$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); +$client = new Predis\Client($single_server + ['read_write_timeout' => 0]); // Initialize a new pubsub consumer. $pubsub = $client->pubSubLoop(); diff --git a/examples/replication_complex.php b/examples/replication_complex.php index 6c35c090..d0d4d6f1 100644 --- a/examples/replication_complex.php +++ b/examples/replication_complex.php @@ -47,15 +47,15 @@ LUA; // ------------------------------------------------------------------------- // -$parameters = array( +$parameters = [ 'tcp://127.0.0.1:6381?role=master&database=15', 'tcp://127.0.0.1:6382?role=slave&alias=slave-01&database=15', -); +]; -$options = array( - 'commands' => array( +$options = [ + 'commands' => [ 'hmgetall' => 'HashMultipleGetAll', - ), + ], 'replication' => function () { $strategy = new ReplicationStrategy(); $strategy->setScriptReadOnly(HashMultipleGetAll::BODY); @@ -64,7 +64,7 @@ $options = array( return $replication; }, -); +]; // ------------------------------------------------------------------------- // diff --git a/examples/replication_sentinel.php b/examples/replication_sentinel.php index 3b9f5631..6375545f 100644 --- a/examples/replication_sentinel.php +++ b/examples/replication_sentinel.php @@ -26,16 +26,16 @@ require __DIR__.'/shared.php'; // without an explicit timeout value. // // NOTE: in real-world scenarios sentinels should be running on different hosts! -$sentinels = array( +$sentinels = [ 'tcp://127.0.0.1:5380?timeout=0.100', 'tcp://127.0.0.1:5381?timeout=0.100', 'tcp://127.0.0.1:5382?timeout=0.100', -); +]; -$client = new Predis\Client($sentinels, array( +$client = new Predis\Client($sentinels, [ 'replication' => 'sentinel', 'service' => 'mymaster', -)); +]); // Read operation. $exists = $client->exists('foo') ? 'yes' : 'no'; diff --git a/examples/replication_simple.php b/examples/replication_simple.php index d377a91b..51bc3fc4 100644 --- a/examples/replication_simple.php +++ b/examples/replication_simple.php @@ -22,12 +22,12 @@ require __DIR__.'/shared.php'; // slave of the first one (see the "SLAVEOF" command). // -$parameters = array( +$parameters = [ 'tcp://127.0.0.1:6381?role=master&database=15', 'tcp://127.0.0.1:6382?role=slave&database=15', -); +]; -$options = array('replication' => 'predis'); +$options = ['replication' => 'predis']; $client = new Predis\Client($parameters, $options); diff --git a/examples/session_handler.php b/examples/session_handler.php index 1011b18b..6597d31d 100644 --- a/examples/session_handler.php +++ b/examples/session_handler.php @@ -32,10 +32,10 @@ if (!interface_exists('SessionHandlerInterface')) { // Instantiate a new client just like you would normally do. Using a prefix for // keys will effectively prefix all session keys with the specified string. -$client = new Predis\Client($single_server, array('prefix' => 'sessions:')); +$client = new Predis\Client($single_server, ['prefix' => 'sessions:']); // Set `gc_maxlifetime` to specify a time-to-live of 5 seconds for session keys. -$handler = new Predis\Session\Handler($client, array('gc_maxlifetime' => 5)); +$handler = new Predis\Session\Handler($client, ['gc_maxlifetime' => 5]); // Register the session handler. $handler->register(); diff --git a/examples/shared.php b/examples/shared.php index 51f6cbb6..74b783fb 100644 --- a/examples/shared.php +++ b/examples/shared.php @@ -27,23 +27,23 @@ function redis_version($info) } } -$single_server = array( +$single_server = [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 15, -); +]; -$multiple_servers = array( - array( +$multiple_servers = [ + [ 'host' => '127.0.0.1', 'port' => 6379, 'database' => 15, 'alias' => 'first', - ), - array( + ], + [ 'host' => '127.0.0.1', 'port' => 6380, 'database' => 15, 'alias' => 'second', - ), -); + ], +]; diff --git a/examples/transaction_using_cas.php b/examples/transaction_using_cas.php index 39d5c255..666aaa9c 100644 --- a/examples/transaction_using_cas.php +++ b/examples/transaction_using_cas.php @@ -28,12 +28,12 @@ require __DIR__.'/shared.php'; function zpop($client, $key) { $element = null; - $options = array( + $options = [ 'cas' => true, // Initialize with support for CAS operations 'watch' => $key, // Key that needs to be WATCHed to detect changes 'retry' => 3, // Number of retries on aborted transactions, after // which the client bails out with an exception. - ); + ]; $client->transaction($options, function ($tx) use ($key, &$element) { @list($element) = $tx->zrange($key, 0, 0); diff --git a/src/Autoloader.php b/src/Autoloader.php index d810d9e0..11cacf84 100644 --- a/src/Autoloader.php +++ b/src/Autoloader.php @@ -42,7 +42,7 @@ class Autoloader */ public static function register($prepend = false) { - spl_autoload_register(array(new self(), 'autoload'), true, $prepend); + spl_autoload_register([new self(), 'autoload'], true, $prepend); } /** diff --git a/src/Client.php b/src/Client.php index 48f2282c..d70fa676 100644 --- a/src/Client.php +++ b/src/Client.php @@ -197,7 +197,7 @@ class Client implements ClientInterface, \IteratorAggregate { $selector = strtolower($selector); - if (!in_array($selector, array('id', 'key', 'slot', 'role', 'alias', 'command'))) { + if (!in_array($selector, ['id', 'key', 'slot', 'role', 'alias', 'command'])) { throw new \InvalidArgumentException("Invalid selector type: `$selector`"); } @@ -304,7 +304,7 @@ class Client implements ClientInterface, \IteratorAggregate /** * {@inheritdoc} */ - public function createCommand($commandID, $arguments = array()) + public function createCommand($commandID, $arguments = []) { return $this->commands->create($commandID, $arguments); } @@ -517,13 +517,13 @@ class Client implements ClientInterface, \IteratorAggregate #[\ReturnTypeWillChange] public function getIterator() { - $clients = array(); + $clients = []; $connection = $this->getConnection(); if (!$connection instanceof Traversable) { - return new \ArrayIterator(array( + return new \ArrayIterator([ (string) $connection => new static($connection, $this->getOptions()) - )); + ]); } foreach ($connection as $node) { diff --git a/src/ClientInterface.php b/src/ClientInterface.php index b3d396cd..79f8595e 100644 --- a/src/ClientInterface.php +++ b/src/ClientInterface.php @@ -252,7 +252,7 @@ interface ClientInterface * * @return CommandInterface */ - public function createCommand($method, $arguments = array()); + public function createCommand($method, $arguments = []); /** * Executes the specified Redis command. diff --git a/src/Cluster/ClusterStrategy.php b/src/Cluster/ClusterStrategy.php index 48b35c49..a693e172 100644 --- a/src/Cluster/ClusterStrategy.php +++ b/src/Cluster/ClusterStrategy.php @@ -37,10 +37,10 @@ abstract class ClusterStrategy implements StrategyInterface */ protected function getDefaultCommands() { - $getKeyFromFirstArgument = array($this, 'getKeyFromFirstArgument'); - $getKeyFromAllArguments = array($this, 'getKeyFromAllArguments'); + $getKeyFromFirstArgument = [$this, 'getKeyFromFirstArgument']; + $getKeyFromAllArguments = [$this, 'getKeyFromAllArguments']; - return array( + return [ /* commands operating on the key space */ 'EXISTS' => $getKeyFromAllArguments, 'DEL' => $getKeyFromAllArguments, @@ -52,7 +52,7 @@ abstract class ClusterStrategy implements StrategyInterface 'PEXPIREAT' => $getKeyFromFirstArgument, 'TTL' => $getKeyFromFirstArgument, 'PTTL' => $getKeyFromFirstArgument, - 'SORT' => array($this, 'getKeyFromSortCommand'), + 'SORT' => [$this, 'getKeyFromSortCommand'], 'DUMP' => $getKeyFromFirstArgument, 'RESTORE' => $getKeyFromFirstArgument, @@ -71,13 +71,13 @@ abstract class ClusterStrategy implements StrategyInterface 'INCRBYFLOAT' => $getKeyFromFirstArgument, 'SETBIT' => $getKeyFromFirstArgument, 'SETEX' => $getKeyFromFirstArgument, - 'MSET' => array($this, 'getKeyFromInterleavedArguments'), - 'MSETNX' => array($this, 'getKeyFromInterleavedArguments'), + 'MSET' => [$this, 'getKeyFromInterleavedArguments'], + 'MSETNX' => [$this, 'getKeyFromInterleavedArguments'], 'SETNX' => $getKeyFromFirstArgument, 'SETRANGE' => $getKeyFromFirstArgument, 'STRLEN' => $getKeyFromFirstArgument, 'SUBSTR' => $getKeyFromFirstArgument, - 'BITOP' => array($this, 'getKeyFromBitOp'), + 'BITOP' => [$this, 'getKeyFromBitOp'], 'BITCOUNT' => $getKeyFromFirstArgument, 'BITFIELD' => $getKeyFromFirstArgument, @@ -88,9 +88,9 @@ abstract class ClusterStrategy implements StrategyInterface 'LPOP' => $getKeyFromFirstArgument, 'RPOP' => $getKeyFromFirstArgument, 'RPOPLPUSH' => $getKeyFromAllArguments, - 'BLPOP' => array($this, 'getKeyFromBlockingListCommands'), - 'BRPOP' => array($this, 'getKeyFromBlockingListCommands'), - 'BRPOPLPUSH' => array($this, 'getKeyFromBlockingListCommands'), + 'BLPOP' => [$this, 'getKeyFromBlockingListCommands'], + 'BRPOP' => [$this, 'getKeyFromBlockingListCommands'], + 'BRPOPLPUSH' => [$this, 'getKeyFromBlockingListCommands'], 'LPUSH' => $getKeyFromFirstArgument, 'LPUSHX' => $getKeyFromFirstArgument, 'RPUSH' => $getKeyFromFirstArgument, @@ -121,7 +121,7 @@ abstract class ClusterStrategy implements StrategyInterface 'ZCARD' => $getKeyFromFirstArgument, 'ZCOUNT' => $getKeyFromFirstArgument, 'ZINCRBY' => $getKeyFromFirstArgument, - 'ZINTERSTORE' => array($this, 'getKeyFromZsetAggregationCommands'), + 'ZINTERSTORE' => [$this, 'getKeyFromZsetAggregationCommands'], 'ZRANGE' => $getKeyFromFirstArgument, 'ZRANGEBYSCORE' => $getKeyFromFirstArgument, 'ZRANK' => $getKeyFromFirstArgument, @@ -132,7 +132,7 @@ abstract class ClusterStrategy implements StrategyInterface 'ZREVRANGEBYSCORE' => $getKeyFromFirstArgument, 'ZREVRANK' => $getKeyFromFirstArgument, 'ZSCORE' => $getKeyFromFirstArgument, - 'ZUNIONSTORE' => array($this, 'getKeyFromZsetAggregationCommands'), + 'ZUNIONSTORE' => [$this, 'getKeyFromZsetAggregationCommands'], 'ZSCAN' => $getKeyFromFirstArgument, 'ZLEXCOUNT' => $getKeyFromFirstArgument, 'ZRANGEBYLEX' => $getKeyFromFirstArgument, @@ -162,17 +162,17 @@ abstract class ClusterStrategy implements StrategyInterface 'PFMERGE' => $getKeyFromAllArguments, /* scripting */ - 'EVAL' => array($this, 'getKeyFromScriptingCommands'), - 'EVALSHA' => array($this, 'getKeyFromScriptingCommands'), + 'EVAL' => [$this, 'getKeyFromScriptingCommands'], + 'EVALSHA' => [$this, 'getKeyFromScriptingCommands'], /* commands performing geospatial operations */ 'GEOADD' => $getKeyFromFirstArgument, 'GEOHASH' => $getKeyFromFirstArgument, 'GEOPOS' => $getKeyFromFirstArgument, 'GEODIST' => $getKeyFromFirstArgument, - 'GEORADIUS' => array($this, 'getKeyFromGeoradiusCommands'), - 'GEORADIUSBYMEMBER' => array($this, 'getKeyFromGeoradiusCommands'), - ); + 'GEORADIUS' => [$this, 'getKeyFromGeoradiusCommands'], + 'GEORADIUSBYMEMBER' => [$this, 'getKeyFromGeoradiusCommands'], + ]; } /** @@ -258,7 +258,7 @@ abstract class ClusterStrategy implements StrategyInterface protected function getKeyFromInterleavedArguments(CommandInterface $command) { $arguments = $command->getArguments(); - $keys = array(); + $keys = []; for ($i = 0; $i < count($arguments); $i += 2) { $keys[] = $arguments[$i]; @@ -285,7 +285,7 @@ abstract class ClusterStrategy implements StrategyInterface return $firstKey; } - $keys = array($firstKey); + $keys = [$firstKey]; for ($i = 1; $i < $argc; ++$i) { if (strtoupper($arguments[$i]) === 'STORE') { @@ -344,7 +344,7 @@ abstract class ClusterStrategy implements StrategyInterface $startIndex = $command->getId() === 'GEORADIUS' ? 5 : 4; if ($argc > $startIndex) { - $keys = array($arguments[0]); + $keys = [$arguments[0]]; for ($i = $startIndex; $i < $argc; ++$i) { $argument = strtoupper($arguments[$i]); @@ -373,7 +373,7 @@ abstract class ClusterStrategy implements StrategyInterface protected function getKeyFromZsetAggregationCommands(CommandInterface $command) { $arguments = $command->getArguments(); - $keys = array_merge(array($arguments[0]), array_slice($arguments, 2, $arguments[1])); + $keys = array_merge([$arguments[0]], array_slice($arguments, 2, $arguments[1])); if ($this->checkSameSlotForKeys($keys)) { return $arguments[0]; diff --git a/src/Cluster/Distributor/HashRing.php b/src/Cluster/Distributor/HashRing.php index a9976957..c1aa752b 100644 --- a/src/Cluster/Distributor/HashRing.php +++ b/src/Cluster/Distributor/HashRing.php @@ -30,7 +30,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface private $ringKeysCount; private $replicas; private $nodeHashCallback; - private $nodes = array(); + private $nodes = []; /** * @param int $replicas Number of replicas in the ring. @@ -52,10 +52,10 @@ class HashRing implements DistributorInterface, HashGeneratorInterface { // In case of collisions in the hashes of the nodes, the node added // last wins, thus the order in which nodes are added is significant. - $this->nodes[] = array( + $this->nodes[] = [ 'object' => $node, 'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT, - ); + ]; $this->reset(); } @@ -130,7 +130,7 @@ class HashRing implements DistributorInterface, HashGeneratorInterface throw new EmptyRingException('Cannot initialize an empty hashring.'); } - $this->ring = array(); + $this->ring = []; $totalWeight = $this->computeTotalWeight(); $nodesCount = count($this->nodes); diff --git a/src/Cluster/Hash/CRC16.php b/src/Cluster/Hash/CRC16.php index 2c2a5985..4b21d5d2 100644 --- a/src/Cluster/Hash/CRC16.php +++ b/src/Cluster/Hash/CRC16.php @@ -17,7 +17,7 @@ namespace Predis\Cluster\Hash; */ class CRC16 implements HashGeneratorInterface { - private static $CCITT_16 = array( + private static $CCITT_16 = [ 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, @@ -50,7 +50,7 @@ class CRC16 implements HashGeneratorInterface 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0, - ); + ]; /** * {@inheritdoc} diff --git a/src/Cluster/SlotMap.php b/src/Cluster/SlotMap.php index 019c448e..0784e716 100644 --- a/src/Cluster/SlotMap.php +++ b/src/Cluster/SlotMap.php @@ -17,7 +17,7 @@ namespace Predis\Cluster; */ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable { - private $slots = array(); + private $slots = []; /** * Checks if the given slot is valid. @@ -49,7 +49,7 @@ class SlotMap implements \ArrayAccess, \IteratorAggregate, \Countable */ public function reset() { - $this->slots = array(); + $this->slots = []; } /** diff --git a/src/Collection/Iterator/CursorBasedIterator.php b/src/Collection/Iterator/CursorBasedIterator.php index 53166d1f..4a5413b4 100644 --- a/src/Collection/Iterator/CursorBasedIterator.php +++ b/src/Collection/Iterator/CursorBasedIterator.php @@ -76,7 +76,7 @@ abstract class CursorBasedIterator implements \Iterator { $this->valid = true; $this->fetchmore = true; - $this->elements = array(); + $this->elements = []; $this->cursor = 0; $this->position = -1; $this->current = null; @@ -89,7 +89,7 @@ abstract class CursorBasedIterator implements \Iterator */ protected function getScanOptions() { - $options = array(); + $options = []; if (strlen(strval($this->match)) > 0) { $options['MATCH'] = $this->match; diff --git a/src/Collection/Iterator/ListKey.php b/src/Collection/Iterator/ListKey.php index f1ae2c1a..c0658ebd 100644 --- a/src/Collection/Iterator/ListKey.php +++ b/src/Collection/Iterator/ListKey.php @@ -84,7 +84,7 @@ class ListKey implements \Iterator { $this->valid = true; $this->fetchmore = true; - $this->elements = array(); + $this->elements = []; $this->position = -1; $this->current = null; } diff --git a/src/Command/Command.php b/src/Command/Command.php index 0e08e4b4..b2c53e6c 100644 --- a/src/Command/Command.php +++ b/src/Command/Command.php @@ -18,7 +18,7 @@ namespace Predis\Command; abstract class Command implements CommandInterface { private $slot; - private $arguments = array(); + private $arguments = []; /** * {@inheritdoc} @@ -108,7 +108,7 @@ abstract class Command implements CommandInterface public static function normalizeVariadic(array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { - return array_merge(array($arguments[0]), $arguments[1]); + return array_merge([$arguments[0]], $arguments[1]); } return $arguments; diff --git a/src/Command/FactoryInterface.php b/src/Command/FactoryInterface.php index 48c8a08f..ff56f9bc 100644 --- a/src/Command/FactoryInterface.php +++ b/src/Command/FactoryInterface.php @@ -38,5 +38,5 @@ interface FactoryInterface * * @return CommandInterface */ - public function create(string $commandID, array $arguments = array()): CommandInterface; + public function create(string $commandID, array $arguments = []): CommandInterface; } diff --git a/src/Command/Processor/ProcessorChain.php b/src/Command/Processor/ProcessorChain.php index 553c01dc..d387e092 100644 --- a/src/Command/Processor/ProcessorChain.php +++ b/src/Command/Processor/ProcessorChain.php @@ -19,12 +19,12 @@ use Predis\Command\CommandInterface; */ class ProcessorChain implements \ArrayAccess, ProcessorInterface { - private $processors = array(); + private $processors = []; /** * @param array $processors List of instances of ProcessorInterface. */ - public function __construct($processors = array()) + public function __construct($processors = []) { foreach ($processors as $processor) { $this->add($processor); diff --git a/src/Command/RawCommand.php b/src/Command/RawCommand.php index f6b95b05..3d312823 100644 --- a/src/Command/RawCommand.php +++ b/src/Command/RawCommand.php @@ -33,7 +33,7 @@ final class RawCommand implements CommandInterface * @param string $commandID Command ID * @param array $arguments Command arguments */ - public function __construct($commandID, array $arguments = array()) + public function __construct($commandID, array $arguments = []) { $this->commandID = strtoupper($commandID); $this->setArguments($arguments); diff --git a/src/Command/Redis/CLIENT.php b/src/Command/Redis/CLIENT.php index ea5676c0..521a221b 100644 --- a/src/Command/Redis/CLIENT.php +++ b/src/Command/Redis/CLIENT.php @@ -57,10 +57,10 @@ class CLIENT extends RedisCommand */ protected function parseClientList($data) { - $clients = array(); + $clients = []; foreach (explode("\n", $data, -1) as $clientData) { - $client = array(); + $client = []; foreach (explode(' ', $clientData) as $kv) { @list($k, $v) = explode('=', $kv); diff --git a/src/Command/Redis/CONFIG.php b/src/Command/Redis/CONFIG.php index 1f057e84..38019c2f 100644 --- a/src/Command/Redis/CONFIG.php +++ b/src/Command/Redis/CONFIG.php @@ -36,7 +36,7 @@ class CONFIG extends RedisCommand public function parseResponse($data) { if (is_array($data)) { - $result = array(); + $result = []; for ($i = 0; $i < count($data); ++$i) { $result[$data[$i]] = $data[++$i]; diff --git a/src/Command/Redis/HGETALL.php b/src/Command/Redis/HGETALL.php index 0cb2c85c..b52b0a48 100644 --- a/src/Command/Redis/HGETALL.php +++ b/src/Command/Redis/HGETALL.php @@ -32,7 +32,7 @@ class HGETALL extends RedisCommand */ public function parseResponse($data) { - $result = array(); + $result = []; for ($i = 0; $i < count($data); ++$i) { $result[$data[$i]] = $data[++$i]; diff --git a/src/Command/Redis/HMSET.php b/src/Command/Redis/HMSET.php index c11f6a78..bf98c54d 100644 --- a/src/Command/Redis/HMSET.php +++ b/src/Command/Redis/HMSET.php @@ -33,7 +33,7 @@ class HMSET extends RedisCommand public function setArguments(array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { - $flattenedKVs = array($arguments[0]); + $flattenedKVs = [$arguments[0]]; $args = $arguments[1]; foreach ($args as $k => $v) { diff --git a/src/Command/Redis/HSCAN.php b/src/Command/Redis/HSCAN.php index 5b0ef326..ef591077 100644 --- a/src/Command/Redis/HSCAN.php +++ b/src/Command/Redis/HSCAN.php @@ -50,7 +50,7 @@ class HSCAN extends RedisCommand protected function prepareOptions($options) { $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); + $normalized = []; if (!empty($options['MATCH'])) { $normalized[] = 'MATCH'; @@ -72,7 +72,7 @@ class HSCAN extends RedisCommand { if (is_array($data)) { $fields = $data[1]; - $result = array(); + $result = []; for ($i = 0; $i < count($fields); ++$i) { $result[$fields[$i]] = $fields[++$i]; diff --git a/src/Command/Redis/INFO.php b/src/Command/Redis/INFO.php index 2539bfb2..ed0b5cd8 100644 --- a/src/Command/Redis/INFO.php +++ b/src/Command/Redis/INFO.php @@ -33,7 +33,7 @@ class INFO extends RedisCommand public function parseResponse($data) { if (empty($data) || !$lines = preg_split('/\r?\n/', $data)) { - return array(); + return []; } if (strpos($lines[0], '#') === 0) { @@ -48,7 +48,7 @@ class INFO extends RedisCommand */ public function parseNewResponseFormat($lines) { - $info = array(); + $info = []; $current = null; foreach ($lines as $row) { @@ -57,7 +57,7 @@ class INFO extends RedisCommand } if (preg_match('/^# (\w+)$/', $row, $matches)) { - $info[$matches[1]] = array(); + $info[$matches[1]] = []; $current = &$info[$matches[1]]; continue; } @@ -74,7 +74,7 @@ class INFO extends RedisCommand */ public function parseOldResponseFormat($lines) { - $info = array(); + $info = []; foreach ($lines as $row) { if (strpos($row, ':') === false) { @@ -103,7 +103,7 @@ class INFO extends RedisCommand $v = $this->parseDatabaseStats($v); } - return array($k, $v); + return [$k, $v]; } /** @@ -115,7 +115,7 @@ class INFO extends RedisCommand */ protected function parseDatabaseStats($str) { - $db = array(); + $db = []; foreach (explode(',', $str) as $dbvar) { list($dbvk, $dbvv) = explode('=', $dbvar); diff --git a/src/Command/Redis/MSET.php b/src/Command/Redis/MSET.php index 93b7f131..a8ae2345 100644 --- a/src/Command/Redis/MSET.php +++ b/src/Command/Redis/MSET.php @@ -33,7 +33,7 @@ class MSET extends RedisCommand public function setArguments(array $arguments) { if (count($arguments) === 1 && is_array($arguments[0])) { - $flattenedKVs = array(); + $flattenedKVs = []; $args = $arguments[0]; foreach ($args as $k => $v) { diff --git a/src/Command/Redis/PUBSUB.php b/src/Command/Redis/PUBSUB.php index 774c6682..dbe5e31f 100644 --- a/src/Command/Redis/PUBSUB.php +++ b/src/Command/Redis/PUBSUB.php @@ -50,7 +50,7 @@ class PUBSUB extends RedisCommand */ protected static function processNumsub(array $channels) { - $processed = array(); + $processed = []; $count = count($channels); for ($i = 0; $i < $count; ++$i) { diff --git a/src/Command/Redis/SCAN.php b/src/Command/Redis/SCAN.php index 038f7d81..18bfc963 100644 --- a/src/Command/Redis/SCAN.php +++ b/src/Command/Redis/SCAN.php @@ -50,7 +50,7 @@ class SCAN extends RedisCommand protected function prepareOptions($options) { $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); + $normalized = []; if (!empty($options['MATCH'])) { $normalized[] = 'MATCH'; diff --git a/src/Command/Redis/SDIFFSTORE.php b/src/Command/Redis/SDIFFSTORE.php index 63e53b79..2ecf1e3b 100644 --- a/src/Command/Redis/SDIFFSTORE.php +++ b/src/Command/Redis/SDIFFSTORE.php @@ -33,7 +33,7 @@ class SDIFFSTORE extends RedisCommand public function setArguments(array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { - $arguments = array_merge(array($arguments[0]), $arguments[1]); + $arguments = array_merge([$arguments[0]], $arguments[1]); } parent::setArguments($arguments); diff --git a/src/Command/Redis/SENTINEL.php b/src/Command/Redis/SENTINEL.php index f7e6f72c..99c85921 100644 --- a/src/Command/Redis/SENTINEL.php +++ b/src/Command/Redis/SENTINEL.php @@ -55,7 +55,7 @@ class SENTINEL extends RedisCommand protected static function processMastersOrSlaves(array $servers) { foreach ($servers as $idx => $node) { - $processed = array(); + $processed = []; $count = count($node); for ($i = 0; $i < $count; ++$i) { diff --git a/src/Command/Redis/SINTERSTORE.php b/src/Command/Redis/SINTERSTORE.php index 36294aad..6c808ab8 100644 --- a/src/Command/Redis/SINTERSTORE.php +++ b/src/Command/Redis/SINTERSTORE.php @@ -33,7 +33,7 @@ class SINTERSTORE extends RedisCommand public function setArguments(array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { - $arguments = array_merge(array($arguments[0]), $arguments[1]); + $arguments = array_merge([$arguments[0]], $arguments[1]); } parent::setArguments($arguments); diff --git a/src/Command/Redis/SLAVEOF.php b/src/Command/Redis/SLAVEOF.php index 5c6f5c20..6bd85507 100644 --- a/src/Command/Redis/SLAVEOF.php +++ b/src/Command/Redis/SLAVEOF.php @@ -33,7 +33,7 @@ class SLAVEOF extends RedisCommand public function setArguments(array $arguments) { if (count($arguments) === 0 || $arguments[0] === 'NO ONE') { - $arguments = array('NO', 'ONE'); + $arguments = ['NO', 'ONE']; } parent::setArguments($arguments); diff --git a/src/Command/Redis/SLOWLOG.php b/src/Command/Redis/SLOWLOG.php index 87f3bc31..0f576351 100644 --- a/src/Command/Redis/SLOWLOG.php +++ b/src/Command/Redis/SLOWLOG.php @@ -33,15 +33,15 @@ class SLOWLOG extends RedisCommand public function parseResponse($data) { if (is_array($data)) { - $log = array(); + $log = []; foreach ($data as $index => $entry) { - $log[$index] = array( + $log[$index] = [ 'id' => $entry[0], 'timestamp' => $entry[1], 'duration' => $entry[2], 'command' => $entry[3], - ); + ]; } return $log; diff --git a/src/Command/Redis/SORT.php b/src/Command/Redis/SORT.php index 4f377466..4dd2582e 100644 --- a/src/Command/Redis/SORT.php +++ b/src/Command/Redis/SORT.php @@ -38,7 +38,7 @@ class SORT extends RedisCommand return; } - $query = array($arguments[0]); + $query = [$arguments[0]]; $sortParams = array_change_key_case($arguments[1], CASE_UPPER); if (isset($sortParams['BY'])) { diff --git a/src/Command/Redis/SSCAN.php b/src/Command/Redis/SSCAN.php index 68642a4f..cdfc72de 100644 --- a/src/Command/Redis/SSCAN.php +++ b/src/Command/Redis/SSCAN.php @@ -50,7 +50,7 @@ class SSCAN extends RedisCommand protected function prepareOptions($options) { $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); + $normalized = []; if (!empty($options['MATCH'])) { $normalized[] = 'MATCH'; diff --git a/src/Command/Redis/SUNIONSTORE.php b/src/Command/Redis/SUNIONSTORE.php index b3914e05..b59924f6 100644 --- a/src/Command/Redis/SUNIONSTORE.php +++ b/src/Command/Redis/SUNIONSTORE.php @@ -33,7 +33,7 @@ class SUNIONSTORE extends RedisCommand public function setArguments(array $arguments) { if (count($arguments) === 2 && is_array($arguments[1])) { - $arguments = array_merge(array($arguments[0]), $arguments[1]); + $arguments = array_merge([$arguments[0]], $arguments[1]); } parent::setArguments($arguments); diff --git a/src/Command/Redis/XADD.php b/src/Command/Redis/XADD.php index 4653c23b..dda4fa42 100644 --- a/src/Command/Redis/XADD.php +++ b/src/Command/Redis/XADD.php @@ -32,7 +32,7 @@ class XADD extends RedisCommand */ public function setArguments(array $arguments) { - $args = array(); + $args = []; $args[] = $arguments[0]; $options = $arguments[3] ?? []; diff --git a/src/Command/Redis/XRANGE.php b/src/Command/Redis/XRANGE.php index d2805e34..a3e1e485 100644 --- a/src/Command/Redis/XRANGE.php +++ b/src/Command/Redis/XRANGE.php @@ -45,9 +45,9 @@ class XRANGE extends RedisCommand */ public function parseResponse($data) { - $result = array(); + $result = []; foreach ($data as $entry) { - $processed = array(); + $processed = []; $count = count($entry[1]); for ($i = 0; $i < $count; ++$i) { diff --git a/src/Command/Redis/ZPOPMAX.php b/src/Command/Redis/ZPOPMAX.php index 872d44b9..aad3a04a 100644 --- a/src/Command/Redis/ZPOPMAX.php +++ b/src/Command/Redis/ZPOPMAX.php @@ -32,7 +32,7 @@ class ZPOPMAX extends RedisCommand */ public function parseResponse($data) { - $result = array(); + $result = []; for ($i = 0; $i < count($data); ++$i) { $result[$data[$i]] = $data[++$i]; diff --git a/src/Command/Redis/ZPOPMIN.php b/src/Command/Redis/ZPOPMIN.php index 71d5c778..8ef0ff3d 100644 --- a/src/Command/Redis/ZPOPMIN.php +++ b/src/Command/Redis/ZPOPMIN.php @@ -32,7 +32,7 @@ class ZPOPMIN extends RedisCommand */ public function parseResponse($data) { - $result = array(); + $result = []; for ($i = 0; $i < count($data); ++$i) { $result[$data[$i]] = $data[++$i]; diff --git a/src/Command/Redis/ZRANGE.php b/src/Command/Redis/ZRANGE.php index a262afd4..835e1166 100644 --- a/src/Command/Redis/ZRANGE.php +++ b/src/Command/Redis/ZRANGE.php @@ -37,7 +37,7 @@ class ZRANGE extends RedisCommand if ($lastType === 'string' && strtoupper($arguments[3]) === 'WITHSCORES') { // Used for compatibility with older versions - $arguments[3] = array('WITHSCORES' => true); + $arguments[3] = ['WITHSCORES' => true]; $lastType = 'array'; } @@ -60,7 +60,7 @@ class ZRANGE extends RedisCommand protected function prepareOptions($options) { $opts = array_change_key_case($options, CASE_UPPER); - $finalizedOpts = array(); + $finalizedOpts = []; if (!empty($opts['WITHSCORES'])) { $finalizedOpts[] = 'WITHSCORES'; @@ -91,7 +91,7 @@ class ZRANGE extends RedisCommand public function parseResponse($data) { if ($this->withScores()) { - $result = array(); + $result = []; for ($i = 0; $i < count($data); ++$i) { $result[$data[$i]] = $data[++$i]; diff --git a/src/Command/Redis/ZRANGEBYLEX.php b/src/Command/Redis/ZRANGEBYLEX.php index ba637b16..5f264f96 100644 --- a/src/Command/Redis/ZRANGEBYLEX.php +++ b/src/Command/Redis/ZRANGEBYLEX.php @@ -31,7 +31,7 @@ class ZRANGEBYLEX extends ZRANGE protected function prepareOptions($options) { $opts = array_change_key_case($options, CASE_UPPER); - $finalizedOpts = array(); + $finalizedOpts = []; if (isset($opts['LIMIT']) && is_array($opts['LIMIT'])) { $limit = array_change_key_case($opts['LIMIT'], CASE_UPPER); diff --git a/src/Command/Redis/ZRANGEBYSCORE.php b/src/Command/Redis/ZRANGEBYSCORE.php index 6e59c530..10be9e1f 100644 --- a/src/Command/Redis/ZRANGEBYSCORE.php +++ b/src/Command/Redis/ZRANGEBYSCORE.php @@ -31,7 +31,7 @@ class ZRANGEBYSCORE extends ZRANGE protected function prepareOptions($options) { $opts = array_change_key_case($options, CASE_UPPER); - $finalizedOpts = array(); + $finalizedOpts = []; if (isset($opts['LIMIT']) && is_array($opts['LIMIT'])) { $limit = array_change_key_case($opts['LIMIT'], CASE_UPPER); diff --git a/src/Command/Redis/ZSCAN.php b/src/Command/Redis/ZSCAN.php index 01d6b6d6..29d419da 100644 --- a/src/Command/Redis/ZSCAN.php +++ b/src/Command/Redis/ZSCAN.php @@ -50,7 +50,7 @@ class ZSCAN extends RedisCommand protected function prepareOptions($options) { $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); + $normalized = []; if (!empty($options['MATCH'])) { $normalized[] = 'MATCH'; @@ -72,7 +72,7 @@ class ZSCAN extends RedisCommand { if (is_array($data)) { $members = $data[1]; - $result = array(); + $result = []; for ($i = 0; $i < count($members); ++$i) { $result[$members[$i]] = (float) $members[++$i]; diff --git a/src/Command/RedisFactory.php b/src/Command/RedisFactory.php index 753138a8..33f27877 100644 --- a/src/Command/RedisFactory.php +++ b/src/Command/RedisFactory.php @@ -28,11 +28,11 @@ class RedisFactory extends Factory */ public function __construct() { - $this->commands = array( + $this->commands = [ 'ECHO' => 'Predis\Command\Redis\ECHO_', 'EVAL' => 'Predis\Command\Redis\EVAL_', 'OBJECT' => 'Predis\Command\Redis\OBJECT_', - ); + ]; } /** diff --git a/src/Command/ScriptCommand.php b/src/Command/ScriptCommand.php index db271e7b..6894cbcf 100644 --- a/src/Command/ScriptCommand.php +++ b/src/Command/ScriptCommand.php @@ -78,7 +78,7 @@ abstract class ScriptCommand extends Command $numkeys = count($arguments) + $numkeys; } - $arguments = array_merge(array($this->getScriptHash(), (int) $numkeys), $arguments); + $arguments = array_merge([$this->getScriptHash(), (int) $numkeys], $arguments); parent::setArguments($arguments); } diff --git a/src/Connection/AbstractConnection.php b/src/Connection/AbstractConnection.php index b4947734..71fdd7f5 100644 --- a/src/Connection/AbstractConnection.php +++ b/src/Connection/AbstractConnection.php @@ -26,7 +26,7 @@ abstract class AbstractConnection implements NodeConnectionInterface private $cachedId; protected $parameters; - protected $initCommands = array(); + protected $initCommands = []; /** * @param ParametersInterface $parameters Initialization parameters for the connection. @@ -197,6 +197,6 @@ abstract class AbstractConnection implements NodeConnectionInterface */ public function __sleep() { - return array('parameters', 'initCommands'); + return ['parameters', 'initCommands']; } } diff --git a/src/Connection/Cluster/PredisCluster.php b/src/Connection/Cluster/PredisCluster.php index 4beacc2f..07311979 100644 --- a/src/Connection/Cluster/PredisCluster.php +++ b/src/Connection/Cluster/PredisCluster.php @@ -29,12 +29,12 @@ class PredisCluster implements ClusterInterface, \IteratorAggregate, \Countable /** * @var NodeConnectionInterface[] */ - private $pool = array(); + private $pool = []; /** * @var NodeConnectionInterface[] */ - private $aliases = array(); + private $aliases = []; /** * @var StrategyInterface diff --git a/src/Connection/Cluster/RedisCluster.php b/src/Connection/Cluster/RedisCluster.php index 5a7f160e..a02e89bd 100644 --- a/src/Connection/Cluster/RedisCluster.php +++ b/src/Connection/Cluster/RedisCluster.php @@ -49,8 +49,8 @@ use Predis\Response\Error as ErrorResponse; class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable { private $useClusterSlots = true; - private $pool = array(); - private $slots = array(); + private $pool = []; + private $slots = []; private $slotmap; private $strategy; private $connections; @@ -154,7 +154,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable { if (false !== $id = array_search($connection, $this->pool, true)) { $this->slotmap->reset(); - $this->slots = array_diff($this->slots, array($connection)); + $this->slots = array_diff($this->slots, [$connection]); unset($this->pool[$id]); return true; @@ -174,7 +174,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable { if (isset($this->pool[$connectionID])) { $this->slotmap->reset(); - $this->slots = array_diff($this->slots, array($connectionID)); + $this->slots = array_diff($this->slots, [$connectionID]); unset($this->pool[$connectionID]); return true; @@ -331,10 +331,10 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable { $separator = strrpos($connectionID, ':'); - return $this->connections->create(array( + return $this->connections->create([ 'host' => substr($connectionID, 0, $separator), 'port' => substr($connectionID, $separator + 1), - )); + ]); } /** @@ -599,7 +599,7 @@ class RedisCluster implements ClusterInterface, \IteratorAggregate, \Countable $this->useClusterSlots ? $this->askSlotMap() : $this->buildSlotMap(); } - $connections = array(); + $connections = []; foreach ($this->slotmap->getNodes() as $node) { if (!$connection = $this->getConnectionById($node)) { diff --git a/src/Connection/CompositeStreamConnection.php b/src/Connection/CompositeStreamConnection.php index 763ef42a..6ad7c1de 100644 --- a/src/Connection/CompositeStreamConnection.php +++ b/src/Connection/CompositeStreamConnection.php @@ -119,6 +119,6 @@ class CompositeStreamConnection extends StreamConnection implements CompositeCon */ public function __sleep() { - return array_merge(parent::__sleep(), array('protocol')); + return array_merge(parent::__sleep(), ['protocol']); } } diff --git a/src/Connection/Factory.php b/src/Connection/Factory.php index be5c85a5..5535344e 100644 --- a/src/Connection/Factory.php +++ b/src/Connection/Factory.php @@ -19,16 +19,16 @@ use Predis\Command\RawCommand; */ class Factory implements FactoryInterface { - private $defaults = array(); + private $defaults = []; - protected $schemes = array( + protected $schemes = [ 'tcp' => 'Predis\Connection\StreamConnection', 'unix' => 'Predis\Connection\StreamConnection', 'tls' => 'Predis\Connection\StreamConnection', 'redis' => 'Predis\Connection\StreamConnection', 'rediss' => 'Predis\Connection\StreamConnection', 'http' => 'Predis\Connection\WebdisConnection', - ); + ]; /** * Checks if the provided argument represents a valid connection class @@ -143,7 +143,7 @@ class Factory implements FactoryInterface if (is_string($parameters)) { $parameters = Parameters::parse($parameters); } else { - $parameters = $parameters ?: array(); + $parameters = $parameters ?: []; } if ($this->defaults) { @@ -164,8 +164,8 @@ class Factory implements FactoryInterface if (isset($parameters->password) && strlen($parameters->password)) { $cmdAuthArgs = isset($parameters->username) && strlen($parameters->username) - ? array($parameters->username, $parameters->password) - : array($parameters->password); + ? [$parameters->username, $parameters->password] + : [$parameters->password]; $connection->addConnectCommand( new RawCommand('AUTH', $cmdAuthArgs) @@ -174,7 +174,7 @@ class Factory implements FactoryInterface if (isset($parameters->database) && strlen($parameters->database)) { $connection->addConnectCommand( - new RawCommand('SELECT', array($parameters->database)) + new RawCommand('SELECT', [$parameters->database]) ); } } diff --git a/src/Connection/Parameters.php b/src/Connection/Parameters.php index bfc0c31d..796bdf0e 100644 --- a/src/Connection/Parameters.php +++ b/src/Connection/Parameters.php @@ -19,11 +19,11 @@ namespace Predis\Connection; */ class Parameters implements ParametersInterface { - protected static $defaults = array( + protected static $defaults = [ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, - ); + ]; /** * Set of connection paramaters already filtered @@ -36,7 +36,7 @@ class Parameters implements ParametersInterface /** * @param array $parameters Named array of connection parameters. */ - public function __construct(array $parameters = array()) + public function __construct(array $parameters = []) { $this->parameters = $this->filter($parameters + static::$defaults); } @@ -69,7 +69,7 @@ class Parameters implements ParametersInterface $parameters = static::parse($parameters); } - return new static($parameters ?: array()); + return new static($parameters ?: []); } /** @@ -193,6 +193,6 @@ class Parameters implements ParametersInterface */ public function __sleep() { - return array('parameters'); + return ['parameters']; } } diff --git a/src/Connection/PhpiredisSocketConnection.php b/src/Connection/PhpiredisSocketConnection.php index 23f83fba..88319b19 100644 --- a/src/Connection/PhpiredisSocketConnection.php +++ b/src/Connection/PhpiredisSocketConnection.php @@ -259,10 +259,10 @@ class PhpiredisSocketConnection extends AbstractConnection $timeoutSec = floor($rwtimeout); $timeoutUsec = ($rwtimeout - $timeoutSec) * 1000000; - $timeout = array( + $timeout = [ 'sec' => $timeoutSec, 'usec' => $timeoutUsec, - ); + ]; if (!socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, $timeout)) { $this->emitSocketError(); @@ -298,7 +298,7 @@ class PhpiredisSocketConnection extends AbstractConnection socket_set_block($socket); $null = null; - $selectable = array($socket); + $selectable = [$socket]; $timeout = (isset($parameters->timeout) ? (float) $parameters->timeout : 5.0); $timeoutSecs = floor($timeout); diff --git a/src/Connection/PhpiredisStreamConnection.php b/src/Connection/PhpiredisStreamConnection.php index 96db91db..25288764 100644 --- a/src/Connection/PhpiredisStreamConnection.php +++ b/src/Connection/PhpiredisStreamConnection.php @@ -132,10 +132,10 @@ class PhpiredisStreamConnection extends StreamConnection $rwtimeout = (float) $parameters->read_write_timeout; $rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1; - $timeout = array( + $timeout = [ 'sec' => $timeoutSeconds = floor($rwtimeout), 'usec' => ($rwtimeout - $timeoutSeconds) * 1000000, - ); + ]; $socket = $socket ?: socket_import_stream($resource); @socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, $timeout); diff --git a/src/Connection/Replication/MasterSlaveReplication.php b/src/Connection/Replication/MasterSlaveReplication.php index 0eb87f29..7e63bc65 100644 --- a/src/Connection/Replication/MasterSlaveReplication.php +++ b/src/Connection/Replication/MasterSlaveReplication.php @@ -41,17 +41,17 @@ class MasterSlaveReplication implements ReplicationInterface /** * @var NodeConnectionInterface[] */ - protected $slaves = array(); + protected $slaves = []; /** * @var NodeConnectionInterface[] */ - protected $pool = array(); + protected $pool = []; /** * @var NodeConnectionInterface[] */ - protected $aliases = array(); + protected $aliases = []; /** * @var NodeConnectionInterface @@ -367,7 +367,7 @@ class MasterSlaveReplication implements ReplicationInterface */ private function handleInfoResponse($response) { - $info = array(); + $info = []; foreach (preg_split('/\r?\n/', $response) as $row) { if (strpos($row, ':') === false) { @@ -421,17 +421,17 @@ class MasterSlaveReplication implements ReplicationInterface throw new ClientException("Role mismatch (expected master, got slave) [$connection]"); } - $this->slaves = array(); + $this->slaves = []; foreach ($replication as $k => $v) { $parameters = null; if (strpos($k, 'slave') === 0 && preg_match('/ip=(?P.*),port=(?P\d+)/', $v, $parameters)) { - $slaveConnection = $connectionFactory->create(array( + $slaveConnection = $connectionFactory->create([ 'host' => $parameters['host'], 'port' => $parameters['port'], 'role' => 'slave', - )); + ]); $this->add($slaveConnection); } @@ -453,11 +453,11 @@ class MasterSlaveReplication implements ReplicationInterface throw new ClientException("Role mismatch (expected slave, got master) [$connection]"); } - $masterConnection = $connectionFactory->create(array( + $masterConnection = $connectionFactory->create([ 'host' => $replication['master_host'], 'port' => $replication['master_port'], 'role' => 'master', - )); + ]); $this->add($masterConnection); @@ -548,6 +548,6 @@ class MasterSlaveReplication implements ReplicationInterface */ public function __sleep() { - return array('master', 'slaves', 'pool', 'aliases', 'strategy'); + return ['master', 'slaves', 'pool', 'aliases', 'strategy']; } } diff --git a/src/Connection/Replication/SentinelReplication.php b/src/Connection/Replication/SentinelReplication.php index 8cf17e74..6beabcf5 100644 --- a/src/Connection/Replication/SentinelReplication.php +++ b/src/Connection/Replication/SentinelReplication.php @@ -39,12 +39,12 @@ class SentinelReplication implements ReplicationInterface /** * @var NodeConnectionInterface[] */ - protected $slaves = array(); + protected $slaves = []; /** * @var NodeConnectionInterface[] */ - protected $pool = array(); + protected $pool = []; /** * @var NodeConnectionInterface @@ -69,7 +69,7 @@ class SentinelReplication implements ReplicationInterface /** * @var NodeConnectionInterface[] */ - protected $sentinels = array(); + protected $sentinels = []; /** * @var int @@ -194,8 +194,8 @@ class SentinelReplication implements ReplicationInterface $this->reset(); $this->master = null; - $this->slaves = array(); - $this->pool = array(); + $this->slaves = []; + $this->pool = []; } /** @@ -320,17 +320,17 @@ class SentinelReplication implements ReplicationInterface RawCommand::create('SENTINEL', 'sentinels', $this->service) ); - $this->sentinels = array(); + $this->sentinels = []; $this->sentinelIndex = 0; // NOTE: sentinel server does not return itself, so we add it back. $this->sentinels[] = $sentinel->getParameters()->toArray(); foreach ($payload as $sentinel) { - $this->sentinels[] = array( + $this->sentinels[] = [ 'host' => $sentinel[3], 'port' => $sentinel[5], 'role' => 'sentinel', - ); + ]; } } catch (ConnectionException $exception) { $this->sentinelConnection = null; @@ -389,11 +389,11 @@ class SentinelReplication implements ReplicationInterface $this->handleSentinelErrorResponse($sentinel, $payload); } - return array( + return [ 'host' => $payload[0], 'port' => $payload[1], 'role' => 'master', - ); + ]; } /** @@ -406,7 +406,7 @@ class SentinelReplication implements ReplicationInterface */ protected function querySentinelForSlaves(NodeConnectionInterface $sentinel, $service) { - $slaves = array(); + $slaves = []; $payload = $sentinel->executeCommand( RawCommand::create('SENTINEL', 'slaves', $service) @@ -419,15 +419,15 @@ class SentinelReplication implements ReplicationInterface foreach ($payload as $slave) { $flags = explode(',', $slave[9]); - if (array_intersect($flags, array('s_down', 'o_down', 'disconnected'))) { + if (array_intersect($flags, ['s_down', 'o_down', 'disconnected'])) { continue; } - $slaves[] = array( + $slaves[] = [ 'host' => $slave[3], 'port' => $slave[5], 'role' => 'slave', - ); + ]; } return $slaves; @@ -763,8 +763,8 @@ class SentinelReplication implements ReplicationInterface */ public function __sleep() { - return array( + return [ 'master', 'slaves', 'pool', 'service', 'sentinels', 'connectionFactory', 'strategy', - ); + ]; } } diff --git a/src/Connection/StreamConnection.php b/src/Connection/StreamConnection.php index fb0133cd..07513d92 100644 --- a/src/Connection/StreamConnection.php +++ b/src/Connection/StreamConnection.php @@ -203,14 +203,14 @@ class StreamConnection extends AbstractConnection if (is_array($parameters->ssl)) { $options = $parameters->ssl; } else { - $options = array(); + $options = []; } if (!isset($options['crypto_type'])) { $options['crypto_type'] = STREAM_CRYPTO_METHOD_TLS_CLIENT; } - if (!stream_context_set_option($resource, array('ssl' => $options))) { + if (!stream_context_set_option($resource, ['ssl' => $options])) { $this->onConnectionError('Error while setting SSL context options'); } @@ -322,7 +322,7 @@ class StreamConnection extends AbstractConnection return; } - $multibulk = array(); + $multibulk = []; for ($i = 0; $i < $count; ++$i) { $multibulk[$i] = $this->read(); diff --git a/src/Connection/WebdisConnection.php b/src/Connection/WebdisConnection.php index a03f136f..65645a05 100644 --- a/src/Connection/WebdisConnection.php +++ b/src/Connection/WebdisConnection.php @@ -122,14 +122,14 @@ class WebdisConnection implements NodeConnectionInterface $host = "[$host]"; } - $options = array( + $options = [ CURLOPT_FAILONERROR => true, CURLOPT_CONNECTTIMEOUT_MS => $timeout, CURLOPT_URL => "$parameters->scheme://$host:$parameters->port", CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_POST => true, - CURLOPT_WRITEFUNCTION => array($this, 'feedReader'), - ); + CURLOPT_WRITEFUNCTION => [$this, 'feedReader'], + ]; if (isset($parameters->user, $parameters->pass)) { $options[CURLOPT_USERPWD] = "{$parameters->user}:{$parameters->pass}"; @@ -349,7 +349,7 @@ class WebdisConnection implements NodeConnectionInterface */ public function __sleep() { - return array('parameters'); + return ['parameters']; } /** diff --git a/src/Monitor/Consumer.php b/src/Monitor/Consumer.php index 05e0a689..293b33c8 100644 --- a/src/Monitor/Consumer.php +++ b/src/Monitor/Consumer.php @@ -166,12 +166,12 @@ class Consumer implements \Iterator $event = preg_replace_callback('/ \(db (\d+)\) | \[(\d+) (.*?)\] /', $callback, $event, 1); @list($timestamp, $command, $arguments) = explode(' ', $event, 3); - return (object) array( + return (object) [ 'timestamp' => (float) $timestamp, 'database' => $database, 'client' => $client, 'command' => substr($command, 1, -1), 'arguments' => $arguments, - ); + ]; } } diff --git a/src/Pipeline/Atomic.php b/src/Pipeline/Atomic.php index dcf5efb0..da799150 100644 --- a/src/Pipeline/Atomic.php +++ b/src/Pipeline/Atomic.php @@ -94,7 +94,7 @@ class Atomic extends Pipeline ); } - $responses = array(); + $responses = []; $sizeOfPipe = count($commands); $exceptions = $this->throwServerExceptions(); diff --git a/src/Pipeline/ConnectionErrorProof.php b/src/Pipeline/ConnectionErrorProof.php index 0c5a30c4..28f73de8 100644 --- a/src/Pipeline/ConnectionErrorProof.php +++ b/src/Pipeline/ConnectionErrorProof.php @@ -55,7 +55,7 @@ class ConnectionErrorProof extends Pipeline */ protected function executeSingleNode(NodeConnectionInterface $connection, \SplQueue $commands) { - $responses = array(); + $responses = []; $sizeOfPipe = count($commands); foreach ($commands as $command) { @@ -87,9 +87,9 @@ class ConnectionErrorProof extends Pipeline */ protected function executeCluster(ClusterInterface $connection, \SplQueue $commands) { - $responses = array(); + $responses = []; $sizeOfPipe = count($commands); - $exceptions = array(); + $exceptions = []; foreach ($commands as $command) { $cmdConnection = $connection->getConnectionByCommand($command); diff --git a/src/Pipeline/FireAndForget.php b/src/Pipeline/FireAndForget.php index 1fef32c6..7f6f1fe4 100644 --- a/src/Pipeline/FireAndForget.php +++ b/src/Pipeline/FireAndForget.php @@ -30,6 +30,6 @@ class FireAndForget extends Pipeline $connection->disconnect(); - return array(); + return []; } } diff --git a/src/Pipeline/Pipeline.php b/src/Pipeline/Pipeline.php index 6a97aa3b..df7ce01d 100644 --- a/src/Pipeline/Pipeline.php +++ b/src/Pipeline/Pipeline.php @@ -33,7 +33,7 @@ class Pipeline implements ClientContextInterface private $client; private $pipeline; - private $responses = array(); + private $responses = []; private $running = false; /** @@ -132,7 +132,7 @@ class Pipeline implements ClientContextInterface $connection->writeRequest($command); } - $responses = array(); + $responses = []; $exceptions = $this->throwServerExceptions(); while (!$commands->isEmpty()) { diff --git a/src/Protocol/Text/Handler/MultiBulkResponse.php b/src/Protocol/Text/Handler/MultiBulkResponse.php index 18ca13d9..51f69515 100644 --- a/src/Protocol/Text/Handler/MultiBulkResponse.php +++ b/src/Protocol/Text/Handler/MultiBulkResponse.php @@ -41,10 +41,10 @@ class MultiBulkResponse implements ResponseHandlerInterface return; } - $list = array(); + $list = []; if ($length > 0) { - $handlersCache = array(); + $handlersCache = []; $reader = $connection->getProtocol()->getResponseReader(); for ($i = 0; $i < $length; ++$i) { diff --git a/src/Protocol/Text/ProtocolProcessor.php b/src/Protocol/Text/ProtocolProcessor.php index d3573eeb..49875df2 100644 --- a/src/Protocol/Text/ProtocolProcessor.php +++ b/src/Protocol/Text/ProtocolProcessor.php @@ -80,7 +80,7 @@ class ProtocolProcessor implements ProtocolProcessorInterface return new MultiBulkIterator($connection, $count); } - $multibulk = array(); + $multibulk = []; for ($i = 0; $i < $count; ++$i) { $multibulk[$i] = $this->read($connection); diff --git a/src/Protocol/Text/ResponseReader.php b/src/Protocol/Text/ResponseReader.php index 90e65f6e..1de70782 100644 --- a/src/Protocol/Text/ResponseReader.php +++ b/src/Protocol/Text/ResponseReader.php @@ -41,13 +41,13 @@ class ResponseReader implements ResponseReaderInterface */ protected function getDefaultHandlers() { - return array( + return [ '+' => new Handler\StatusResponse(), '-' => new Handler\ErrorResponse(), ':' => new Handler\IntegerResponse(), '$' => new Handler\BulkResponse(), '*' => new Handler\MultiBulkResponse(), - ); + ]; } /** diff --git a/src/PubSub/AbstractConsumer.php b/src/PubSub/AbstractConsumer.php index e5fb3e0d..f5944774 100644 --- a/src/PubSub/AbstractConsumer.php +++ b/src/PubSub/AbstractConsumer.php @@ -102,7 +102,7 @@ abstract class AbstractConsumer implements \Iterator */ public function ping($payload = null) { - $this->writeRequest('PING', array($payload)); + $this->writeRequest('PING', [$payload]); } /** diff --git a/src/PubSub/Consumer.php b/src/PubSub/Consumer.php index 3057d853..253c33fd 100644 --- a/src/PubSub/Consumer.php +++ b/src/PubSub/Consumer.php @@ -34,7 +34,7 @@ class Consumer extends AbstractConsumer { $this->checkCapabilities($client); - $this->options = $options ?: array(); + $this->options = $options ?: []; $this->client = $client; $this->genericSubscribeInit('subscribe'); @@ -67,7 +67,7 @@ class Consumer extends AbstractConsumer ); } - $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe'); + $commands = ['publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe']; if (!$client->getCommandFactory()->supports(...$commands)) { throw new NotSupportedException( @@ -128,25 +128,25 @@ class Consumer extends AbstractConsumer // no break case self::MESSAGE: - return (object) array( + return (object) [ 'kind' => $response[0], 'channel' => $response[1], 'payload' => $response[2], - ); + ]; case self::PMESSAGE: - return (object) array( + return (object) [ 'kind' => $response[0], 'pattern' => $response[1], 'channel' => $response[2], 'payload' => $response[3], - ); + ]; case self::PONG: - return (object) array( + return (object) [ 'kind' => $response[0], 'payload' => $response[1], - ); + ]; default: throw new ClientException( diff --git a/src/PubSub/DispatcherLoop.php b/src/PubSub/DispatcherLoop.php index a81245e0..963f38c6 100644 --- a/src/PubSub/DispatcherLoop.php +++ b/src/PubSub/DispatcherLoop.php @@ -29,7 +29,7 @@ class DispatcherLoop */ public function __construct(Consumer $pubsub) { - $this->callbacks = array(); + $this->callbacks = []; $this->pubsub = $pubsub; } diff --git a/src/Replication/ReplicationStrategy.php b/src/Replication/ReplicationStrategy.php index 0c490c63..a3337292 100644 --- a/src/Replication/ReplicationStrategy.php +++ b/src/Replication/ReplicationStrategy.php @@ -31,7 +31,7 @@ class ReplicationStrategy { $this->disallowed = $this->getDisallowedOperations(); $this->readonly = $this->getReadOnlyOperations(); - $this->readonlySHA1 = array(); + $this->readonlySHA1 = []; } /** @@ -189,7 +189,7 @@ class ReplicationStrategy */ protected function getDisallowedOperations() { - return array( + return [ 'SHUTDOWN' => true, 'INFO' => true, 'DBSIZE' => true, @@ -201,7 +201,7 @@ class ReplicationStrategy 'BGSAVE' => true, 'BGREWRITEAOF' => true, 'SLOWLOG' => true, - ); + ]; } /** @@ -211,7 +211,7 @@ class ReplicationStrategy */ protected function getReadOnlyOperations() { - return array( + return [ 'EXISTS' => true, 'TYPE' => true, 'KEYS' => true, @@ -267,12 +267,12 @@ class ReplicationStrategy 'BITPOS' => true, 'TIME' => true, 'PFCOUNT' => true, - 'BITFIELD' => array($this, 'isBitfieldReadOnly'), + 'BITFIELD' => [$this, 'isBitfieldReadOnly'], 'GEOHASH' => true, 'GEOPOS' => true, 'GEODIST' => true, - 'GEORADIUS' => array($this, 'isGeoradiusReadOnly'), - 'GEORADIUSBYMEMBER' => array($this, 'isGeoradiusReadOnly'), - ); + 'GEORADIUS' => [$this, 'isGeoradiusReadOnly'], + 'GEORADIUSBYMEMBER' => [$this, 'isGeoradiusReadOnly'], + ]; } } diff --git a/src/Response/Iterator/MultiBulkTuple.php b/src/Response/Iterator/MultiBulkTuple.php index b0f9c3d5..8ddf0561 100644 --- a/src/Response/Iterator/MultiBulkTuple.php +++ b/src/Response/Iterator/MultiBulkTuple.php @@ -85,6 +85,6 @@ class MultiBulkTuple extends MultiBulk implements \OuterIterator $v = $this->iterator->current(); $this->iterator->next(); - return array($k, $v); + return [$k, $v]; } } diff --git a/src/Session/Handler.php b/src/Session/Handler.php index 0ba52ef0..d2c8bfa5 100644 --- a/src/Session/Handler.php +++ b/src/Session/Handler.php @@ -31,7 +31,7 @@ class Handler implements \SessionHandlerInterface * @param ClientInterface $client Fully initialized client instance. * @param array $options Session handler options. */ - public function __construct(ClientInterface $client, array $options = array()) + public function __construct(ClientInterface $client, array $options = []) { $this->client = $client; diff --git a/src/Transaction/MultiExec.php b/src/Transaction/MultiExec.php index 5be74487..c3d3ae61 100644 --- a/src/Transaction/MultiExec.php +++ b/src/Transaction/MultiExec.php @@ -37,7 +37,7 @@ class MultiExec implements ClientContextInterface protected $commands; protected $exceptions = true; protected $attempts = 0; - protected $watchKeys = array(); + protected $watchKeys = []; protected $modeCAS = false; /** @@ -51,7 +51,7 @@ class MultiExec implements ClientContextInterface $this->client = $client; $this->state = new MultiExecState(); - $this->configure($client, $options ?: array()); + $this->configure($client, $options ?: []); $this->reset(); } @@ -171,7 +171,7 @@ class MultiExec implements ClientContextInterface * * @return mixed */ - protected function call($commandID, array $arguments = array()) + protected function call($commandID, array $arguments = []) { $response = $this->client->executeCommand( $this->client->createCommand($commandID, $arguments) @@ -235,7 +235,7 @@ class MultiExec implements ClientContextInterface throw new ClientException('Sending WATCH after MULTI is not allowed.'); } - $response = $this->call('WATCH', is_array($keys) ? $keys : array($keys)); + $response = $this->call('WATCH', is_array($keys) ? $keys : [$keys]); $this->state->flag(MultiExecState::WATCH); return $response; @@ -274,7 +274,7 @@ class MultiExec implements ClientContextInterface } $this->state->unflag(MultiExecState::WATCH); - $this->__call('UNWATCH', array()); + $this->__call('UNWATCH', []); return $this; } @@ -392,7 +392,7 @@ class MultiExec implements ClientContextInterface break; } while ($attempts-- > 0); - $response = array(); + $response = []; $commands = $this->commands; $size = count($execResponse); diff --git a/tests/PHPUnit/PredisCommandTestCase.php b/tests/PHPUnit/PredisCommandTestCase.php index 171e4a04..d116a2d7 100644 --- a/tests/PHPUnit/PredisCommandTestCase.php +++ b/tests/PHPUnit/PredisCommandTestCase.php @@ -122,7 +122,7 @@ abstract class PredisCommandTestCase extends PredisTestCase */ public function testRawArguments(): void { - $expected = array('1st', '2nd', '3rd', '4th'); + $expected = ['1st', '2nd', '3rd', '4th']; $command = $this->getCommand(); $command->setRawArguments($expected); diff --git a/tests/PHPUnit/PredisConnectionTestCase.php b/tests/PHPUnit/PredisConnectionTestCase.php index 8e2dfdf6..9fc4099d 100644 --- a/tests/PHPUnit/PredisConnectionTestCase.php +++ b/tests/PHPUnit/PredisConnectionTestCase.php @@ -36,7 +36,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testSupportsSchemeTCP(): void { - $connection = $this->createConnectionWithParams(array('scheme' => 'tcp')); + $connection = $this->createConnectionWithParams(['scheme' => 'tcp']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -46,7 +46,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testSupportsSchemeRedis(): void { - $connection = $this->createConnectionWithParams(array('scheme' => 'redis')); + $connection = $this->createConnectionWithParams(['scheme' => 'redis']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -56,7 +56,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testSupportsSchemeTls(): void { - $connection = $this->createConnectionWithParams(array('scheme' => 'tls')); + $connection = $this->createConnectionWithParams(['scheme' => 'tls']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -66,7 +66,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testSupportsSchemeRediss(): void { - $connection = $this->createConnectionWithParams(array('scheme' => 'rediss')); + $connection = $this->createConnectionWithParams(['scheme' => 'rediss']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -76,7 +76,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testSupportsSchemeUnix(): void { - $connection = $this->createConnectionWithParams(array('scheme' => 'unix')); + $connection = $this->createConnectionWithParams(['scheme' => 'unix']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -89,7 +89,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Invalid scheme: 'udp'"); - $this->createConnectionWithParams(array('scheme' => 'udp')); + $this->createConnectionWithParams(['scheme' => 'udp']); } /** @@ -108,10 +108,10 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testCanBeSerialized(): void { - $parameters = $this->getParameters(array( + $parameters = $this->getParameters([ 'alias' => 'redis', 'read_write_timeout' => 10, - )); + ]); $connection = $this->createConnectionWithParams($parameters); $unserialized = unserialize(serialize($connection)); @@ -130,11 +130,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ public function testAcceptsTcpNodelayParameter(): void { - $connection = $this->createConnectionWithParams(array('tcp_nodelay' => false)); + $connection = $this->createConnectionWithParams(['tcp_nodelay' => false]); $connection->connect(); $this->assertTrue($connection->isConnected()); - $connection = $this->createConnectionWithParams(array('tcp_nodelay' => true)); + $connection = $this->createConnectionWithParams(['tcp_nodelay' => true]); $connection->connect(); $this->assertTrue($connection->isConnected()); } @@ -226,7 +226,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase /** @var CommandInterface|MockObject */ $cmdPing = $this->getMockBuilder($commands->getCommandClass('ping')) - ->onlyMethods(array('parseResponse')) + ->onlyMethods(['parseResponse']) ->getMock(); $cmdPing->expects($this->never()) ->method('parseResponse'); @@ -242,11 +242,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase public function testExecutesCommandWithHolesInArguments(): void { $commands = $this->getCommandFactory(); - $cmdDel = $commands->create('mget', array(0 => 'key:0', 2 => 'key:2')); + $cmdDel = $commands->create('mget', [0 => 'key:0', 2 => 'key:2']); $connection = $this->createConnection(); - $this->assertSame(array(null, null), $connection->executeCommand($cmdDel)); + $this->assertSame([null, null], $connection->executeCommand($cmdDel)); } /** @@ -257,10 +257,10 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); $cmdPing = $commands->create('ping'); - $cmdEcho = $commands->create('echo', array('echoed')); - $cmdGet = $commands->create('get', array('foobar')); - $cmdRpush = $commands->create('rpush', array('metavars', 'foo', 'hoge', 'lol')); - $cmdLrange = $commands->create('lrange', array('metavars', 0, -1)); + $cmdEcho = $commands->create('echo', ['echoed']); + $cmdGet = $commands->create('get', ['foobar']); + $cmdRpush = $commands->create('rpush', ['metavars', 'foo', 'hoge', 'lol']); + $cmdLrange = $commands->create('lrange', ['metavars', 0, -1]); $connection = $this->createConnection(true); @@ -268,7 +268,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); $this->assertNull($connection->executeCommand($cmdGet)); $this->assertSame(3, $connection->executeCommand($cmdRpush)); - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); + $this->assertSame(['foo', 'hoge', 'lol'], $connection->executeCommand($cmdLrange)); } /** @@ -280,9 +280,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase /** @var CommandInterface|MockObject */ $cmdEcho = $this->getMockBuilder($commands->getCommandClass('echo')) - ->onlyMethods(array('parseResponse')) + ->onlyMethods(['parseResponse']) ->getMock(); - $cmdEcho->setArguments(array('ECHOED')); + $cmdEcho->setArguments(['ECHOED']); $cmdEcho ->expects($this->never()) ->method('parseResponse'); @@ -301,9 +301,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase /** @var CommandInterface|MockObject */ $cmdEcho = $this->getMockBuilder($commands->getCommandClass('echo')) - ->onlyMethods(array('parseResponse')) + ->onlyMethods(['parseResponse']) ->getMock(); - $cmdEcho->setArguments(array('ECHOED')); + $cmdEcho->setArguments(['ECHOED']); $cmdEcho ->expects($this->never()) ->method('parseResponse'); @@ -323,7 +323,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase /** @var CommandInterface|MockObject */ $cmdPing = $this->getMockBuilder($commands->getCommandClass('ping')) - ->onlyMethods(array('parseResponse')) + ->onlyMethods(['parseResponse']) ->getMock(); $cmdPing ->expects($this->never()) @@ -331,9 +331,9 @@ abstract class PredisConnectionTestCase extends PredisTestCase /** @var CommandInterface|MockObject */ $cmdEcho = $this->getMockBuilder($commands->getCommandClass('echo')) - ->onlyMethods(array('parseResponse')) + ->onlyMethods(['parseResponse']) ->getMock(); - $cmdEcho->setArguments(array('ECHOED')); + $cmdEcho->setArguments(['ECHOED']); $cmdEcho ->expects($this->never()) ->method('parseResponse'); @@ -356,22 +356,22 @@ abstract class PredisConnectionTestCase extends PredisTestCase /** @var CommandInterface|MockObject */ $cmdPing = $this->getMockBuilder($commands->getCommandClass('ping')) - ->onlyMethods(array('getArguments')) + ->onlyMethods(['getArguments']) ->getMock(); $cmdPing ->expects($this->once()) ->method('getArguments') - ->willReturn(array()); + ->willReturn([]); /** @var CommandInterface|MockObject */ $cmdEcho = $this->getMockBuilder($commands->getCommandClass('echo')) - ->onlyMethods(array('getArguments')) + ->onlyMethods(['getArguments']) ->getMock(); - $cmdEcho->setArguments(array('ECHOED')); + $cmdEcho->setArguments(['ECHOED']); $cmdEcho ->expects($this->once()) ->method('getArguments') - ->willReturn(array('ECHOED')); + ->willReturn(['ECHOED']); $connection = $this->createConnection(); $connection->addConnectCommand($cmdPing); @@ -388,7 +388,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); $connection = $this->createConnection(true); - $connection->writeRequest($commands->create('set', array('foo', 'bar'))); + $connection->writeRequest($commands->create('set', ['foo', 'bar'])); $this->assertInstanceOf('Predis\Response\Status', $connection->read()); $connection->writeRequest($commands->create('ping')); @@ -408,12 +408,12 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); $connection = $this->createConnection(true); - $connection->executeCommand($commands->create('set', array('foo', 'bar'))); + $connection->executeCommand($commands->create('set', ['foo', 'bar'])); - $connection->writeRequest($commands->create('get', array('foo'))); + $connection->writeRequest($commands->create('get', ['foo'])); $this->assertSame('bar', $connection->read()); - $connection->writeRequest($commands->create('get', array('hoge'))); + $connection->writeRequest($commands->create('get', ['hoge'])); $this->assertNull($connection->read()); } @@ -425,8 +425,8 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); $connection = $this->createConnection(true); - $connection->executeCommand($commands->create('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeRequest($commands->create('llen', array('metavars'))); + $connection->executeCommand($commands->create('rpush', ['metavars', 'foo', 'hoge', 'lol'])); + $connection->writeRequest($commands->create('llen', ['metavars'])); $this->assertSame(3, $connection->read()); } @@ -439,8 +439,8 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); $connection = $this->createConnection(true); - $connection->executeCommand($commands->create('set', array('foo', 'bar'))); - $connection->writeRequest($commands->create('rpush', array('foo', 'baz'))); + $connection->executeCommand($commands->create('set', ['foo', 'bar'])); + $connection->writeRequest($commands->create('rpush', ['foo', 'baz'])); $this->assertInstanceOf('Predis\Response\Error', $error = $connection->read()); $this->assertMatchesRegularExpression( @@ -456,10 +456,10 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); $connection = $this->createConnection(true); - $connection->executeCommand($commands->create('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeRequest($commands->create('lrange', array('metavars', 0, -1))); + $connection->executeCommand($commands->create('rpush', ['metavars', 'foo', 'hoge', 'lol'])); + $connection->writeRequest($commands->create('lrange', ['metavars', 0, -1])); - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->read()); + $this->assertSame(['foo', 'hoge', 'lol'], $connection->read()); } /** @@ -471,10 +471,10 @@ abstract class PredisConnectionTestCase extends PredisTestCase $this->expectException('Predis\Connection\ConnectionException'); $this->expectExceptionMessageMatches('/.* \[tcp:\/\/169.254.10.10:6379\]/'); - $connection = $this->createConnectionWithParams(array( + $connection = $this->createConnectionWithParams([ 'host' => '169.254.10.10', 'timeout' => 0.1, - ), false); + ], false); $connection->connect(); } @@ -488,10 +488,10 @@ abstract class PredisConnectionTestCase extends PredisTestCase $this->expectException('Predis\Connection\ConnectionException'); $this->expectExceptionMessageMatches('/.* \[tcp:\/\/\[0:0:0:0:0:ffff:a9fe:a0a\]:6379\]/'); - $connection = $this->createConnectionWithParams(array( + $connection = $this->createConnectionWithParams([ 'host' => '0:0:0:0:0:ffff:a9fe:a0a', 'timeout' => 0.1, - ), false); + ], false); $connection->connect(); } @@ -505,10 +505,10 @@ abstract class PredisConnectionTestCase extends PredisTestCase $this->expectException('Predis\Connection\ConnectionException'); $this->expectExceptionMessageMatches('/.* \[unix:\/tmp\/nonexistent\/redis\.sock]/'); - $connection = $this->createConnectionWithParams(array( + $connection = $this->createConnectionWithParams([ 'scheme' => 'unix', 'path' => '/tmp/nonexistent/redis.sock', - ), false); + ], false); $connection->connect(); } @@ -523,11 +523,11 @@ abstract class PredisConnectionTestCase extends PredisTestCase $commands = $this->getCommandFactory(); - $connection = $this->createConnectionWithParams(array( + $connection = $this->createConnectionWithParams([ 'read_write_timeout' => 0.5, - ), true); + ], true); - $connection->executeCommand($commands->create('brpop', array('foo', 3))); + $connection->executeCommand($commands->create('brpop', ['foo', 3])); } /** @@ -565,13 +565,13 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ protected function getDefaultParametersArray(): array { - return array( + return [ 'scheme' => 'tcp', 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), 'read_write_timeout' => 2, - ); + ]; } /** @@ -609,7 +609,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase */ protected function createConnection(bool $initialize = false): NodeConnectionInterface { - return $this->createConnectionWithParams(array(), $initialize); + return $this->createConnectionWithParams([], $initialize); } /** @@ -633,7 +633,7 @@ abstract class PredisConnectionTestCase extends PredisTestCase if ($initialize) { $connection->addConnectCommand( - $commands->create('select', array($parameters->database)) + $commands->create('select', [$parameters->database]) ); $connection->addConnectCommand( diff --git a/tests/PHPUnit/PredisDistributorTestCase.php b/tests/PHPUnit/PredisDistributorTestCase.php index e521b16e..acdbb9ca 100644 --- a/tests/PHPUnit/PredisDistributorTestCase.php +++ b/tests/PHPUnit/PredisDistributorTestCase.php @@ -36,7 +36,7 @@ abstract class PredisDistributorTestCase extends PredisTestCase */ protected function getNodes(DistributorInterface $distributor, int $iterations = 10): array { - $nodes = array(); + $nodes = []; for ($i = 0; $i < $iterations; ++$i) { $hash = $distributor->hash($i * $i); diff --git a/tests/PHPUnit/PredisTestCase.php b/tests/PHPUnit/PredisTestCase.php index fba2ba4e..5d8b6b59 100644 --- a/tests/PHPUnit/PredisTestCase.php +++ b/tests/PHPUnit/PredisTestCase.php @@ -131,12 +131,12 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase */ protected function getDefaultParametersArray(): array { - return array( + return [ 'scheme' => 'tcp', 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), - ); + ]; } /** @@ -146,9 +146,9 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase */ protected function getDefaultOptionsArray(): array { - return array( + return [ 'commands' => new Command\RedisFactory(), - ); + ]; } /** @@ -172,7 +172,7 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase * * @return Connection\ParametersInterface */ - protected function getParameters($additional = array()): Connection\ParametersInterface + protected function getParameters($additional = []): Connection\ParametersInterface { $parameters = array_merge($this->getDefaultParametersArray(), $additional); $parameters = new Connection\Parameters($parameters); @@ -206,14 +206,14 @@ abstract class PredisTestCase extends \PHPUnit\Framework\TestCase { $parameters = array_merge( $this->getDefaultParametersArray(), - $parameters ?: array() + $parameters ?: [] ); $options = array_merge( - array( + [ 'commands' => $this->getCommandFactory(), - ), - $options ?: array() + ], + $options ?: [] ); $client = new Client($parameters, $options); diff --git a/tests/Predis/ClientTest.php b/tests/Predis/ClientTest.php index a650ec4e..cb39e8b3 100644 --- a/tests/Predis/ClientTest.php +++ b/tests/Predis/ClientTest.php @@ -93,7 +93,7 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithArrayArgument(): void { - $client = new Client($arg1 = array('host' => 'localhost', 'port' => 7000)); + $client = new Client($arg1 = ['host' => 'localhost', 'port' => 7000]); /** @var NodeConnectionInterface */ $connection = $client->getConnection(); @@ -111,10 +111,10 @@ class ClientTest extends PredisTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('Array of connection parameters requires `cluster`, `replication` or `aggregate` client option'); - $arg1 = array( - array('host' => 'localhost', 'port' => 7000), - array('host' => 'localhost', 'port' => 7001), - ); + $arg1 = [ + ['host' => 'localhost', 'port' => 7000], + ['host' => 'localhost', 'port' => 7001], + ]; $client = new Client($arg1); } @@ -124,14 +124,14 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithArrayOfArrayArgumentAndClusterOption(): void { - $arg1 = array( - array('host' => 'localhost', 'port' => 7000), - array('host' => 'localhost', 'port' => 7001), - ); + $arg1 = [ + ['host' => 'localhost', 'port' => 7000], + ['host' => 'localhost', 'port' => 7001], + ]; - $client = new Client($arg1, array( + $client = new Client($arg1, [ 'aggregate' => $this->getAggregateInitializer($arg1), - )); + ]); $this->assertInstanceOf('Predis\Connection\AggregateConnectionInterface', $client->getConnection()); } @@ -156,11 +156,11 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithArrayOfStringArgument(): void { - $arg1 = array('tcp://localhost:7000', 'tcp://localhost:7001'); + $arg1 = ['tcp://localhost:7000', 'tcp://localhost:7001']; - $client = new Client($arg1, array( + $client = new Client($arg1, [ 'aggregate' => $this->getAggregateInitializer($arg1), - )); + ]); $this->assertInstanceOf('Predis\Connection\AggregateConnectionInterface', $client->getConnection()); } @@ -170,14 +170,14 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithArrayOfConnectionsArgument(): void { - $arg1 = array( + $arg1 = [ $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(), $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(), - ); + ]; - $client = new Client($arg1, array( + $client = new Client($arg1, [ 'aggregate' => $this->getAggregateInitializer($arg1), - )); + ]); $this->assertInstanceOf('Predis\Connection\AggregateConnectionInterface', $client->getConnection()); } @@ -245,7 +245,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -269,7 +269,7 @@ class ClientTest extends PredisTestCase $wrongType = $this->getMockBuilder('stdClass')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -287,7 +287,7 @@ class ClientTest extends PredisTestCase { $connections = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); - $arg2 = array('prefix' => 'prefix:', 'connections' => $connections); + $arg2 = ['prefix' => 'prefix:', 'connections' => $connections]; $client = new Client(null, $arg2); /** @var CommandFactory */ @@ -305,8 +305,8 @@ class ClientTest extends PredisTestCase */ public function testConstructorWithArrayAndOptionReplication(): void { - $arg1 = array('tcp://127.0.0.1:6379?role=master', 'tcp://127.0.0.1:6380?role=slave'); - $arg2 = array('replication' => 'predis'); + $arg1 = ['tcp://127.0.0.1:6379?role=master', 'tcp://127.0.0.1:6380?role=slave']; + $arg2 = ['replication' => 'predis']; $client = new Client($arg1, $arg2); /** @var MasterSlaveReplication */ @@ -322,12 +322,12 @@ class ClientTest extends PredisTestCase */ public function testClusterOptionHasPrecedenceOverReplicationOptionAndAggregateOption(): void { - $arg1 = array('tcp://host1', 'tcp://host2'); + $arg1 = ['tcp://host1', 'tcp://host2']; $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $fncluster = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $fncluster ->expects($this->once()) @@ -340,24 +340,24 @@ class ClientTest extends PredisTestCase ->willReturn($connection); $fnreplication = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $fnreplication ->expects($this->never()) ->method('__invoke'); $fnaggregate = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $fnaggregate ->expects($this->never()) ->method('__invoke'); - $arg2 = array( + $arg2 = [ 'cluster' => $fncluster, 'replication' => $fnreplication, 'aggregate' => $fnaggregate, - ); + ]; $client = new Client($arg1, $arg2); @@ -369,12 +369,12 @@ class ClientTest extends PredisTestCase */ public function testReplicationOptionHasPrecedenceOverAggregateOption(): void { - $arg1 = array('tcp://host1', 'tcp://host2'); + $arg1 = ['tcp://host1', 'tcp://host2']; $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $fnreplication = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $fnreplication ->expects($this->once()) @@ -387,16 +387,16 @@ class ClientTest extends PredisTestCase ->willReturn($connection); $fnaggregate = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $fnaggregate ->expects($this->never()) ->method('__invoke'); - $arg2 = array( + $arg2 = [ 'replication' => $fnreplication, 'aggregate' => $fnaggregate, - ); + ]; $client = new Client($arg1, $arg2); } @@ -406,7 +406,7 @@ class ClientTest extends PredisTestCase */ public function testAggregateOptionDoesNotTriggerAggregationInClient(): void { - $arg1 = array('tcp://host1', 'tcp://host2'); + $arg1 = ['tcp://host1', 'tcp://host2']; $connections = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); $connections @@ -420,7 +420,7 @@ class ClientTest extends PredisTestCase ->method('add'); $fnaggregate = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $fnaggregate ->expects($this->once()) @@ -432,7 +432,7 @@ class ClientTest extends PredisTestCase ) ->willReturn($connection); - $arg2 = array('aggregate' => $fnaggregate, 'connections' => $connections); + $arg2 = ['aggregate' => $fnaggregate, 'connections' => $connections]; $client = new Client($arg1, $arg2); @@ -512,17 +512,17 @@ class ClientTest extends PredisTestCase */ public function testCreatesNewCommandUsingSpecifiedCommandFactory(): void { - $ping = $this->getCommandFactory()->create('ping', array()); + $ping = $this->getCommandFactory()->create('ping', []); $commands = $this->getMockBuilder('Predis\Command\FactoryInterface')->getMock(); $commands ->expects($this->once()) ->method('create') - ->with('ping', array()) + ->with('ping', []) ->willReturn($ping); - $client = new Client(null, array('commands' => $commands)); - $this->assertSame($ping, $client->createCommand('ping', array())); + $client = new Client(null, ['commands' => $commands]); + $this->assertSame($ping, $client->createCommand('ping', [])); } /** @@ -532,26 +532,26 @@ class ClientTest extends PredisTestCase { $commands = $this->getCommandFactory(); - $ping = $commands->create('ping', array()); - $hgetall = $commands->create('hgetall', array('metavars', 'foo', 'hoge')); + $ping = $commands->create('ping', []); + $hgetall = $commands->create('hgetall', ['metavars', 'foo', 'hoge']); $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $connection ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($ping), - array($hgetall) + [$ping], + [$hgetall] ) ->willReturnOnConsecutiveCalls( new Response\Status('PONG'), - array('foo', 'bar', 'hoge', 'piyo') + ['foo', 'bar', 'hoge', 'piyo'] ); $client = new Client($connection); $this->assertEquals('PONG', $client->executeCommand($ping)); - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo'), $client->executeCommand($hgetall)); + $this->assertSame(['foo' => 'bar', 'hoge' => 'piyo'], $client->executeCommand($hgetall)); } /** @@ -562,7 +562,7 @@ class ClientTest extends PredisTestCase $this->expectException('Predis\Response\ServerException'); $this->expectExceptionMessage('Operation against a key holding the wrong kind of value'); - $ping = $this->getCommandFactory()->create('ping', array()); + $ping = $this->getCommandFactory()->create('ping', []); $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); @@ -580,7 +580,7 @@ class ClientTest extends PredisTestCase */ public function testExecuteCommandReturnsErrorResponseOnRedisError(): void { - $ping = $this->getCommandFactory()->create('ping', array()); + $ping = $this->getCommandFactory()->create('ping', []); $expectedResponse = new Response\Error('ERR Operation against a key holding the wrong kind of value'); $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); @@ -589,7 +589,7 @@ class ClientTest extends PredisTestCase ->method('executeCommand') ->willReturn($expectedResponse); - $client = new Client($connection, array('exceptions' => false)); + $client = new Client($connection, ['exceptions' => false]); $response = $client->executeCommand($ping); $this->assertSame($response, $expectedResponse); @@ -600,7 +600,7 @@ class ClientTest extends PredisTestCase */ public function testCallingRedisCommandExecutesInstanceOfCommand(): void { - $ping = $this->getCommandFactory()->create('ping', array()); + $ping = $this->getCommandFactory()->create('ping', []); $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $connection @@ -613,15 +613,15 @@ class ClientTest extends PredisTestCase $commands ->expects($this->once()) ->method('create') - ->with('ping', array()) + ->with('ping', []) ->willReturn($ping); - $options = array('commands' => $commands); + $options = ['commands' => $commands]; /** @var ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array()) - ->setConstructorArgs(array($connection, $options)) + ->onlyMethods([]) + ->setConstructorArgs([$connection, $options]) ->getMock(); $this->assertEquals('PONG', $client->ping()); @@ -662,7 +662,7 @@ class ClientTest extends PredisTestCase ->with($this->isRedisCommand('PING')) ->willReturn($expectedResponse); - $client = new Client($connection, array('exceptions' => false)); + $client = new Client($connection, ['exceptions' => false]); $response = $client->ping(); $this->assertSame($response, $expectedResponse); @@ -678,9 +678,9 @@ class ClientTest extends PredisTestCase ->expects($this->exactly(3)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SET', array('foo', 'bar'))), - array($this->isRedisCommand('GET', array('foo'))), - array($this->isRedisCommand('PING')) + [$this->isRedisCommand('SET', ['foo', 'bar'])], + [$this->isRedisCommand('GET', ['foo'])], + [$this->isRedisCommand('PING')] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), @@ -690,11 +690,11 @@ class ClientTest extends PredisTestCase $client = new Client($connection); - $this->assertSame('OK', $client->executeRaw(array('SET', 'foo', 'bar'))); - $this->assertSame('bar', $client->executeRaw(array('GET', 'foo'))); + $this->assertSame('OK', $client->executeRaw(['SET', 'foo', 'bar'])); + $this->assertSame('bar', $client->executeRaw(['GET', 'foo'])); $error = true; // $error is always populated by reference. - $this->assertSame('PONG', $client->executeRaw(array('PING'), $error)); + $this->assertSame('PONG', $client->executeRaw(['PING'], $error)); $this->assertFalse($error); } @@ -708,18 +708,18 @@ class ClientTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SET', array('foo', 'bar'))), - array($this->isRedisCommand('GET', array('foo'))) + [$this->isRedisCommand('SET', ['foo', 'bar'])], + [$this->isRedisCommand('GET', ['foo'])] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), 'bar' ); - $client = new Client($connection, array('prefix' => 'predis:')); + $client = new Client($connection, ['prefix' => 'predis:']); - $this->assertSame('OK', $client->executeRaw(array('SET', 'foo', 'bar'))); - $this->assertSame('bar', $client->executeRaw(array('GET', 'foo'))); + $this->assertSame('OK', $client->executeRaw(['SET', 'foo', 'bar'])); + $this->assertSame('bar', $client->executeRaw(['GET', 'foo'])); } /** @@ -737,9 +737,9 @@ class ClientTest extends PredisTestCase ->with($this->isRedisCommand('PING')) ->willReturn($response); - $client = new Client($connection, array('exceptions' => true)); + $client = new Client($connection, ['exceptions' => true]); - $this->assertSame($message, $client->executeRaw(array('PING'), $error)); + $this->assertSame($message, $client->executeRaw(['PING'], $error)); $this->assertTrue($error); } @@ -762,11 +762,11 @@ class ClientTest extends PredisTestCase { /** @var Client */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array()) - ->setConstructorArgs(array( - array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), - array('cluster' => 'predis'), - )) + ->onlyMethods([]) + ->setConstructorArgs([ + ['tcp://host1?alias=node01', 'tcp://host2?alias=node02'], + ['cluster' => 'predis'], + ]) ->setMockClassName('SubclassedClient') ->getMock(); @@ -781,7 +781,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface') - ->onlyMethods(array('getConnectionById')) + ->onlyMethods(['getConnectionById']) ->getMockForAbstractClass(); $aggregate ->expects($this->once()) @@ -823,7 +823,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface') - ->addMethods(array('getConnectionByAlias')) + ->addMethods(['getConnectionByAlias']) ->getMockForAbstractClass(); $aggregate ->expects($this->once()) @@ -846,7 +846,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface') - ->addMethods(array('getConnectionByKey')) + ->addMethods(['getConnectionByKey']) ->getMockForAbstractClass(); $aggregate ->expects($this->once()) @@ -869,7 +869,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface') - ->addMethods(array('getConnectionBySlot')) + ->addMethods(['getConnectionBySlot']) ->getMockForAbstractClass(); $aggregate ->expects($this->once()) @@ -892,7 +892,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface') - ->addMethods(array('getConnectionByRole')) + ->addMethods(['getConnectionByRole']) ->getMockForAbstractClass(); $aggregate ->expects($this->once()) @@ -916,7 +916,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\ConnectionInterface')->getMock(); $aggregate = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface') - ->onlyMethods(array('getConnectionByCommand')) + ->onlyMethods(['getConnectionByCommand']) ->getMockForAbstractClass(); $aggregate ->expects($this->once()) @@ -974,9 +974,9 @@ class ClientTest extends PredisTestCase { $client = new Client(); - $this->assertInstanceOf('Predis\Pipeline\Pipeline', $client->pipeline(array())); - $this->assertInstanceOf('Predis\Pipeline\Atomic', $client->pipeline(array('atomic' => true))); - $this->assertInstanceOf('Predis\Pipeline\FireAndForget', $client->pipeline(array('fire-and-forget' => true))); + $this->assertInstanceOf('Predis\Pipeline\Pipeline', $client->pipeline([])); + $this->assertInstanceOf('Predis\Pipeline\Atomic', $client->pipeline(['atomic' => true])); + $this->assertInstanceOf('Predis\Pipeline\FireAndForget', $client->pipeline(['fire-and-forget' => true])); } /** @@ -985,7 +985,7 @@ class ClientTest extends PredisTestCase public function testPipelineWithCallableExecutesPipeline(): void { $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -1012,7 +1012,7 @@ class ClientTest extends PredisTestCase public function testPubSubLoopWithArrayReturnsPubSubConsumerWithOptions(): void { $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); - $options = array('subscribe' => 'channel'); + $options = ['subscribe' => 'channel']; $client = new Client($connection); @@ -1036,17 +1036,17 @@ class ClientTest extends PredisTestCase $connection ->expects($this->once()) ->method('read') - ->willReturn(array('subscribe', 'channel', 0)); + ->willReturn(['subscribe', 'channel', 0]); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) ->method('__invoke'); $client = new Client($connection); - $this->assertNull($client->pubSubLoop(array('subscribe' => 'channel'), $callable)); + $this->assertNull($client->pubSubLoop(['subscribe' => 'channel'], $callable)); } /** @@ -1059,32 +1059,32 @@ class ClientTest extends PredisTestCase ->expects($this->exactly(2)) ->method('read') ->willReturnOnConsecutiveCalls( - array('subscribe', 'channel', 1), - array('unsubscribe', 'channel', 0) + ['subscribe', 'channel', 1], + ['unsubscribe', 'channel', 0] ); $connection ->expects($this->exactly(2)) ->method('writeRequest') ->withConsecutive( - array($this->isRedisCommand('SUBSCRIBE')), - array($this->isRedisCommand('UNSUBSCRIBE')) + [$this->isRedisCommand('SUBSCRIBE')], + [$this->isRedisCommand('UNSUBSCRIBE')] ); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->exactly(2)) ->method('__invoke') ->withConsecutive( - array( + [ $this->isInstanceOf('Predis\PubSub\Consumer'), - (object) array('kind' => 'subscribe', 'channel' => 'channel', 'payload' => 1) - ), - array( + (object) ['kind' => 'subscribe', 'channel' => 'channel', 'payload' => 1] + ], + [ $this->isInstanceOf('Predis\PubSub\Consumer'), - (object) array('kind' => 'unsubscribe', 'channel' => 'channel', 'payload' => 0) - ) + (object) ['kind' => 'unsubscribe', 'channel' => 'channel', 'payload' => 0] + ] ) ->willReturnOnConsecutiveCalls( false, @@ -1093,7 +1093,7 @@ class ClientTest extends PredisTestCase $client = new Client($connection); - $this->assertNull($client->pubSubLoop(array('subscribe' => 'channel'), $callable)); + $this->assertNull($client->pubSubLoop(['subscribe' => 'channel'], $callable)); } /** @@ -1111,7 +1111,7 @@ class ClientTest extends PredisTestCase */ public function testTransactionWithArrayReturnsMultiExecTransactionWithOptions(): void { - $options = array('cas' => true, 'retry' => 3); + $options = ['cas' => true, 'retry' => 3]; $client = new Client(); @@ -1133,7 +1133,7 @@ class ClientTest extends PredisTestCase public function testTransactionWithArrayAndCallableExecutesMultiExec(): void { // We use CAS here as we don't care about the actual MULTI/EXEC context. - $options = array('cas' => true, 'retry' => 3); + $options = ['cas' => true, 'retry' => 3]; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -1142,7 +1142,7 @@ class ClientTest extends PredisTestCase ->willReturn(new Response\Status('QUEUED')); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -1171,7 +1171,7 @@ class ClientTest extends PredisTestCase { $luaScriptBody = 'return redis.call(\'exists\', KEYS[1])'; - $command = $this->getMockForAbstractClass('Predis\Command\ScriptCommand', array(), '', true, true, true, array('parseResponse')); + $command = $this->getMockForAbstractClass('Predis\Command\ScriptCommand', [], '', true, true, true, ['parseResponse']); $command ->expects($this->once()) ->method('getScript') @@ -1187,8 +1187,8 @@ class ClientTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($command), - array($this->isRedisCommand('EVAL', array($luaScriptBody))) + [$command], + [$this->isRedisCommand('EVAL', [$luaScriptBody])] ) ->willReturnOnConsecutiveCalls( new Response\Error('NOSCRIPT'), @@ -1294,7 +1294,7 @@ class ClientTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) diff --git a/tests/Predis/Cluster/Distributor/HashRingTest.php b/tests/Predis/Cluster/Distributor/HashRingTest.php index 0ae7fffd..47b5dc7d 100644 --- a/tests/Predis/Cluster/Distributor/HashRingTest.php +++ b/tests/Predis/Cluster/Distributor/HashRingTest.php @@ -57,13 +57,13 @@ class HashRingTest extends PredisDistributorTestCase */ public function testMultipleNodesInRing(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); - $expected = array( + $expected = [ '127.0.0.1:7001', '127.0.0.1:7001', '127.0.0.1:7001', @@ -84,7 +84,7 @@ class HashRingTest extends PredisDistributorTestCase '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - ); + ]; $actual = $this->getNodes($ring, 20); @@ -100,7 +100,7 @@ class HashRingTest extends PredisDistributorTestCase $expected1 = array_fill(0, 10, '127.0.0.1:7000'); $expected3 = array_fill(0, 10, '127.0.0.1:7001'); - $expected2 = array( + $expected2 = [ '127.0.0.1:7001', '127.0.0.1:7001', '127.0.0.1:7001', @@ -111,7 +111,7 @@ class HashRingTest extends PredisDistributorTestCase '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7000', - ); + ]; $ring->add('127.0.0.1:7000'); $actual1 = $this->getNodes($ring, 10); @@ -132,11 +132,11 @@ class HashRingTest extends PredisDistributorTestCase */ public function testGetByValue(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); $this->assertSame('127.0.0.1:7001', $ring->get('uid:256')); $this->assertSame('127.0.0.1:7001', $ring->get('uid:281')); @@ -151,11 +151,11 @@ class HashRingTest extends PredisDistributorTestCase */ public function testGetByHash(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); $this->assertSame('127.0.0.1:7001', $ring->getByHash(PHP_INT_SIZE == 4 ? -1249390087 : 3045577209)); // uid:256 $this->assertSame('127.0.0.1:7001', $ring->getByHash(PHP_INT_SIZE == 4 ? -1639106025 : 2655861271)); // uid:281 @@ -170,11 +170,11 @@ class HashRingTest extends PredisDistributorTestCase */ public function testGetBySlot(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); $this->assertSame('127.0.0.1:7001', $ring->getBySlot(PHP_INT_SIZE == 4 ? -1255075679 : 3039891617)); // uid:256 $this->assertSame('127.0.0.1:7001', $ring->getBySlot(PHP_INT_SIZE == 4 ? -1642314910 : 2652652386)); // uid:281 @@ -198,7 +198,7 @@ class HashRingTest extends PredisDistributorTestCase { $node = '127.0.0.1:7000'; $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable diff --git a/tests/Predis/Cluster/Distributor/KetamaRingTest.php b/tests/Predis/Cluster/Distributor/KetamaRingTest.php index 95876220..119d3a6f 100644 --- a/tests/Predis/Cluster/Distributor/KetamaRingTest.php +++ b/tests/Predis/Cluster/Distributor/KetamaRingTest.php @@ -58,13 +58,13 @@ class KetamaRingTest extends PredisDistributorTestCase */ public function testMultipleNodesInRing(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); - $expected = array( + $expected = [ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7000', @@ -85,7 +85,7 @@ class KetamaRingTest extends PredisDistributorTestCase '127.0.0.1:7002', '127.0.0.1:7001', '127.0.0.1:7002', - ); + ]; $actual = $this->getNodes($ring, 20); @@ -101,7 +101,7 @@ class KetamaRingTest extends PredisDistributorTestCase $expected1 = array_fill(0, 10, '127.0.0.1:7000'); $expected3 = array_fill(0, 10, '127.0.0.1:7001'); - $expected2 = array( + $expected2 = [ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7000', @@ -112,7 +112,7 @@ class KetamaRingTest extends PredisDistributorTestCase '127.0.0.1:7001', '127.0.0.1:7000', '127.0.0.1:7001', - ); + ]; $ring->add('127.0.0.1:7000'); $actual1 = $this->getNodes($ring, 10); @@ -133,11 +133,11 @@ class KetamaRingTest extends PredisDistributorTestCase */ public function testGetByValue(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); $this->assertSame('127.0.0.1:7001', $ring->get('uid:256')); $this->assertSame('127.0.0.1:7002', $ring->get('uid:281')); @@ -152,11 +152,11 @@ class KetamaRingTest extends PredisDistributorTestCase */ public function testGetByHash(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); $this->assertSame('127.0.0.1:7001', $ring->getByHash(PHP_INT_SIZE == 4 ? -591277534 : 3703689762)); // uid:256 $this->assertSame('127.0.0.1:7002', $ring->getByHash(PHP_INT_SIZE == 4 ? -1632011260 : 2662956036)); // uid:281 @@ -171,11 +171,11 @@ class KetamaRingTest extends PredisDistributorTestCase */ public function testGetBySlot(): void { - $ring = $this->getSampleDistribution(array( + $ring = $this->getSampleDistribution([ '127.0.0.1:7000', '127.0.0.1:7001', '127.0.0.1:7002', - )); + ]); $this->assertSame('127.0.0.1:7001', $ring->getBySlot(PHP_INT_SIZE == 4 ? -585685153 : 3709282143)); // uid:256 $this->assertSame('127.0.0.1:7002', $ring->getBySlot(PHP_INT_SIZE == 4 ? -1617239533 : 2677727763)); // uid:281 @@ -199,7 +199,7 @@ class KetamaRingTest extends PredisDistributorTestCase { $node = '127.0.0.1:7000'; $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable diff --git a/tests/Predis/Cluster/PredisStrategyTest.php b/tests/Predis/Cluster/PredisStrategyTest.php index 32acbf60..a698365f 100644 --- a/tests/Predis/Cluster/PredisStrategyTest.php +++ b/tests/Predis/Cluster/PredisStrategyTest.php @@ -71,7 +71,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key'); + $arguments = ['key']; foreach ($this->getExpectedCommands('keys-first') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -86,7 +86,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('{key}:1', '{key}:2', '{key}:3', '{key}:4'); + $arguments = ['{key}:1', '{key}:2', '{key}:3', '{key}:4']; foreach ($this->getExpectedCommands('keys-all') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -101,7 +101,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); + $arguments = ['{key}:1', 'value1', '{key}:2', 'value2']; foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -116,14 +116,14 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); + $arguments = ['{key}:1', 'value1', '{key}:2', 'value2']; $commandID = 'SORT'; - $command = $commands->create($commandID, array('{key}:1')); + $command = $commands->create($commandID, ['{key}:1']); $this->assertNotNull($strategy->getSlot($command), $commandID); - $command = $commands->create($commandID, array('{key}:1', array('STORE' => '{key}:2'))); + $command = $commands->create($commandID, ['{key}:1', ['STORE' => '{key}:2']]); $this->assertNotNull($strategy->getSlot($command), $commandID); } @@ -134,7 +134,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('{key}:1', '{key}:2', 10); + $arguments = ['{key}:1', '{key}:2', 10]; foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -149,7 +149,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('{key}:destination', ['{key}:1', '{key}:1'], [], 'sum'); + $arguments = ['{key}:destination', ['{key}:1', '{key}:1'], [], 'sum']; foreach ($this->getExpectedCommands('keys-zaggregated') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -164,7 +164,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('AND', '{key}:destination', '{key}:src:1', '{key}:src:2'); + $arguments = ['AND', '{key}:destination', '{key}:src:1', '{key}:src:2']; foreach ($this->getExpectedCommands('keys-bitop') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -181,10 +181,10 @@ class PredisStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); $commandID = 'GEORADIUS'; - $command = $commands->create($commandID, array('{key}:1', 10, 10, 1, 'km')); + $command = $commands->create($commandID, ['{key}:1', 10, 10, 1, 'km']); $this->assertNotNull($strategy->getSlot($command), $commandID); - $command = $commands->create($commandID, array('{key}:1', 10, 10, 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3')); + $command = $commands->create($commandID, ['{key}:1', 10, 10, 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3']); $this->assertNotNull($strategy->getSlot($command), $commandID); } @@ -197,10 +197,10 @@ class PredisStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); $commandID = 'GEORADIUSBYMEMBER'; - $command = $commands->create($commandID, array('{key}:1', 'member', 1, 'km')); + $command = $commands->create($commandID, ['{key}:1', 'member', 1, 'km']); $this->assertNotNull($strategy->getSlot($command), $commandID); - $command = $commands->create($commandID, array('{key}:1', 'member', 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3')); + $command = $commands->create($commandID, ['{key}:1', 'member', 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3']); $this->assertNotNull($strategy->getSlot($command), $commandID); } @@ -211,7 +211,7 @@ class PredisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('%SCRIPT%', 2, '{key}:1', '{key}:2', 'value1', 'value2'); + $arguments = ['%SCRIPT%', 2, '{key}:1', '{key}:2', 'value1', 'value2']; foreach ($this->getExpectedCommands('keys-script') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -225,11 +225,11 @@ class PredisStrategyTest extends PredisTestCase public function testKeysForScriptCommand(): void { $strategy = $this->getClusterStrategy(); - $arguments = array('{key}:1', '{key}:2', 'value1', 'value2'); + $arguments = ['{key}:1', '{key}:2', 'value1', 'value2']; /** @var \Predis\Command\CommandInterface|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) @@ -256,10 +256,10 @@ class PredisStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); - $command = $commands->create('set', array('key', 'value')); + $command = $commands->create('set', ['key', 'value']); $this->assertNull($strategy->getSlot($command)); - $command = $commands->create('get', array('key')); + $command = $commands->create('get', ['key']); $this->assertNull($strategy->getSlot($command)); } @@ -269,7 +269,7 @@ class PredisStrategyTest extends PredisTestCase public function testSettingCustomCommandHandler(): void { $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -282,7 +282,7 @@ class PredisStrategyTest extends PredisTestCase $strategy->setCommandHandler('get', $callable); $commands = $this->getCommandFactory(); - $command = $commands->create('get', array('key')); + $command = $commands->create('get', ['key']); $this->assertNotNull($strategy->getSlot($command)); } @@ -315,7 +315,7 @@ class PredisStrategyTest extends PredisTestCase */ protected function getExpectedCommands(?string $type = null): array { - $commands = array( + $commands = [ /* commands operating on the key space */ 'EXISTS' => 'keys-all', 'DEL' => 'keys-all', @@ -447,7 +447,7 @@ class PredisStrategyTest extends PredisTestCase 'GEODIST' => 'keys-first', 'GEORADIUS' => 'keys-georadius', 'GEORADIUSBYMEMBER' => 'keys-georadius', - ); + ]; if (isset($type)) { $commands = array_filter($commands, function (string $expectedType) use ($type) { diff --git a/tests/Predis/Cluster/RedisStrategyTest.php b/tests/Predis/Cluster/RedisStrategyTest.php index 9299ab0b..f3e2661b 100644 --- a/tests/Predis/Cluster/RedisStrategyTest.php +++ b/tests/Predis/Cluster/RedisStrategyTest.php @@ -69,7 +69,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key'); + $arguments = ['key']; foreach ($this->getExpectedCommands('keys-first') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -84,7 +84,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key'); + $arguments = ['key']; foreach ($this->getExpectedCommands('keys-all') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -99,7 +99,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key1', 'key2'); + $arguments = ['key1', 'key2']; foreach ($this->getExpectedCommands('keys-all') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -114,7 +114,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key:1', 'value1'); + $arguments = ['key:1', 'value1']; foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -129,7 +129,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key:1', 'value1', 'key:2', 'value2'); + $arguments = ['key:1', 'value1', 'key:2', 'value2']; foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -144,14 +144,14 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); + $arguments = ['{key}:1', 'value1', '{key}:2', 'value2']; $commandID = 'SORT'; - $command = $commands->create($commandID, array('{key}:1')); + $command = $commands->create($commandID, ['{key}:1']); $this->assertNotNull($strategy->getSlot($command), $commandID); - $command = $commands->create($commandID, array('{key}:1', array('STORE' => '{key}:2'))); + $command = $commands->create($commandID, ['{key}:1', ['STORE' => '{key}:2']]); $this->assertNotNull($strategy->getSlot($command), $commandID); } @@ -162,7 +162,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key:1', 10); + $arguments = ['key:1', 10]; foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -177,7 +177,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('key:1', 'key:2', 10); + $arguments = ['key:1', 'key:2', 10]; foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -195,10 +195,10 @@ class RedisStrategyTest extends PredisTestCase $commandID = 'GEORADIUS'; - $command = $commands->create($commandID, array('{key}:1', 10, 10, 1, 'km')); + $command = $commands->create($commandID, ['{key}:1', 10, 10, 1, 'km']); $this->assertNotNull($strategy->getSlot($command), $commandID); - $command = $commands->create($commandID, array('{key}:1', 10, 10, 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3')); + $command = $commands->create($commandID, ['{key}:1', 10, 10, 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3']); $this->assertNotNull($strategy->getSlot($command), $commandID); } @@ -212,10 +212,10 @@ class RedisStrategyTest extends PredisTestCase $commandID = 'GEORADIUSBYMEMBER'; - $command = $commands->create($commandID, array('{key}:1', 'member', 1, 'km')); + $command = $commands->create($commandID, ['{key}:1', 'member', 1, 'km']); $this->assertNotNull($strategy->getSlot($command), $commandID); - $command = $commands->create($commandID, array('{key}:1', 'member', 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3')); + $command = $commands->create($commandID, ['{key}:1', 'member', 1, 'km', 'store', '{key}:2', 'storedist', '{key}:3']); $this->assertNotNull($strategy->getSlot($command), $commandID); } @@ -226,7 +226,7 @@ class RedisStrategyTest extends PredisTestCase { $strategy = $this->getClusterStrategy(); $commands = $this->getCommandFactory(); - $arguments = array('%SCRIPT%', 1, 'key:1', 'value1'); + $arguments = ['%SCRIPT%', 1, 'key:1', 'value1']; foreach ($this->getExpectedCommands('keys-script') as $commandID) { $command = $commands->create($commandID, $arguments); @@ -240,11 +240,11 @@ class RedisStrategyTest extends PredisTestCase public function testKeysForScriptCommand(): void { $strategy = $this->getClusterStrategy(); - $arguments = array('key:1', 'value1'); + $arguments = ['key:1', 'value1']; /** @var \Predis\Command\CommandInterface|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) @@ -270,10 +270,10 @@ class RedisStrategyTest extends PredisTestCase $strategy->setCommandHandler('get', null); $commands = $this->getCommandFactory(); - $command = $commands->create('set', array('key', 'value')); + $command = $commands->create('set', ['key', 'value']); $this->assertNull($strategy->getSlot($command)); - $command = $commands->create('get', array('key')); + $command = $commands->create('get', ['key']); $this->assertNull($strategy->getSlot($command)); } @@ -283,7 +283,7 @@ class RedisStrategyTest extends PredisTestCase public function testSettingCustomCommandHandler(): void { $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -296,7 +296,7 @@ class RedisStrategyTest extends PredisTestCase $strategy->setCommandHandler('get', $callable); $commands = $this->getCommandFactory(); - $command = $commands->create('get', array('key')); + $command = $commands->create('get', ['key']); $this->assertNotNull($strategy->getSlot($command)); } @@ -338,7 +338,7 @@ class RedisStrategyTest extends PredisTestCase */ protected function getExpectedCommands(?string $type = null): array { - $commands = array( + $commands = [ /* commands operating on the key space */ 'EXISTS' => 'keys-all', 'DEL' => 'keys-all', @@ -470,7 +470,7 @@ class RedisStrategyTest extends PredisTestCase 'GEODIST' => 'keys-first', 'GEORADIUS' => 'keys-georadius', 'GEORADIUSBYMEMBER' => 'keys-georadius', - ); + ]; if (isset($type)) { $commands = array_filter($commands, function (string $expectedType) use ($type) { diff --git a/tests/Predis/Cluster/SlotMapTest.php b/tests/Predis/Cluster/SlotMapTest.php index 80fc5425..6be35786 100644 --- a/tests/Predis/Cluster/SlotMapTest.php +++ b/tests/Predis/Cluster/SlotMapTest.php @@ -117,7 +117,7 @@ class SlotMapTest extends PredisTestCase $slotmap->setSlots(10, 10, '127.0.0.1:6379'); - $this->assertSame(array(10 => '127.0.0.1:6379'), $slotmap->toArray()); + $this->assertSame([10 => '127.0.0.1:6379'], $slotmap->toArray()); } /** @@ -135,7 +135,7 @@ class SlotMapTest extends PredisTestCase $slotmap->setSlots(10, 10, $connection); - $this->assertSame(array(10 => '127.0.0.1:6379'), $slotmap->toArray()); + $this->assertSame([10 => '127.0.0.1:6379'], $slotmap->toArray()); } /** @@ -171,13 +171,13 @@ class SlotMapTest extends PredisTestCase $slotmap->setSlots(0, 5, '127.0.0.1:6379'); $slotmap->setSlots(10, 13, '127.0.0.1:6380'); - $expectedMap = array( + $expectedMap = [ 3 => '127.0.0.1:6379', 4 => '127.0.0.1:6379', 5 => '127.0.0.1:6379', 10 => '127.0.0.1:6380', 11 => '127.0.0.1:6380', - ); + ]; $this->assertSame($expectedMap, $slotmap->getSlots(3, 11)); } @@ -296,7 +296,7 @@ class SlotMapTest extends PredisTestCase $slotmap->setSlots(5461, 10922, '127.0.0.1:6380'); $slotmap->setSlots(10923, 16383, '127.0.0.1:6381'); - $this->assertSame(array('127.0.0.1:6379', '127.0.0.1:6380', '127.0.0.1:6381'), $slotmap->getNodes()); + $this->assertSame(['127.0.0.1:6379', '127.0.0.1:6380', '127.0.0.1:6381'], $slotmap->getNodes()); } /** diff --git a/tests/Predis/Collection/Iterator/HashKeyTest.php b/tests/Predis/Collection/Iterator/HashKeyTest.php index c1b23245..bc0b8b99 100644 --- a/tests/Predis/Collection/Iterator/HashKeyTest.php +++ b/tests/Predis/Collection/Iterator/HashKeyTest.php @@ -50,8 +50,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -60,10 +60,10 @@ class HashKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('hscan') - ->with('key:hash', 0, array()) + ->with('key:hash', 0, []) ->willReturn( - array(0, array(), - )); + [0, [], + ]); $iterator = new HashKey($client, 'key:hash'); @@ -80,8 +80,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -90,9 +90,9 @@ class HashKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('hscan') - ->with('key:hash', 0, array()) + ->with('key:hash', 0, []) ->willReturn( - array(0, array(1 => 'a', 2 => 'b', 3 => 100, 'foo' => 'bar')) + [0, [1 => 'a', 2 => 'b', 3 => 100, 'foo' => 'bar']] ); $iterator = new HashKey($client, 'key:hash'); @@ -128,8 +128,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -138,9 +138,9 @@ class HashKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('hscan') - ->with('key:hash', 0, array()) + ->with('key:hash', 0, []) ->willReturn( - array(0, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', 'field:3rd' => 'value:3rd')) + [0, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', 'field:3rd' => 'value:3rd']] ); $iterator = new HashKey($client, 'key:hash'); @@ -171,8 +171,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -182,12 +182,12 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array()), - array('key:hash', 2, array()) + ['key:hash', 0, []], + ['key:hash', 2, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')), - array(0, array('field:3rd' => 'value:3rd')) + [2, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']], + [0, ['field:3rd' => 'value:3rd']] ); $iterator = new HashKey($client, 'key:hash'); @@ -218,8 +218,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -229,12 +229,12 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array()), - array('key:hash', 4, array()) + ['key:hash', 0, []], + ['key:hash', 4, []] ) ->willReturnOnConsecutiveCalls( - array(4, array()), - array(0, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')) + [4, []], + [0, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash'); @@ -260,8 +260,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -271,14 +271,14 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(3)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array()), - array('key:hash', 2, array()), - array('key:hash', 5, array()) + ['key:hash', 0, []], + ['key:hash', 2, []], + ['key:hash', 5, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')), - array(5, array()), - array(0, array('field:3rd' => 'value:3rd')) + [2, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']], + [5, []], + [0, ['field:3rd' => 'value:3rd']] ); $iterator = new HashKey($client, 'key:hash'); @@ -309,8 +309,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -320,12 +320,12 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array('MATCH' => 'field:*')), - array('key:hash', 2, array('MATCH' => 'field:*')) + ['key:hash', 0, ['MATCH' => 'field:*']], + ['key:hash', 2, ['MATCH' => 'field:*']] ) ->willReturn( - array(2, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')), - array(0, array()) + [2, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']], + [0, []] ); $iterator = new HashKey($client, 'key:hash', 'field:*'); @@ -351,8 +351,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -362,12 +362,12 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array('MATCH' => 'field:*')), - array('key:hash', 1, array('MATCH' => 'field:*')) + ['key:hash', 0, ['MATCH' => 'field:*']], + ['key:hash', 1, ['MATCH' => 'field:*']] ) ->willReturn( - array(1, array('field:1st' => 'value:1st')), - array(0, array('field:2nd' => 'value:2nd')) + [1, ['field:1st' => 'value:1st']], + [0, ['field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash', 'field:*'); @@ -393,8 +393,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -404,10 +404,10 @@ class HashKeyTest extends PredisTestCase ->expects($this->once()) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array('COUNT' => 2)) + ['key:hash', 0, ['COUNT' => 2]] ) ->willReturn( - array(0, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')) + [0, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash', null, 2); @@ -433,8 +433,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -444,12 +444,12 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array('COUNT' => 1)), - array('key:hash', 1, array('COUNT' => 1)) + ['key:hash', 0, ['COUNT' => 1]], + ['key:hash', 1, ['COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('field:1st' => 'value:1st')), - array(0, array('field:2nd' => 'value:2nd')) + [1, ['field:1st' => 'value:1st']], + [0, ['field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash', null, 1); @@ -475,8 +475,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -486,10 +486,10 @@ class HashKeyTest extends PredisTestCase ->expects($this->once(1)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 2)) + ['key:hash', 0, ['MATCH' => 'field:*', 'COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')) + [0, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash', 'field:*', 2); @@ -515,8 +515,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -526,12 +526,12 @@ class HashKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('hscan') ->withConsecutive( - array('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 1)), - array('key:hash', 1, array('MATCH' => 'field:*', 'COUNT' => 1)) + ['key:hash', 0, ['MATCH' => 'field:*', 'COUNT' => 1]], + ['key:hash', 1, ['MATCH' => 'field:*', 'COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('field:1st' => 'value:1st')), - array(0, array('field:2nd' => 'value:2nd')) + [1, ['field:1st' => 'value:1st']], + [0, ['field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash', 'field:*', 1); @@ -557,8 +557,8 @@ class HashKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('hscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['hscan']) ->getMock(); $client ->expects($this->any()) @@ -567,9 +567,9 @@ class HashKeyTest extends PredisTestCase $client ->expects($this->exactly(2)) ->method('hscan') - ->with('key:hash', 0, array()) + ->with('key:hash', 0, []) ->willReturn( - array(0, array('field:1st' => 'value:1st', 'field:2nd' => 'value:2nd')) + [0, ['field:1st' => 'value:1st', 'field:2nd' => 'value:2nd']] ); $iterator = new HashKey($client, 'key:hash'); diff --git a/tests/Predis/Collection/Iterator/KeyspaceTest.php b/tests/Predis/Collection/Iterator/KeyspaceTest.php index 028c04c5..d3fb12c7 100644 --- a/tests/Predis/Collection/Iterator/KeyspaceTest.php +++ b/tests/Predis/Collection/Iterator/KeyspaceTest.php @@ -50,8 +50,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -60,9 +60,9 @@ class KeyspaceTest extends PredisTestCase $client ->expects($this->once()) ->method('scan') - ->with(0, array()) + ->with(0, []) ->willReturn( - array(0, array()) + [0, []] ); $iterator = new Keyspace($client); @@ -78,8 +78,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -88,9 +88,9 @@ class KeyspaceTest extends PredisTestCase $client ->expects($this->once()) ->method('scan') - ->with(0, array()) + ->with(0, []) ->willReturn( - array(0, array('key:1st', 'key:2nd', 'key:3rd')) + [0, ['key:1st', 'key:2nd', 'key:3rd']] ); $iterator = new Keyspace($client); @@ -121,8 +121,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -132,12 +132,12 @@ class KeyspaceTest extends PredisTestCase ->expects($this->exactly(2)) ->method('scan') ->withConsecutive( - array(0, array()), - array(2, array()) + [0, []], + [2, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('key:1st', 'key:2nd')), - array(0, array('key:3rd')) + [2, ['key:1st', 'key:2nd']], + [0, ['key:3rd']] ); $iterator = new Keyspace($client); @@ -168,8 +168,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -179,12 +179,12 @@ class KeyspaceTest extends PredisTestCase ->expects($this->exactly(2)) ->method('scan') ->withConsecutive( - array(0, array()), - array(4, array()) + [0, []], + [4, []] ) ->willReturnOnConsecutiveCalls( - array(4, array()), - array(0, array('key:1st', 'key:2nd')) + [4, []], + [0, ['key:1st', 'key:2nd']] ); $iterator = new Keyspace($client); @@ -210,8 +210,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -221,14 +221,14 @@ class KeyspaceTest extends PredisTestCase ->expects($this->exactly(3)) ->method('scan') ->withConsecutive( - array(0, array()), - array(2, array()), - array(5, array()) + [0, []], + [2, []], + [5, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('key:1st', 'key:2nd')), - array(5, array()), - array(0, array('key:3rd')) + [2, ['key:1st', 'key:2nd']], + [5, []], + [0, ['key:3rd']] ); $iterator = new Keyspace($client); @@ -259,8 +259,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -270,10 +270,10 @@ class KeyspaceTest extends PredisTestCase ->expects($this->once()) ->method('scan') ->withConsecutive( - array(0, array('MATCH' => 'key:*')) + [0, ['MATCH' => 'key:*']] ) ->willReturnOnConsecutiveCalls( - array(0, array('key:1st', 'key:2nd')) + [0, ['key:1st', 'key:2nd']] ); $iterator = new Keyspace($client, 'key:*'); @@ -299,8 +299,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -310,12 +310,12 @@ class KeyspaceTest extends PredisTestCase ->expects($this->exactly(2)) ->method('scan') ->withConsecutive( - array(0, array('MATCH' => 'key:*')), - array(1, array('MATCH' => 'key:*')) + [0, ['MATCH' => 'key:*']], + [1, ['MATCH' => 'key:*']] ) ->willReturnOnConsecutiveCalls( - array(1, array('key:1st')), - array(0, array('key:2nd')) + [1, ['key:1st']], + [0, ['key:2nd']] ); $iterator = new Keyspace($client, 'key:*'); @@ -341,8 +341,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -352,10 +352,10 @@ class KeyspaceTest extends PredisTestCase ->expects($this->once()) ->method('scan') ->withConsecutive( - array(0, array('COUNT' => 2)) + [0, ['COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('key:1st', 'key:2nd')) + [0, ['key:1st', 'key:2nd']] ); $iterator = new Keyspace($client, null, 2); @@ -381,8 +381,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -394,12 +394,12 @@ class KeyspaceTest extends PredisTestCase ->expects($this->exactly(2)) ->method('scan') ->withConsecutive( - array(0, array('COUNT' => 1)), - array(1, array('COUNT' => 1)) + [0, ['COUNT' => 1]], + [1, ['COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('key:1st')), - array(0, array('key:2nd')) + [1, ['key:1st']], + [0, ['key:2nd']] ); $iterator = new Keyspace($client, null, 1); @@ -425,8 +425,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -436,10 +436,10 @@ class KeyspaceTest extends PredisTestCase ->expects($this->once()) ->method('scan') ->withConsecutive( - array(0, array('MATCH' => 'key:*', 'COUNT' => 2)) + [0, ['MATCH' => 'key:*', 'COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('key:1st', 'key:2nd')) + [0, ['key:1st', 'key:2nd']] ); $iterator = new Keyspace($client, 'key:*', 2); @@ -465,8 +465,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -478,12 +478,12 @@ class KeyspaceTest extends PredisTestCase ->expects($this->exactly(2)) ->method('scan') ->withConsecutive( - array(0, array('MATCH' => 'key:*', 'COUNT' => 1)), - array(1, array('MATCH' => 'key:*', 'COUNT' => 1)) + [0, ['MATCH' => 'key:*', 'COUNT' => 1]], + [1, ['MATCH' => 'key:*', 'COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('key:1st')), - array(0, array('key:2nd')) + [1, ['key:1st']], + [0, ['key:2nd']] ); $iterator = new Keyspace($client, 'key:*', 1); @@ -509,8 +509,8 @@ class KeyspaceTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('scan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['scan']) ->getMock(); $client ->expects($this->any()) @@ -519,9 +519,9 @@ class KeyspaceTest extends PredisTestCase $client ->expects($this->exactly(2)) ->method('scan') - ->with(0, array()) + ->with(0, []) ->willReturn( - array(0, array('key:1st', 'key:2nd')) + [0, ['key:1st', 'key:2nd']] ); $iterator = new Keyspace($client); diff --git a/tests/Predis/Collection/Iterator/ListKeyTest.php b/tests/Predis/Collection/Iterator/ListKeyTest.php index fb5eeed9..0b2a1fb6 100644 --- a/tests/Predis/Collection/Iterator/ListKeyTest.php +++ b/tests/Predis/Collection/Iterator/ListKeyTest.php @@ -35,8 +35,8 @@ class ListKeyTest extends PredisTestCase /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -53,8 +53,8 @@ class ListKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -65,7 +65,7 @@ class ListKeyTest extends PredisTestCase ->method('lrange') ->with('key:list', 0, 9) ->willReturn( - array() + [] ); $iterator = new ListKey($client, 'key:list'); @@ -81,8 +81,8 @@ class ListKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -93,7 +93,7 @@ class ListKeyTest extends PredisTestCase ->method('lrange') ->with('key:list', 0, 9) ->willReturn( - array('item:1', 'item:2', 'item:3') + ['item:1', 'item:2', 'item:3'] ); $iterator = new ListKey($client, 'key:list'); @@ -124,8 +124,8 @@ class ListKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -135,15 +135,15 @@ class ListKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('lrange') ->withConsecutive( - array('key:list', 0, 9), - array('key:list', 10, 19) + ['key:list', 0, 9], + ['key:list', 10, 19] ) ->willReturnOnConsecutiveCalls( - array( + [ 'item:1', 'item:2', 'item:3', 'item:4', 'item:5', 'item:6', 'item:7', 'item:8', 'item:9', 'item:10', - ), - array('item:11', 'item:12') + ], + ['item:11', 'item:12'] ); $iterator = new ListKey($client, 'key:list'); @@ -167,7 +167,7 @@ class ListKeyTest extends PredisTestCase /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) + ->onlyMethods(['getCommandFactory']) ->getMock(); $client ->expects($this->any()) @@ -187,7 +187,7 @@ class ListKeyTest extends PredisTestCase /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) + ->onlyMethods(['getCommandFactory']) ->getMock(); $client ->expects($this->any()) @@ -204,8 +204,8 @@ class ListKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -216,7 +216,7 @@ class ListKeyTest extends PredisTestCase ->method('lrange') ->with('key:list', 0, 4) ->willReturn( - array('item:1', 'item:2') + ['item:1', 'item:2'] ); $iterator = new ListKey($client, 'key:list', 5); @@ -242,8 +242,8 @@ class ListKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -253,12 +253,12 @@ class ListKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('lrange') ->withConsecutive( - array('key:list', 0, 1), - array('key:list', 2, 3) + ['key:list', 0, 1], + ['key:list', 2, 3] ) ->willReturnOnConsecutiveCalls( - array('item:1', 'item:2'), - array('item:3') + ['item:1', 'item:2'], + ['item:3'] ); $iterator = new ListKey($client, 'key:list', 2); @@ -289,8 +289,8 @@ class ListKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('lrange')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['lrange']) ->getMock(); $client ->expects($this->any()) @@ -301,7 +301,7 @@ class ListKeyTest extends PredisTestCase ->method('lrange') ->with('key:list', 0, 9) ->willReturn( - array('item:1', 'item:2') + ['item:1', 'item:2'] ); $iterator = new ListKey($client, 'key:list'); diff --git a/tests/Predis/Collection/Iterator/SetKeyTest.php b/tests/Predis/Collection/Iterator/SetKeyTest.php index e104dd46..48a5d8d2 100644 --- a/tests/Predis/Collection/Iterator/SetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SetKeyTest.php @@ -50,8 +50,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -60,9 +60,9 @@ class SetKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('sscan') - ->with('key:set', 0, array()) + ->with('key:set', 0, []) ->willReturn( - array(0, array()) + [0, []] ); $iterator = new SetKey($client, 'key:set'); @@ -78,8 +78,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -88,9 +88,9 @@ class SetKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('sscan') - ->with('key:set', 0, array()) + ->with('key:set', 0, []) ->willReturn( - array(0, array('member:1st', 'member:2nd', 'member:3rd')) + [0, ['member:1st', 'member:2nd', 'member:3rd']] ); $iterator = new SetKey($client, 'key:set'); @@ -121,8 +121,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -132,12 +132,12 @@ class SetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('sscan') ->withConsecutive( - array('key:set', 0, array()), - array('key:set', 2, array()) + ['key:set', 0, []], + ['key:set', 2, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('member:1st', 'member:2nd')), - array(0, array('member:3rd')) + [2, ['member:1st', 'member:2nd']], + [0, ['member:3rd']] ); $iterator = new SetKey($client, 'key:set'); @@ -168,8 +168,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -179,12 +179,12 @@ class SetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('sscan') ->withConsecutive( - array('key:set', 0, array()), - array('key:set', 4, array()) + ['key:set', 0, []], + ['key:set', 4, []] ) ->willReturnOnConsecutiveCalls( - array(4, array()), - array(0, array('member:1st', 'member:2nd')) + [4, []], + [0, ['member:1st', 'member:2nd']] ); $iterator = new SetKey($client, 'key:set'); @@ -210,8 +210,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -221,14 +221,14 @@ class SetKeyTest extends PredisTestCase ->expects($this->exactly(3)) ->method('sscan') ->withConsecutive( - array('key:set', 0, array()), - array('key:set', 2, array()), - array('key:set', 5, array()) + ['key:set', 0, []], + ['key:set', 2, []], + ['key:set', 5, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('member:1st', 'member:2nd')), - array(5, array()), - array(0, array('member:3rd')) + [2, ['member:1st', 'member:2nd']], + [5, []], + [0, ['member:3rd']] ); $iterator = new SetKey($client, 'key:set'); @@ -259,8 +259,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -270,10 +270,10 @@ class SetKeyTest extends PredisTestCase ->expects($this->once()) ->method('sscan') ->withConsecutive( - array('key:set', 0, array('MATCH' => 'member:*')) + ['key:set', 0, ['MATCH' => 'member:*']] ) ->willReturnOnConsecutiveCalls( - array(0, array('member:1st', 'member:2nd')) + [0, ['member:1st', 'member:2nd']] ); $iterator = new SetKey($client, 'key:set', 'member:*'); @@ -299,8 +299,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -310,12 +310,12 @@ class SetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('sscan') ->withConsecutive( - array('key:set', 0, array('MATCH' => 'member:*')), - array('key:set', 1, array('MATCH' => 'member:*')) + ['key:set', 0, ['MATCH' => 'member:*']], + ['key:set', 1, ['MATCH' => 'member:*']] ) ->willReturnOnConsecutiveCalls( - array(1, array('member:1st')), - array(0, array('member:2nd')) + [1, ['member:1st']], + [0, ['member:2nd']] ); $iterator = new SetKey($client, 'key:set', 'member:*'); @@ -341,8 +341,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -352,10 +352,10 @@ class SetKeyTest extends PredisTestCase ->expects($this->once()) ->method('sscan') ->withConsecutive( - array('key:set', 0, array('COUNT' => 2)) + ['key:set', 0, ['COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('member:1st', 'member:2nd')) + [0, ['member:1st', 'member:2nd']] ); $iterator = new SetKey($client, 'key:set', null, 2); @@ -381,8 +381,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -392,12 +392,12 @@ class SetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('sscan') ->withConsecutive( - array('key:set', 0, array('COUNT' => 1)), - array('key:set', 1, array('COUNT' => 1)) + ['key:set', 0, ['COUNT' => 1]], + ['key:set', 1, ['COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('member:1st')), - array(0, array('member:2nd')) + [1, ['member:1st']], + [0, ['member:2nd']] ); $iterator = new SetKey($client, 'key:set', null, 1); @@ -423,8 +423,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -434,10 +434,10 @@ class SetKeyTest extends PredisTestCase ->expects($this->once()) ->method('sscan') ->withConsecutive( - array('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) + ['key:set', 0, ['MATCH' => 'member:*', 'COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('member:1st', 'member:2nd')) + [0, ['member:1st', 'member:2nd']] ); $iterator = new SetKey($client, 'key:set', 'member:*', 2); @@ -463,8 +463,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -474,12 +474,12 @@ class SetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('sscan') ->withConsecutive( - array('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 1)), - array('key:set', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) + ['key:set', 0, ['MATCH' => 'member:*', 'COUNT' => 1]], + ['key:set', 1, ['MATCH' => 'member:*', 'COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('member:1st')), - array(0, array('member:2nd')) + [1, ['member:1st']], + [0, ['member:2nd']] ); $iterator = new SetKey($client, 'key:set', 'member:*', 1); @@ -505,8 +505,8 @@ class SetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('sscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['sscan']) ->getMock(); $client ->expects($this->any()) @@ -515,9 +515,9 @@ class SetKeyTest extends PredisTestCase $client ->expects($this->exactly(2)) ->method('sscan') - ->with('key:set', 0, array()) + ->with('key:set', 0, []) ->willReturn( - array(0, array('member:1st', 'member:2nd')) + [0, ['member:1st', 'member:2nd']] ); $iterator = new SetKey($client, 'key:set'); diff --git a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php index 56dc1e2e..a397b9e0 100644 --- a/tests/Predis/Collection/Iterator/SortedSetKeyTest.php +++ b/tests/Predis/Collection/Iterator/SortedSetKeyTest.php @@ -51,8 +51,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -61,9 +61,9 @@ class SortedSetKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('zscan') - ->with('key:zset', 0, array()) + ->with('key:zset', 0, []) ->willReturn( - array(0, array()) + [0, []] ); $iterator = new SortedSetKey($client, 'key:zset'); @@ -80,8 +80,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -90,9 +90,9 @@ class SortedSetKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('zscan') - ->with('key:zset', 0, array()) + ->with('key:zset', 0, []) ->willReturn( - array(0, array(0 => 0, 101 => 1, 102 => 2)) + [0, [0 => 0, 101 => 1, 102 => 2]] ); $iterator = new SortedSetKey($client, 'key:zset'); @@ -123,8 +123,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -133,9 +133,9 @@ class SortedSetKeyTest extends PredisTestCase $client ->expects($this->once()) ->method('zscan') - ->with('key:zset', 0, array()) + ->with('key:zset', 0, []) ->willReturn( - array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0, 'member:3rd' => 3.0)) + [0, ['member:1st' => 1.0, 'member:2nd' => 2.0, 'member:3rd' => 3.0]] ); $iterator = new SortedSetKey($client, 'key:zset'); @@ -166,8 +166,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -177,12 +177,12 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array()), - array('key:zset', 2, array()) + ['key:zset', 0, []], + ['key:zset', 2, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0)), - array(0, array('member:3rd' => 3.0)) + [2, ['member:1st' => 1.0, 'member:2nd' => 2.0]], + [0, ['member:3rd' => 3.0]] ); $iterator = new SortedSetKey($client, 'key:zset'); @@ -213,8 +213,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -224,12 +224,12 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array()), - array('key:zset', 4, array()) + ['key:zset', 0, []], + ['key:zset', 4, []] ) ->willReturnOnConsecutiveCalls( - array(4, array()), - array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0)) + [4, []], + [0, ['member:1st' => 1.0, 'member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset'); @@ -255,8 +255,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -266,14 +266,14 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(3)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array()), - array('key:zset', 2, array()), - array('key:zset', 5, array()) + ['key:zset', 0, []], + ['key:zset', 2, []], + ['key:zset', 5, []] ) ->willReturnOnConsecutiveCalls( - array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0)), - array(5, array()), - array(0, array('member:3rd' => 3.0)) + [2, ['member:1st' => 1.0, 'member:2nd' => 2.0]], + [5, []], + [0, ['member:3rd' => 3.0]] ); $iterator = new SortedSetKey($client, 'key:zset'); @@ -304,8 +304,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -315,12 +315,12 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array('MATCH' => 'member:*')), - array('key:zset', 2, array('MATCH' => 'member:*')) + ['key:zset', 0, ['MATCH' => 'member:*']], + ['key:zset', 2, ['MATCH' => 'member:*']] ) ->willReturnOnConsecutiveCalls( - array(2, array('member:1st' => 1.0, 'member:2nd' => 2.0)), - array(0, array()) + [2, ['member:1st' => 1.0, 'member:2nd' => 2.0]], + [0, []] ); $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); @@ -346,8 +346,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -357,12 +357,12 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array('MATCH' => 'member:*')), - array('key:zset', 1, array('MATCH' => 'member:*')) + ['key:zset', 0, ['MATCH' => 'member:*']], + ['key:zset', 1, ['MATCH' => 'member:*']] ) ->willReturnOnConsecutiveCalls( - array(1, array('member:1st' => 1.0)), - array(0, array('member:2nd' => 2.0)) + [1, ['member:1st' => 1.0]], + [0, ['member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); @@ -388,8 +388,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -399,10 +399,10 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->once()) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array('COUNT' => 2)) + ['key:zset', 0, ['COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0)) + [0, ['member:1st' => 1.0, 'member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset', null, 2); @@ -428,8 +428,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -439,12 +439,12 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array('COUNT' => 1)), - array('key:zset', 1, array('COUNT' => 1)) + ['key:zset', 0, ['COUNT' => 1]], + ['key:zset', 1, ['COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('member:1st' => 1.0)), - array(0, array('member:2nd' => 2.0)) + [1, ['member:1st' => 1.0]], + [0, ['member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset', null, 1); @@ -470,8 +470,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -481,10 +481,10 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->once()) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) + ['key:zset', 0, ['MATCH' => 'member:*', 'COUNT' => 2]] ) ->willReturnOnConsecutiveCalls( - array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0)) + [0, ['member:1st' => 1.0, 'member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 2); @@ -510,8 +510,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -521,12 +521,12 @@ class SortedSetKeyTest extends PredisTestCase ->expects($this->exactly(2)) ->method('zscan') ->withConsecutive( - array('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 1)), - array('key:zset', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) + ['key:zset', 0, ['MATCH' => 'member:*', 'COUNT' => 1]], + ['key:zset', 1, ['MATCH' => 'member:*', 'COUNT' => 1]] ) ->willReturnOnConsecutiveCalls( - array(1, array('member:1st' => 1.0)), - array(0, array('member:2nd' => 2.0)) + [1, ['member:1st' => 1.0]], + [0, ['member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 1); @@ -552,8 +552,8 @@ class SortedSetKeyTest extends PredisTestCase { /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('getCommandFactory')) - ->addMethods(array('zscan')) + ->onlyMethods(['getCommandFactory']) + ->addMethods(['zscan']) ->getMock(); $client ->expects($this->any()) @@ -562,9 +562,9 @@ class SortedSetKeyTest extends PredisTestCase $client ->expects($this->exactly(2)) ->method('zscan') - ->with('key:zset', 0, array()) + ->with('key:zset', 0, []) ->willReturn( - array(0, array('member:1st' => 1.0, 'member:2nd' => 2.0)) + [0, ['member:1st' => 1.0, 'member:2nd' => 2.0]] ); $iterator = new SortedSetKey($client, 'key:zset'); diff --git a/tests/Predis/Command/CommandTest.php b/tests/Predis/Command/CommandTest.php index feb1257f..b7c838ca 100644 --- a/tests/Predis/Command/CommandTest.php +++ b/tests/Predis/Command/CommandTest.php @@ -44,7 +44,7 @@ class CommandTest extends PredisTestCase */ public function testSetRawArguments(): void { - $arguments = array('1st', '2nd', '3rd'); + $arguments = ['1st', '2nd', '3rd']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -60,7 +60,7 @@ class CommandTest extends PredisTestCase */ public function testSetArguments(): void { - $arguments = array('1st', '2nd', '3rd'); + $arguments = ['1st', '2nd', '3rd']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setArguments($arguments); @@ -73,7 +73,7 @@ class CommandTest extends PredisTestCase */ public function testGetArgumentAtIndex(): void { - $arguments = array('1st', '2nd', '3rd'); + $arguments = ['1st', '2nd', '3rd']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setArguments($arguments); @@ -102,18 +102,18 @@ class CommandTest extends PredisTestCase $slot = 1024; $command = $this->getMockForAbstractClass('Predis\Command\Command'); - $command->setRawArguments(array('key')); + $command->setRawArguments(['key']); $this->assertNull($command->getSlot()); $command->setSlot($slot); $this->assertSame($slot, $command->getSlot()); - $command->setArguments(array('key')); + $command->setArguments(['key']); $this->assertNull($command->getSlot()); $command->setSlot($slot); - $command->setRawArguments(array('key')); + $command->setRawArguments(['key']); $this->assertNull($command->getSlot()); } @@ -122,15 +122,15 @@ class CommandTest extends PredisTestCase */ public function testNormalizeArguments(): void { - $arguments = array('arg1', 'arg2', 'arg3', 'arg4'); + $arguments = ['arg1', 'arg2', 'arg3', 'arg4']; $this->assertSame($arguments, Command::normalizeArguments($arguments)); - $this->assertSame($arguments, Command::normalizeArguments(array($arguments))); + $this->assertSame($arguments, Command::normalizeArguments([$arguments])); - $arguments = array(array(), array()); + $arguments = [[], []]; $this->assertSame($arguments, Command::normalizeArguments($arguments)); - $arguments = array(new \stdClass()); + $arguments = [new \stdClass()]; $this->assertSame($arguments, Command::normalizeArguments($arguments)); } @@ -139,12 +139,12 @@ class CommandTest extends PredisTestCase */ public function testNormalizeVariadic(): void { - $arguments = array('key', 'value1', 'value2', 'value3'); + $arguments = ['key', 'value1', 'value2', 'value3']; $this->assertSame($arguments, Command::normalizeVariadic($arguments)); - $this->assertSame($arguments, Command::normalizeVariadic(array('key', array('value1', 'value2', 'value3')))); + $this->assertSame($arguments, Command::normalizeVariadic(['key', ['value1', 'value2', 'value3']])); - $arguments = array(new \stdClass()); + $arguments = [new \stdClass()]; $this->assertSame($arguments, Command::normalizeVariadic($arguments)); } } diff --git a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php index 716bf460..ab92a509 100644 --- a/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ b/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php @@ -106,8 +106,8 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixFirst(): void { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', '2nd', '3rd', '4th'); + $arguments = ['1st', '2nd', '3rd', '4th']; + $expected = ['prefix:1st', '2nd', '3rd', '4th']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -127,8 +127,8 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixAll(): void { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', 'prefix:2nd', 'prefix:3rd', 'prefix:4th'); + $arguments = ['1st', '2nd', '3rd', '4th']; + $expected = ['prefix:1st', 'prefix:2nd', 'prefix:3rd', 'prefix:4th']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -148,8 +148,8 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixInterleaved(): void { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', '2nd', 'prefix:3rd', '4th'); + $arguments = ['1st', '2nd', '3rd', '4th']; + $expected = ['prefix:1st', '2nd', 'prefix:3rd', '4th']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -169,8 +169,8 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixSkipLast(): void { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', 'prefix:2nd', 'prefix:3rd', '4th'); + $arguments = ['1st', '2nd', '3rd', '4th']; + $expected = ['prefix:1st', 'prefix:2nd', 'prefix:3rd', '4th']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -190,8 +190,8 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixSort(): void { - $arguments = array('key', 'BY', 'by_key_*', 'STORE', 'destination_key'); - $expected = array('prefix:key', 'BY', 'prefix:by_key_*', 'STORE', 'prefix:destination_key'); + $arguments = ['key', 'BY', 'by_key_*', 'STORE', 'destination_key']; + $expected = ['prefix:key', 'BY', 'prefix:by_key_*', 'STORE', 'prefix:destination_key']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -211,10 +211,10 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixZSetStore(): void { - $arguments = array('key:destination', 2, 'key1', 'key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'); - $expected = array( + $arguments = ['key:destination', 2, 'key1', 'key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum']; + $expected = [ 'prefix:key:destination', 2, 'prefix:key1', 'prefix:key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum', - ); + ]; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -234,10 +234,10 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixEval(): void { - $arguments = array('return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'foo', 'hoge', 'bar', 'piyo'); - $expected = array( + $arguments = ['return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'foo', 'hoge', 'bar', 'piyo']; + $expected = [ 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo', - ); + ]; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -257,8 +257,8 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testPrefixMigrate(): void { - $arguments = array('127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'); - $expected = array('127.0.0.1', '6379', 'prefix:key', '0', '10', 'COPY', 'REPLACE'); + $arguments = ['127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE']; + $expected = ['127.0.0.1', '6379', 'prefix:key', '0', '10', 'COPY', 'REPLACE']; $command = $this->getMockForAbstractClass('Predis\Command\Command'); $command->setRawArguments($arguments); @@ -296,24 +296,24 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testCanDefineNewCommandHandlers(): void { - $command = $this->getCommandInstance('NEWCMD', array('key', 'value')); + $command = $this->getCommandInstance('NEWCMD', ['key', 'value']); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) ->method('__invoke') ->with($command, 'prefix:') ->willReturnCallback(function ($command, $prefix) { - $command->setRawArguments(array('prefix:key', 'value')); + $command->setRawArguments(['prefix:key', 'value']); }); $processor = new KeyPrefixProcessor('prefix:'); $processor->setCommandHandler('NEWCMD', $callable); $processor->process($command); - $this->assertSame(array('prefix:key', 'value'), $command->getArguments()); + $this->assertSame(['prefix:key', 'value'], $command->getArguments()); } /** @@ -321,24 +321,24 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testCanOverrideExistingCommandHandlers(): void { - $command = $this->getCommandInstance('SET', array('key', 'value')); + $command = $this->getCommandInstance('SET', ['key', 'value']); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) ->method('__invoke') ->with($command, 'prefix:') ->willReturnCallback(function ($command, $prefix) { - $command->setRawArguments(array('prefix:key', 'value')); + $command->setRawArguments(['prefix:key', 'value']); }); $processor = new KeyPrefixProcessor('prefix:'); $processor->setCommandHandler('SET', $callable); $processor->process($command); - $this->assertSame(array('prefix:key', 'value'), $command->getArguments()); + $this->assertSame(['prefix:key', 'value'], $command->getArguments()); } /** @@ -346,13 +346,13 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function testCanUndefineCommandHandlers(): void { - $command = $this->getCommandInstance('SET', array('key', 'value')); + $command = $this->getCommandInstance('SET', ['key', 'value']); $processor = new KeyPrefixProcessor('prefix:'); $processor->setCommandHandler('SET', null); $processor->process($command); - $this->assertSame(array('key', 'value'), $command->getArguments()); + $this->assertSame(['key', 'value'], $command->getArguments()); } /** @@ -394,558 +394,558 @@ class KeyPrefixProcessorTest extends PredisTestCase */ public function commandArgumentsDataProvider(): array { - return array( + return [ /* ---------------- Redis 1.2 ---------------- */ - array('EXISTS', - array('key'), - array('prefix:key'), - ), - array('DEL', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), - array('TYPE', - array('key'), - array('prefix:key'), - ), - array('KEYS', - array('pattern'), - array('prefix:pattern'), - ), - array('RENAME', - array('key', 'newkey'), - array('prefix:key', 'prefix:newkey'), - ), - array('RENAMENX', - array('key', 'newkey'), - array('prefix:key', 'prefix:newkey'), - ), - array('EXPIRE', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('EXPIREAT', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('TTL', - array('key', 10), - array('prefix:key', 10), - ), - array('MOVE', - array('key', 'db'), - array('prefix:key', 'db'), - ), - array('SORT', - array('key'), - array('prefix:key'), - ), - array('SORT', - array('key', 'BY', 'by_key_*'), - array('prefix:key', 'BY', 'prefix:by_key_*'), - ), - array('SORT', - array('key', 'BY', 'by_key_*', 'STORE', 'destination_key'), - array('prefix:key', 'BY', 'prefix:by_key_*', 'STORE', 'prefix:destination_key'), - ), - array('SORT', - array('key', 'BY', 'by_key_*', 'GET', 'object_*', 'GET', '#', 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'destination_key'), - array('prefix:key', 'BY', 'prefix:by_key_*', 'GET', 'prefix:object_*', 'GET', '#', 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'prefix:destination_key'), - ), - array('DUMP', - array('key'), - array('prefix:key'), - ), - array('RESTORE', - array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("), - array('prefix:key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("), - ), - array('SET', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('SET', - array('key', 'value', 'EX', 10, 'NX'), - array('prefix:key', 'value', 'EX', 10, 'NX'), - ), - array('SETNX', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('MSET', - array('foo', 'bar', 'hoge', 'piyo'), - array('prefix:foo', 'bar', 'prefix:hoge', 'piyo'), - ), - array('MSETNX', - array('foo', 'bar', 'hoge', 'piyo'), - array('prefix:foo', 'bar', 'prefix:hoge', 'piyo'), - ), - array('GET', - array('key'), - array('prefix:key'), - ), - array('MGET', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), - array('GETSET', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('INCR', - array('key'), - array('prefix:key'), - ), - array('INCRBY', - array('key', 5), - array('prefix:key', 5), - ), - array('DECR', - array('key'), - array('prefix:key'), - ), - array('DECRBY', - array('key', 5), - array('prefix:key', 5), - ), - array('RPUSH', - array('key', 'value1', 'value2', 'value3'), - array('prefix:key', 'value1', 'value2', 'value3'), - ), - array('LPUSH', - array('key', 'value1', 'value2', 'value3'), - array('prefix:key', 'value1', 'value2', 'value3'), - ), - array('LLEN', - array('key'), - array('prefix:key'), - ), - array('LRANGE', - array('key', 0, -1), - array('prefix:key', 0, -1), - ), - array('LTRIM', - array('key', 0, 1), - array('prefix:key', 0, 1), - ), - array('LINDEX', - array('key', 1), - array('prefix:key', 1), - ), - array('LSET', - array('key', 0, 'value'), - array('prefix:key', 0, 'value'), - ), - array('LREM', - array('key', 0, 'value'), - array('prefix:key', 0, 'value'), - ), - array('LPOP', - array('key'), - array('prefix:key'), - ), - array('RPOP', - array('key'), - array('prefix:key'), - ), - array('RPOPLPUSH', - array('key:source', 'key:destination'), - array('prefix:key:source', 'prefix:key:destination'), - ), - array('SADD', - array('key', 'member1', 'member2', 'member3'), - array('prefix:key', 'member1', 'member2', 'member3'), - ), - array('SREM', - array('key', 'member1', 'member2', 'member3'), - array('prefix:key', 'member1', 'member2', 'member3'), - ), - array('SPOP', - array('key'), - array('prefix:key'), - ), - array('SMOVE', - array('key:source', 'key:destination', 'member'), - array('prefix:key:source', 'prefix:key:destination', 'member'), - ), - array('SCARD', - array('key'), - array('prefix:key'), - ), - array('SISMEMBER', - array('key', 'member'), - array('prefix:key', 'member'), - ), - array('SINTER', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), - array('SINTERSTORE', - array('key:destination', 'key1', 'key2'), - array('prefix:key:destination', 'prefix:key1', 'prefix:key2'), - ), - array('SUNION', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), - array('SUNIONSTORE', - array('key:destination', 'key1', 'key2'), - array('prefix:key:destination', 'prefix:key1', 'prefix:key2'), - ), - array('SDIFF', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), - array('SDIFFSTORE', - array('key:destination', 'key1', 'key2'), - array('prefix:key:destination', 'prefix:key1', 'prefix:key2'), - ), - array('SMEMBERS', - array('key'), - array('prefix:key'), - ), - array('SRANDMEMBER', - array('key', 1), - array('prefix:key', 1), - ), - array('ZADD', - array('key', 'score1', 'member1', 'score2', 'member2'), - array('prefix:key', 'score1', 'member1', 'score2', 'member2'), - ), - array('ZINCRBY', - array('key', 1.0, 'member'), - array('prefix:key', 1.0, 'member'), - ), - array('ZREM', - array('key', 'member1', 'member2', 'member3'), - array('prefix:key', 'member1', 'member2', 'member3'), - ), - array('ZRANGE', - array('key', 0, 100, 'WITHSCORES'), - array('prefix:key', 0, 100, 'WITHSCORES'), - ), - array('ZREVRANGE', - array('key', 0, 100, 'WITHSCORES'), - array('prefix:key', 0, 100, 'WITHSCORES'), - ), - array('ZRANGEBYSCORE', - array('key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'), - array('prefix:key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'), - ), - array('ZCARD', - array('key'), - array('prefix:key'), - ), - array('ZSCORE', - array('key', 'member'), - array('prefix:key', 'member'), - ), - array('ZREMRANGEBYSCORE', - array('key', 0, 10), - array('prefix:key', 0, 10), - ), + ['EXISTS', + ['key'], + ['prefix:key'], + ], + ['DEL', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], + ['TYPE', + ['key'], + ['prefix:key'], + ], + ['KEYS', + ['pattern'], + ['prefix:pattern'], + ], + ['RENAME', + ['key', 'newkey'], + ['prefix:key', 'prefix:newkey'], + ], + ['RENAMENX', + ['key', 'newkey'], + ['prefix:key', 'prefix:newkey'], + ], + ['EXPIRE', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['EXPIREAT', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['TTL', + ['key', 10], + ['prefix:key', 10], + ], + ['MOVE', + ['key', 'db'], + ['prefix:key', 'db'], + ], + ['SORT', + ['key'], + ['prefix:key'], + ], + ['SORT', + ['key', 'BY', 'by_key_*'], + ['prefix:key', 'BY', 'prefix:by_key_*'], + ], + ['SORT', + ['key', 'BY', 'by_key_*', 'STORE', 'destination_key'], + ['prefix:key', 'BY', 'prefix:by_key_*', 'STORE', 'prefix:destination_key'], + ], + ['SORT', + ['key', 'BY', 'by_key_*', 'GET', 'object_*', 'GET', '#', 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'destination_key'], + ['prefix:key', 'BY', 'prefix:by_key_*', 'GET', 'prefix:object_*', 'GET', '#', 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'prefix:destination_key'], + ], + ['DUMP', + ['key'], + ['prefix:key'], + ], + ['RESTORE', + ['key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("], + ['prefix:key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("], + ], + ['SET', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['SET', + ['key', 'value', 'EX', 10, 'NX'], + ['prefix:key', 'value', 'EX', 10, 'NX'], + ], + ['SETNX', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['MSET', + ['foo', 'bar', 'hoge', 'piyo'], + ['prefix:foo', 'bar', 'prefix:hoge', 'piyo'], + ], + ['MSETNX', + ['foo', 'bar', 'hoge', 'piyo'], + ['prefix:foo', 'bar', 'prefix:hoge', 'piyo'], + ], + ['GET', + ['key'], + ['prefix:key'], + ], + ['MGET', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], + ['GETSET', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['INCR', + ['key'], + ['prefix:key'], + ], + ['INCRBY', + ['key', 5], + ['prefix:key', 5], + ], + ['DECR', + ['key'], + ['prefix:key'], + ], + ['DECRBY', + ['key', 5], + ['prefix:key', 5], + ], + ['RPUSH', + ['key', 'value1', 'value2', 'value3'], + ['prefix:key', 'value1', 'value2', 'value3'], + ], + ['LPUSH', + ['key', 'value1', 'value2', 'value3'], + ['prefix:key', 'value1', 'value2', 'value3'], + ], + ['LLEN', + ['key'], + ['prefix:key'], + ], + ['LRANGE', + ['key', 0, -1], + ['prefix:key', 0, -1], + ], + ['LTRIM', + ['key', 0, 1], + ['prefix:key', 0, 1], + ], + ['LINDEX', + ['key', 1], + ['prefix:key', 1], + ], + ['LSET', + ['key', 0, 'value'], + ['prefix:key', 0, 'value'], + ], + ['LREM', + ['key', 0, 'value'], + ['prefix:key', 0, 'value'], + ], + ['LPOP', + ['key'], + ['prefix:key'], + ], + ['RPOP', + ['key'], + ['prefix:key'], + ], + ['RPOPLPUSH', + ['key:source', 'key:destination'], + ['prefix:key:source', 'prefix:key:destination'], + ], + ['SADD', + ['key', 'member1', 'member2', 'member3'], + ['prefix:key', 'member1', 'member2', 'member3'], + ], + ['SREM', + ['key', 'member1', 'member2', 'member3'], + ['prefix:key', 'member1', 'member2', 'member3'], + ], + ['SPOP', + ['key'], + ['prefix:key'], + ], + ['SMOVE', + ['key:source', 'key:destination', 'member'], + ['prefix:key:source', 'prefix:key:destination', 'member'], + ], + ['SCARD', + ['key'], + ['prefix:key'], + ], + ['SISMEMBER', + ['key', 'member'], + ['prefix:key', 'member'], + ], + ['SINTER', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], + ['SINTERSTORE', + ['key:destination', 'key1', 'key2'], + ['prefix:key:destination', 'prefix:key1', 'prefix:key2'], + ], + ['SUNION', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], + ['SUNIONSTORE', + ['key:destination', 'key1', 'key2'], + ['prefix:key:destination', 'prefix:key1', 'prefix:key2'], + ], + ['SDIFF', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], + ['SDIFFSTORE', + ['key:destination', 'key1', 'key2'], + ['prefix:key:destination', 'prefix:key1', 'prefix:key2'], + ], + ['SMEMBERS', + ['key'], + ['prefix:key'], + ], + ['SRANDMEMBER', + ['key', 1], + ['prefix:key', 1], + ], + ['ZADD', + ['key', 'score1', 'member1', 'score2', 'member2'], + ['prefix:key', 'score1', 'member1', 'score2', 'member2'], + ], + ['ZINCRBY', + ['key', 1.0, 'member'], + ['prefix:key', 1.0, 'member'], + ], + ['ZREM', + ['key', 'member1', 'member2', 'member3'], + ['prefix:key', 'member1', 'member2', 'member3'], + ], + ['ZRANGE', + ['key', 0, 100, 'WITHSCORES'], + ['prefix:key', 0, 100, 'WITHSCORES'], + ], + ['ZREVRANGE', + ['key', 0, 100, 'WITHSCORES'], + ['prefix:key', 0, 100, 'WITHSCORES'], + ], + ['ZRANGEBYSCORE', + ['key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'], + ['prefix:key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'], + ], + ['ZCARD', + ['key'], + ['prefix:key'], + ], + ['ZSCORE', + ['key', 'member'], + ['prefix:key', 'member'], + ], + ['ZREMRANGEBYSCORE', + ['key', 0, 10], + ['prefix:key', 0, 10], + ], /* ---------------- Redis 2.0 ---------------- */ - array('SETEX', - array('key', 10, 'value'), - array('prefix:key', 10, 'value'), - ), - array('APPEND', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('SUBSTR', - array('key', 5, 10), - array('prefix:key', 5, 10), - ), - array('BLPOP', - array('key1', 'key2', 'key3', 10), - array('prefix:key1', 'prefix:key2', 'prefix:key3', 10), - ), - array('BRPOP', - array('key1', 'key2', 'key3', 10), - array('prefix:key1', 'prefix:key2', 'prefix:key3', 10), - ), - array('ZUNIONSTORE', - array('key:destination', 2, 'key1', 'key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'), - array('prefix:key:destination', 2, 'prefix:key1', 'prefix:key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'), - ), - array('ZINTERSTORE', - array('key:destination', 2, 'key1', 'key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'), - array('prefix:key:destination', 2, 'prefix:key1', 'prefix:key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'), - ), - array('ZCOUNT', - array('key', 0, 10), - array('prefix:key', 0, 10), - ), - array('ZRANK', - array('key', 'member'), - array('prefix:key', 'member'), - ), - array('ZREVRANK', - array('key', 'member'), - array('prefix:key', 'member'), - ), - array('ZREMRANGEBYRANK', - array('key', 0, 10), - array('prefix:key', 0, 10), - ), - array('HSET', - array('key', 'field', 'value'), - array('prefix:key', 'field', 'value'), - ), - array('HSETNX', - array('key', 'field', 'value'), - array('prefix:key', 'field', 'value'), - ), - array('HMSET', - array('key', 'field1', 'value1', 'field2', 'value2'), - array('prefix:key', 'field1', 'value1', 'field2', 'value2'), - ), - array('HINCRBY', - array('key', 'field', 10), - array('prefix:key', 'field', 10), - ), - array('HGET', - array('key', 'field'), - array('prefix:key', 'field'), - ), - array('HMGET', - array('key', 'field1', 'field2', 'field3'), - array('prefix:key', 'field1', 'field2', 'field3'), - ), - array('HDEL', - array('key', 'field1', 'field2', 'field3'), - array('prefix:key', 'field1', 'field2', 'field3'), - ), - array('HEXISTS', - array('key', 'field'), - array('prefix:key', 'field'), - ), - array('HLEN', - array('key'), - array('prefix:key'), - ), - array('HKEYS', - array('key'), - array('prefix:key'), - ), - array('HVALS', - array('key'), - array('prefix:key'), - ), - array('HGETALL', - array('key'), - array('prefix:key'), - ), - array('SUBSCRIBE', - array('channel:foo', 'channel:hoge'), - array('prefix:channel:foo', 'prefix:channel:hoge'), - ), - array('UNSUBSCRIBE', - array('channel:foo', 'channel:hoge'), - array('prefix:channel:foo', 'prefix:channel:hoge'), - ), - array('PSUBSCRIBE', - array('channel:foo:*', 'channel:hoge:*'), - array('prefix:channel:foo:*', 'prefix:channel:hoge:*'), - ), - array('PUNSUBSCRIBE', - array('channel:foo:*', 'channel:hoge:*'), - array('prefix:channel:foo:*', 'prefix:channel:hoge:*'), - ), - array('PUBLISH', - array('channel', 'message'), - array('prefix:channel', 'message'), - ), + ['SETEX', + ['key', 10, 'value'], + ['prefix:key', 10, 'value'], + ], + ['APPEND', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['SUBSTR', + ['key', 5, 10], + ['prefix:key', 5, 10], + ], + ['BLPOP', + ['key1', 'key2', 'key3', 10], + ['prefix:key1', 'prefix:key2', 'prefix:key3', 10], + ], + ['BRPOP', + ['key1', 'key2', 'key3', 10], + ['prefix:key1', 'prefix:key2', 'prefix:key3', 10], + ], + ['ZUNIONSTORE', + ['key:destination', 2, 'key1', 'key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'], + ['prefix:key:destination', 2, 'prefix:key1', 'prefix:key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'], + ], + ['ZINTERSTORE', + ['key:destination', 2, 'key1', 'key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'], + ['prefix:key:destination', 2, 'prefix:key1', 'prefix:key2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum'], + ], + ['ZCOUNT', + ['key', 0, 10], + ['prefix:key', 0, 10], + ], + ['ZRANK', + ['key', 'member'], + ['prefix:key', 'member'], + ], + ['ZREVRANK', + ['key', 'member'], + ['prefix:key', 'member'], + ], + ['ZREMRANGEBYRANK', + ['key', 0, 10], + ['prefix:key', 0, 10], + ], + ['HSET', + ['key', 'field', 'value'], + ['prefix:key', 'field', 'value'], + ], + ['HSETNX', + ['key', 'field', 'value'], + ['prefix:key', 'field', 'value'], + ], + ['HMSET', + ['key', 'field1', 'value1', 'field2', 'value2'], + ['prefix:key', 'field1', 'value1', 'field2', 'value2'], + ], + ['HINCRBY', + ['key', 'field', 10], + ['prefix:key', 'field', 10], + ], + ['HGET', + ['key', 'field'], + ['prefix:key', 'field'], + ], + ['HMGET', + ['key', 'field1', 'field2', 'field3'], + ['prefix:key', 'field1', 'field2', 'field3'], + ], + ['HDEL', + ['key', 'field1', 'field2', 'field3'], + ['prefix:key', 'field1', 'field2', 'field3'], + ], + ['HEXISTS', + ['key', 'field'], + ['prefix:key', 'field'], + ], + ['HLEN', + ['key'], + ['prefix:key'], + ], + ['HKEYS', + ['key'], + ['prefix:key'], + ], + ['HVALS', + ['key'], + ['prefix:key'], + ], + ['HGETALL', + ['key'], + ['prefix:key'], + ], + ['SUBSCRIBE', + ['channel:foo', 'channel:hoge'], + ['prefix:channel:foo', 'prefix:channel:hoge'], + ], + ['UNSUBSCRIBE', + ['channel:foo', 'channel:hoge'], + ['prefix:channel:foo', 'prefix:channel:hoge'], + ], + ['PSUBSCRIBE', + ['channel:foo:*', 'channel:hoge:*'], + ['prefix:channel:foo:*', 'prefix:channel:hoge:*'], + ], + ['PUNSUBSCRIBE', + ['channel:foo:*', 'channel:hoge:*'], + ['prefix:channel:foo:*', 'prefix:channel:hoge:*'], + ], + ['PUBLISH', + ['channel', 'message'], + ['prefix:channel', 'message'], + ], /* ---------------- Redis 2.2 ---------------- */ - array('PERSIST', - array('key'), - array('prefix:key'), - ), - array('STRLEN', - array('key'), - array('prefix:key'), - ), - array('SETRANGE', - array('key', 5, 'string'), - array('prefix:key', 5, 'string'), - ), - array('GETRANGE', - array('key', 5, 10), - array('prefix:key', 5, 10), - ), - array('SETBIT', - array('key', 7, 1), - array('prefix:key', 7, 1), - ), - array('GETBIT', - array('key', 100), - array('prefix:key', 100), - ), - array('RPUSHX', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('LPUSHX', - array('key', 'value'), - array('prefix:key', 'value'), - ), - array('LINSERT', - array('key', 'before', 'value1', 'value2'), - array('prefix:key', 'before', 'value1', 'value2'), - ), - array('BRPOPLPUSH', - array('key:source', 'key:destination', 10), - array('prefix:key:source', 'prefix:key:destination', 10), - ), - array('ZREVRANGEBYSCORE', - array('key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'), - array('prefix:key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'), - ), - array('WATCH', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), + ['PERSIST', + ['key'], + ['prefix:key'], + ], + ['STRLEN', + ['key'], + ['prefix:key'], + ], + ['SETRANGE', + ['key', 5, 'string'], + ['prefix:key', 5, 'string'], + ], + ['GETRANGE', + ['key', 5, 10], + ['prefix:key', 5, 10], + ], + ['SETBIT', + ['key', 7, 1], + ['prefix:key', 7, 1], + ], + ['GETBIT', + ['key', 100], + ['prefix:key', 100], + ], + ['RPUSHX', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['LPUSHX', + ['key', 'value'], + ['prefix:key', 'value'], + ], + ['LINSERT', + ['key', 'before', 'value1', 'value2'], + ['prefix:key', 'before', 'value1', 'value2'], + ], + ['BRPOPLPUSH', + ['key:source', 'key:destination', 10], + ['prefix:key:source', 'prefix:key:destination', 10], + ], + ['ZREVRANGEBYSCORE', + ['key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'], + ['prefix:key', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'], + ], + ['WATCH', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], /* ---------------- Redis 2.6 ---------------- */ - array('PTTL', - array('key', 10), - array('prefix:key', 10), - ), - array('PEXPIRE', - array('key', 1500), - array('prefix:key', 1500), - ), - array('PEXPIREAT', - array('key', 1555555555005), - array('prefix:key', 1555555555005), - ), - array('PSETEX', - array('key', 1500, 'value'), - array('prefix:key', 1500, 'value'), - ), - array('INCRBYFLOAT', - array('key', 10.5), - array('prefix:key', 10.5), - ), - array('BITOP', - array('AND', 'key:dst', 'key:01', 'key:02'), - array('AND', 'prefix:key:dst', 'prefix:key:01', 'prefix:key:02'), - ), - array('BITCOUNT', - array('key', 0, 10), - array('prefix:key', 0, 10), - ), - array('HINCRBYFLOAT', - array('key', 'field', 10.5), - array('prefix:key', 'field', 10.5), - ), - array('EVAL', - array('return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'foo', 'hoge', 'bar', 'piyo'), - array('return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'), - ), - array('EVALSHA', - array('a42059b356c875f0717db19a51f6aaca9ae659ea', 2, 'foo', 'hoge', 'bar', 'piyo'), - array('a42059b356c875f0717db19a51f6aaca9ae659ea', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'), - ), - array('BITPOS', - array('key', 0), - array('prefix:key', 0), - ), - array('MIGRATE', - array('127.0.0.1', '6379', 'key', '0', '10'), - array('127.0.0.1', '6379', 'prefix:key', '0', '10'), - ), + ['PTTL', + ['key', 10], + ['prefix:key', 10], + ], + ['PEXPIRE', + ['key', 1500], + ['prefix:key', 1500], + ], + ['PEXPIREAT', + ['key', 1555555555005], + ['prefix:key', 1555555555005], + ], + ['PSETEX', + ['key', 1500, 'value'], + ['prefix:key', 1500, 'value'], + ], + ['INCRBYFLOAT', + ['key', 10.5], + ['prefix:key', 10.5], + ], + ['BITOP', + ['AND', 'key:dst', 'key:01', 'key:02'], + ['AND', 'prefix:key:dst', 'prefix:key:01', 'prefix:key:02'], + ], + ['BITCOUNT', + ['key', 0, 10], + ['prefix:key', 0, 10], + ], + ['HINCRBYFLOAT', + ['key', 'field', 10.5], + ['prefix:key', 'field', 10.5], + ], + ['EVAL', + ['return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'foo', 'hoge', 'bar', 'piyo'], + ['return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'], + ], + ['EVALSHA', + ['a42059b356c875f0717db19a51f6aaca9ae659ea', 2, 'foo', 'hoge', 'bar', 'piyo'], + ['a42059b356c875f0717db19a51f6aaca9ae659ea', 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'], + ], + ['BITPOS', + ['key', 0], + ['prefix:key', 0], + ], + ['MIGRATE', + ['127.0.0.1', '6379', 'key', '0', '10'], + ['127.0.0.1', '6379', 'prefix:key', '0', '10'], + ], /* ---------------- Redis 2.8 ---------------- */ - array('SSCAN', - array('key', '0', 'MATCH', 'member:*', 'COUNT', 10), - array('prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10), - ), - array('ZSCAN', - array('key', '0', 'MATCH', 'member:*', 'COUNT', 10), - array('prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10), - ), - array('HSCAN', - array('key', '0', 'MATCH', 'field:*', 'COUNT', 10), - array('prefix:key', '0', 'MATCH', 'field:*', 'COUNT', 10), - ), - array('PFADD', - array('key', 'a', 'b', 'c'), - array('prefix:key', 'a', 'b', 'c'), - ), - array('PFCOUNT', - array('key:1', 'key:2', 'key:3'), - array('prefix:key:1', 'prefix:key:2', 'prefix:key:3'), - ), - array('PFMERGE', - array('key:1', 'key:2', 'key:3'), - array('prefix:key:1', 'prefix:key:2', 'prefix:key:3'), - ), - array('ZLEXCOUNT', - array('key', '-', '+'), - array('prefix:key', '-', '+'), - ), - array('ZRANGEBYLEX', - array('key', '-', '+', 'LIMIT', '0', '10'), - array('prefix:key', '-', '+', 'LIMIT', '0', '10'), - ), - array('ZREMRANGEBYLEX', - array('key', '-', '+'), - array('prefix:key', '-', '+'), - ), - array('ZREVRANGEBYLEX', - array('key', '+', '-', 'LIMIT', '0', '10'), - array('prefix:key', '+', '-', 'LIMIT', '0', '10'), - ), + ['SSCAN', + ['key', '0', 'MATCH', 'member:*', 'COUNT', 10], + ['prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10], + ], + ['ZSCAN', + ['key', '0', 'MATCH', 'member:*', 'COUNT', 10], + ['prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10], + ], + ['HSCAN', + ['key', '0', 'MATCH', 'field:*', 'COUNT', 10], + ['prefix:key', '0', 'MATCH', 'field:*', 'COUNT', 10], + ], + ['PFADD', + ['key', 'a', 'b', 'c'], + ['prefix:key', 'a', 'b', 'c'], + ], + ['PFCOUNT', + ['key:1', 'key:2', 'key:3'], + ['prefix:key:1', 'prefix:key:2', 'prefix:key:3'], + ], + ['PFMERGE', + ['key:1', 'key:2', 'key:3'], + ['prefix:key:1', 'prefix:key:2', 'prefix:key:3'], + ], + ['ZLEXCOUNT', + ['key', '-', '+'], + ['prefix:key', '-', '+'], + ], + ['ZRANGEBYLEX', + ['key', '-', '+', 'LIMIT', '0', '10'], + ['prefix:key', '-', '+', 'LIMIT', '0', '10'], + ], + ['ZREMRANGEBYLEX', + ['key', '-', '+'], + ['prefix:key', '-', '+'], + ], + ['ZREVRANGEBYLEX', + ['key', '+', '-', 'LIMIT', '0', '10'], + ['prefix:key', '+', '-', 'LIMIT', '0', '10'], + ], /* ---------------- Redis 3.0 ---------------- */ - array('MIGRATE', - array('127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'), - array('127.0.0.1', '6379', 'prefix:key', '0', '10', 'COPY', 'REPLACE'), - ), - array('EXISTS', - array('key1', 'key2', 'key3'), - array('prefix:key1', 'prefix:key2', 'prefix:key3'), - ), + ['MIGRATE', + ['127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'], + ['127.0.0.1', '6379', 'prefix:key', '0', '10', 'COPY', 'REPLACE'], + ], + ['EXISTS', + ['key1', 'key2', 'key3'], + ['prefix:key1', 'prefix:key2', 'prefix:key3'], + ], /* ---------------- Redis 3.2 ---------------- */ - array('HSTRLEN', - array('key', 'field'), - array('prefix:key', 'field'), - ), - array('BITFIELD', - array('key', 'GET', 'u8', '0', 'SET', 'u8', '0', '1'), - array('prefix:key', 'GET', 'u8', '0', 'SET', 'u8', '0', '1'), - ), - array('GEOADD', - array('key', '13.361389', '38.115556', 'member:1', '15.087269', '37.502669', 'member:2'), - array('prefix:key', '13.361389', '38.115556', 'member:1', '15.087269', '37.502669', 'member:2'), - ), - array('GEOHASH', - array('key', 'member:1', 'member:2'), - array('prefix:key', 'member:1', 'member:2'), - ), - array('GEOPOS', - array('key', 'member:1', 'member:2'), - array('prefix:key', 'member:1', 'member:2'), - ), - array('GEODIST', - array('key', 'member:1', 'member:2', 'km'), - array('prefix:key', 'member:1', 'member:2', 'km'), - ), - array('GEORADIUS', - array('key', '15', '37', '200', 'km'), - array('prefix:key', '15', '37', '200', 'km'), - ), - array('GEORADIUS', - array('key', '15', '37', '200', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'), - array('prefix:key', '15', '37', '200', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'), - ), - array('GEORADIUSBYMEMBER', - array('key', 'member', '100', 'km'), - array('prefix:key', 'member', '100', 'km'), - ), - array('GEORADIUSBYMEMBER', - array('key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'), - array('prefix:key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'), - ), - ); + ['HSTRLEN', + ['key', 'field'], + ['prefix:key', 'field'], + ], + ['BITFIELD', + ['key', 'GET', 'u8', '0', 'SET', 'u8', '0', '1'], + ['prefix:key', 'GET', 'u8', '0', 'SET', 'u8', '0', '1'], + ], + ['GEOADD', + ['key', '13.361389', '38.115556', 'member:1', '15.087269', '37.502669', 'member:2'], + ['prefix:key', '13.361389', '38.115556', 'member:1', '15.087269', '37.502669', 'member:2'], + ], + ['GEOHASH', + ['key', 'member:1', 'member:2'], + ['prefix:key', 'member:1', 'member:2'], + ], + ['GEOPOS', + ['key', 'member:1', 'member:2'], + ['prefix:key', 'member:1', 'member:2'], + ], + ['GEODIST', + ['key', 'member:1', 'member:2', 'km'], + ['prefix:key', 'member:1', 'member:2', 'km'], + ], + ['GEORADIUS', + ['key', '15', '37', '200', 'km'], + ['prefix:key', '15', '37', '200', 'km'], + ], + ['GEORADIUS', + ['key', '15', '37', '200', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'], + ['prefix:key', '15', '37', '200', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'], + ], + ['GEORADIUSBYMEMBER', + ['key', 'member', '100', 'km'], + ['prefix:key', 'member', '100', 'km'], + ], + ['GEORADIUSBYMEMBER', + ['key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'], + ['prefix:key', 'member', '100', 'km', 'WITHDIST', 'STORE', 'prefix:key:store', 'STOREDIST', 'prefix:key:storedist'], + ], + ]; } } diff --git a/tests/Predis/Command/Processor/ProcessorChainTest.php b/tests/Predis/Command/Processor/ProcessorChainTest.php index dc693850..3070a8ae 100644 --- a/tests/Predis/Command/Processor/ProcessorChainTest.php +++ b/tests/Predis/Command/Processor/ProcessorChainTest.php @@ -36,10 +36,10 @@ class ProcessorChainTest extends PredisTestCase */ public function testConstructorWithProcessorsArray(): void { - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); @@ -51,10 +51,10 @@ class ProcessorChainTest extends PredisTestCase */ public function testCountProcessors(): void { - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); @@ -67,10 +67,10 @@ class ProcessorChainTest extends PredisTestCase public function testAddProcessors(): void { /** @var ProcessorInterface[] */ - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain(); $chain->add($processors[0]); @@ -85,16 +85,16 @@ class ProcessorChainTest extends PredisTestCase public function testAddMoreProcessors(): void { /** @var ProcessorInterface */ - $processors1 = array( + $processors1 = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; /** @var ProcessorInterface */ - $processors2 = array( + $processors2 = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors1); $chain->add($processors2[0]); @@ -109,15 +109,15 @@ class ProcessorChainTest extends PredisTestCase public function testRemoveProcessors(): void { /** @var ProcessorInterface */ - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); $chain->remove($processors[0]); - $this->assertSame(array($processors[1]), $chain->getProcessors()); + $this->assertSame([$processors[1]], $chain->getProcessors()); $chain->remove($processors[1]); $this->assertEmpty($chain->getProcessors()); @@ -131,10 +131,10 @@ class ProcessorChainTest extends PredisTestCase /** @var ProcessorInterface */ $processor = $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(); - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); $chain->remove($processor); @@ -162,10 +162,10 @@ class ProcessorChainTest extends PredisTestCase */ public function testOffsetGet(): void { - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); @@ -178,10 +178,10 @@ class ProcessorChainTest extends PredisTestCase */ public function testOffsetIsset(): void { - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); @@ -220,10 +220,10 @@ class ProcessorChainTest extends PredisTestCase */ public function testGetIterator(): void { - $processors = array( + $processors = [ $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), $this->getMockBuilder('Predis\Command\Processor\ProcessorInterface')->getMock(), - ); + ]; $chain = new ProcessorChain($processors); @@ -250,7 +250,7 @@ class ProcessorChainTest extends PredisTestCase ->method('process') ->with($command); - $processors = array($processor1, $processor2); + $processors = [$processor1, $processor2]; $chain = new ProcessorChain($processors); $chain->process($command); diff --git a/tests/Predis/Command/RawCommandTest.php b/tests/Predis/Command/RawCommandTest.php index 77855c53..55097aef 100644 --- a/tests/Predis/Command/RawCommandTest.php +++ b/tests/Predis/Command/RawCommandTest.php @@ -37,7 +37,7 @@ class RawCommandTest extends PredisTestCase public function testConstructorWithCommandIDAndArguments(): void { $commandID = 'SET'; - $commandArgs = array('foo', 'bar'); + $commandArgs = ['foo', 'bar']; $command = new RawCommand($commandID, $commandArgs); @@ -56,7 +56,7 @@ class RawCommandTest extends PredisTestCase $command = RawCommand::create('SET', 'foo', 'bar'); $this->assertSame('SET', $command->getId()); - $this->assertSame(array('foo', 'bar'), $command->getArguments()); + $this->assertSame(['foo', 'bar'], $command->getArguments()); } /** @@ -81,10 +81,10 @@ class RawCommandTest extends PredisTestCase $commandID = 'SET'; $command = new RawCommand($commandID); - $command->setArguments($commandArgs = array('foo', 'bar')); + $command->setArguments($commandArgs = ['foo', 'bar']); $this->assertSame($commandArgs, $command->getArguments()); - $command->setArguments($commandArgs = array('hoge', 'piyo')); + $command->setArguments($commandArgs = ['hoge', 'piyo']); $this->assertSame($commandArgs, $command->getArguments()); } @@ -96,10 +96,10 @@ class RawCommandTest extends PredisTestCase $commandID = 'SET'; $command = new RawCommand($commandID); - $command->setRawArguments($commandArgs = array('foo', 'bar')); + $command->setRawArguments($commandArgs = ['foo', 'bar']); $this->assertSame($commandArgs, $command->getArguments()); - $command->setRawArguments($commandArgs = array('hoge', 'piyo')); + $command->setRawArguments($commandArgs = ['hoge', 'piyo']); $this->assertSame($commandArgs, $command->getArguments()); } @@ -108,7 +108,7 @@ class RawCommandTest extends PredisTestCase */ public function testGetArgumentAtIndex(): void { - $command = new RawCommand('GET', array('key')); + $command = new RawCommand('GET', ['key']); $this->assertSame('key', $command->getArgument(0)); $this->assertNull($command->getArgument(1)); @@ -120,7 +120,7 @@ class RawCommandTest extends PredisTestCase public function testSetAndGetHash(): void { $slot = 1024; - $arguments = array('key', 'value'); + $arguments = ['key', 'value']; $command = new RawCommand('SET', $arguments); $this->assertNull($command->getSlot()); @@ -128,7 +128,7 @@ class RawCommandTest extends PredisTestCase $command->setSlot($slot); $this->assertSame($slot, $command->getSlot()); - $command->setArguments(array('hoge', 'piyo')); + $command->setArguments(['hoge', 'piyo']); $this->assertNull($command->getSlot()); } @@ -137,7 +137,7 @@ class RawCommandTest extends PredisTestCase */ public function testNormalizesCommandIdentifiersToUppercase(): void { - $command = new RawCommand('set', array('key', 'value')); + $command = new RawCommand('set', ['key', 'value']); $this->assertSame('SET', $command->getId()); } diff --git a/tests/Predis/Command/RawFactoryTest.php b/tests/Predis/Command/RawFactoryTest.php index 681f9ce3..f94a2337 100644 --- a/tests/Predis/Command/RawFactoryTest.php +++ b/tests/Predis/Command/RawFactoryTest.php @@ -75,7 +75,7 @@ class RawFactoryTest extends PredisTestCase $this->assertInstanceOf('Predis\Command\RawCommand', $command); $this->assertEquals('INFO', $command->getId()); - $this->assertEquals(array(), $command->getArguments()); + $this->assertEquals([], $command->getArguments()); } /** @@ -85,7 +85,7 @@ class RawFactoryTest extends PredisTestCase { $factory = new RawFactory(); - $arguments = array('foo', 'bar'); + $arguments = ['foo', 'bar']; $command = $factory->create('set', $arguments); $this->assertInstanceOf('Predis\Command\RawCommand', $command); diff --git a/tests/Predis/Command/Redis/APPEND_Test.php b/tests/Predis/Command/Redis/APPEND_Test.php index b5af5df6..295766c7 100644 --- a/tests/Predis/Command/Redis/APPEND_Test.php +++ b/tests/Predis/Command/Redis/APPEND_Test.php @@ -39,8 +39,8 @@ class APPEND_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); + $arguments = ['key', 'value']; + $expected = ['key', 'value']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/AUTH_Test.php b/tests/Predis/Command/Redis/AUTH_Test.php index be88b7f0..68eead65 100644 --- a/tests/Predis/Command/Redis/AUTH_Test.php +++ b/tests/Predis/Command/Redis/AUTH_Test.php @@ -39,8 +39,8 @@ class AUTH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('password'); - $expected = array('password'); + $arguments = ['password']; + $expected = ['password']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/BGREWRITEAOF_Test.php b/tests/Predis/Command/Redis/BGREWRITEAOF_Test.php index 82a5e70a..be8a6857 100644 --- a/tests/Predis/Command/Redis/BGREWRITEAOF_Test.php +++ b/tests/Predis/Command/Redis/BGREWRITEAOF_Test.php @@ -40,9 +40,9 @@ class BGREWRITEAOF_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/BGSAVE_Test.php b/tests/Predis/Command/Redis/BGSAVE_Test.php index df802d97..43407f3d 100644 --- a/tests/Predis/Command/Redis/BGSAVE_Test.php +++ b/tests/Predis/Command/Redis/BGSAVE_Test.php @@ -40,9 +40,9 @@ class BGSAVE_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/BITCOUNT_Test.php b/tests/Predis/Command/Redis/BITCOUNT_Test.php index 2e1b1180..9ec01350 100644 --- a/tests/Predis/Command/Redis/BITCOUNT_Test.php +++ b/tests/Predis/Command/Redis/BITCOUNT_Test.php @@ -39,8 +39,8 @@ class BITCOUNT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); + $arguments = ['key', 0, 10]; + $expected = ['key', 0, 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/BITFIELD_Test.php b/tests/Predis/Command/Redis/BITFIELD_Test.php index 5b10134a..dbe3a59e 100644 --- a/tests/Predis/Command/Redis/BITFIELD_Test.php +++ b/tests/Predis/Command/Redis/BITFIELD_Test.php @@ -39,8 +39,8 @@ class BITFIELD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class BITFIELD_Test extends PredisCommandTestCase */ public function testFilterMultipleArguments(): void { - $arguments = array('key', 'incrby', 'u2', '100', '1', 'OVERFLOW', 'SAT', 'incrby', 'u2', '102', '1', 'GET', 'u2', '100'); - $expected = array('key', 'incrby', 'u2', '100', '1', 'OVERFLOW', 'SAT', 'incrby', 'u2', '102', '1', 'GET', 'u2', '100'); + $arguments = ['key', 'incrby', 'u2', '100', '1', 'OVERFLOW', 'SAT', 'incrby', 'u2', '102', '1', 'GET', 'u2', '100']; + $expected = ['key', 'incrby', 'u2', '100', '1', 'OVERFLOW', 'SAT', 'incrby', 'u2', '102', '1', 'GET', 'u2', '100']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class BITFIELD_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array(1); - $expected = array(1); + $raw = [1]; + $expected = [1]; $command = $this->getCommand(); @@ -80,8 +80,8 @@ class BITFIELD_Test extends PredisCommandTestCase */ public function testParseResponseComplex(): void { - $raw = array(1, 0, 3); - $expected = array(1, 0, 3); + $raw = [1, 0, 3]; + $expected = [1, 0, 3]; $command = $this->getCommand(); @@ -99,8 +99,8 @@ class BITFIELD_Test extends PredisCommandTestCase $redis->setbit('string', 0, 1); $redis->setbit('string', 8, 1); - $this->assertSame(array(128), $redis->bitfield('string', 'GET', 'u8', 0)); - $this->assertSame(array(128, 1, 128), $redis->bitfield('string', 'GET', 'u8', 0, 'GET', 'u8', 1, 'GET', 'u8', 8)); + $this->assertSame([128], $redis->bitfield('string', 'GET', 'u8', 0)); + $this->assertSame([128, 1, 128], $redis->bitfield('string', 'GET', 'u8', 0, 'GET', 'u8', 1, 'GET', 'u8', 8)); } /** @@ -114,9 +114,9 @@ class BITFIELD_Test extends PredisCommandTestCase $redis->setbit('string', 0, 1); $redis->setbit('string', 8, 1); - $this->assertSame(array(128), $redis->bitfield('string', 'SET', 'u8', 0, 1)); - $this->assertSame(array(1, 128), $redis->bitfield('string', 'SET', 'u8', 0, 128, 'SET', 'u8', 8, 1)); - $this->assertSame(array(1, 128), $redis->bitfield('string', 'SET', 'u8', 8, 128, 'GET', 'u8', 8)); + $this->assertSame([128], $redis->bitfield('string', 'SET', 'u8', 0, 1)); + $this->assertSame([1, 128], $redis->bitfield('string', 'SET', 'u8', 0, 128, 'SET', 'u8', 8, 1)); + $this->assertSame([1, 128], $redis->bitfield('string', 'SET', 'u8', 8, 128, 'GET', 'u8', 8)); $this->assertSame("\x80\x80", $redis->get('string')); } @@ -132,8 +132,8 @@ class BITFIELD_Test extends PredisCommandTestCase $redis->setbit('string', 0, 1); $redis->setbit('string', 8, 1); - $this->assertSame(array(138), $redis->bitfield('string', 'INCRBY', 'u8', 0, 10)); - $this->assertSame(array(143, 128), $redis->bitfield('string', 'INCRBY', 'u8', 0, 5, 'INCRBY', 'u8', 0, -15)); + $this->assertSame([138], $redis->bitfield('string', 'INCRBY', 'u8', 0, 10)); + $this->assertSame([143, 128], $redis->bitfield('string', 'INCRBY', 'u8', 0, 5, 'INCRBY', 'u8', 0, -15)); $this->assertSame("\x80\x80", $redis->get('string')); } diff --git a/tests/Predis/Command/Redis/BITOP_Test.php b/tests/Predis/Command/Redis/BITOP_Test.php index f9e84a8b..8328fb9c 100644 --- a/tests/Predis/Command/Redis/BITOP_Test.php +++ b/tests/Predis/Command/Redis/BITOP_Test.php @@ -39,8 +39,8 @@ class BITOP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('AND', 'key:dst', 'key:01', 'key:02'); - $expected = array('AND', 'key:dst', 'key:01', 'key:02'); + $arguments = ['AND', 'key:dst', 'key:01', 'key:02']; + $expected = ['AND', 'key:dst', 'key:01', 'key:02']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class BITOP_Test extends PredisCommandTestCase */ public function testFilterArgumentsKeysAsSingleArray(): void { - $arguments = array('AND', 'key:dst', array('key:01', 'key:02')); - $expected = array('AND', 'key:dst', 'key:01', 'key:02'); + $arguments = ['AND', 'key:dst', ['key:01', 'key:02']]; + $expected = ['AND', 'key:dst', 'key:01', 'key:02']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/BITPOS_Test.php b/tests/Predis/Command/Redis/BITPOS_Test.php index 137ca64e..9ea3e3ae 100644 --- a/tests/Predis/Command/Redis/BITPOS_Test.php +++ b/tests/Predis/Command/Redis/BITPOS_Test.php @@ -39,8 +39,8 @@ class BITPOS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 1, 10); - $expected = array('key', 0, 1, 10); + $arguments = ['key', 0, 1, 10]; + $expected = ['key', 0, 1, 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/BLPOP_Test.php b/tests/Predis/Command/Redis/BLPOP_Test.php index a0edbad2..60d50d31 100644 --- a/tests/Predis/Command/Redis/BLPOP_Test.php +++ b/tests/Predis/Command/Redis/BLPOP_Test.php @@ -39,8 +39,8 @@ class BLPOP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3', 10); - $expected = array('key1', 'key2', 'key3', 10); + $arguments = ['key1', 'key2', 'key3', 10]; + $expected = ['key1', 'key2', 'key3', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class BLPOP_Test extends PredisCommandTestCase */ public function testFilterArgumentsKeysAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3'), 10); - $expected = array('key1', 'key2', 'key3', 10); + $arguments = [['key1', 'key2', 'key3'], 10]; + $expected = ['key1', 'key2', 'key3', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class BLPOP_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('key', 'value'); - $expected = array('key', 'value'); + $raw = ['key', 'value']; + $expected = ['key', 'value']; $command = $this->getCommand(); diff --git a/tests/Predis/Command/Redis/BRPOPLPUSH_Test.php b/tests/Predis/Command/Redis/BRPOPLPUSH_Test.php index b218258c..6d94f460 100644 --- a/tests/Predis/Command/Redis/BRPOPLPUSH_Test.php +++ b/tests/Predis/Command/Redis/BRPOPLPUSH_Test.php @@ -39,8 +39,8 @@ class BRPOPLPUSH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:source', 'key:destination', 10); - $expected = array('key:source', 'key:destination', 10); + $arguments = ['key:source', 'key:destination', 10]; + $expected = ['key:source', 'key:destination', 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/BRPOP_Test.php b/tests/Predis/Command/Redis/BRPOP_Test.php index fbe4f693..4fdb70bc 100644 --- a/tests/Predis/Command/Redis/BRPOP_Test.php +++ b/tests/Predis/Command/Redis/BRPOP_Test.php @@ -39,8 +39,8 @@ class BRPOP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3', 10); - $expected = array('key1', 'key2', 'key3', 10); + $arguments = ['key1', 'key2', 'key3', 10]; + $expected = ['key1', 'key2', 'key3', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class BRPOP_Test extends PredisCommandTestCase */ public function testFilterArgumentsKeysAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3'), 10); - $expected = array('key1', 'key2', 'key3', 10); + $arguments = [['key1', 'key2', 'key3'], 10]; + $expected = ['key1', 'key2', 'key3', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class BRPOP_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('key', 'value'); - $expected = array('key', 'value'); + $raw = ['key', 'value']; + $expected = ['key', 'value']; $command = $this->getCommand(); diff --git a/tests/Predis/Command/Redis/CLIENT_Test.php b/tests/Predis/Command/Redis/CLIENT_Test.php index 83c4741f..e1ed3c79 100644 --- a/tests/Predis/Command/Redis/CLIENT_Test.php +++ b/tests/Predis/Command/Redis/CLIENT_Test.php @@ -39,8 +39,8 @@ class CLIENT_Test extends PredisCommandTestCase */ public function testFilterArgumentsOfClientKill(): void { - $arguments = array('kill', '127.0.0.1:45393'); - $expected = array('kill', '127.0.0.1:45393'); + $arguments = ['kill', '127.0.0.1:45393']; + $expected = ['kill', '127.0.0.1:45393']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class CLIENT_Test extends PredisCommandTestCase */ public function testFilterArgumentsOfClientList(): void { - $arguments = array('list'); - $expected = array('list'); + $arguments = ['list']; + $expected = ['list']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class CLIENT_Test extends PredisCommandTestCase */ public function testFilterArgumentsOfClientGetname(): void { - $arguments = $expected = array('getname'); + $arguments = $expected = ['getname']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -80,7 +80,7 @@ class CLIENT_Test extends PredisCommandTestCase */ public function testFilterArgumentsOfClientSetname(): void { - $arguments = $expected = array('setname', 'connection-a'); + $arguments = $expected = ['setname', 'connection-a']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -94,7 +94,7 @@ class CLIENT_Test extends PredisCommandTestCase public function testParseResponseOfClientKill(): void { $command = $this->getCommand(); - $command->setArguments(array('kill')); + $command->setArguments(['kill']); $this->assertSame(true, $command->parseResponse(true)); } @@ -105,7 +105,7 @@ class CLIENT_Test extends PredisCommandTestCase public function testParseResponseOfClientList(): void { $command = $this->getCommand(); - $command->setArguments(array('list')); + $command->setArguments(['list']); $raw = << '127.0.0.1:45393', 'fd' => '6', 'idle' => '0', 'flags' => 'N', 'db' => '0', 'sub' => '0', 'psub' => '0'), - array('addr' => '127.0.0.1:45394', 'fd' => '7', 'idle' => '0', 'flags' => 'N', 'db' => '0', 'sub' => '0', 'psub' => '0'), - array('addr' => '127.0.0.1:45395', 'fd' => '8', 'idle' => '0', 'flags' => 'N', 'db' => '0', 'sub' => '0', 'psub' => '0'), - ); + $parsed = [ + ['addr' => '127.0.0.1:45393', 'fd' => '6', 'idle' => '0', 'flags' => 'N', 'db' => '0', 'sub' => '0', 'psub' => '0'], + ['addr' => '127.0.0.1:45394', 'fd' => '7', 'idle' => '0', 'flags' => 'N', 'db' => '0', 'sub' => '0', 'psub' => '0'], + ['addr' => '127.0.0.1:45395', 'fd' => '8', 'idle' => '0', 'flags' => 'N', 'db' => '0', 'sub' => '0', 'psub' => '0'], + ]; $this->assertSame($parsed, $command->parseResponse($raw)); } @@ -176,11 +176,11 @@ BUFFER; */ public function invalidConnectionNameProvider() { - return array( - array('foo space'), - array('foo \n'), - array('foo $'), - ); + return [ + ['foo space'], + ['foo \n'], + ['foo $'], + ]; } /** diff --git a/tests/Predis/Command/Redis/COMMAND_Test.php b/tests/Predis/Command/Redis/COMMAND_Test.php index 54d4749b..f484f255 100644 --- a/tests/Predis/Command/Redis/COMMAND_Test.php +++ b/tests/Predis/Command/Redis/COMMAND_Test.php @@ -41,8 +41,8 @@ class COMMAND_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('INFO', 'DEL'); - $expected = array('INFO', 'DEL'); + $arguments = ['INFO', 'DEL']; + $expected = ['INFO', 'DEL']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -55,13 +55,13 @@ class COMMAND_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array( - array('get', 2, array(new Status('readonly'), new Status('fast')), 1, 1, 1), - array('set', -3, array(new Status('write'), new Status('denyoom')), 1, 1, 1), - array('watch', -2, array(new Status('readonly'), new Status('noscript'), new Status('fast')), 1, -1, 1), - array('unwatch', 1, array(new Status('readonly'), new Status('noscript'), new Status('fast')), 0, 0, 0), - array('info', -1, array(new Status('readonly'), new Status('loading'), new Status('stale')), 0, 0, 0), - ); + $raw = [ + ['get', 2, [new Status('readonly'), new Status('fast')], 1, 1, 1], + ['set', -3, [new Status('write'), new Status('denyoom')], 1, 1, 1], + ['watch', -2, [new Status('readonly'), new Status('noscript'), new Status('fast')], 1, -1, 1], + ['unwatch', 1, [new Status('readonly'), new Status('noscript'), new Status('fast')], 0, 0, 0], + ['info', -1, [new Status('readonly'), new Status('loading'), new Status('stale')], 0, 0, 0], + ]; $expected = $raw; @@ -75,8 +75,8 @@ class COMMAND_Test extends PredisCommandTestCase */ public function testParseEmptyResponse(): void { - $raw = array(null); - $expected = array(null); + $raw = [null]; + $expected = [null]; $command = $this->getCommand(); @@ -92,7 +92,7 @@ class COMMAND_Test extends PredisCommandTestCase $redis = $this->getClient(); $this->assertCount(1, $response = $redis->command('INFO', 'FOOBAR')); - $this->assertSame(array(null), $response); + $this->assertSame([null], $response); } /** @@ -103,7 +103,7 @@ class COMMAND_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $expected = array(array('get', 2, array('readonly', 'fast'), 1, 1, 1)); + $expected = [['get', 2, ['readonly', 'fast'], 1, 1, 1]]; // NOTE: starting with Redis 6.0 and the introduction of Access Control // Lists, COMMAND INFO returns an additional array for each specified @@ -111,7 +111,7 @@ class COMMAND_Test extends PredisCommandTestCase // to a command. We simply append this additional array in the expected // response if the test suite is executed against Redis >= 6.0. if ($this->isRedisServerVersion('>=', '6.0')) { - $expected[0][] = array('@read', '@string', '@fast'); + $expected[0][] = ['@read', '@string', '@fast']; } // NOTE: starting with Redis 7.0 COMMAND INFO returns an additional arrays: @@ -121,18 +121,18 @@ class COMMAND_Test extends PredisCommandTestCase // We simply append this additional array in the expected response if the // test suite is executed against Redis >= 7.0. if ($this->isRedisServerVersion('>=', '7.0')) { - $expected[0][] = array(); - $expected[0][] = array( - array( + $expected[0][] = []; + $expected[0][] = [ + [ 'flags', - array('RO','access'), + ['RO','access'], 'begin_search', - array('type','index','spec', array('index',1)), + ['type','index','spec', ['index',1]], 'find_keys', - array('type','range','spec', array('lastkey',0,'keystep',1,'limit',0)) - ) - ); - $expected[0][] = array(); + ['type','range','spec', ['lastkey',0,'keystep',1,'limit',0]] + ] + ]; + $expected[0][] = []; } $this->assertCount(1, $response = $redis->command('INFO', 'GET')); diff --git a/tests/Predis/Command/Redis/CONFIG_Test.php b/tests/Predis/Command/Redis/CONFIG_Test.php index de5940a0..cfb79196 100644 --- a/tests/Predis/Command/Redis/CONFIG_Test.php +++ b/tests/Predis/Command/Redis/CONFIG_Test.php @@ -39,8 +39,8 @@ class CONFIG_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('GET', 'slowlog'); - $expected = array('GET', 'slowlog'); + $arguments = ['GET', 'slowlog']; + $expected = ['GET', 'slowlog']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,12 +53,12 @@ class CONFIG_Test extends PredisCommandTestCase */ public function testParseResponseOfConfigGet(): void { - $raw = array('slowlog-log-slower-than', '10000', 'slowlog-max-len', '64', 'loglevel', 'verbose'); - $expected = array( + $raw = ['slowlog-log-slower-than', '10000', 'slowlog-max-len', '64', 'loglevel', 'verbose']; + $expected = [ 'slowlog-log-slower-than' => '10000', 'slowlog-max-len' => '64', 'loglevel' => 'verbose', - ); + ]; $command = $this->getCommand(); @@ -117,7 +117,7 @@ class CONFIG_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array(), $redis->config('GET', 'foobar')); + $this->assertSame([], $redis->config('GET', 'foobar')); } /** @@ -131,7 +131,7 @@ class CONFIG_Test extends PredisCommandTestCase $previous = $redis->config('GET', 'loglevel'); $this->assertEquals('OK', $redis->config('SET', 'loglevel', 'notice')); - $this->assertSame(array('loglevel' => 'notice'), $redis->config('GET', 'loglevel')); + $this->assertSame(['loglevel' => 'notice'], $redis->config('GET', 'loglevel')); // We set the loglevel configuration to the previous value. $redis->config('SET', 'loglevel', $previous['loglevel']); diff --git a/tests/Predis/Command/Redis/DBSIZE_Test.php b/tests/Predis/Command/Redis/DBSIZE_Test.php index 6e61f627..cc946cae 100644 --- a/tests/Predis/Command/Redis/DBSIZE_Test.php +++ b/tests/Predis/Command/Redis/DBSIZE_Test.php @@ -40,9 +40,9 @@ class DBSIZE_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/DECRBY_Test.php b/tests/Predis/Command/Redis/DECRBY_Test.php index 629c62e9..e3dda940 100644 --- a/tests/Predis/Command/Redis/DECRBY_Test.php +++ b/tests/Predis/Command/Redis/DECRBY_Test.php @@ -39,8 +39,8 @@ class DECRBY_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 5); - $expected = array('key', 5); + $arguments = ['key', 5]; + $expected = ['key', 5]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/DECR_Test.php b/tests/Predis/Command/Redis/DECR_Test.php index 4ffd6019..2047b084 100644 --- a/tests/Predis/Command/Redis/DECR_Test.php +++ b/tests/Predis/Command/Redis/DECR_Test.php @@ -39,8 +39,8 @@ class DECR_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/DEL_Test.php b/tests/Predis/Command/Redis/DEL_Test.php index 93d6d1e8..3f1afc76 100644 --- a/tests/Predis/Command/Redis/DEL_Test.php +++ b/tests/Predis/Command/Redis/DEL_Test.php @@ -39,8 +39,8 @@ class DEL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); + $arguments = ['key1', 'key2', 'key3']; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -52,8 +52,8 @@ class DEL_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); + $arguments = [['key1', 'key2', 'key3']]; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/DISCARD_Test.php b/tests/Predis/Command/Redis/DISCARD_Test.php index a484009e..843fe58a 100644 --- a/tests/Predis/Command/Redis/DISCARD_Test.php +++ b/tests/Predis/Command/Redis/DISCARD_Test.php @@ -40,9 +40,9 @@ class DISCARD_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/DUMP_Test.php b/tests/Predis/Command/Redis/DUMP_Test.php index a57a9e7a..c9e58aaa 100644 --- a/tests/Predis/Command/Redis/DUMP_Test.php +++ b/tests/Predis/Command/Redis/DUMP_Test.php @@ -39,8 +39,8 @@ class DUMP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ECHO_Test.php b/tests/Predis/Command/Redis/ECHO_Test.php index 3d145134..26af4807 100644 --- a/tests/Predis/Command/Redis/ECHO_Test.php +++ b/tests/Predis/Command/Redis/ECHO_Test.php @@ -39,8 +39,8 @@ class ECHO_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('message'); - $expected = array('message'); + $arguments = ['message']; + $expected = ['message']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/EVALSHA_Test.php b/tests/Predis/Command/Redis/EVALSHA_Test.php index 5e57ba29..76d6c984 100644 --- a/tests/Predis/Command/Redis/EVALSHA_Test.php +++ b/tests/Predis/Command/Redis/EVALSHA_Test.php @@ -39,8 +39,8 @@ class EVALSHA_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar'); - $expected = array('9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar'); + $arguments = ['9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar']; + $expected = ['9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -61,7 +61,7 @@ class EVALSHA_Test extends PredisCommandTestCase */ public function testGetScriptHash(): void { - $command = $this->getCommandWithArgumentsArray(array($sha1 = sha1('return true')), 0); + $command = $this->getCommandWithArgumentsArray([$sha1 = sha1('return true')], 0); $this->assertSame($sha1, $command->getScriptHash()); } @@ -75,7 +75,7 @@ class EVALSHA_Test extends PredisCommandTestCase $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; $sha1 = sha1($lua); - $result = array('foo', 'hoge', 'bar', 'piyo'); + $result = ['foo', 'hoge', 'bar', 'piyo']; $this->assertSame($result, $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo')); $this->assertSame($result, $redis->evalsha($sha1, 2, 'foo', 'hoge', 'bar', 'piyo')); diff --git a/tests/Predis/Command/Redis/EVAL_Test.php b/tests/Predis/Command/Redis/EVAL_Test.php index f196ff20..14db41fe 100644 --- a/tests/Predis/Command/Redis/EVAL_Test.php +++ b/tests/Predis/Command/Redis/EVAL_Test.php @@ -39,8 +39,8 @@ class EVAL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar'); - $expected = array('return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar'); + $arguments = ['return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar']; + $expected = ['return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -61,7 +61,7 @@ class EVAL_Test extends PredisCommandTestCase */ public function testGetScriptHash(): void { - $command = $this->getCommandWithArgumentsArray(array($lua = 'return true', 0)); + $command = $this->getCommandWithArgumentsArray([$lua = 'return true', 0]); $this->assertSame(sha1($lua), $command->getScriptHash()); } @@ -74,7 +74,7 @@ class EVAL_Test extends PredisCommandTestCase $redis = $this->getClient(); $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; - $result = array('foo', 'hoge', 'bar', 'piyo'); + $result = ['foo', 'hoge', 'bar', 'piyo']; $this->assertSame($result, $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo')); } diff --git a/tests/Predis/Command/Redis/EXEC_Test.php b/tests/Predis/Command/Redis/EXEC_Test.php index a4140073..0d2a8270 100644 --- a/tests/Predis/Command/Redis/EXEC_Test.php +++ b/tests/Predis/Command/Redis/EXEC_Test.php @@ -40,9 +40,9 @@ class EXEC_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** @@ -50,8 +50,8 @@ class EXEC_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('tx1', 'tx2'); - $expected = array('tx1', 'tx2'); + $raw = ['tx1', 'tx2']; + $expected = ['tx1', 'tx2']; $command = $this->getCommand(); @@ -69,7 +69,7 @@ class EXEC_Test extends PredisCommandTestCase $redis->echo('tx1'); $redis->echo('tx2'); - $this->assertSame(array('tx1', 'tx2'), $redis->exec()); + $this->assertSame(['tx1', 'tx2'], $redis->exec()); } /** @@ -81,7 +81,7 @@ class EXEC_Test extends PredisCommandTestCase $redis->multi(); - $this->assertSame(array(), $redis->exec()); + $this->assertSame([], $redis->exec()); } /** @@ -96,7 +96,7 @@ class EXEC_Test extends PredisCommandTestCase $redis->set('foo', 'bar'); $redis->exists('foo'); - $this->assertEquals(array('PONG', 'OK', 1), $redis->exec()); + $this->assertEquals(['PONG', 'OK', 1], $redis->exec()); } /** diff --git a/tests/Predis/Command/Redis/EXISTS_Test.php b/tests/Predis/Command/Redis/EXISTS_Test.php index 2dc07e71..093a7e2d 100644 --- a/tests/Predis/Command/Redis/EXISTS_Test.php +++ b/tests/Predis/Command/Redis/EXISTS_Test.php @@ -39,8 +39,8 @@ class EXISTS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class EXISTS_Test extends PredisCommandTestCase */ public function testFilterArgumentsMultipleKeys(): void { - $arguments = array('key:1', 'key:2', 'key:3'); - $expected = array('key:1', 'key:2', 'key:3'); + $arguments = ['key:1', 'key:2', 'key:3']; + $expected = ['key:1', 'key:2', 'key:3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/EXPIREAT_Test.php b/tests/Predis/Command/Redis/EXPIREAT_Test.php index 0e182515..bbc71769 100644 --- a/tests/Predis/Command/Redis/EXPIREAT_Test.php +++ b/tests/Predis/Command/Redis/EXPIREAT_Test.php @@ -39,8 +39,8 @@ class EXPIREAT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'ttl'); - $expected = array('key', 'ttl'); + $arguments = ['key', 'ttl']; + $expected = ['key', 'ttl']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/EXPIRE_Test.php b/tests/Predis/Command/Redis/EXPIRE_Test.php index c5528615..eb325109 100644 --- a/tests/Predis/Command/Redis/EXPIRE_Test.php +++ b/tests/Predis/Command/Redis/EXPIRE_Test.php @@ -39,8 +39,8 @@ class EXPIRE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'ttl'); - $expected = array('key', 'ttl'); + $arguments = ['key', 'ttl']; + $expected = ['key', 'ttl']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/FLUSHALL_Test.php b/tests/Predis/Command/Redis/FLUSHALL_Test.php index 125e6c64..31e48fe3 100644 --- a/tests/Predis/Command/Redis/FLUSHALL_Test.php +++ b/tests/Predis/Command/Redis/FLUSHALL_Test.php @@ -40,9 +40,9 @@ class FLUSHALL_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/FLUSHDB_Test.php b/tests/Predis/Command/Redis/FLUSHDB_Test.php index 492dafc6..9bf146ad 100644 --- a/tests/Predis/Command/Redis/FLUSHDB_Test.php +++ b/tests/Predis/Command/Redis/FLUSHDB_Test.php @@ -40,9 +40,9 @@ class FLUSHDB_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/GEOADD_Test.php b/tests/Predis/Command/Redis/GEOADD_Test.php index be049e57..dc54fd55 100644 --- a/tests/Predis/Command/Redis/GEOADD_Test.php +++ b/tests/Predis/Command/Redis/GEOADD_Test.php @@ -39,8 +39,8 @@ class GEOADD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); - $expected = array('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); + $arguments = ['Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania']; + $expected = ['Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,12 +53,12 @@ class GEOADD_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithMembersAsSingleArray(): void { - $arguments = array('Sicily', array( - array('13.361389', '38.115556', 'Palermo'), - array('15.087269', '37.502669', 'Catania'), - )); + $arguments = ['Sicily', [ + ['13.361389', '38.115556', 'Palermo'], + ['15.087269', '37.502669', 'Catania'], + ]]; - $expected = array('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); + $expected = ['Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -88,7 +88,7 @@ class GEOADD_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo'); - $this->assertSame(array('Palermo' => '3479099956230698'), $redis->zrange('Sicily', 0, -1, 'WITHSCORES')); + $this->assertSame(['Palermo' => '3479099956230698'], $redis->zrange('Sicily', 0, -1, 'WITHSCORES')); } /** diff --git a/tests/Predis/Command/Redis/GEODIST_Test.php b/tests/Predis/Command/Redis/GEODIST_Test.php index edeaf9b3..0ae3652e 100644 --- a/tests/Predis/Command/Redis/GEODIST_Test.php +++ b/tests/Predis/Command/Redis/GEODIST_Test.php @@ -39,8 +39,8 @@ class GEODIST_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member:1', 'member:2', 'km'); - $expected = array('key', 'member:1', 'member:2', 'km'); + $arguments = ['key', 'member:1', 'member:2', 'km']; + $expected = ['key', 'member:1', 'member:2', 'km']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class GEODIST_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('103.31822459492736'); - $expected = array('103.31822459492736'); + $raw = ['103.31822459492736']; + $expected = ['103.31822459492736']; $command = $this->getCommand(); diff --git a/tests/Predis/Command/Redis/GEOHASH_Test.php b/tests/Predis/Command/Redis/GEOHASH_Test.php index b4547616..840e0fa5 100644 --- a/tests/Predis/Command/Redis/GEOHASH_Test.php +++ b/tests/Predis/Command/Redis/GEOHASH_Test.php @@ -39,8 +39,8 @@ class GEOHASH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member:1', 'member:2'); - $expected = array('key', 'member:1', 'member:2'); + $arguments = ['key', 'member:1', 'member:2']; + $expected = ['key', 'member:1', 'member:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class GEOHASH_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithMembersAsSingleArray(): void { - $arguments = array('key', array('member:1', 'member:2')); - $expected = array('key', 'member:1', 'member:2'); + $arguments = ['key', ['member:1', 'member:2']]; + $expected = ['key', 'member:1', 'member:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class GEOHASH_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('sqc8b49rny0', 'sqdtr74hyu0'); - $expected = array('sqc8b49rny0', 'sqdtr74hyu0'); + $raw = ['sqc8b49rny0', 'sqdtr74hyu0']; + $expected = ['sqc8b49rny0', 'sqdtr74hyu0']; $command = $this->getCommand(); @@ -84,7 +84,7 @@ class GEOHASH_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); - $this->assertSame(array('sqc8b49rny0', 'sqdtr74hyu0'), $redis->geohash('Sicily', 'Palermo', 'Catania')); + $this->assertSame(['sqc8b49rny0', 'sqdtr74hyu0'], $redis->geohash('Sicily', 'Palermo', 'Catania')); } /** diff --git a/tests/Predis/Command/Redis/GEOPOS_Test.php b/tests/Predis/Command/Redis/GEOPOS_Test.php index f6646eda..1a0fab9b 100644 --- a/tests/Predis/Command/Redis/GEOPOS_Test.php +++ b/tests/Predis/Command/Redis/GEOPOS_Test.php @@ -39,8 +39,8 @@ class GEOPOS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member:1', 'member:2'); - $expected = array('key', 'member:1', 'member:2'); + $arguments = ['key', 'member:1', 'member:2']; + $expected = ['key', 'member:1', 'member:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class GEOPOS_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithMembersAsSingleArray(): void { - $arguments = array('key', array('member:1', 'member:2')); - $expected = array('key', 'member:1', 'member:2'); + $arguments = ['key', ['member:1', 'member:2']]; + $expected = ['key', 'member:1', 'member:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,15 +67,15 @@ class GEOPOS_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array( - array('13.36138933897018433', '38.11555639549629859'), - array('15.08726745843887329', '37.50266842333162032'), - ); + $raw = [ + ['13.36138933897018433', '38.11555639549629859'], + ['15.08726745843887329', '37.50266842333162032'], + ]; - $expected = array( - array('13.36138933897018433', '38.11555639549629859'), - array('15.08726745843887329', '37.50266842333162032'), - ); + $expected = [ + ['13.36138933897018433', '38.11555639549629859'], + ['15.08726745843887329', '37.50266842333162032'], + ]; $command = $this->getCommand(); @@ -91,10 +91,10 @@ class GEOPOS_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); - $this->assertEquals(array( - array('13.36138933897018433', '38.11555639549629859'), - array('15.08726745843887329', '37.50266842333162032'), - ), $redis->geopos('Sicily', 'Palermo', 'Catania')); + $this->assertEquals([ + ['13.36138933897018433', '38.11555639549629859'], + ['15.08726745843887329', '37.50266842333162032'], + ], $redis->geopos('Sicily', 'Palermo', 'Catania')); } /** diff --git a/tests/Predis/Command/Redis/GEORADIUSBYMEMBER_Test.php b/tests/Predis/Command/Redis/GEORADIUSBYMEMBER_Test.php index 9723adeb..175ad48a 100644 --- a/tests/Predis/Command/Redis/GEORADIUSBYMEMBER_Test.php +++ b/tests/Predis/Command/Redis/GEORADIUSBYMEMBER_Test.php @@ -39,15 +39,15 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array( + $arguments = [ 'Sicily', 'Agrigento', 100, 'km', 'WITHCOORD', 'WITHDIST', 'WITHHASH', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist', - ); + ]; - $expected = array( + $expected = [ 'Sicily', 'Agrigento', 100, 'km', 'WITHCOORD', 'WITHDIST', 'WITHHASH', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist', - ); + ]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -60,8 +60,8 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithComplexOptions(): void { - $arguments = array( - 'Sicily', 'Agrigento', 100, 'km', array( + $arguments = [ + 'Sicily', 'Agrigento', 100, 'km', [ 'store' => 'key:store', 'storedist' => 'key:storedist', 'withdist' => true, @@ -69,13 +69,13 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase 'withhash' => true, 'count' => 1, 'sort' => 'asc', - ), - ); + ], + ]; - $expected = array( + $expected = [ 'Sicily', 'Agrigento', 100, 'km', 'WITHCOORD', 'WITHDIST', 'WITHHASH', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist', - ); + ]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -88,8 +88,8 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithSpecificOptionsSetToFalse(): void { - $arguments = array( - 'Sicily', 'Agrigento', 100, 'km', array( + $arguments = [ + 'Sicily', 'Agrigento', 100, 'km', [ 'store' => 'key:store', 'storedist' => 'key:storedist', 'withdist' => false, @@ -97,10 +97,10 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase 'withhash' => false, 'count' => 1, 'sort' => 'asc', - ), - ); + ], + ]; - $expected = array('Sicily', 'Agrigento', 100, 'km', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'); + $expected = ['Sicily', 'Agrigento', 100, 'km', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -113,13 +113,13 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase */ public function testParseResponseWithNoOptions(): void { - $raw = array( - array('Agrigento', 'Palermo'), - ); + $raw = [ + ['Agrigento', 'Palermo'], + ]; - $expected = array( - array('Agrigento', 'Palermo'), - ); + $expected = [ + ['Agrigento', 'Palermo'], + ]; $command = $this->getCommand(); @@ -135,7 +135,7 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania', '13.583333', '37.316667', 'Agrigento'); - $this->assertEquals(array('Agrigento', 'Palermo'), $redis->georadiusbymember('Sicily', 'Agrigento', 100, 'km')); + $this->assertEquals(['Agrigento', 'Palermo'], $redis->georadiusbymember('Sicily', 'Agrigento', 100, 'km')); } /** @@ -147,10 +147,10 @@ class GEORADIUSBYMEMBER_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania', '13.583333', '37.316667', 'Agrigento'); - $this->assertEquals(array( - array('Agrigento', '0.0000', array('13.5833314061164856', '37.31666804993816555')), - array('Palermo', '90.9778', array('13.36138933897018433', '38.11555639549629859')), - ), $redis->georadiusbymember('Sicily', 'Agrigento', 100, 'km', 'WITHDIST', 'WITHCOORD')); + $this->assertEquals([ + ['Agrigento', '0.0000', ['13.5833314061164856', '37.31666804993816555']], + ['Palermo', '90.9778', ['13.36138933897018433', '38.11555639549629859']], + ], $redis->georadiusbymember('Sicily', 'Agrigento', 100, 'km', 'WITHDIST', 'WITHCOORD')); } /** diff --git a/tests/Predis/Command/Redis/GEORADIUS_Test.php b/tests/Predis/Command/Redis/GEORADIUS_Test.php index a4efaf56..230908b4 100644 --- a/tests/Predis/Command/Redis/GEORADIUS_Test.php +++ b/tests/Predis/Command/Redis/GEORADIUS_Test.php @@ -39,15 +39,15 @@ class GEORADIUS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array( + $arguments = [ 'Sicily', 15, 37, 200, 'km', 'WITHCOORD', 'WITHDIST', 'WITHHASH', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist', - ); + ]; - $expected = array( + $expected = [ 'Sicily', 15, 37, 200, 'km', 'WITHCOORD', 'WITHDIST', 'WITHHASH', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist', - ); + ]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -60,8 +60,8 @@ class GEORADIUS_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithComplexOptions(): void { - $arguments = array( - 'Sicily', 15, 37, 200, 'km', array( + $arguments = [ + 'Sicily', 15, 37, 200, 'km', [ 'store' => 'key:store', 'storedist' => 'key:storedist', 'withdist' => true, @@ -69,13 +69,13 @@ class GEORADIUS_Test extends PredisCommandTestCase 'withhash' => true, 'count' => 1, 'sort' => 'asc', - ), - ); + ], + ]; - $expected = array( + $expected = [ 'Sicily', 15, 37, 200, 'km', 'WITHCOORD', 'WITHDIST', 'WITHHASH', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist', - ); + ]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -88,8 +88,8 @@ class GEORADIUS_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithSpecificOptionsSetToFalse(): void { - $arguments = array( - 'Sicily', 15, 37, 200, 'km', array( + $arguments = [ + 'Sicily', 15, 37, 200, 'km', [ 'store' => 'key:store', 'storedist' => 'key:storedist', 'withdist' => false, @@ -97,10 +97,10 @@ class GEORADIUS_Test extends PredisCommandTestCase 'withhash' => false, 'count' => 1, 'sort' => 'asc', - ), - ); + ], + ]; - $expected = array('Sicily', 15, 37, 200, 'km', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist'); + $expected = ['Sicily', 15, 37, 200, 'km', 'COUNT', 1, 'ASC', 'STORE', 'key:store', 'STOREDIST', 'key:storedist']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -113,15 +113,15 @@ class GEORADIUS_Test extends PredisCommandTestCase */ public function testParseResponseWithNoOptions(): void { - $raw = array( - array('Palermo', '190.4424'), - array('Catania', '56.4413'), - ); + $raw = [ + ['Palermo', '190.4424'], + ['Catania', '56.4413'], + ]; - $expected = array( - array('Palermo', '190.4424'), - array('Catania', '56.4413'), - ); + $expected = [ + ['Palermo', '190.4424'], + ['Catania', '56.4413'], + ]; $command = $this->getCommand(); @@ -137,7 +137,7 @@ class GEORADIUS_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); - $this->assertEquals(array('Palermo', 'Catania'), $redis->georadius('Sicily', 15, 37, 200, 'km')); + $this->assertEquals(['Palermo', 'Catania'], $redis->georadius('Sicily', 15, 37, 200, 'km')); } /** @@ -149,10 +149,10 @@ class GEORADIUS_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->geoadd('Sicily', '13.361389', '38.115556', 'Palermo', '15.087269', '37.502669', 'Catania'); - $this->assertEquals(array( - array('Palermo', '190.4424', array('13.36138933897018433', '38.11555639549629859')), - array('Catania', '56.4413', array('15.08726745843887329', '37.50266842333162032')), - ), $redis->georadius('Sicily', 15, 37, 200, 'km', 'WITHDIST', 'WITHCOORD')); + $this->assertEquals([ + ['Palermo', '190.4424', ['13.36138933897018433', '38.11555639549629859']], + ['Catania', '56.4413', ['15.08726745843887329', '37.50266842333162032']], + ], $redis->georadius('Sicily', 15, 37, 200, 'km', 'WITHDIST', 'WITHCOORD')); } /** diff --git a/tests/Predis/Command/Redis/GETBIT_Test.php b/tests/Predis/Command/Redis/GETBIT_Test.php index c4783fa1..c38bfbb1 100644 --- a/tests/Predis/Command/Redis/GETBIT_Test.php +++ b/tests/Predis/Command/Redis/GETBIT_Test.php @@ -39,8 +39,8 @@ class GETBIT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 100); - $expected = array('key', 100); + $arguments = ['key', 100]; + $expected = ['key', 100]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/GETRANGE_Test.php b/tests/Predis/Command/Redis/GETRANGE_Test.php index 241eb94f..df0803e4 100644 --- a/tests/Predis/Command/Redis/GETRANGE_Test.php +++ b/tests/Predis/Command/Redis/GETRANGE_Test.php @@ -39,8 +39,8 @@ class GETRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 5, 10); - $expected = array('key', 5, 10); + $arguments = ['key', 5, 10]; + $expected = ['key', 5, 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/GETSET_Test.php b/tests/Predis/Command/Redis/GETSET_Test.php index 4055558c..f359bfba 100644 --- a/tests/Predis/Command/Redis/GETSET_Test.php +++ b/tests/Predis/Command/Redis/GETSET_Test.php @@ -39,8 +39,8 @@ class GETSET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); + $arguments = ['key', 'value']; + $expected = ['key', 'value']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/GET_Test.php b/tests/Predis/Command/Redis/GET_Test.php index f3fd92cb..80c047b7 100644 --- a/tests/Predis/Command/Redis/GET_Test.php +++ b/tests/Predis/Command/Redis/GET_Test.php @@ -39,8 +39,8 @@ class GET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('foo'); - $expected = array('foo'); + $arguments = ['foo']; + $expected = ['foo']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/HDEL_Test.php b/tests/Predis/Command/Redis/HDEL_Test.php index 27cad324..3e612734 100644 --- a/tests/Predis/Command/Redis/HDEL_Test.php +++ b/tests/Predis/Command/Redis/HDEL_Test.php @@ -39,8 +39,8 @@ class HDEL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field1', 'field2', 'field3'); - $expected = array('key', 'field1', 'field2', 'field3'); + $arguments = ['key', 'field1', 'field2', 'field3']; + $expected = ['key', 'field1', 'field2', 'field3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HDEL_Test extends PredisCommandTestCase */ public function testFilterArgumentsFieldsAsSingleArray(): void { - $arguments = array('key', array('field1', 'field2', 'field3')); - $expected = array('key', 'field1', 'field2', 'field3'); + $arguments = ['key', ['field1', 'field2', 'field3']]; + $expected = ['key', 'field1', 'field2', 'field3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/HEXISTS_Test.php b/tests/Predis/Command/Redis/HEXISTS_Test.php index 05bd3272..55732c7e 100644 --- a/tests/Predis/Command/Redis/HEXISTS_Test.php +++ b/tests/Predis/Command/Redis/HEXISTS_Test.php @@ -39,8 +39,8 @@ class HEXISTS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field'); - $expected = array('key', 'field'); + $arguments = ['key', 'field']; + $expected = ['key', 'field']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/HGETALL_Test.php b/tests/Predis/Command/Redis/HGETALL_Test.php index 360a53ff..308a3f58 100644 --- a/tests/Predis/Command/Redis/HGETALL_Test.php +++ b/tests/Predis/Command/Redis/HGETALL_Test.php @@ -39,8 +39,8 @@ class HGETALL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HGETALL_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $expected = array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'); + $raw = ['foo', 'bar', 'hoge', 'piyo', 'lol', 'wut']; + $expected = ['foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut']; $command = $this->getCommand(); @@ -71,8 +71,8 @@ class HGETALL_Test extends PredisCommandTestCase $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); - $this->assertSame(array(), $redis->hgetall('unknown')); + $this->assertSame(['foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'], $redis->hgetall('metavars')); + $this->assertSame([], $redis->hgetall('unknown')); } /** diff --git a/tests/Predis/Command/Redis/HGET_Test.php b/tests/Predis/Command/Redis/HGET_Test.php index 9868d582..443cb4e8 100644 --- a/tests/Predis/Command/Redis/HGET_Test.php +++ b/tests/Predis/Command/Redis/HGET_Test.php @@ -39,8 +39,8 @@ class HGET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field'); - $expected = array('key', 'field'); + $arguments = ['key', 'field']; + $expected = ['key', 'field']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/HINCRBYFLOAT_Test.php b/tests/Predis/Command/Redis/HINCRBYFLOAT_Test.php index bac3c31f..8d31448a 100644 --- a/tests/Predis/Command/Redis/HINCRBYFLOAT_Test.php +++ b/tests/Predis/Command/Redis/HINCRBYFLOAT_Test.php @@ -39,8 +39,8 @@ class HINCRBYFLOAT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field', 10.5); - $expected = array('key', 'field', 10.5); + $arguments = ['key', 'field', 10.5]; + $expected = ['key', 'field', 10.5]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -69,7 +69,7 @@ class HINCRBYFLOAT_Test extends PredisCommandTestCase $redis->hincrbyfloat('metavars', 'hoge', 10.001); $this->assertSame('11', $redis->hincrbyfloat('metavars', 'hoge', 0.999)); - $this->assertSame(array('foo' => '10.5', 'hoge' => '11'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => '10.5', 'hoge' => '11'], $redis->hgetall('metavars')); } /** @@ -85,7 +85,7 @@ class HINCRBYFLOAT_Test extends PredisCommandTestCase $redis->hincrbyfloat('metavars', 'hoge', -10.001); $this->assertSame('-11', $redis->hincrbyfloat('metavars', 'hoge', -0.999)); - $this->assertSame(array('foo' => '-10.5', 'hoge' => '-11'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => '-10.5', 'hoge' => '-11'], $redis->hgetall('metavars')); } /** diff --git a/tests/Predis/Command/Redis/HINCRBY_Test.php b/tests/Predis/Command/Redis/HINCRBY_Test.php index 3adbc124..fb3096ba 100644 --- a/tests/Predis/Command/Redis/HINCRBY_Test.php +++ b/tests/Predis/Command/Redis/HINCRBY_Test.php @@ -39,8 +39,8 @@ class HINCRBY_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field', 10); - $expected = array('key', 'field', 10); + $arguments = ['key', 'field', 10]; + $expected = ['key', 'field', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class HINCRBY_Test extends PredisCommandTestCase $this->assertSame(10, $redis->hincrby('metavars', 'foo', 10)); $this->assertSame(5, $redis->hincrby('metavars', 'hoge', 5)); $this->assertSame(15, $redis->hincrby('metavars', 'hoge', 10)); - $this->assertSame(array('foo' => '10', 'hoge' => '15'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => '10', 'hoge' => '15'], $redis->hgetall('metavars')); } /** @@ -81,7 +81,7 @@ class HINCRBY_Test extends PredisCommandTestCase $this->assertSame(-10, $redis->hincrby('metavars', 'foo', -10)); $this->assertSame(-5, $redis->hincrby('metavars', 'hoge', -5)); $this->assertSame(-15, $redis->hincrby('metavars', 'hoge', -10)); - $this->assertSame(array('foo' => '-10', 'hoge' => '-15'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => '-10', 'hoge' => '-15'], $redis->hgetall('metavars')); } /** diff --git a/tests/Predis/Command/Redis/HKEYS_Test.php b/tests/Predis/Command/Redis/HKEYS_Test.php index cbb68e66..e2044e94 100644 --- a/tests/Predis/Command/Redis/HKEYS_Test.php +++ b/tests/Predis/Command/Redis/HKEYS_Test.php @@ -39,8 +39,8 @@ class HKEYS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HKEYS_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('foo', 'hoge', 'lol'); - $expected = array('foo', 'hoge', 'lol'); + $raw = ['foo', 'hoge', 'lol']; + $expected = ['foo', 'hoge', 'lol']; $command = $this->getCommand(); @@ -71,8 +71,8 @@ class HKEYS_Test extends PredisCommandTestCase $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $this->assertSame(array('foo', 'hoge', 'lol'), $redis->hkeys('metavars')); - $this->assertSame(array(), $redis->hkeys('unknown')); + $this->assertSame(['foo', 'hoge', 'lol'], $redis->hkeys('metavars')); + $this->assertSame([], $redis->hkeys('unknown')); } /** diff --git a/tests/Predis/Command/Redis/HLEN_Test.php b/tests/Predis/Command/Redis/HLEN_Test.php index 2ddcf9d2..5fe9d674 100644 --- a/tests/Predis/Command/Redis/HLEN_Test.php +++ b/tests/Predis/Command/Redis/HLEN_Test.php @@ -39,8 +39,8 @@ class HLEN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/HMGET_Test.php b/tests/Predis/Command/Redis/HMGET_Test.php index ff767486..989e94e5 100644 --- a/tests/Predis/Command/Redis/HMGET_Test.php +++ b/tests/Predis/Command/Redis/HMGET_Test.php @@ -39,8 +39,8 @@ class HMGET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field1', 'field2', 'field3'); - $expected = array('key', 'field1', 'field2', 'field3'); + $arguments = ['key', 'field1', 'field2', 'field3']; + $expected = ['key', 'field1', 'field2', 'field3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HMGET_Test extends PredisCommandTestCase */ public function testFilterArgumentsFieldsAsSingleArray(): void { - $arguments = array('key', array('field1', 'field2', 'field3')); - $expected = array('key', 'field1', 'field2', 'field3'); + $arguments = ['key', ['field1', 'field2', 'field3']]; + $expected = ['key', 'field1', 'field2', 'field3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class HMGET_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('bar', 'piyo', 'wut'); - $expected = array('bar', 'piyo', 'wut'); + $raw = ['bar', 'piyo', 'wut']; + $expected = ['bar', 'piyo', 'wut']; $command = $this->getCommand(); @@ -85,10 +85,10 @@ class HMGET_Test extends PredisCommandTestCase $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $this->assertSame(array('bar', 'piyo', null), $redis->hmget('metavars', 'foo', 'hoge', 'unknown')); - $this->assertSame(array('bar', 'bar'), $redis->hmget('metavars', 'foo', 'foo')); - $this->assertSame(array(null, null), $redis->hmget('metavars', 'unknown', 'unknown')); - $this->assertSame(array(null, null), $redis->hmget('unknown', 'foo', 'hoge')); + $this->assertSame(['bar', 'piyo', null], $redis->hmget('metavars', 'foo', 'hoge', 'unknown')); + $this->assertSame(['bar', 'bar'], $redis->hmget('metavars', 'foo', 'foo')); + $this->assertSame([null, null], $redis->hmget('metavars', 'unknown', 'unknown')); + $this->assertSame([null, null], $redis->hmget('unknown', 'foo', 'hoge')); } /** diff --git a/tests/Predis/Command/Redis/HMSET_Test.php b/tests/Predis/Command/Redis/HMSET_Test.php index f7f4770e..5804df6a 100644 --- a/tests/Predis/Command/Redis/HMSET_Test.php +++ b/tests/Predis/Command/Redis/HMSET_Test.php @@ -39,8 +39,8 @@ class HMSET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field1', 'value1', 'field2', 'value2'); - $expected = array('key', 'field1', 'value1', 'field2', 'value2'); + $arguments = ['key', 'field1', 'value1', 'field2', 'value2']; + $expected = ['key', 'field1', 'value1', 'field2', 'value2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HMSET_Test extends PredisCommandTestCase */ public function testFilterArgumentsFieldsValuesAsSingleArray(): void { - $arguments = array('key', array('field1' => 'value1', 'field2' => 'value2')); - $expected = array('key', 'field1', 'value1', 'field2', 'value2'); + $arguments = ['key', ['field1' => 'value1', 'field2' => 'value2']]; + $expected = ['key', 'field1', 'value1', 'field2', 'value2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -79,10 +79,10 @@ class HMSET_Test extends PredisCommandTestCase $redis = $this->getClient(); $this->assertEquals('OK', $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo')); - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => 'bar', 'hoge' => 'piyo'], $redis->hgetall('metavars')); $this->assertEquals('OK', $redis->hmset('metavars', 'foo', 'barbar', 'lol', 'wut')); - $this->assertSame(array('foo' => 'barbar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => 'barbar', 'hoge' => 'piyo', 'lol' => 'wut'], $redis->hgetall('metavars')); } /** @@ -95,7 +95,7 @@ class HMSET_Test extends PredisCommandTestCase $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); + $this->assertSame(['foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'], $redis->hgetall('metavars')); } /** diff --git a/tests/Predis/Command/Redis/HSCAN_Test.php b/tests/Predis/Command/Redis/HSCAN_Test.php index 6e493a69..83ad92c5 100644 --- a/tests/Predis/Command/Redis/HSCAN_Test.php +++ b/tests/Predis/Command/Redis/HSCAN_Test.php @@ -39,8 +39,8 @@ class HSCAN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); - $expected = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); + $arguments = ['key', 0, 'MATCH', 'field:*', 'COUNT', 10]; + $expected = ['key', 0, 'MATCH', 'field:*', 'COUNT', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HSCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsBasicUsage(): void { - $arguments = array('key', 0); - $expected = array('key', 0); + $arguments = ['key', 0]; + $expected = ['key', 0]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class HSCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithOptionsArray(): void { - $arguments = array('key', 0, array('match' => 'field:*', 'count' => 10)); - $expected = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); + $arguments = ['key', 0, ['match' => 'field:*', 'count' => 10]]; + $expected = ['key', 0, 'MATCH', 'field:*', 'COUNT', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -81,8 +81,8 @@ class HSCAN_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('3', array('field:1', '1', 'field:2', '2', 'field:3', '3')); - $expected = array('3', array('field:1' => '1', 'field:2' => '2', 'field:3' => '3')); + $raw = ['3', ['field:1', '1', 'field:2', '2', 'field:3', '3']]; + $expected = ['3', ['field:1' => '1', 'field:2' => '2', 'field:3' => '3']]; $command = $this->getCommand(); @@ -95,8 +95,8 @@ class HSCAN_Test extends PredisCommandTestCase */ public function testScanWithoutMatch(): void { - $expectedFields = array('field:one', 'field:two', 'field:three', 'field:four'); - $expectedValues = array('one', 'two', 'three', 'four'); + $expectedFields = ['field:one', 'field:two', 'field:three', 'field:four']; + $expectedValues = ['one', 'two', 'three', 'four']; $redis = $this->getClient(); $redis->hmset('key', array_combine($expectedFields, $expectedValues)); @@ -115,12 +115,12 @@ class HSCAN_Test extends PredisCommandTestCase public function testScanWithMatchingMembers(): void { $redis = $this->getClient(); - $redis->hmset('key', array('field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four')); + $redis->hmset('key', ['field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four']); $response = $redis->hscan('key', 0, 'MATCH', 'field:t*'); - $this->assertSame(array('field:two', 'field:three'), array_keys($response[1])); - $this->assertSame(array('two', 'three'), array_values($response[1])); + $this->assertSame(['field:two', 'field:three'], array_keys($response[1])); + $this->assertSame(['two', 'three'], array_values($response[1])); } /** @@ -130,7 +130,7 @@ class HSCAN_Test extends PredisCommandTestCase public function testScanWithNoMatchingMembers(): void { $redis = $this->getClient(); - $redis->hmset('key', array('field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four')); + $redis->hmset('key', ['field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four']); $response = $redis->hscan('key', 0, 'MATCH', 'nofield:*'); diff --git a/tests/Predis/Command/Redis/HSETNX_Test.php b/tests/Predis/Command/Redis/HSETNX_Test.php index c1ad3473..1ccb19e1 100644 --- a/tests/Predis/Command/Redis/HSETNX_Test.php +++ b/tests/Predis/Command/Redis/HSETNX_Test.php @@ -39,8 +39,8 @@ class HSETNX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field', 'value'); - $expected = array('key', 'field', 'value'); + $arguments = ['key', 'field', 'value']; + $expected = ['key', 'field', 'value']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -71,7 +71,7 @@ class HSETNX_Test extends PredisCommandTestCase $this->assertSame(1, $redis->hsetnx('metavars', 'hoge', 'piyo')); $this->assertSame(0, $redis->hsetnx('metavars', 'foo', 'barbar')); - $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge')); + $this->assertSame(['bar', 'piyo'], $redis->hmget('metavars', 'foo', 'hoge')); } /** diff --git a/tests/Predis/Command/Redis/HSET_Test.php b/tests/Predis/Command/Redis/HSET_Test.php index b3b5e0cd..e6d77ae2 100644 --- a/tests/Predis/Command/Redis/HSET_Test.php +++ b/tests/Predis/Command/Redis/HSET_Test.php @@ -39,8 +39,8 @@ class HSET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field', 'value'); - $expected = array('key', 'field', 'value'); + $arguments = ['key', 'field', 'value']; + $expected = ['key', 'field', 'value']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -70,7 +70,7 @@ class HSET_Test extends PredisCommandTestCase $this->assertSame(1, $redis->hset('metavars', 'foo', 'bar')); $this->assertSame(1, $redis->hset('metavars', 'hoge', 'piyo')); - $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge')); + $this->assertSame(['bar', 'piyo'], $redis->hmget('metavars', 'foo', 'hoge')); } /** diff --git a/tests/Predis/Command/Redis/HSTRLEN_Test.php b/tests/Predis/Command/Redis/HSTRLEN_Test.php index 07dbc6b2..d832ac62 100644 --- a/tests/Predis/Command/Redis/HSTRLEN_Test.php +++ b/tests/Predis/Command/Redis/HSTRLEN_Test.php @@ -39,8 +39,8 @@ class HSTRLEN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'field'); - $expected = array('key', 'field'); + $arguments = ['key', 'field']; + $expected = ['key', 'field']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/HVALS_Test.php b/tests/Predis/Command/Redis/HVALS_Test.php index 1d94ee96..7456be0e 100644 --- a/tests/Predis/Command/Redis/HVALS_Test.php +++ b/tests/Predis/Command/Redis/HVALS_Test.php @@ -39,8 +39,8 @@ class HVALS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class HVALS_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('foo', 'hoge', 'lol'); - $expected = array('foo', 'hoge', 'lol'); + $raw = ['foo', 'hoge', 'lol']; + $expected = ['foo', 'hoge', 'lol']; $command = $this->getCommand(); @@ -71,8 +71,8 @@ class HVALS_Test extends PredisCommandTestCase $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $this->assertSame(array('bar', 'piyo', 'wut'), $redis->hvals('metavars')); - $this->assertSame(array(), $redis->hvals('unknown')); + $this->assertSame(['bar', 'piyo', 'wut'], $redis->hvals('metavars')); + $this->assertSame([], $redis->hvals('unknown')); } /** diff --git a/tests/Predis/Command/Redis/INCRBYFLOAT_Test.php b/tests/Predis/Command/Redis/INCRBYFLOAT_Test.php index 6829823d..54f1e019 100644 --- a/tests/Predis/Command/Redis/INCRBYFLOAT_Test.php +++ b/tests/Predis/Command/Redis/INCRBYFLOAT_Test.php @@ -39,8 +39,8 @@ class INCRBYFLOAT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 5.0); - $expected = array('key', 5.0); + $arguments = ['key', 5.0]; + $expected = ['key', 5.0]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/INCRBY_Test.php b/tests/Predis/Command/Redis/INCRBY_Test.php index e936f396..98ea60f0 100644 --- a/tests/Predis/Command/Redis/INCRBY_Test.php +++ b/tests/Predis/Command/Redis/INCRBY_Test.php @@ -39,8 +39,8 @@ class INCRBY_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 5); - $expected = array('key', 5); + $arguments = ['key', 5]; + $expected = ['key', 5]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/INCR_Test.php b/tests/Predis/Command/Redis/INCR_Test.php index 3563a88b..a7080276 100644 --- a/tests/Predis/Command/Redis/INCR_Test.php +++ b/tests/Predis/Command/Redis/INCR_Test.php @@ -39,8 +39,8 @@ class INCR_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/INFO_Test.php b/tests/Predis/Command/Redis/INFO_Test.php index 100eb5c7..d5920910 100644 --- a/tests/Predis/Command/Redis/INFO_Test.php +++ b/tests/Predis/Command/Redis/INFO_Test.php @@ -40,9 +40,9 @@ class INFO_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** @@ -118,8 +118,8 @@ db5:keys=1,expires=0 BUFFER; - $expected = array( - 'Server' => array( + $expected = [ + 'Server' => [ 'redis_version' => '2.9.0', 'redis_git_sha1' => '237194b7', 'redis_git_dirty' => '0', @@ -130,14 +130,14 @@ BUFFER; 'uptime_in_seconds' => '444', 'uptime_in_days' => '0', 'lru_clock' => '198040', - ), - 'Clients' => array( + ], + 'Clients' => [ 'connected_clients' => '1', 'client_longest_output_list' => '0', 'client_biggest_input_buf' => '0', 'blocked_clients' => '0', - ), - 'Memory' => array( + ], + 'Memory' => [ 'used_memory' => '628076', 'used_memory_human' => '613.36K', 'used_memory_rss' => '1568768', @@ -146,16 +146,16 @@ BUFFER; 'used_memory_lua' => '14336', 'mem_fragmentation_ratio' => '2.50', 'mem_allocator' => 'jemalloc-2.2.1', - ), - 'Persistence' => array( + ], + 'Persistence' => [ 'loading' => '0', 'aof_enabled' => '0', 'changes_since_last_save' => '0', 'bgsave_in_progress' => '0', 'last_save_time' => '1323185719', 'bgrewriteaof_in_progress' => '0', - ), - 'Stats' => array( + ], + 'Stats' => [ 'total_connections_received' => '4', 'total_commands_processed' => '3', 'rejected_connections' => '0', @@ -166,25 +166,25 @@ BUFFER; 'pubsub_channels' => '0', 'pubsub_patterns' => '0', 'latest_fork_usec' => '0', - ), - 'Replication' => array( + ], + 'Replication' => [ 'role' => 'master', 'connected_slaves' => '0', - ), - 'CPU' => array( + ], + 'CPU' => [ 'used_cpu_sys' => '0.06', 'used_cpu_user' => '0.06', 'used_cpu_sys_children' => '0.00', 'used_cpu_user_children' => '0.00', - ), - 'Cluster' => array( + ], + 'Cluster' => [ 'cluster_enabled' => '0', - ), - 'Keyspace' => array( - 'db0' => array('keys' => '2', 'expires' => '0'), - 'db5' => array('keys' => '1', 'expires' => '0'), - ), - ); + ], + 'Keyspace' => [ + 'db0' => ['keys' => '2', 'expires' => '0'], + 'db5' => ['keys' => '1', 'expires' => '0'], + ], + ]; $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); } @@ -242,7 +242,7 @@ db5:keys=1,expires=0 BUFFER; - $expected = array( + $expected = [ 'redis_version' => '2.4.4', 'redis_git_sha1' => 'bc62bc5e', 'redis_git_dirty' => '0', @@ -285,9 +285,9 @@ BUFFER; 'latest_fork_usec' => '0', 'vm_enabled' => '0', 'role' => 'master', - 'db0' => array('keys' => '2', 'expires' => '0'), - 'db5' => array('keys' => '1', 'expires' => '0'), - ); + 'db0' => ['keys' => '2', 'expires' => '0'], + 'db5' => ['keys' => '1', 'expires' => '0'], + ]; $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); } @@ -297,7 +297,7 @@ BUFFER; */ public function testDoesNotEmitPhpNoticeOnEmptyResponse(): void { - $this->assertSame(array(), $this->getCommand()->parseResponse('')); + $this->assertSame([], $this->getCommand()->parseResponse('')); } /** diff --git a/tests/Predis/Command/Redis/KEYS_Test.php b/tests/Predis/Command/Redis/KEYS_Test.php index 5921c3da..8ca855a6 100644 --- a/tests/Predis/Command/Redis/KEYS_Test.php +++ b/tests/Predis/Command/Redis/KEYS_Test.php @@ -39,8 +39,8 @@ class KEYS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('pattern:*'); - $expected = array('pattern:*'); + $arguments = ['pattern:*']; + $expected = ['pattern:*']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class KEYS_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('key1', 'key2', 'key3'); - $parsed = array('key1', 'key2', 'key3'); + $raw = ['key1', 'key2', 'key3']; + $parsed = ['key1', 'key2', 'key3']; $this->assertSame($parsed, $this->getCommand()->parseResponse($raw)); } @@ -64,14 +64,14 @@ class KEYS_Test extends PredisCommandTestCase */ public function testReturnsArrayOfMatchingKeys(): void { - $keys = array('aaa' => 1, 'aba' => 2, 'aca' => 3); - $keysNS = array('metavar:foo' => 'bar', 'metavar:hoge' => 'piyo'); + $keys = ['aaa' => 1, 'aba' => 2, 'aca' => 3]; + $keysNS = ['metavar:foo' => 'bar', 'metavar:hoge' => 'piyo']; $keysAll = array_merge($keys, $keysNS); $redis = $this->getClient(); $redis->mset($keysAll); - $this->assertSame(array(), $redis->keys('nomatch:*')); + $this->assertSame([], $redis->keys('nomatch:*')); $this->assertSameValues(array_keys($keysNS), $redis->keys('metavar:*')); $this->assertSameValues(array_keys($keysAll), $redis->keys('*')); $this->assertSameValues(array_keys($keys), $redis->keys('a?a')); diff --git a/tests/Predis/Command/Redis/LASTSAVE_Test.php b/tests/Predis/Command/Redis/LASTSAVE_Test.php index 14c7a7ad..7ced5e96 100644 --- a/tests/Predis/Command/Redis/LASTSAVE_Test.php +++ b/tests/Predis/Command/Redis/LASTSAVE_Test.php @@ -40,9 +40,9 @@ class LASTSAVE_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/LINDEX_Test.php b/tests/Predis/Command/Redis/LINDEX_Test.php index 7ec73cf4..beb06544 100644 --- a/tests/Predis/Command/Redis/LINDEX_Test.php +++ b/tests/Predis/Command/Redis/LINDEX_Test.php @@ -39,8 +39,8 @@ class LINDEX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 1); - $expected = array('key', 1); + $arguments = ['key', 1]; + $expected = ['key', 1]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/LINSERT_Test.php b/tests/Predis/Command/Redis/LINSERT_Test.php index 5037ed5b..ae996936 100644 --- a/tests/Predis/Command/Redis/LINSERT_Test.php +++ b/tests/Predis/Command/Redis/LINSERT_Test.php @@ -39,8 +39,8 @@ class LINSERT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'before', 'value1', 'value2'); - $expected = array('key', 'before', 'value1', 'value2'); + $arguments = ['key', 'before', 'value1', 'value2']; + $expected = ['key', 'before', 'value1', 'value2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class LINSERT_Test extends PredisCommandTestCase $this->assertSame(4, $redis->linsert('letters', 'before', 'c', 'b')); $this->assertSame(5, $redis->linsert('letters', 'after', 'c', 'd')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd', 'e'], $redis->lrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/LLEN_Test.php b/tests/Predis/Command/Redis/LLEN_Test.php index f24713cf..282b3447 100644 --- a/tests/Predis/Command/Redis/LLEN_Test.php +++ b/tests/Predis/Command/Redis/LLEN_Test.php @@ -39,8 +39,8 @@ class LLEN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/LPOP_Test.php b/tests/Predis/Command/Redis/LPOP_Test.php index 76233e1c..242aab7f 100644 --- a/tests/Predis/Command/Redis/LPOP_Test.php +++ b/tests/Predis/Command/Redis/LPOP_Test.php @@ -39,8 +39,8 @@ class LPOP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class LPOP_Test extends PredisCommandTestCase $this->assertSame('a', $redis->lpop('letters')); $this->assertSame('b', $redis->lpop('letters')); - $this->assertSame(array('c', 'd'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['c', 'd'], $redis->lrange('letters', 0, -1)); } /** @@ -104,8 +104,8 @@ class LPOP_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f'); - $this->assertSame(array('a', 'b'), $redis->lpop('letters', 2)); - $this->assertSame(array('c', 'd'), $redis->lpop('letters', 2)); - $this->assertSame(array('e', 'f'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b'], $redis->lpop('letters', 2)); + $this->assertSame(['c', 'd'], $redis->lpop('letters', 2)); + $this->assertSame(['e', 'f'], $redis->lrange('letters', 0, -1)); } } diff --git a/tests/Predis/Command/Redis/LPUSHX_Test.php b/tests/Predis/Command/Redis/LPUSHX_Test.php index c04e304e..fa9ef4a6 100644 --- a/tests/Predis/Command/Redis/LPUSHX_Test.php +++ b/tests/Predis/Command/Redis/LPUSHX_Test.php @@ -39,8 +39,8 @@ class LPUSHX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); + $arguments = ['key', 'value']; + $expected = ['key', 'value']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class LPUSHX_Test extends PredisCommandTestCase $redis->lpush('metavars', 'foo'); $this->assertSame(2, $redis->lpushx('metavars', 'hoge')); - $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1)); + $this->assertSame(['hoge', 'foo'], $redis->lrange('metavars', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/LPUSH_Test.php b/tests/Predis/Command/Redis/LPUSH_Test.php index 66b99235..788289db 100644 --- a/tests/Predis/Command/Redis/LPUSH_Test.php +++ b/tests/Predis/Command/Redis/LPUSH_Test.php @@ -39,8 +39,8 @@ class LPUSH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'value1', 'value2', 'value3'); - $expected = array('key', 'value1', 'value2', 'value3'); + $arguments = ['key', 'value1', 'value2', 'value3']; + $expected = ['key', 'value1', 'value2', 'value3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class LPUSH_Test extends PredisCommandTestCase */ public function testFilterArgumentsValuesAsSingleArray(): void { - $arguments = array('key', array('value1', 'value2', 'value3')); - $expected = array('key', 'value1', 'value2', 'value3'); + $arguments = ['key', ['value1', 'value2', 'value3']]; + $expected = ['key', 'value1', 'value2', 'value3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -80,7 +80,7 @@ class LPUSH_Test extends PredisCommandTestCase // NOTE: List push operations return the list length since Redis commit 520b5a3 $this->assertSame(1, $redis->lpush('metavars', 'foo')); $this->assertSame(2, $redis->lpush('metavars', 'hoge')); - $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1)); + $this->assertSame(['hoge', 'foo'], $redis->lrange('metavars', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/LRANGE_Test.php b/tests/Predis/Command/Redis/LRANGE_Test.php index bb1b5d5d..56e0ee22 100644 --- a/tests/Predis/Command/Redis/LRANGE_Test.php +++ b/tests/Predis/Command/Redis/LRANGE_Test.php @@ -39,8 +39,8 @@ class LRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, -1); - $expected = array('key', 0, -1); + $arguments = ['key', 0, -1]; + $expected = ['key', 0, -1]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class LRANGE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('value1', 'value2', 'value3'); - $expected = array('value1', 'value2', 'value3'); + $raw = ['value1', 'value2', 'value3']; + $expected = ['value1', 'value2', 'value3']; $command = $this->getCommand(); @@ -70,10 +70,10 @@ class LRANGE_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - $this->assertSame(array('a', 'b', 'c', 'd'), $redis->lrange('letters', 0, 3)); - $this->assertSame(array('e', 'f', 'g', 'h'), $redis->lrange('letters', 4, 7)); - $this->assertSame(array('a', 'b'), $redis->lrange('letters', 0, 1)); - $this->assertSame(array('a'), $redis->lrange('letters', 0, 0)); + $this->assertSame(['a', 'b', 'c', 'd'], $redis->lrange('letters', 0, 3)); + $this->assertSame(['e', 'f', 'g', 'h'], $redis->lrange('letters', 4, 7)); + $this->assertSame(['a', 'b'], $redis->lrange('letters', 0, 1)); + $this->assertSame(['a'], $redis->lrange('letters', 0, 0)); } /** @@ -85,9 +85,9 @@ class LRANGE_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', 0, -1)); - $this->assertSame(array('f'), $redis->lrange('letters', 5, -5)); - $this->assertSame(array(), $redis->lrange('letters', 7, -5)); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'], $redis->lrange('letters', 0, -1)); + $this->assertSame(['f'], $redis->lrange('letters', 5, -5)); + $this->assertSame([], $redis->lrange('letters', 7, -5)); } /** @@ -99,7 +99,7 @@ class LRANGE_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - $this->assertSame(array('f'), $redis->lrange('letters', -5, -5)); + $this->assertSame(['f'], $redis->lrange('letters', -5, -5)); } /** @@ -111,7 +111,7 @@ class LRANGE_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', -100, 100)); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'], $redis->lrange('letters', -100, 100)); } /** @@ -121,7 +121,7 @@ class LRANGE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array(), $redis->lrange('letters', 0, -1)); + $this->assertSame([], $redis->lrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/LREM_Test.php b/tests/Predis/Command/Redis/LREM_Test.php index 0bd49168..ba758a2f 100644 --- a/tests/Predis/Command/Redis/LREM_Test.php +++ b/tests/Predis/Command/Redis/LREM_Test.php @@ -39,8 +39,8 @@ class LREM_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 1, 'value'); - $expected = array('key', 1, 'value'); + $arguments = ['key', 1, 'value']; + $expected = ['key', 1, 'value']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -66,7 +66,7 @@ class LREM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); $this->assertSame(2, $redis->lrem('letters', 2, '_')); - $this->assertSame(array('a', 'b', 'c', '_', 'd', '_'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', '_', 'd', '_'], $redis->lrange('letters', 0, -1)); } /** @@ -79,7 +79,7 @@ class LREM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); $this->assertSame(2, $redis->lrem('letters', -2, '_')); - $this->assertSame(array('a', '_', 'b', '_', 'c', 'd'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', '_', 'b', '_', 'c', 'd'], $redis->lrange('letters', 0, -1)); } /** @@ -92,7 +92,7 @@ class LREM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); $this->assertSame(4, $redis->lrem('letters', 0, '_')); - $this->assertSame(array('a', 'b', 'c', 'd'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd'], $redis->lrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/LSET_Test.php b/tests/Predis/Command/Redis/LSET_Test.php index 52ef0573..3b217ba1 100644 --- a/tests/Predis/Command/Redis/LSET_Test.php +++ b/tests/Predis/Command/Redis/LSET_Test.php @@ -39,8 +39,8 @@ class LSET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 'value'); - $expected = array('key', 0, 'value'); + $arguments = ['key', 0, 'value']; + $expected = ['key', 0, 'value']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -66,7 +66,7 @@ class LSET_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c'); $this->assertEquals('OK', $redis->lset('letters', 1, 'B')); - $this->assertSame(array('a', 'B', 'c'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'B', 'c'], $redis->lrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/LTRIM_Test.php b/tests/Predis/Command/Redis/LTRIM_Test.php index 213e0ea0..85ba29b7 100644 --- a/tests/Predis/Command/Redis/LTRIM_Test.php +++ b/tests/Predis/Command/Redis/LTRIM_Test.php @@ -39,8 +39,8 @@ class LTRIM_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 1); - $expected = array('key', 0, 1); + $arguments = ['key', 0, 1]; + $expected = ['key', 0, 1]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -66,13 +66,13 @@ class LTRIM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); $this->assertEquals('OK', $redis->ltrim('letters', 0, 2)); - $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c'], $redis->lrange('letters', 0, -1)); $redis->flushdb(); $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); $this->assertEquals('OK', $redis->ltrim('letters', 5, 9)); - $this->assertSame(array('f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['f', 'g', 'h', 'i', 'l'], $redis->lrange('letters', 0, -1)); } /** @@ -85,7 +85,7 @@ class LTRIM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); $this->assertEquals('OK', $redis->ltrim('letters', 0, -6)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd', 'e'], $redis->lrange('letters', 0, -1)); } /** @@ -98,7 +98,7 @@ class LTRIM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); $this->assertEquals('OK', $redis->ltrim('letters', -5, -5)); - $this->assertSame(array('f'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['f'], $redis->lrange('letters', 0, -1)); } /** @@ -111,7 +111,7 @@ class LTRIM_Test extends PredisCommandTestCase $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); $this->assertEquals('OK', $redis->ltrim('letters', -100, 100)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', -100, 100)); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'], $redis->lrange('letters', -100, 100)); } /** diff --git a/tests/Predis/Command/Redis/MGET_Test.php b/tests/Predis/Command/Redis/MGET_Test.php index 036f76e8..126e0076 100644 --- a/tests/Predis/Command/Redis/MGET_Test.php +++ b/tests/Predis/Command/Redis/MGET_Test.php @@ -39,8 +39,8 @@ class MGET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); + $arguments = ['key1', 'key2', 'key3']; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class MGET_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); + $arguments = [['key1', 'key2', 'key3']]; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class MGET_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('value1', 'value2', 'value3'); - $expected = array('value1', 'value2', 'value3'); + $raw = ['value1', 'value2', 'value3']; + $expected = ['value1', 'value2', 'value3']; $command = $this->getCommand(); @@ -85,7 +85,7 @@ class MGET_Test extends PredisCommandTestCase $redis->set('foo', 'bar'); $redis->set('hoge', 'piyo'); - $this->assertSame(array('bar', 'piyo'), $redis->mget('foo', 'hoge')); + $this->assertSame(['bar', 'piyo'], $redis->mget('foo', 'hoge')); } /** @@ -95,7 +95,7 @@ class MGET_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array(null, null), $redis->mget('foo', 'hoge')); + $this->assertSame([null, null], $redis->mget('foo', 'hoge')); } /** @@ -106,6 +106,6 @@ class MGET_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->lpush('metavars', 'foo'); - $this->assertSame(array(null), $redis->mget('metavars')); + $this->assertSame([null], $redis->mget('metavars')); } } diff --git a/tests/Predis/Command/Redis/MIGRATE_Test.php b/tests/Predis/Command/Redis/MIGRATE_Test.php index 68e56ca0..6d4b27d6 100644 --- a/tests/Predis/Command/Redis/MIGRATE_Test.php +++ b/tests/Predis/Command/Redis/MIGRATE_Test.php @@ -39,8 +39,8 @@ class MIGRATE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('127.0.0.1', '6379', 'key', '0', '10'); - $expected = array('127.0.0.1', '6379', 'key', '0', '10'); + $arguments = ['127.0.0.1', '6379', 'key', '0', '10']; + $expected = ['127.0.0.1', '6379', 'key', '0', '10']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class MIGRATE_Test extends PredisCommandTestCase */ public function testFilterArgumentsRedis300(): void { - $arguments = array('127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'); - $expected = array('127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'); + $arguments = ['127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE']; + $expected = ['127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class MIGRATE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithOptionsArray(): void { - $arguments = array('127.0.0.1', '6379', 'key', '0', '10', array('COPY' => true, 'REPLACE' => true)); - $expected = array('127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE'); + $arguments = ['127.0.0.1', '6379', 'key', '0', '10', ['COPY' => true, 'REPLACE' => true]]; + $expected = ['127.0.0.1', '6379', 'key', '0', '10', 'COPY', 'REPLACE']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/MONITOR_Test.php b/tests/Predis/Command/Redis/MONITOR_Test.php index a42241eb..21f6ea4b 100644 --- a/tests/Predis/Command/Redis/MONITOR_Test.php +++ b/tests/Predis/Command/Redis/MONITOR_Test.php @@ -41,9 +41,9 @@ class MONITOR_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/MOVE_Test.php b/tests/Predis/Command/Redis/MOVE_Test.php index da6976c3..65c1838c 100644 --- a/tests/Predis/Command/Redis/MOVE_Test.php +++ b/tests/Predis/Command/Redis/MOVE_Test.php @@ -39,8 +39,8 @@ class MOVE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 10); - $expected = array('key', 10); + $arguments = ['key', 10]; + $expected = ['key', 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/MSETNX_Test.php b/tests/Predis/Command/Redis/MSETNX_Test.php index c5d8e9f7..d3948b3b 100644 --- a/tests/Predis/Command/Redis/MSETNX_Test.php +++ b/tests/Predis/Command/Redis/MSETNX_Test.php @@ -39,8 +39,8 @@ class MSETNX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('foo', 'bar', 'hoge', 'piyo'); - $expected = array('foo', 'bar', 'hoge', 'piyo'); + $arguments = ['foo', 'bar', 'hoge', 'piyo']; + $expected = ['foo', 'bar', 'hoge', 'piyo']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class MSETNX_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleNamedArray(): void { - $arguments = array(array('foo' => 'bar', 'hoge' => 'piyo')); - $expected = array('foo', 'bar', 'hoge', 'piyo'); + $arguments = [['foo' => 'bar', 'hoge' => 'piyo']]; + $expected = ['foo', 'bar', 'hoge', 'piyo']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/MSET_Test.php b/tests/Predis/Command/Redis/MSET_Test.php index 1141bee8..3430d787 100644 --- a/tests/Predis/Command/Redis/MSET_Test.php +++ b/tests/Predis/Command/Redis/MSET_Test.php @@ -39,8 +39,8 @@ class MSET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('foo', 'bar', 'hoge', 'piyo'); - $expected = array('foo', 'bar', 'hoge', 'piyo'); + $arguments = ['foo', 'bar', 'hoge', 'piyo']; + $expected = ['foo', 'bar', 'hoge', 'piyo']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class MSET_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleNamedArray(): void { - $arguments = array(array('foo' => 'bar', 'hoge' => 'piyo')); - $expected = array('foo', 'bar', 'hoge', 'piyo'); + $arguments = [['foo' => 'bar', 'hoge' => 'piyo']]; + $expected = ['foo', 'bar', 'hoge', 'piyo']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/MULTI_Test.php b/tests/Predis/Command/Redis/MULTI_Test.php index 0af17a92..9992149d 100644 --- a/tests/Predis/Command/Redis/MULTI_Test.php +++ b/tests/Predis/Command/Redis/MULTI_Test.php @@ -40,9 +40,9 @@ class MULTI_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/OBJECT_Test.php b/tests/Predis/Command/Redis/OBJECT_Test.php index 0a3535dc..7fbec0e6 100644 --- a/tests/Predis/Command/Redis/OBJECT_Test.php +++ b/tests/Predis/Command/Redis/OBJECT_Test.php @@ -39,8 +39,8 @@ class OBJECT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('REFCOUNT', 'key'); - $expected = array('REFCOUNT', 'key'); + $arguments = ['REFCOUNT', 'key']; + $expected = ['REFCOUNT', 'key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PERSIST_Test.php b/tests/Predis/Command/Redis/PERSIST_Test.php index 5b3ff44f..99432a50 100644 --- a/tests/Predis/Command/Redis/PERSIST_Test.php +++ b/tests/Predis/Command/Redis/PERSIST_Test.php @@ -39,8 +39,8 @@ class PERSIST_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PEXPIREAT_Test.php b/tests/Predis/Command/Redis/PEXPIREAT_Test.php index 8e6cbe7d..0456e859 100644 --- a/tests/Predis/Command/Redis/PEXPIREAT_Test.php +++ b/tests/Predis/Command/Redis/PEXPIREAT_Test.php @@ -39,8 +39,8 @@ class PEXPIREAT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 100); - $expected = array('key', 100); + $arguments = ['key', 100]; + $expected = ['key', 100]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PEXPIRE_Test.php b/tests/Predis/Command/Redis/PEXPIRE_Test.php index 841ff158..c1e24dc2 100644 --- a/tests/Predis/Command/Redis/PEXPIRE_Test.php +++ b/tests/Predis/Command/Redis/PEXPIRE_Test.php @@ -39,8 +39,8 @@ class PEXPIRE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 100); - $expected = array('key', 100); + $arguments = ['key', 100]; + $expected = ['key', 100]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PFADD_Test.php b/tests/Predis/Command/Redis/PFADD_Test.php index aa96bf6e..e15421d7 100644 --- a/tests/Predis/Command/Redis/PFADD_Test.php +++ b/tests/Predis/Command/Redis/PFADD_Test.php @@ -41,8 +41,8 @@ class PFADD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'a', 'b', 'c'); - $expected = array('key', 'a', 'b', 'c'); + $arguments = ['key', 'a', 'b', 'c']; + $expected = ['key', 'a', 'b', 'c']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -55,8 +55,8 @@ class PFADD_Test extends PredisCommandTestCase */ public function testFilterArgumentsFieldsAsSingleArray(): void { - $arguments = array('key', array('a', 'b', 'c')); - $expected = array('key', 'a', 'b', 'c'); + $arguments = ['key', ['a', 'b', 'c']]; + $expected = ['key', 'a', 'b', 'c']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PFCOUNT_Test.php b/tests/Predis/Command/Redis/PFCOUNT_Test.php index ad80d8ba..302f6d2b 100644 --- a/tests/Predis/Command/Redis/PFCOUNT_Test.php +++ b/tests/Predis/Command/Redis/PFCOUNT_Test.php @@ -41,8 +41,8 @@ class PFCOUNT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:1', 'key:2'); - $expected = array('key:1', 'key:2'); + $arguments = ['key:1', 'key:2']; + $expected = ['key:1', 'key:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -55,8 +55,8 @@ class PFCOUNT_Test extends PredisCommandTestCase */ public function testFilterArgumentsFieldsAsSingleArray(): void { - $arguments = array(array('key:1', 'key:2')); - $expected = array('key:1', 'key:2'); + $arguments = [['key:1', 'key:2']]; + $expected = ['key:1', 'key:2']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PFMERGE_Test.php b/tests/Predis/Command/Redis/PFMERGE_Test.php index 5ec45b0f..d6a57210 100644 --- a/tests/Predis/Command/Redis/PFMERGE_Test.php +++ b/tests/Predis/Command/Redis/PFMERGE_Test.php @@ -41,8 +41,8 @@ class PFMERGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:1', 'key:2', 'key:3'); - $expected = array('key:1', 'key:2', 'key:3'); + $arguments = ['key:1', 'key:2', 'key:3']; + $expected = ['key:1', 'key:2', 'key:3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -55,8 +55,8 @@ class PFMERGE_Test extends PredisCommandTestCase */ public function testFilterArgumentsFieldsAsSingleArray(): void { - $arguments = array(array('key:1', 'key:2', 'key:3')); - $expected = array('key:1', 'key:2', 'key:3'); + $arguments = [['key:1', 'key:2', 'key:3']]; + $expected = ['key:1', 'key:2', 'key:3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PING_Test.php b/tests/Predis/Command/Redis/PING_Test.php index c134b7f1..731597b0 100644 --- a/tests/Predis/Command/Redis/PING_Test.php +++ b/tests/Predis/Command/Redis/PING_Test.php @@ -39,8 +39,8 @@ class PING_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array(); - $expected = array(); + $arguments = []; + $expected = []; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PSETEX_Test.php b/tests/Predis/Command/Redis/PSETEX_Test.php index 71cca643..e70731a6 100644 --- a/tests/Predis/Command/Redis/PSETEX_Test.php +++ b/tests/Predis/Command/Redis/PSETEX_Test.php @@ -39,8 +39,8 @@ class PSETEX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 10, 'hello'); - $expected = array('key', 10, 'hello'); + $arguments = ['key', 10, 'hello']; + $expected = ['key', 10, 'hello']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PSUBSCRIBE_Test.php b/tests/Predis/Command/Redis/PSUBSCRIBE_Test.php index 0ead4886..92e99b44 100644 --- a/tests/Predis/Command/Redis/PSUBSCRIBE_Test.php +++ b/tests/Predis/Command/Redis/PSUBSCRIBE_Test.php @@ -39,8 +39,8 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('channel:foo:*', 'channel:hoge:*'); - $expected = array('channel:foo:*', 'channel:hoge:*'); + $arguments = ['channel:foo:*', 'channel:hoge:*']; + $expected = ['channel:foo:*', 'channel:hoge:*']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('channel:foo:*', 'channel:hoge:*')); - $expected = array('channel:foo:*', 'channel:hoge:*'); + $arguments = [['channel:foo:*', 'channel:hoge:*']]; + $expected = ['channel:foo:*', 'channel:hoge:*']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('psubscribe', 'channel:*', 1); - $expected = array('psubscribe', 'channel:*', 1); + $raw = ['psubscribe', 'channel:*', 1]; + $expected = ['psubscribe', 'channel:*', 1]; $command = $this->getCommand(); @@ -83,7 +83,7 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('psubscribe', 'channel:*', 1), $redis->psubscribe('channel:*')); + $this->assertSame(['psubscribe', 'channel:*', 1], $redis->psubscribe('channel:*')); } /** @@ -94,8 +94,8 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); + $this->assertSame(['psubscribe', 'channel:foo:*', 1], $redis->psubscribe('channel:foo:*')); + $this->assertSame(['psubscribe', 'channel:hoge:*', 2], $redis->psubscribe('channel:hoge:*')); } /** @@ -106,8 +106,8 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('subscribe', 'channel:foo:bar', 2), $redis->subscribe('channel:foo:bar')); + $this->assertSame(['psubscribe', 'channel:foo:*', 1], $redis->psubscribe('channel:foo:*')); + $this->assertSame(['subscribe', 'channel:foo:bar', 2], $redis->subscribe('channel:foo:bar')); } /** @@ -118,9 +118,9 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); - $this->assertSame(array('unsubscribe', 'channel:foo:bar', 2), $redis->unsubscribe('channel:foo:bar')); + $this->assertSame(['psubscribe', 'channel:foo:*', 1], $redis->psubscribe('channel:foo:*')); + $this->assertSame(['psubscribe', 'channel:hoge:*', 2], $redis->psubscribe('channel:hoge:*')); + $this->assertSame(['unsubscribe', 'channel:foo:bar', 2], $redis->unsubscribe('channel:foo:bar')); } /** @@ -131,9 +131,9 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); - $this->assertSame(array('punsubscribe', 'channel:*:*', 2), $redis->punsubscribe('channel:*:*')); + $this->assertSame(['psubscribe', 'channel:foo:*', 1], $redis->psubscribe('channel:foo:*')); + $this->assertSame(['psubscribe', 'channel:hoge:*', 2], $redis->psubscribe('channel:hoge:*')); + $this->assertSame(['punsubscribe', 'channel:*:*', 2], $redis->punsubscribe('channel:*:*')); } /** @@ -145,7 +145,7 @@ class PSUBSCRIBE_Test extends PredisCommandTestCase $redis = $this->getClient(); $quit = $this->getCommandFactory()->create('quit'); - $this->assertSame(array('subscribe', 'channel1', 1), $redis->subscribe('channel1')); + $this->assertSame(['subscribe', 'channel1', 1], $redis->subscribe('channel1')); $this->assertEquals('OK', $redis->executeCommand($quit)); } diff --git a/tests/Predis/Command/Redis/PTTL_Test.php b/tests/Predis/Command/Redis/PTTL_Test.php index 39e8f1f3..495e02be 100644 --- a/tests/Predis/Command/Redis/PTTL_Test.php +++ b/tests/Predis/Command/Redis/PTTL_Test.php @@ -39,8 +39,8 @@ class PTTL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 10); - $expected = array('key', 10); + $arguments = ['key', 10]; + $expected = ['key', 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PUBLISH_Test.php b/tests/Predis/Command/Redis/PUBLISH_Test.php index 841a16b8..8d42ec85 100644 --- a/tests/Predis/Command/Redis/PUBLISH_Test.php +++ b/tests/Predis/Command/Redis/PUBLISH_Test.php @@ -39,8 +39,8 @@ class PUBLISH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('channel', 'message'); - $expected = array('channel', 'message'); + $arguments = ['channel', 'message']; + $expected = ['channel', 'message']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/PUBSUB_Test.php b/tests/Predis/Command/Redis/PUBSUB_Test.php index 0430401f..5fb348da 100644 --- a/tests/Predis/Command/Redis/PUBSUB_Test.php +++ b/tests/Predis/Command/Redis/PUBSUB_Test.php @@ -39,8 +39,8 @@ class PUBSUB_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('channels', 'predis:*'); - $expected = array('channels', 'predis:*'); + $arguments = ['channels', 'predis:*']; + $expected = ['channels', 'predis:*']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class PUBSUB_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $response = array('predis:incoming', 'predis:outgoing'); - $expected = array('predis:incoming', 'predis:outgoing'); + $response = ['predis:incoming', 'predis:outgoing']; + $expected = ['predis:incoming', 'predis:outgoing']; $command = $this->getCommandWithArguments('channels', 'predis:*'); @@ -66,8 +66,8 @@ class PUBSUB_Test extends PredisCommandTestCase */ public function testPubsubNumsub(): void { - $response = array('predis:incoming', '10', 'predis:outgoing', '8'); - $expected = array('predis:incoming' => '10', 'predis:outgoing' => '8'); + $response = ['predis:incoming', '10', 'predis:outgoing', '8']; + $expected = ['predis:incoming' => '10', 'predis:outgoing' => '8']; $command = $this->getCommandWithArguments('numsub', 'predis:incoming', 'predis:outgoing'); diff --git a/tests/Predis/Command/Redis/PUNSUBSCRIBE_Test.php b/tests/Predis/Command/Redis/PUNSUBSCRIBE_Test.php index 16f9c608..c3804bb6 100644 --- a/tests/Predis/Command/Redis/PUNSUBSCRIBE_Test.php +++ b/tests/Predis/Command/Redis/PUNSUBSCRIBE_Test.php @@ -39,8 +39,8 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('channel:foo:*', 'channel:bar:*'); - $expected = array('channel:foo:*', 'channel:bar:*'); + $arguments = ['channel:foo:*', 'channel:bar:*']; + $expected = ['channel:foo:*', 'channel:bar:*']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('channel:foo:*', 'channel:bar:*')); - $expected = array('channel:foo:*', 'channel:bar:*'); + $arguments = [['channel:foo:*', 'channel:bar:*']]; + $expected = ['channel:foo:*', 'channel:bar:*']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('punsubscribe', 'channel:*', 1); - $expected = array('punsubscribe', 'channel:*', 1); + $raw = ['punsubscribe', 'channel:*', 1]; + $expected = ['punsubscribe', 'channel:*', 1]; $command = $this->getCommand(); @@ -83,7 +83,7 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('punsubscribe', 'channel:*', 0), $redis->punsubscribe('channel:*')); + $this->assertSame(['punsubscribe', 'channel:*', 0], $redis->punsubscribe('channel:*')); $this->assertSame('echoed', $redis->echo('echoed')); } @@ -95,7 +95,7 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('punsubscribe', 'channel:*', 0), $redis->punsubscribe('channel:*')); + $this->assertSame(['punsubscribe', 'channel:*', 0], $redis->punsubscribe('channel:*')); } /** @@ -106,9 +106,9 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('punsubscribe', 'channel:*', 2), $redis->punsubscribe('channel:*')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:bar', 2], $redis->subscribe('channel:bar')); + $this->assertSame(['punsubscribe', 'channel:*', 2], $redis->punsubscribe('channel:*')); } /** @@ -119,8 +119,8 @@ class PUNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('punsubscribe', null, 2), $redis->punsubscribe()); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:bar', 2], $redis->subscribe('channel:bar')); + $this->assertSame(['punsubscribe', null, 2], $redis->punsubscribe()); } } diff --git a/tests/Predis/Command/Redis/QUIT_Test.php b/tests/Predis/Command/Redis/QUIT_Test.php index aa831378..12cd82f2 100644 --- a/tests/Predis/Command/Redis/QUIT_Test.php +++ b/tests/Predis/Command/Redis/QUIT_Test.php @@ -39,8 +39,8 @@ class QUIT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array(); - $expected = array(); + $arguments = []; + $expected = []; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/RANDOMKEY_Test.php b/tests/Predis/Command/Redis/RANDOMKEY_Test.php index b162abe8..d074fa64 100644 --- a/tests/Predis/Command/Redis/RANDOMKEY_Test.php +++ b/tests/Predis/Command/Redis/RANDOMKEY_Test.php @@ -39,8 +39,8 @@ class RANDOMKEY_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array(); - $expected = array(); + $arguments = []; + $expected = []; $command = $this->getCommand(); $command->setArguments($arguments); @@ -66,7 +66,7 @@ class RANDOMKEY_Test extends PredisCommandTestCase */ public function testReturnsZeroOnNonExpiringKeys(): void { - $keys = array('key:1' => 1, 'key:2' => 2, 'key:3' => 3); + $keys = ['key:1' => 1, 'key:2' => 2, 'key:3' => 3]; $redis = $this->getClient(); $redis->mset($keys); diff --git a/tests/Predis/Command/Redis/RENAMENX_Test.php b/tests/Predis/Command/Redis/RENAMENX_Test.php index d6befca9..5f991ecc 100644 --- a/tests/Predis/Command/Redis/RENAMENX_Test.php +++ b/tests/Predis/Command/Redis/RENAMENX_Test.php @@ -39,8 +39,8 @@ class RENAMENX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'newkey'); - $expected = array('key', 'newkey'); + $arguments = ['key', 'newkey']; + $expected = ['key', 'newkey']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/RENAME_Test.php b/tests/Predis/Command/Redis/RENAME_Test.php index 17b9e086..f08f96b7 100644 --- a/tests/Predis/Command/Redis/RENAME_Test.php +++ b/tests/Predis/Command/Redis/RENAME_Test.php @@ -39,8 +39,8 @@ class RENAME_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'newkey'); - $expected = array('key', 'newkey'); + $arguments = ['key', 'newkey']; + $expected = ['key', 'newkey']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/RESTORE_Test.php b/tests/Predis/Command/Redis/RESTORE_Test.php index d6944e71..9d7a3d29 100644 --- a/tests/Predis/Command/Redis/RESTORE_Test.php +++ b/tests/Predis/Command/Redis/RESTORE_Test.php @@ -39,8 +39,8 @@ class RESTORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); - $expected = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); + $arguments = ['key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("]; + $expected = ['key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/RPOPLPUSH_Test.php b/tests/Predis/Command/Redis/RPOPLPUSH_Test.php index 8da47308..43f9a4a5 100644 --- a/tests/Predis/Command/Redis/RPOPLPUSH_Test.php +++ b/tests/Predis/Command/Redis/RPOPLPUSH_Test.php @@ -39,8 +39,8 @@ class RPOPLPUSH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:source', 'key:destination'); - $expected = array('key:source', 'key:destination'); + $arguments = ['key:source', 'key:destination']; + $expected = ['key:source', 'key:destination']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -69,8 +69,8 @@ class RPOPLPUSH_Test extends PredisCommandTestCase $this->assertSame('b', $redis->rpoplpush('letters:source', 'letters:destination')); $this->assertSame('a', $redis->rpoplpush('letters:source', 'letters:destination')); - $this->assertSame(array(), $redis->lrange('letters:source', 0, -1)); - $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters:destination', 0, -1)); + $this->assertSame([], $redis->lrange('letters:source', 0, -1)); + $this->assertSame(['a', 'b', 'c'], $redis->lrange('letters:destination', 0, -1)); } /** @@ -86,7 +86,7 @@ class RPOPLPUSH_Test extends PredisCommandTestCase $this->assertSame('b', $redis->rpoplpush('letters:source', 'letters:source')); $this->assertSame('a', $redis->rpoplpush('letters:source', 'letters:source')); - $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters:source', 0, -1)); + $this->assertSame(['a', 'b', 'c'], $redis->lrange('letters:source', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/RPOP_Test.php b/tests/Predis/Command/Redis/RPOP_Test.php index 153131f3..e65a3f81 100644 --- a/tests/Predis/Command/Redis/RPOP_Test.php +++ b/tests/Predis/Command/Redis/RPOP_Test.php @@ -39,8 +39,8 @@ class RPOP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class RPOP_Test extends PredisCommandTestCase $this->assertSame('d', $redis->rpop('letters')); $this->assertSame('c', $redis->rpop('letters')); - $this->assertSame(array('a', 'b'), $redis->lrange('letters', 0, -1)); + $this->assertSame(['a', 'b'], $redis->lrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/RPUSHX_Test.php b/tests/Predis/Command/Redis/RPUSHX_Test.php index 83228036..bc9bf497 100644 --- a/tests/Predis/Command/Redis/RPUSHX_Test.php +++ b/tests/Predis/Command/Redis/RPUSHX_Test.php @@ -39,8 +39,8 @@ class RPUSHX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); + $arguments = ['key', 'value']; + $expected = ['key', 'value']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class RPUSHX_Test extends PredisCommandTestCase $redis->rpush('metavars', 'foo'); $this->assertSame(2, $redis->rpushx('metavars', 'hoge')); - $this->assertSame(array('foo', 'hoge'), $redis->lrange('metavars', 0, -1)); + $this->assertSame(['foo', 'hoge'], $redis->lrange('metavars', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/RPUSH_Test.php b/tests/Predis/Command/Redis/RPUSH_Test.php index b9b4483a..ad7a64cb 100644 --- a/tests/Predis/Command/Redis/RPUSH_Test.php +++ b/tests/Predis/Command/Redis/RPUSH_Test.php @@ -39,8 +39,8 @@ class RPUSH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'value1', 'value2', 'value3'); - $expected = array('key', 'value1', 'value2', 'value3'); + $arguments = ['key', 'value1', 'value2', 'value3']; + $expected = ['key', 'value1', 'value2', 'value3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class RPUSH_Test extends PredisCommandTestCase */ public function testFilterArgumentsValuesAsSingleArray(): void { - $arguments = array('key', array('value1', 'value2', 'value3')); - $expected = array('key', 'value1', 'value2', 'value3'); + $arguments = ['key', ['value1', 'value2', 'value3']]; + $expected = ['key', 'value1', 'value2', 'value3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -80,7 +80,7 @@ class RPUSH_Test extends PredisCommandTestCase // NOTE: List push operations return the list length since Redis commit 520b5a3 $this->assertSame(1, $redis->rpush('metavars', 'foo')); $this->assertSame(2, $redis->rpush('metavars', 'hoge')); - $this->assertSame(array('foo', 'hoge'), $redis->lrange('metavars', 0, -1)); + $this->assertSame(['foo', 'hoge'], $redis->lrange('metavars', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/SADD_Test.php b/tests/Predis/Command/Redis/SADD_Test.php index cfe41e5a..54287aef 100644 --- a/tests/Predis/Command/Redis/SADD_Test.php +++ b/tests/Predis/Command/Redis/SADD_Test.php @@ -39,8 +39,8 @@ class SADD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member1', 'member2', 'member3'); - $expected = array('key', 'member1', 'member2', 'member3'); + $arguments = ['key', 'member1', 'member2', 'member3']; + $expected = ['key', 'member1', 'member2', 'member3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SADD_Test extends PredisCommandTestCase */ public function testFilterArgumentsValuesAsSingleArray(): void { - $arguments = array('key', array('member1', 'member2', 'member3')); - $expected = array('key', 'member1', 'member2', 'member3'); + $arguments = ['key', ['member1', 'member2', 'member3']]; + $expected = ['key', 'member1', 'member2', 'member3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SAVE_Test.php b/tests/Predis/Command/Redis/SAVE_Test.php index 39e9d7ed..5ba3ed3a 100644 --- a/tests/Predis/Command/Redis/SAVE_Test.php +++ b/tests/Predis/Command/Redis/SAVE_Test.php @@ -40,9 +40,9 @@ class SAVE_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** diff --git a/tests/Predis/Command/Redis/SCAN_Test.php b/tests/Predis/Command/Redis/SCAN_Test.php index 78ac7454..f5242817 100644 --- a/tests/Predis/Command/Redis/SCAN_Test.php +++ b/tests/Predis/Command/Redis/SCAN_Test.php @@ -39,8 +39,8 @@ class SCAN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array(0, 'MATCH', 'key:*', 'COUNT', 5); - $expected = array(0, 'MATCH', 'key:*', 'COUNT', 5); + $arguments = [0, 'MATCH', 'key:*', 'COUNT', 5]; + $expected = [0, 'MATCH', 'key:*', 'COUNT', 5]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsBasicUsage(): void { - $arguments = array(0); - $expected = array(0); + $arguments = [0]; + $expected = [0]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithOptionsArray(): void { - $arguments = array(0, array('match' => 'key:*', 'count' => 5)); - $expected = array(0, 'MATCH', 'key:*', 'COUNT', 5); + $arguments = [0, ['match' => 'key:*', 'count' => 5]]; + $expected = [0, 'MATCH', 'key:*', 'COUNT', 5]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -81,8 +81,8 @@ class SCAN_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('3', array('key:1', 'key:2', 'key:3')); - $expected = array('3', array('key:1', 'key:2', 'key:3')); + $raw = ['3', ['key:1', 'key:2', 'key:3']]; + $expected = ['3', ['key:1', 'key:2', 'key:3']]; $command = $this->getCommand(); @@ -95,7 +95,7 @@ class SCAN_Test extends PredisCommandTestCase */ public function testScanWithoutMatch(): void { - $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); + $kvs = ['key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four']; $redis = $this->getClient(); $redis->mset($kvs); @@ -111,14 +111,14 @@ class SCAN_Test extends PredisCommandTestCase */ public function testScanWithMatchingKeys(): void { - $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); + $kvs = ['key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four']; $redis = $this->getClient(); $redis->mset($kvs); $response = $redis->scan('0', 'MATCH', 'key:t*'); - $this->assertSameValues(array('key:two', 'key:three'), $response[1]); + $this->assertSameValues(['key:two', 'key:three'], $response[1]); } /** @@ -127,7 +127,7 @@ class SCAN_Test extends PredisCommandTestCase */ public function testScanWithNoMatchingKeys(): void { - $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); + $kvs = ['key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four']; $redis = $this->getClient(); $redis->mset($kvs); diff --git a/tests/Predis/Command/Redis/SCARD_Test.php b/tests/Predis/Command/Redis/SCARD_Test.php index 65a3fc8e..c5bec1a2 100644 --- a/tests/Predis/Command/Redis/SCARD_Test.php +++ b/tests/Predis/Command/Redis/SCARD_Test.php @@ -39,8 +39,8 @@ class SCARD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SCRIPT_Test.php b/tests/Predis/Command/Redis/SCRIPT_Test.php index adbea93c..ee92d6e6 100644 --- a/tests/Predis/Command/Redis/SCRIPT_Test.php +++ b/tests/Predis/Command/Redis/SCRIPT_Test.php @@ -39,8 +39,8 @@ class SCRIPT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff'); - $expected = array('EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff'); + $arguments = ['EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff']; + $expected = ['EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class SCRIPT_Test extends PredisCommandTestCase $redis->eval($lua = 'return true', 0); $sha1 = sha1($lua); - $this->assertSame(array(1, 0), $redis->script('EXISTS', $sha1, 'ffffffffffffffffffffffffffffffffffffffff')); + $this->assertSame([1, 0], $redis->script('EXISTS', $sha1, 'ffffffffffffffffffffffffffffffffffffffff')); } /** @@ -95,7 +95,7 @@ class SCRIPT_Test extends PredisCommandTestCase $sha1 = $redis->script('LOAD', 'return true'); $this->assertEquals('OK', $redis->script('FLUSH')); - $this->assertSame(array(0), $redis->script('EXISTS', $sha1)); + $this->assertSame([0], $redis->script('EXISTS', $sha1)); } /** diff --git a/tests/Predis/Command/Redis/SDIFFSTORE_Test.php b/tests/Predis/Command/Redis/SDIFFSTORE_Test.php index 282fd137..d4fc78d8 100644 --- a/tests/Predis/Command/Redis/SDIFFSTORE_Test.php +++ b/tests/Predis/Command/Redis/SDIFFSTORE_Test.php @@ -39,8 +39,8 @@ class SDIFFSTORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('key:destination', 'key:source1', 'key:source:2'); + $arguments = ['key:destination', 'key:source1', 'key:source:2']; + $expected = ['key:destination', 'key:source1', 'key:source:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SDIFFSTORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsSourceKeysAsSingleArray(): void { - $arguments = array('key:destination', array('key:source1', 'key:source:2')); - $expected = array('key:destination', 'key:source1', 'key:source:2'); + $arguments = ['key:destination', ['key:source1', 'key:source:2']]; + $expected = ['key:destination', 'key:source1', 'key:source:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -80,7 +80,7 @@ class SDIFFSTORE_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); $this->assertSame(7, $redis->sdiffstore('letters:destination', 'letters:1st')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->smembers('letters:destination')); } /** @@ -95,10 +95,10 @@ class SDIFFSTORE_Test extends PredisCommandTestCase $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); $this->assertSame(3, $redis->sdiffstore('letters:destination', 'letters:1st', 'letters:2nd')); - $this->assertSameValues(array('b', 'd', 'e'), $redis->smembers('letters:destination')); + $this->assertSameValues(['b', 'd', 'e'], $redis->smembers('letters:destination')); $this->assertSame(1, $redis->sdiffstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('d'), $redis->smembers('letters:destination')); + $this->assertSameValues(['d'], $redis->smembers('letters:destination')); } /** diff --git a/tests/Predis/Command/Redis/SDIFF_Test.php b/tests/Predis/Command/Redis/SDIFF_Test.php index 4a332377..8233b3f4 100644 --- a/tests/Predis/Command/Redis/SDIFF_Test.php +++ b/tests/Predis/Command/Redis/SDIFF_Test.php @@ -39,8 +39,8 @@ class SDIFF_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); + $arguments = ['key1', 'key2', 'key3']; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SDIFF_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); + $arguments = [['key1', 'key2', 'key3']]; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SDIFF_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); + $raw = ['member1', 'member2', 'member3']; + $expected = ['member1', 'member2', 'member3']; $command = $this->getCommand(); @@ -84,8 +84,8 @@ class SDIFF_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sdiff('letters:1st')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sdiff('letters:1st', 'letters:2nd')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->sdiff('letters:1st')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->sdiff('letters:1st', 'letters:2nd')); } /** @@ -99,8 +99,8 @@ class SDIFF_Test extends PredisCommandTestCase $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); - $this->assertSameValues(array('b', 'd', 'e'), $redis->sdiff('letters:1st', 'letters:2nd')); - $this->assertSameValues(array('d'), $redis->sdiff('letters:1st', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(['b', 'd', 'e'], $redis->sdiff('letters:1st', 'letters:2nd')); + $this->assertSameValues(['d'], $redis->sdiff('letters:1st', 'letters:2nd', 'letters:3rd')); } /** diff --git a/tests/Predis/Command/Redis/SELECT_Test.php b/tests/Predis/Command/Redis/SELECT_Test.php index fba8020c..ea78de6e 100644 --- a/tests/Predis/Command/Redis/SELECT_Test.php +++ b/tests/Predis/Command/Redis/SELECT_Test.php @@ -39,8 +39,8 @@ class SELECT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array(10); - $expected = array(10); + $arguments = [10]; + $expected = [10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SENTINEL_Test.php b/tests/Predis/Command/Redis/SENTINEL_Test.php index 43dacb40..9563719c 100644 --- a/tests/Predis/Command/Redis/SENTINEL_Test.php +++ b/tests/Predis/Command/Redis/SENTINEL_Test.php @@ -39,8 +39,8 @@ class SENTINEL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('get-master-addr-by-name', 'predis:master'); - $expected = array('get-master-addr-by-name', 'predis:master'); + $arguments = ['get-master-addr-by-name', 'predis:master']; + $expected = ['get-master-addr-by-name', 'predis:master']; $command = $this->getCommandWithArgumentsArray($arguments); @@ -52,7 +52,7 @@ class SENTINEL_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $expected = array('127.0.0.1', '6379'); + $expected = ['127.0.0.1', '6379']; $command = $this->getCommand(); $this->assertSame($expected, $command->parseResponse($expected)); @@ -63,8 +63,8 @@ class SENTINEL_Test extends PredisCommandTestCase */ public function testSentinelMastersResponse(): void { - $response = array( - array( + $response = [ + [ 'name', 'predis:master', 'ip', '127.0.0.1', 'port', '6379', @@ -77,11 +77,11 @@ class SENTINEL_Test extends PredisCommandTestCase 'num-slaves', '1', 'num-other-sentinels', '0', 'quorum', '2', - ), - ); + ], + ]; - $expected = array( - array( + $expected = [ + [ 'name' => 'predis:master', 'ip' => '127.0.0.1', 'port' => '6379', @@ -94,8 +94,8 @@ class SENTINEL_Test extends PredisCommandTestCase 'num-slaves' => '1', 'num-other-sentinels' => '0', 'quorum' => '2', - ), - ); + ], + ]; $command = $this->getCommandWithArguments('masters'); @@ -107,8 +107,8 @@ class SENTINEL_Test extends PredisCommandTestCase */ public function testSentinelSlavesResponse(): void { - $response = array( - array( + $response = [ + [ 'name', '127.0.0.1:6380', 'ip', '127.0.0.1', 'port', '6380', @@ -123,11 +123,11 @@ class SENTINEL_Test extends PredisCommandTestCase 'master-host', '127.0.0.1', 'master-port', '6379', 'slave-priority', '100', - ), - ); + ], + ]; - $expected = array( - array( + $expected = [ + [ 'name' => '127.0.0.1:6380', 'ip' => '127.0.0.1', 'port' => '6380', @@ -142,8 +142,8 @@ class SENTINEL_Test extends PredisCommandTestCase 'master-host' => '127.0.0.1', 'master-port' => '6379', 'slave-priority' => '100', - ), - ); + ], + ]; $command = $this->getCommandWithArguments('slaves', 'predis:master'); @@ -155,8 +155,8 @@ class SENTINEL_Test extends PredisCommandTestCase */ public function testSentinelIsMasterDownByAddr(): void { - $response = array('0', '7388832d5fdee6a2e301d6bbc5052bd1526d741c'); - $expected = array('0', '7388832d5fdee6a2e301d6bbc5052bd1526d741c'); + $response = ['0', '7388832d5fdee6a2e301d6bbc5052bd1526d741c']; + $expected = ['0', '7388832d5fdee6a2e301d6bbc5052bd1526d741c']; $command = $this->getCommandWithArguments('is-master-down-by-addr', '127.0.0.1', '6379'); @@ -168,8 +168,8 @@ class SENTINEL_Test extends PredisCommandTestCase */ public function testSentinelGetMasterAddrByName(): void { - $response = array('127.0.0.1', '6379'); - $expected = array('127.0.0.1', '6379'); + $response = ['127.0.0.1', '6379']; + $expected = ['127.0.0.1', '6379']; $command = $this->getCommandWithArguments('get-master-addr-by-name', 'predis:master'); diff --git a/tests/Predis/Command/Redis/SETBIT_Test.php b/tests/Predis/Command/Redis/SETBIT_Test.php index b222bf52..e905fde7 100644 --- a/tests/Predis/Command/Redis/SETBIT_Test.php +++ b/tests/Predis/Command/Redis/SETBIT_Test.php @@ -39,8 +39,8 @@ class SETBIT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 7, 1); - $expected = array('key', 7, 1); + $arguments = ['key', 7, 1]; + $expected = ['key', 7, 1]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SETEX_Test.php b/tests/Predis/Command/Redis/SETEX_Test.php index 02fadb19..d714d34d 100644 --- a/tests/Predis/Command/Redis/SETEX_Test.php +++ b/tests/Predis/Command/Redis/SETEX_Test.php @@ -39,8 +39,8 @@ class SETEX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 10, 'hello'); - $expected = array('key', 10, 'hello'); + $arguments = ['key', 10, 'hello']; + $expected = ['key', 10, 'hello']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SETNX_Test.php b/tests/Predis/Command/Redis/SETNX_Test.php index 2bb56a66..f68f8cfe 100644 --- a/tests/Predis/Command/Redis/SETNX_Test.php +++ b/tests/Predis/Command/Redis/SETNX_Test.php @@ -39,8 +39,8 @@ class SETNX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('foo', 'bar'); - $expected = array('foo', 'bar'); + $arguments = ['foo', 'bar']; + $expected = ['foo', 'bar']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SETRANGE_Test.php b/tests/Predis/Command/Redis/SETRANGE_Test.php index 5be75d61..8c8edb15 100644 --- a/tests/Predis/Command/Redis/SETRANGE_Test.php +++ b/tests/Predis/Command/Redis/SETRANGE_Test.php @@ -39,8 +39,8 @@ class SETRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 5, 'range'); - $expected = array('key', 5, 'range'); + $arguments = ['key', 5, 'range']; + $expected = ['key', 5, 'range']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SET_Test.php b/tests/Predis/Command/Redis/SET_Test.php index fd19d730..5127e9e1 100644 --- a/tests/Predis/Command/Redis/SET_Test.php +++ b/tests/Predis/Command/Redis/SET_Test.php @@ -39,8 +39,8 @@ class SET_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('foo', 'bar'); - $expected = array('foo', 'bar'); + $arguments = ['foo', 'bar']; + $expected = ['foo', 'bar']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SET_Test extends PredisCommandTestCase */ public function testFilterArgumentsRedisWithModifiers(): void { - $arguments = array('foo', 'bar', 'EX', '10', 'NX'); - $expected = array('foo', 'bar', 'EX', '10', 'NX'); + $arguments = ['foo', 'bar', 'EX', '10', 'NX']; + $expected = ['foo', 'bar', 'EX', '10', 'NX']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SHUTDOWN_Test.php b/tests/Predis/Command/Redis/SHUTDOWN_Test.php index 6bb5ceb9..ddf9f112 100644 --- a/tests/Predis/Command/Redis/SHUTDOWN_Test.php +++ b/tests/Predis/Command/Redis/SHUTDOWN_Test.php @@ -40,8 +40,8 @@ class SHUTDOWN_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } } diff --git a/tests/Predis/Command/Redis/SINTERSTORE_Test.php b/tests/Predis/Command/Redis/SINTERSTORE_Test.php index 99f37a2c..39d59ac5 100644 --- a/tests/Predis/Command/Redis/SINTERSTORE_Test.php +++ b/tests/Predis/Command/Redis/SINTERSTORE_Test.php @@ -39,8 +39,8 @@ class SINTERSTORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('key:destination', 'key:source1', 'key:source:2'); + $arguments = ['key:destination', 'key:source1', 'key:source:2']; + $expected = ['key:destination', 'key:source1', 'key:source:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SINTERSTORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsSourceKeysAsSingleArray(): void { - $arguments = array('key:destination', array('key:source1', 'key:source:2')); - $expected = array('key:destination', 'key:source1', 'key:source:2'); + $arguments = ['key:destination', ['key:source1', 'key:source:2']]; + $expected = ['key:destination', 'key:source1', 'key:source:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -80,7 +80,7 @@ class SINTERSTORE_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); $this->assertSame(7, $redis->sinterstore('letters:destination', 'letters:1st')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->smembers('letters:destination')); } /** @@ -108,10 +108,10 @@ class SINTERSTORE_Test extends PredisCommandTestCase $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); $this->assertSame(4, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd')); - $this->assertSameValues(array('a', 'c', 'f', 'g'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'c', 'f', 'g'], $redis->smembers('letters:destination')); $this->assertSame(2, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('a', 'f'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'f'], $redis->smembers('letters:destination')); } /** diff --git a/tests/Predis/Command/Redis/SINTER_Test.php b/tests/Predis/Command/Redis/SINTER_Test.php index 11fd4687..af7fee33 100644 --- a/tests/Predis/Command/Redis/SINTER_Test.php +++ b/tests/Predis/Command/Redis/SINTER_Test.php @@ -39,8 +39,8 @@ class SINTER_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); + $arguments = ['key1', 'key2', 'key3']; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SINTER_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); + $arguments = [['key1', 'key2', 'key3']]; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SINTER_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); + $raw = ['member1', 'member2', 'member3']; + $expected = ['member1', 'member2', 'member3']; $command = $this->getCommand(); @@ -84,7 +84,7 @@ class SINTER_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sinter('letters:1st')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->sinter('letters:1st')); } /** @@ -96,7 +96,7 @@ class SINTER_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $this->assertSameValues(array(), $redis->sinter('letters:1st', 'letters:2nd')); + $this->assertSameValues([], $redis->sinter('letters:1st', 'letters:2nd')); } /** @@ -110,8 +110,8 @@ class SINTER_Test extends PredisCommandTestCase $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); - $this->assertSameValues(array('a', 'c', 'f', 'g'), $redis->sinter('letters:1st', 'letters:2nd')); - $this->assertSameValues(array('a', 'f'), $redis->sinter('letters:1st', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(['a', 'c', 'f', 'g'], $redis->sinter('letters:1st', 'letters:2nd')); + $this->assertSameValues(['a', 'f'], $redis->sinter('letters:1st', 'letters:2nd', 'letters:3rd')); } /** diff --git a/tests/Predis/Command/Redis/SISMEMBER_Test.php b/tests/Predis/Command/Redis/SISMEMBER_Test.php index c68bec3c..5db5fe15 100644 --- a/tests/Predis/Command/Redis/SISMEMBER_Test.php +++ b/tests/Predis/Command/Redis/SISMEMBER_Test.php @@ -39,8 +39,8 @@ class SISMEMBER_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); + $arguments = ['key', 'member']; + $expected = ['key', 'member']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SLAVEOF_Test.php b/tests/Predis/Command/Redis/SLAVEOF_Test.php index 2a61e351..25fdaca1 100644 --- a/tests/Predis/Command/Redis/SLAVEOF_Test.php +++ b/tests/Predis/Command/Redis/SLAVEOF_Test.php @@ -39,8 +39,8 @@ class SLAVEOF_Test extends PredisCommandTestCase */ public function testFilterArgumentsHostPortArray(): void { - $arguments = array('127.0.0.1', '80'); - $expected = array('127.0.0.1', '80'); + $arguments = ['127.0.0.1', '80']; + $expected = ['127.0.0.1', '80']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SLAVEOF_Test extends PredisCommandTestCase */ public function testFilterArgumentsNoOneArray(): void { - $arguments = array('NO', 'ONE'); - $expected = array('NO', 'ONE'); + $arguments = ['NO', 'ONE']; + $expected = ['NO', 'ONE']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SLAVEOF_Test extends PredisCommandTestCase */ public function testFilterArgumentsNoOneString(): void { - $arguments = array('NO ONE'); - $expected = array('NO', 'ONE'); + $arguments = ['NO ONE']; + $expected = ['NO', 'ONE']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SLOWLOG_Test.php b/tests/Predis/Command/Redis/SLOWLOG_Test.php index ffd36ead..dce2dc44 100644 --- a/tests/Predis/Command/Redis/SLOWLOG_Test.php +++ b/tests/Predis/Command/Redis/SLOWLOG_Test.php @@ -42,8 +42,8 @@ class SLOWLOG_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('GET', '2'); - $expected = array('GET', '2'); + $arguments = ['GET', '2']; + $expected = ['GET', '2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -58,15 +58,15 @@ class SLOWLOG_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array(array(0, 1323163469, 12451, array('SORT', 'list:unordered'))); - $expected = array( - array( + $raw = [[0, 1323163469, 12451, ['SORT', 'list:unordered']]]; + $expected = [ + [ 'id' => 0, 'timestamp' => 1323163469, 'duration' => 12451, - 'command' => array('SORT', 'list:unordered'), - ), - ); + 'command' => ['SORT', 'list:unordered'], + ], + ]; $command = $this->getCommand(); diff --git a/tests/Predis/Command/Redis/SMEMBERS_Test.php b/tests/Predis/Command/Redis/SMEMBERS_Test.php index 1f7a60c0..7c99ff8b 100644 --- a/tests/Predis/Command/Redis/SMEMBERS_Test.php +++ b/tests/Predis/Command/Redis/SMEMBERS_Test.php @@ -39,8 +39,8 @@ class SMEMBERS_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SMEMBERS_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); + $raw = ['member1', 'member2', 'member3']; + $expected = ['member1', 'member2', 'member3']; $command = $this->getCommand(); @@ -70,8 +70,8 @@ class SMEMBERS_Test extends PredisCommandTestCase $redis->sadd('letters', 'a', 'b', 'c', 'd', 'e'); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e'), $redis->smembers('letters')); - $this->assertSame(array(), $redis->smembers('digits')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e'], $redis->smembers('letters')); + $this->assertSame([], $redis->smembers('digits')); } /** diff --git a/tests/Predis/Command/Redis/SMOVE_Test.php b/tests/Predis/Command/Redis/SMOVE_Test.php index f6d6eacb..8a5301d4 100644 --- a/tests/Predis/Command/Redis/SMOVE_Test.php +++ b/tests/Predis/Command/Redis/SMOVE_Test.php @@ -39,8 +39,8 @@ class SMOVE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:source', 'key:destination', 'member'); - $expected = array('key:source', 'key:destination', 'member'); + $arguments = ['key:source', 'key:destination', 'member']; + $expected = ['key:source', 'key:destination', 'member']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -71,8 +71,8 @@ class SMOVE_Test extends PredisCommandTestCase $this->assertSame(1, $redis->smove('letters:source', 'letters:destination', 'b')); $this->assertSame(0, $redis->smove('letters:source', 'letters:destination', 'z')); - $this->assertSameValues(array('a', 'c'), $redis->smembers('letters:source')); - $this->assertSameValues(array('b'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'c'], $redis->smembers('letters:source')); + $this->assertSameValues(['b'], $redis->smembers('letters:destination')); } /** diff --git a/tests/Predis/Command/Redis/SORT_Test.php b/tests/Predis/Command/Redis/SORT_Test.php index c55d961d..3fe5ba96 100644 --- a/tests/Predis/Command/Redis/SORT_Test.php +++ b/tests/Predis/Command/Redis/SORT_Test.php @@ -46,7 +46,7 @@ class SORT_Test extends PredisCommandTestCase */ protected function lpushUnorderedList(Client $redis, $key) { - $list = array(2, 100, 3, 1, 30, 10); + $list = [2, 100, 3, 1, 30, 10]; $redis->lpush($key, $list); return $list; @@ -57,20 +57,20 @@ class SORT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $modifiers = array( + $modifiers = [ 'by' => 'by_key_*', - 'limit' => array(1, 4), - 'get' => array('object_*', '#'), + 'limit' => [1, 4], + 'get' => ['object_*', '#'], 'sort' => 'asc', 'alpha' => true, 'store' => 'destination_key', - ); - $arguments = array('key', $modifiers); + ]; + $arguments = ['key', $modifiers]; - $expected = array( + $expected = [ 'key', 'BY', 'by_key_*', 'GET', 'object_*', 'GET', '#', 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'destination_key', - ); + ]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -83,8 +83,8 @@ class SORT_Test extends PredisCommandTestCase */ public function testGetModifierCanBeString(): void { - $arguments = array('key', array('get' => '#')); - $expected = array('key', 'GET', '#'); + $arguments = ['key', ['get' => '#']]; + $expected = ['key', 'GET', '#']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -97,8 +97,8 @@ class SORT_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('value1', 'value2', 'value3'); - $expected = array('value1', 'value2', 'value3'); + $raw = ['value1', 'value2', 'value3']; + $expected = ['value1', 'value2', 'value3']; $command = $this->getCommand(); @@ -111,9 +111,9 @@ class SORT_Test extends PredisCommandTestCase public function testBasicSort(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); - $this->assertEquals(array(1, 2, 3, 10, 30, 100), $redis->sort('list:unordered')); + $this->assertEquals([1, 2, 3, 10, 30, 100], $redis->sort('list:unordered')); } /** @@ -122,20 +122,20 @@ class SORT_Test extends PredisCommandTestCase public function testSortWithAscOrDescModifier(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); $this->assertEquals( - array(100, 30, 10, 3, 2, 1), - $redis->sort('list:unordered', array( + [100, 30, 10, 3, 2, 1], + $redis->sort('list:unordered', [ 'sort' => 'desc', - )) + ]) ); $this->assertEquals( - array(1, 2, 3, 10, 30, 100), - $redis->sort('list:unordered', array( + [1, 2, 3, 10, 30, 100], + $redis->sort('list:unordered', [ 'sort' => 'asc', - )) + ]) ); } @@ -145,20 +145,20 @@ class SORT_Test extends PredisCommandTestCase public function testSortWithLimitModifier(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); $this->assertEquals( - array(1, 2, 3), - $redis->sort('list:unordered', array( - 'limit' => array(0, 3), - )) + [1, 2, 3], + $redis->sort('list:unordered', [ + 'limit' => [0, 3], + ]) ); $this->assertEquals( - array(10, 30), - $redis->sort('list:unordered', array( - 'limit' => array(3, 2), - )) + [10, 30], + $redis->sort('list:unordered', [ + 'limit' => [3, 2], + ]) ); } @@ -168,13 +168,13 @@ class SORT_Test extends PredisCommandTestCase public function testSortWithAlphaModifier(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); $this->assertEquals( - array(1, 10, 100, 2, 3, 30), - $redis->sort('list:unordered', array( + [1, 10, 100, 2, 3, 30], + $redis->sort('list:unordered', [ 'alpha' => true, - )) + ]) ); } @@ -184,16 +184,16 @@ class SORT_Test extends PredisCommandTestCase public function testSortWithStoreModifier(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); $this->assertCount( - $redis->sort('list:unordered', array( + $redis->sort('list:unordered', [ 'store' => 'list:ordered', - )), + ]), $unordered ); - $this->assertEquals(array(1, 2, 3, 10, 30, 100), $redis->lrange('list:ordered', 0, -1)); + $this->assertEquals([1, 2, 3, 10, 30, 100], $redis->lrange('list:ordered', 0, -1)); } /** @@ -202,15 +202,15 @@ class SORT_Test extends PredisCommandTestCase public function testSortWithCombinedModifiers(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); $this->assertEquals( - array(30, 10, 3, 2), - $redis->sort('list:unordered', array( + [30, 10, 3, 2], + $redis->sort('list:unordered', [ 'alpha' => false, 'sort' => 'desc', - 'limit' => array(1, 4), - )) + 'limit' => [1, 4], + ]) ); } @@ -220,15 +220,15 @@ class SORT_Test extends PredisCommandTestCase public function testSortWithGetModifiers(): void { $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); + $redis->lpush('list:unordered', $unordered = [2, 100, 3, 1, 30, 10]); - $redis->rpush('list:uids', $uids = array(1003, 1001, 1002, 1000)); - $redis->mset($sortget = array( + $redis->rpush('list:uids', $uids = [1003, 1001, 1002, 1000]); + $redis->mset($sortget = [ 'uid:1000' => 'foo', 'uid:1001' => 'bar', 'uid:1002' => 'hoge', 'uid:1003' => 'piyo', - )); + ]); - $this->assertEquals(array_values($sortget), $redis->sort('list:uids', array('get' => 'uid:*'))); + $this->assertEquals(array_values($sortget), $redis->sort('list:uids', ['get' => 'uid:*'])); } /** diff --git a/tests/Predis/Command/Redis/SPOP_Test.php b/tests/Predis/Command/Redis/SPOP_Test.php index fbc42ce4..b7ffe2f6 100644 --- a/tests/Predis/Command/Redis/SPOP_Test.php +++ b/tests/Predis/Command/Redis/SPOP_Test.php @@ -39,8 +39,8 @@ class SPOP_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 2); - $expected = array('key', 2); + $arguments = ['key', 2]; + $expected = ['key', 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -65,8 +65,8 @@ class SPOP_Test extends PredisCommandTestCase $redis->sadd('letters', 'a', 'b'); - $this->assertContains($redis->spop('letters'), array('a', 'b')); - $this->assertContains($redis->spop('letters'), array('a', 'b')); + $this->assertContains($redis->spop('letters'), ['a', 'b']); + $this->assertContains($redis->spop('letters'), ['a', 'b']); $this->assertNull($redis->spop('letters')); } @@ -81,7 +81,7 @@ class SPOP_Test extends PredisCommandTestCase $redis->sadd('letters', 'a', 'b', 'c'); - $this->assertSameValues(array('a', 'b', 'c'), $redis->spop('letters', 3)); + $this->assertSameValues(['a', 'b', 'c'], $redis->spop('letters', 3)); $this->assertEmpty($redis->spop('letters', 3)); $this->assertNull($redis->spop('letters')); diff --git a/tests/Predis/Command/Redis/SRANDMEMBER_Test.php b/tests/Predis/Command/Redis/SRANDMEMBER_Test.php index 23b39886..4d03a074 100644 --- a/tests/Predis/Command/Redis/SRANDMEMBER_Test.php +++ b/tests/Predis/Command/Redis/SRANDMEMBER_Test.php @@ -39,8 +39,8 @@ class SRANDMEMBER_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 1); - $expected = array('key', 1); + $arguments = ['key', 1]; + $expected = ['key', 1]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -65,8 +65,8 @@ class SRANDMEMBER_Test extends PredisCommandTestCase $redis->sadd('letters', 'a', 'b'); - $this->assertContains($redis->srandmember('letters'), array('a', 'b')); - $this->assertContains($redis->srandmember('letters'), array('a', 'b')); + $this->assertContains($redis->srandmember('letters'), ['a', 'b']); + $this->assertContains($redis->srandmember('letters'), ['a', 'b']); $this->assertSame(2, $redis->scard('letters')); } diff --git a/tests/Predis/Command/Redis/SREM_Test.php b/tests/Predis/Command/Redis/SREM_Test.php index e5412667..90969f40 100644 --- a/tests/Predis/Command/Redis/SREM_Test.php +++ b/tests/Predis/Command/Redis/SREM_Test.php @@ -39,8 +39,8 @@ class SREM_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member1', 'member2', 'member3'); - $expected = array('key', 'member1', 'member2', 'member3'); + $arguments = ['key', 'member1', 'member2', 'member3']; + $expected = ['key', 'member1', 'member2', 'member3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SREM_Test extends PredisCommandTestCase */ public function testFilterArgumentsMembersAsSingleArray(): void { - $arguments = array('key', array('member1', 'member2', 'member3')); - $expected = array('key', 'member1', 'member2', 'member3'); + $arguments = ['key', ['member1', 'member2', 'member3']]; + $expected = ['key', 'member1', 'member2', 'member3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -81,7 +81,7 @@ class SREM_Test extends PredisCommandTestCase $this->assertSame(1, $redis->srem('letters', 'b')); $this->assertSame(1, $redis->srem('letters', 'd', 'z')); - $this->assertSameValues(array('a', 'c'), $redis->smembers('letters')); + $this->assertSameValues(['a', 'c'], $redis->smembers('letters')); $this->assertSame(0, $redis->srem('digits', 1)); } @@ -97,7 +97,7 @@ class SREM_Test extends PredisCommandTestCase $redis->sadd('letters', 'a', 'b', 'c', 'd'); $this->assertSame(2, $redis->srem('letters', 'b', 'd', 'z')); - $this->assertSameValues(array('a', 'c'), $redis->smembers('letters')); + $this->assertSameValues(['a', 'c'], $redis->smembers('letters')); $this->assertSame(0, $redis->srem('digits', 1)); } @@ -113,7 +113,7 @@ class SREM_Test extends PredisCommandTestCase $redis->sadd('letters', 'a', 'b', 'c', 'd'); $this->assertSame(2, $redis->srem('letters', ['b', 'd', 'z'])); - $this->assertSameValues(array('a', 'c'), $redis->smembers('letters')); + $this->assertSameValues(['a', 'c'], $redis->smembers('letters')); $this->assertSame(0, $redis->srem('digits', [1])); } diff --git a/tests/Predis/Command/Redis/SSCAN_Test.php b/tests/Predis/Command/Redis/SSCAN_Test.php index c388a70e..d22ff999 100644 --- a/tests/Predis/Command/Redis/SSCAN_Test.php +++ b/tests/Predis/Command/Redis/SSCAN_Test.php @@ -39,8 +39,8 @@ class SSCAN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + $arguments = ['key', 0, 'MATCH', 'member:*', 'COUNT', 10]; + $expected = ['key', 0, 'MATCH', 'member:*', 'COUNT', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SSCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsBasicUsage(): void { - $arguments = array('key', 0); - $expected = array('key', 0); + $arguments = ['key', 0]; + $expected = ['key', 0]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SSCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithOptionsArray(): void { - $arguments = array('key', 0, array('match' => 'member:*', 'count' => 10)); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + $arguments = ['key', 0, ['match' => 'member:*', 'count' => 10]]; + $expected = ['key', 0, 'MATCH', 'member:*', 'COUNT', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -81,8 +81,8 @@ class SSCAN_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('3', array('member:1', 'member:2', 'member:3')); - $expected = array('3', array('member:1', 'member:2', 'member:3')); + $raw = ['3', ['member:1', 'member:2', 'member:3']]; + $expected = ['3', ['member:1', 'member:2', 'member:3']]; $command = $this->getCommand(); @@ -96,7 +96,7 @@ class SSCAN_Test extends PredisCommandTestCase public function testScanWithoutMatch(): void { $redis = $this->getClient(); - $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); + $redis->sadd('key', $members = ['member:one', 'member:two', 'member:three', 'member:four']); $response = $redis->sscan('key', 0); @@ -111,11 +111,11 @@ class SSCAN_Test extends PredisCommandTestCase public function testScanWithMatchingMembers(): void { $redis = $this->getClient(); - $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); + $redis->sadd('key', $members = ['member:one', 'member:two', 'member:three', 'member:four']); $response = $redis->sscan('key', 0, 'MATCH', 'member:t*'); - $this->assertSameValues(array('member:two', 'member:three'), $response[1]); + $this->assertSameValues(['member:two', 'member:three'], $response[1]); } /** @@ -125,7 +125,7 @@ class SSCAN_Test extends PredisCommandTestCase public function testScanWithNoMatchingMembers(): void { $redis = $this->getClient(); - $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); + $redis->sadd('key', $members = ['member:one', 'member:two', 'member:three', 'member:four']); $response = $redis->sscan('key', 0, 'MATCH', 'nomember:*'); diff --git a/tests/Predis/Command/Redis/STRLEN_Test.php b/tests/Predis/Command/Redis/STRLEN_Test.php index fefb92f5..fd4f28ce 100644 --- a/tests/Predis/Command/Redis/STRLEN_Test.php +++ b/tests/Predis/Command/Redis/STRLEN_Test.php @@ -39,8 +39,8 @@ class STRLEN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SUBSCRIBE_Test.php b/tests/Predis/Command/Redis/SUBSCRIBE_Test.php index 5404dbce..4ed3600b 100644 --- a/tests/Predis/Command/Redis/SUBSCRIBE_Test.php +++ b/tests/Predis/Command/Redis/SUBSCRIBE_Test.php @@ -39,8 +39,8 @@ class SUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('channel:foo', 'channel:bar'); - $expected = array('channel:foo', 'channel:bar'); + $arguments = ['channel:foo', 'channel:bar']; + $expected = ['channel:foo', 'channel:bar']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('channel:foo', 'channel:bar')); - $expected = array('channel:foo', 'channel:bar'); + $arguments = [['channel:foo', 'channel:bar']]; + $expected = ['channel:foo', 'channel:bar']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SUBSCRIBE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('subscribe', 'channel', 1); - $expected = array('subscribe', 'channel', 1); + $raw = ['subscribe', 'channel', 1]; + $expected = ['subscribe', 'channel', 1]; $command = $this->getCommand(); @@ -83,7 +83,7 @@ class SUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel', 1), $redis->subscribe('channel')); + $this->assertSame(['subscribe', 'channel', 1], $redis->subscribe('channel')); } /** @@ -94,8 +94,8 @@ class SUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:bar', 2], $redis->subscribe('channel:bar')); } /** @@ -106,8 +106,8 @@ class SUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('psubscribe', 'channel:*', 2), $redis->psubscribe('channel:*')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['psubscribe', 'channel:*', 2], $redis->psubscribe('channel:*')); } /** @@ -118,9 +118,9 @@ class SUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('unsubscribe', 'channel:foo', 1), $redis->unsubscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:bar', 2], $redis->subscribe('channel:bar')); + $this->assertSame(['unsubscribe', 'channel:foo', 1], $redis->unsubscribe('channel:foo')); } /** @@ -131,9 +131,9 @@ class SUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('punsubscribe', 'channel:*', 2), $redis->punsubscribe('channel:*')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:bar', 2], $redis->subscribe('channel:bar')); + $this->assertSame(['punsubscribe', 'channel:*', 2], $redis->punsubscribe('channel:*')); } /** @@ -145,7 +145,7 @@ class SUBSCRIBE_Test extends PredisCommandTestCase $redis = $this->getClient(); $quit = $this->getCommandFactory()->create('quit'); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); $this->assertEquals('OK', $redis->executeCommand($quit)); } diff --git a/tests/Predis/Command/Redis/SUBSTR_Test.php b/tests/Predis/Command/Redis/SUBSTR_Test.php index d4792e9b..9924ea5d 100644 --- a/tests/Predis/Command/Redis/SUBSTR_Test.php +++ b/tests/Predis/Command/Redis/SUBSTR_Test.php @@ -43,8 +43,8 @@ class SUBSTR_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 5, 10); - $expected = array('key', 5, 10); + $arguments = ['key', 5, 10]; + $expected = ['key', 5, 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/SUNIONSTORE_Test.php b/tests/Predis/Command/Redis/SUNIONSTORE_Test.php index 2b6013f5..ee4af08a 100644 --- a/tests/Predis/Command/Redis/SUNIONSTORE_Test.php +++ b/tests/Predis/Command/Redis/SUNIONSTORE_Test.php @@ -39,8 +39,8 @@ class SUNIONSTORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('key:destination', 'key:source1', 'key:source:2'); + $arguments = ['key:destination', 'key:source1', 'key:source:2']; + $expected = ['key:destination', 'key:source1', 'key:source:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SUNIONSTORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsSourceKeysAsSingleArray(): void { - $arguments = array('key:destination', array('key:source1', 'key:source:2')); - $expected = array('key:destination', 'key:source1', 'key:source:2'); + $arguments = ['key:destination', ['key:source1', 'key:source:2']]; + $expected = ['key:destination', 'key:source1', 'key:source:2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -80,7 +80,7 @@ class SUNIONSTORE_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); $this->assertSame(7, $redis->sunionstore('letters:destination', 'letters:1st')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->smembers('letters:destination')); } /** @@ -95,10 +95,10 @@ class SUNIONSTORE_Test extends PredisCommandTestCase $redis->sadd('letters:3rd', 'a', 'e', 'f'); $this->assertSame(5, $redis->sunionstore('letters:destination', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('a', 'c', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'c', 'e', 'f', 'g'], $redis->smembers('letters:destination')); $this->assertSame(7, $redis->sunionstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->smembers('letters:destination')); } /** diff --git a/tests/Predis/Command/Redis/SUNION_Test.php b/tests/Predis/Command/Redis/SUNION_Test.php index dcec35f1..2016d129 100644 --- a/tests/Predis/Command/Redis/SUNION_Test.php +++ b/tests/Predis/Command/Redis/SUNION_Test.php @@ -39,8 +39,8 @@ class SUNION_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); + $arguments = ['key1', 'key2', 'key3']; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class SUNION_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); + $arguments = [['key1', 'key2', 'key3']]; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class SUNION_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); + $raw = ['member1', 'member2', 'member3']; + $expected = ['member1', 'member2', 'member3']; $command = $this->getCommand(); @@ -84,8 +84,8 @@ class SUNION_Test extends PredisCommandTestCase $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st', 'letters:2nd')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->sunion('letters:1st')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->sunion('letters:1st', 'letters:2nd')); } /** @@ -99,8 +99,8 @@ class SUNION_Test extends PredisCommandTestCase $redis->sadd('letters:2nd', 'a', 'c', 'g'); $redis->sadd('letters:3rd', 'a', 'e', 'f'); - $this->assertSameValues(array('a', 'c', 'e', 'f', 'g'), $redis->sunion('letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st', 'letters:2nd', 'letters:3rd')); + $this->assertSameValues(['a', 'c', 'e', 'f', 'g'], $redis->sunion('letters:2nd', 'letters:3rd')); + $this->assertSameValues(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->sunion('letters:1st', 'letters:2nd', 'letters:3rd')); } /** diff --git a/tests/Predis/Command/Redis/TIME_Test.php b/tests/Predis/Command/Redis/TIME_Test.php index 7374ba8e..8363224b 100644 --- a/tests/Predis/Command/Redis/TIME_Test.php +++ b/tests/Predis/Command/Redis/TIME_Test.php @@ -39,8 +39,8 @@ class TIME_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array(); - $expected = array(); + $arguments = []; + $expected = []; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,7 +53,7 @@ class TIME_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $expected = array(1331114908, 453990); + $expected = [1331114908, 453990]; $command = $this->getCommand(); $this->assertSame($expected, $command->parseResponse($expected)); diff --git a/tests/Predis/Command/Redis/TTL_Test.php b/tests/Predis/Command/Redis/TTL_Test.php index 8a574487..c640aeba 100644 --- a/tests/Predis/Command/Redis/TTL_Test.php +++ b/tests/Predis/Command/Redis/TTL_Test.php @@ -39,8 +39,8 @@ class TTL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 10); - $expected = array('key', 10); + $arguments = ['key', 10]; + $expected = ['key', 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/TYPE_Test.php b/tests/Predis/Command/Redis/TYPE_Test.php index 48394fcc..3bdbb220 100644 --- a/tests/Predis/Command/Redis/TYPE_Test.php +++ b/tests/Predis/Command/Redis/TYPE_Test.php @@ -39,8 +39,8 @@ class TYPE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/UNSUBSCRIBE_Test.php b/tests/Predis/Command/Redis/UNSUBSCRIBE_Test.php index c7c8cae6..7fe0fafa 100644 --- a/tests/Predis/Command/Redis/UNSUBSCRIBE_Test.php +++ b/tests/Predis/Command/Redis/UNSUBSCRIBE_Test.php @@ -39,8 +39,8 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('channel1', 'channel2', 'channel3'); - $expected = array('channel1', 'channel2', 'channel3'); + $arguments = ['channel1', 'channel2', 'channel3']; + $expected = ['channel1', 'channel2', 'channel3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('channel1', 'channel2', 'channel3')); - $expected = array('channel1', 'channel2', 'channel3'); + $arguments = [['channel1', 'channel2', 'channel3']]; + $expected = ['channel1', 'channel2', 'channel3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('unsubscribe', 'channel', 1); - $expected = array('unsubscribe', 'channel', 1); + $raw = ['unsubscribe', 'channel', 1]; + $expected = ['unsubscribe', 'channel', 1]; $command = $this->getCommand(); @@ -83,7 +83,7 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); + $this->assertSame(['unsubscribe', 'channel', 0], $redis->unsubscribe('channel')); $this->assertSame('echoed', $redis->echo('echoed')); } @@ -95,7 +95,7 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); + $this->assertSame(['unsubscribe', 'channel', 0], $redis->unsubscribe('channel')); } /** @@ -106,8 +106,8 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel', 1), $redis->subscribe('channel')); - $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); + $this->assertSame(['subscribe', 'channel', 1], $redis->subscribe('channel')); + $this->assertSame(['unsubscribe', 'channel', 0], $redis->unsubscribe('channel')); } /** @@ -118,12 +118,12 @@ class UNSUBSCRIBE_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); + $this->assertSame(['subscribe', 'channel:foo', 1], $redis->subscribe('channel:foo')); + $this->assertSame(['subscribe', 'channel:bar', 2], $redis->subscribe('channel:bar')); list($_, $unsubscribed1, $_) = $redis->unsubscribe(); list($_, $unsubscribed2, $_) = $redis->getConnection()->read(); - $this->assertSameValues(array('channel:foo', 'channel:bar'), array($unsubscribed1, $unsubscribed2)); + $this->assertSameValues(['channel:foo', 'channel:bar'], [$unsubscribed1, $unsubscribed2]); $this->assertSame('echoed', $redis->echo('echoed')); } diff --git a/tests/Predis/Command/Redis/UNWATCH_Test.php b/tests/Predis/Command/Redis/UNWATCH_Test.php index 059bcc4d..556d9340 100644 --- a/tests/Predis/Command/Redis/UNWATCH_Test.php +++ b/tests/Predis/Command/Redis/UNWATCH_Test.php @@ -40,9 +40,9 @@ class UNWATCH_Test extends PredisCommandTestCase public function testFilterArguments(): void { $command = $this->getCommand(); - $command->setArguments(array()); + $command->setArguments([]); - $this->assertSame(array(), $command->getArguments()); + $this->assertSame([], $command->getArguments()); } /** @@ -70,7 +70,7 @@ class UNWATCH_Test extends PredisCommandTestCase $redis2->set('foo', 'hijacked'); - $this->assertSame(array('hijacked'), $redis1->exec()); + $this->assertSame(['hijacked'], $redis1->exec()); } /** diff --git a/tests/Predis/Command/Redis/WATCH_Test.php b/tests/Predis/Command/Redis/WATCH_Test.php index 9aa22fcf..c963aade 100644 --- a/tests/Predis/Command/Redis/WATCH_Test.php +++ b/tests/Predis/Command/Redis/WATCH_Test.php @@ -39,8 +39,8 @@ class WATCH_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); + $arguments = ['key1', 'key2', 'key3']; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class WATCH_Test extends PredisCommandTestCase */ public function testFilterArgumentsAsSingleArray(): void { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); + $arguments = [['key1', 'key2', 'key3']]; + $expected = ['key1', 'key2', 'key3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/XDEL_Test.php b/tests/Predis/Command/Redis/XDEL_Test.php index b903541f..a9ac18be 100644 --- a/tests/Predis/Command/Redis/XDEL_Test.php +++ b/tests/Predis/Command/Redis/XDEL_Test.php @@ -39,8 +39,8 @@ class XDEL_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('stream', 'id1', 'id2', 'id3'); - $expected = array('stream', 'id1', 'id2', 'id3'); + $arguments = ['stream', 'id1', 'id2', 'id3']; + $expected = ['stream', 'id1', 'id2', 'id3']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/XLEN_Test.php b/tests/Predis/Command/Redis/XLEN_Test.php index 815c505a..6a120c66 100644 --- a/tests/Predis/Command/Redis/XLEN_Test.php +++ b/tests/Predis/Command/Redis/XLEN_Test.php @@ -39,8 +39,8 @@ class XLEN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/XRANGE_Test.php b/tests/Predis/Command/Redis/XRANGE_Test.php index d7a37cb8..5ce45439 100644 --- a/tests/Predis/Command/Redis/XRANGE_Test.php +++ b/tests/Predis/Command/Redis/XRANGE_Test.php @@ -39,8 +39,8 @@ class XRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('stream', '0-1', '1-2', 123); - $expected = array('stream', '0-1', '1-2', 'COUNT', 123); + $arguments = ['stream', '0-1', '1-2', 123]; + $expected = ['stream', '0-1', '1-2', 'COUNT', 123]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class XRANGE_Test extends PredisCommandTestCase */ public function testFilterArgumentsNoCount(): void { - $arguments = array('stream', '0-1', '1-2'); - $expected = array('stream', '0-1', '1-2'); + $arguments = ['stream', '0-1', '1-2']; + $expected = ['stream', '0-1', '1-2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class XRANGE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array(array('0-1', ['key', 'val'])); - $expected = array('0-1' => ['key' => 'val']); + $raw = [['0-1', ['key', 'val']]]; + $expected = ['0-1' => ['key' => 'val']]; $command = $this->getCommand(); @@ -80,8 +80,8 @@ class XRANGE_Test extends PredisCommandTestCase */ public function testParseResponseMultipleKeys(): void { - $raw = array(array('0-1', ['key1', 'val1', 'key2', 'val2'])); - $expected = array('0-1' => ['key1' => 'val1', 'key2' => 'val2']); + $raw = [['0-1', ['key1', 'val1', 'key2', 'val2']]]; + $expected = ['0-1' => ['key1' => 'val1', 'key2' => 'val2']]; $command = $this->getCommand(); @@ -100,25 +100,25 @@ class XRANGE_Test extends PredisCommandTestCase $redis->xadd('stream', ['key' . $i => 'val' . $i], $i . '-1'); } - $this->assertSame(array(), $redis->xrange('stream', '1-1', '0-1')); + $this->assertSame([], $redis->xrange('stream', '1-1', '0-1')); $this->assertSame( - array('0-1' => ['key0' => 'val0']), + ['0-1' => ['key0' => 'val0']], $redis->xrange('stream', '0-1', '0-1') ); $this->assertSame( - array('0-1' => ['key0' => 'val0'], '1-1' => ['key1' => 'val1']), + ['0-1' => ['key0' => 'val0'], '1-1' => ['key1' => 'val1']], $redis->xrange('stream', '0-1', '1-1') ); $this->assertSame( - array('0-1' => ['key0' => 'val0'], '1-1' => ['key1' => 'val1']), + ['0-1' => ['key0' => 'val0'], '1-1' => ['key1' => 'val1']], $redis->xrange('stream', '-', '1-1') ); $this->assertSame( - array('8-1' => ['key8' => 'val8'], '9-1' => ['key9' => 'val9']), + ['8-1' => ['key8' => 'val8'], '9-1' => ['key9' => 'val9']], $redis->xrange('stream', '8-1', '+') ); $this->assertSame( - array('5-1' => ['key5' => 'val5'], '6-1' => ['key6' => 'val6']), + ['5-1' => ['key5' => 'val5'], '6-1' => ['key6' => 'val6']], $redis->xrange('stream', '5-1', '6-1') ); } @@ -135,10 +135,10 @@ class XRANGE_Test extends PredisCommandTestCase $redis->xadd('stream', ['key1' => 'val1', 'key2' => 'val2'], '1-1'); $this->assertSame( - array( + [ '0-1' => ['key1' => 'val1', 'key2' => 'val2'], '1-1' => ['key1' => 'val1', 'key2' => 'val2'], - ), + ], $redis->xrange('stream', '-', '+') ); } diff --git a/tests/Predis/Command/Redis/XREVRANGE_Test.php b/tests/Predis/Command/Redis/XREVRANGE_Test.php index 5071b3d4..63b65a2b 100644 --- a/tests/Predis/Command/Redis/XREVRANGE_Test.php +++ b/tests/Predis/Command/Redis/XREVRANGE_Test.php @@ -39,8 +39,8 @@ class XREVRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('stream', '1-1', '0-1', 123); - $expected = array('stream', '1-1', '0-1', 'COUNT', 123); + $arguments = ['stream', '1-1', '0-1', 123]; + $expected = ['stream', '1-1', '0-1', 'COUNT', 123]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class XREVRANGE_Test extends PredisCommandTestCase */ public function testFilterArgumentsNoCount(): void { - $arguments = array('stream', '1-1', '0-1'); - $expected = array('stream', '1-1', '0-1'); + $arguments = ['stream', '1-1', '0-1']; + $expected = ['stream', '1-1', '0-1']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class XREVRANGE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array(array('0-1', ['key', 'val'])); - $expected = array('0-1' => ['key' => 'val']); + $raw = [['0-1', ['key', 'val']]]; + $expected = ['0-1' => ['key' => 'val']]; $command = $this->getCommand(); @@ -80,8 +80,8 @@ class XREVRANGE_Test extends PredisCommandTestCase */ public function testParseResponseMultipleKeys(): void { - $raw = array(array('0-1', ['key1', 'val1', 'key2', 'val2'])); - $expected = array('0-1' => ['key1' => 'val1', 'key2' => 'val2']); + $raw = [['0-1', ['key1', 'val1', 'key2', 'val2']]]; + $expected = ['0-1' => ['key1' => 'val1', 'key2' => 'val2']]; $command = $this->getCommand(); @@ -100,25 +100,25 @@ class XREVRANGE_Test extends PredisCommandTestCase $redis->xadd('stream', ['key' . $i => 'val' . $i], $i . '-1'); } - $this->assertSame(array(), $redis->xrevrange('stream', '0-1', '1-1')); + $this->assertSame([], $redis->xrevrange('stream', '0-1', '1-1')); $this->assertSame( - array('0-1' => ['key0' => 'val0']), + ['0-1' => ['key0' => 'val0']], $redis->xrevrange('stream', '0-1', '0-1') ); $this->assertSame( - array('1-1' => ['key1' => 'val1'], '0-1' => ['key0' => 'val0']), + ['1-1' => ['key1' => 'val1'], '0-1' => ['key0' => 'val0']], $redis->xrevrange('stream', '1-1', '0-1') ); $this->assertSame( - array('1-1' => ['key1' => 'val1'], '0-1' => ['key0' => 'val0']), + ['1-1' => ['key1' => 'val1'], '0-1' => ['key0' => 'val0']], $redis->xrevrange('stream', '1-1', '-') ); $this->assertSame( - array('9-1' => ['key9' => 'val9'], '8-1' => ['key8' => 'val8']), + ['9-1' => ['key9' => 'val9'], '8-1' => ['key8' => 'val8']], $redis->xrevrange('stream', '+', '8-1') ); $this->assertSame( - array('6-1' => ['key6' => 'val6'], '5-1' => ['key5' => 'val5']), + ['6-1' => ['key6' => 'val6'], '5-1' => ['key5' => 'val5']], $redis->xrevrange('stream', '6-1', '5-1') ); } @@ -135,10 +135,10 @@ class XREVRANGE_Test extends PredisCommandTestCase $redis->xadd('stream', ['key1' => 'val1', 'key2' => 'val2'], '1-1'); $this->assertSame( - array( + [ '1-1' => ['key1' => 'val1', 'key2' => 'val2'], '0-1' => ['key1' => 'val1', 'key2' => 'val2'], - ), + ], $redis->xrevrange('stream', '+', '-') ); } diff --git a/tests/Predis/Command/Redis/ZADD_Test.php b/tests/Predis/Command/Redis/ZADD_Test.php index 55d43a78..bee4e21d 100644 --- a/tests/Predis/Command/Redis/ZADD_Test.php +++ b/tests/Predis/Command/Redis/ZADD_Test.php @@ -39,8 +39,8 @@ class ZADD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 1, 'member1', 2, 'member2'); - $expected = array('key', 1, 'member1', 2, 'member2'); + $arguments = ['key', 1, 'member1', 2, 'member2']; + $expected = ['key', 1, 'member1', 2, 'member2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class ZADD_Test extends PredisCommandTestCase */ public function testFilterArgumentsMembersScoresAsSingleArray(): void { - $arguments = array('key', array('member1' => 1, 'member2' => 2)); - $expected = array('key', 1, 'member1', 2, 'member2'); + $arguments = ['key', ['member1' => 1, 'member2' => 2]]; + $expected = ['key', 1, 'member1', 2, 'member2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class ZADD_Test extends PredisCommandTestCase */ public function testFilterArgumentsMembersScoresAsSingleArrayWithModifiers(): void { - $arguments = array('key', 'NX', 'CH', array('member1' => 1, 'member2' => 2)); - $expected = array('key', 'NX', 'CH', 1, 'member1', 2, 'member2'); + $arguments = ['key', 'NX', 'CH', ['member1' => 1, 'member2' => 2]]; + $expected = ['key', 'NX', 'CH', 1, 'member1', 2, 'member2']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -92,10 +92,10 @@ class ZADD_Test extends PredisCommandTestCase $redis = $this->getClient(); $this->assertSame(5, $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd', 'e'], $redis->zrange('letters', 0, -1)); $this->assertSame(1, $redis->zadd('letters', 1, 'e', 8, 'c', 6, 'f')); - $this->assertSame(array('a', 'e', 'b', 'd', 'f', 'c'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'e', 'b', 'd', 'f', 'c'], $redis->zrange('letters', 0, -1)); } /** @@ -107,10 +107,10 @@ class ZADD_Test extends PredisCommandTestCase $redis = $this->getClient(); $this->assertSame(5, $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd', 'e'], $redis->zrange('letters', 0, -1)); $this->assertSame(2, $redis->zadd('letters', 'NX', 8, 'a', 1, 'f', 8, 'g', 4, 'e')); - $this->assertSame(array('a', 'f', 'b', 'c', 'd', 'e', 'g'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'f', 'b', 'c', 'd', 'e', 'g'], $redis->zrange('letters', 0, -1)); } /** @@ -122,10 +122,10 @@ class ZADD_Test extends PredisCommandTestCase $redis = $this->getClient(); $this->assertSame(5, $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd', 'e'], $redis->zrange('letters', 0, -1)); $this->assertSame(0, $redis->zadd('letters', 'XX', 1, 'd', 2, 'c', 3, 'b', 1, 'x', 0, 'y')); - $this->assertSame(array('a', 'd', 'c', 'b', 'e'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'd', 'c', 'b', 'e'], $redis->zrange('letters', 0, -1)); } /** @@ -137,13 +137,13 @@ class ZADD_Test extends PredisCommandTestCase $redis = $this->getClient(); $this->assertSame(5, $redis->zadd('letters', 'CH', 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'd', 'e'], $redis->zrange('letters', 0, -1)); $this->assertSame(2, $redis->zadd('letters', 'NX', 'CH', 8, 'a', 1, 'f', 8, 'g', 4, 'e')); - $this->assertSame(array('a', 'f', 'b', 'c', 'd', 'e', 'g'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'f', 'b', 'c', 'd', 'e', 'g'], $redis->zrange('letters', 0, -1)); $this->assertSame(3, $redis->zadd('letters', 'XX', 'CH', 1, 'd', 2, 'c', 3, 'b', 1, 'x', 0, 'y')); - $this->assertSame(array('a', 'd', 'f', 'c', 'b', 'e', 'g'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'd', 'f', 'c', 'b', 'e', 'g'], $redis->zrange('letters', 0, -1)); } /** @@ -182,7 +182,7 @@ class ZADD_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', 0.2, 'b', 0.3, 'a', 0.1, 'c'); - $this->assertSame(array('c', 'b', 'a'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['c', 'b', 'a'], $redis->zrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/ZCARD_Test.php b/tests/Predis/Command/Redis/ZCARD_Test.php index ac4ba6ef..7194e66f 100644 --- a/tests/Predis/Command/Redis/ZCARD_Test.php +++ b/tests/Predis/Command/Redis/ZCARD_Test.php @@ -39,8 +39,8 @@ class ZCARD_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key'); - $expected = array('key'); + $arguments = ['key']; + $expected = ['key']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ZCOUNT_Test.php b/tests/Predis/Command/Redis/ZCOUNT_Test.php index 6ca713d1..04657c91 100644 --- a/tests/Predis/Command/Redis/ZCOUNT_Test.php +++ b/tests/Predis/Command/Redis/ZCOUNT_Test.php @@ -39,8 +39,8 @@ class ZCOUNT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); + $arguments = ['key', 0, 10]; + $expected = ['key', 0, 10]; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ZINCRBY_Test.php b/tests/Predis/Command/Redis/ZINCRBY_Test.php index 9b5ba6c6..121eb35a 100644 --- a/tests/Predis/Command/Redis/ZINCRBY_Test.php +++ b/tests/Predis/Command/Redis/ZINCRBY_Test.php @@ -39,8 +39,8 @@ class ZINCRBY_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 1.0, 'member'); - $expected = array('key', 1.0, 'member'); + $arguments = ['key', 1.0, 'member']; + $expected = ['key', 1.0, 'member']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ZLEXCOUNT_Test.php b/tests/Predis/Command/Redis/ZLEXCOUNT_Test.php index 6a78ffd4..f644aa6c 100644 --- a/tests/Predis/Command/Redis/ZLEXCOUNT_Test.php +++ b/tests/Predis/Command/Redis/ZLEXCOUNT_Test.php @@ -39,8 +39,8 @@ class ZLEXCOUNT_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', '+', '-'); - $expected = array('key', '+', '-'); + $arguments = ['key', '+', '-']; + $expected = ['key', '+', '-']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ZPOPMAX_Test.php b/tests/Predis/Command/Redis/ZPOPMAX_Test.php index e7a072c4..072234fe 100644 --- a/tests/Predis/Command/Redis/ZPOPMAX_Test.php +++ b/tests/Predis/Command/Redis/ZPOPMAX_Test.php @@ -42,8 +42,8 @@ class ZPOPMAX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('zset', 2); - $expected = array('zset', 2); + $arguments = ['zset', 2]; + $expected = ['zset', 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -58,8 +58,8 @@ class ZPOPMAX_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array('element1' => '1', 'element2' => '2', 'element3' => '3'); + $raw = ['element1', '1', 'element2', '2', 'element3', '3']; + $expected = ['element1' => '1', 'element2' => '2', 'element3' => '3']; $command = $this->getCommand(); @@ -75,14 +75,14 @@ class ZPOPMAX_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array(), $redis->zpopmax('letters')); - $this->assertSame(array(), $redis->zpopmax('letters', 3)); + $this->assertSame([], $redis->zpopmax('letters')); + $this->assertSame([], $redis->zpopmax('letters', 3)); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('f' => '30'), $redis->zpopmax('letters')); - $this->assertSame(array('e' => '20', 'd' => '20', 'c' => '10'), $redis->zpopmax('letters', 3)); - $this->assertSame(array('b' => '0', 'a' => '-10'), $redis->zpopmax('letters', 3)); + $this->assertSame(['f' => '30'], $redis->zpopmax('letters')); + $this->assertSame(['e' => '20', 'd' => '20', 'c' => '10'], $redis->zpopmax('letters', 3)); + $this->assertSame(['b' => '0', 'a' => '-10'], $redis->zpopmax('letters', 3)); } /** diff --git a/tests/Predis/Command/Redis/ZPOPMIN_Test.php b/tests/Predis/Command/Redis/ZPOPMIN_Test.php index 107f71dc..a15abade 100644 --- a/tests/Predis/Command/Redis/ZPOPMIN_Test.php +++ b/tests/Predis/Command/Redis/ZPOPMIN_Test.php @@ -41,8 +41,8 @@ class ZPOPMIN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('zset', 2); - $expected = array('zset', 2); + $arguments = ['zset', 2]; + $expected = ['zset', 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -57,8 +57,8 @@ class ZPOPMIN_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array('element1' => '1', 'element2' => '2', 'element3' => '3'); + $raw = ['element1', '1', 'element2', '2', 'element3', '3']; + $expected = ['element1' => '1', 'element2' => '2', 'element3' => '3']; $command = $this->getCommand(); @@ -74,14 +74,14 @@ class ZPOPMIN_Test extends PredisCommandTestCase { $redis = $this->getClient(); - $this->assertSame(array(), $redis->zpopmin('letters')); - $this->assertSame(array(), $redis->zpopmin('letters', 3)); + $this->assertSame([], $redis->zpopmin('letters')); + $this->assertSame([], $redis->zpopmin('letters', 3)); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('a' => '-10'), $redis->zpopmin('letters')); - $this->assertSame(array('b' => '0', 'c' => '10', 'd' => '20'), $redis->zpopmin('letters', 3)); - $this->assertSame(array('e' => '20', 'f' => '30'), $redis->zpopmin('letters', 3)); + $this->assertSame(['a' => '-10'], $redis->zpopmin('letters')); + $this->assertSame(['b' => '0', 'c' => '10', 'd' => '20'], $redis->zpopmin('letters', 3)); + $this->assertSame(['e' => '20', 'f' => '30'], $redis->zpopmin('letters', 3)); } /** diff --git a/tests/Predis/Command/Redis/ZRANGEBYLEX_Test.php b/tests/Predis/Command/Redis/ZRANGEBYLEX_Test.php index cca5897d..040ead8a 100644 --- a/tests/Predis/Command/Redis/ZRANGEBYLEX_Test.php +++ b/tests/Predis/Command/Redis/ZRANGEBYLEX_Test.php @@ -39,12 +39,12 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $modifiers = array( - 'limit' => array(0, 100), - ); + $modifiers = [ + 'limit' => [0, 100], + ]; - $arguments = array('zset', '[a', '[z', $modifiers); - $expected = array('zset', '[a', '[z', 'LIMIT', 0, 100); + $arguments = ['zset', '[a', '[z', $modifiers]; + $expected = ['zset', '[a', '[z', 'LIMIT', 0, 100]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -57,8 +57,8 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithNamedLimit(): void { - $arguments = array('zset', '[a', '[z', array('limit' => array('offset' => 1, 'count' => 2))); - $expected = array('zset', '[a', '[z', 'LIMIT', 1, 2); + $arguments = ['zset', '[a', '[z', ['limit' => ['offset' => 1, 'count' => 2]]]; + $expected = ['zset', '[a', '[z', 'LIMIT', 1, 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -71,8 +71,8 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('a', 'b', 'c'); - $expected = array('a', 'b', 'c'); + $raw = ['a', 'b', 'c']; + $expected = ['a', 'b', 'c']; $command = $this->getCommand(); @@ -89,10 +89,10 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->zrangebylex('letters', '-', '+')); - $this->assertSame(array(), $redis->zrangebylex('letters', '+', '-')); - $this->assertSame(array(), $redis->zrangebylex('unknown', '-', '+')); - $this->assertSame(array(), $redis->zrangebylex('unknown', '+', '-')); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f', 'g'], $redis->zrangebylex('letters', '-', '+')); + $this->assertSame([], $redis->zrangebylex('letters', '+', '-')); + $this->assertSame([], $redis->zrangebylex('unknown', '-', '+')); + $this->assertSame([], $redis->zrangebylex('unknown', '+', '-')); } /** @@ -105,12 +105,12 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array('a'), $redis->zrangebylex('letters', '[a', '[a')); - $this->assertSame(array('c', 'd', 'e', 'f'), $redis->zrangebylex('letters', '[c', '[f')); - $this->assertSame(array('a', 'b', 'c'), $redis->zrangebylex('letters', '-', '[c')); - $this->assertSame(array(), $redis->zrangebylex('letters', '+', '[c')); - $this->assertSame(array(), $redis->zrangebylex('letters', '[x', '[z')); - $this->assertSame(array(), $redis->zrangebylex('unknown', '[0', '[1')); + $this->assertSame(['a'], $redis->zrangebylex('letters', '[a', '[a')); + $this->assertSame(['c', 'd', 'e', 'f'], $redis->zrangebylex('letters', '[c', '[f')); + $this->assertSame(['a', 'b', 'c'], $redis->zrangebylex('letters', '-', '[c')); + $this->assertSame([], $redis->zrangebylex('letters', '+', '[c')); + $this->assertSame([], $redis->zrangebylex('letters', '[x', '[z')); + $this->assertSame([], $redis->zrangebylex('unknown', '[0', '[1')); } /** @@ -123,12 +123,12 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array(), $redis->zrangebylex('letters', '(a', '(a')); - $this->assertSame(array('d', 'e'), $redis->zrangebylex('letters', '(c', '(f')); - $this->assertSame(array('a', 'b'), $redis->zrangebylex('letters', '-', '(c')); - $this->assertSame(array(), $redis->zrangebylex('letters', '+', '(c')); - $this->assertSame(array(), $redis->zrangebylex('letters', '(x', '(z')); - $this->assertSame(array(), $redis->zrangebylex('unknown', '(0', '(1')); + $this->assertSame([], $redis->zrangebylex('letters', '(a', '(a')); + $this->assertSame(['d', 'e'], $redis->zrangebylex('letters', '(c', '(f')); + $this->assertSame(['a', 'b'], $redis->zrangebylex('letters', '-', '(c')); + $this->assertSame([], $redis->zrangebylex('letters', '+', '(c')); + $this->assertSame([], $redis->zrangebylex('letters', '(x', '(z')); + $this->assertSame([], $redis->zrangebylex('unknown', '(0', '(1')); } /** @@ -141,11 +141,11 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array(), $redis->zrangebylex('letters', '[a', '(a')); - $this->assertSame(array(), $redis->zrangebylex('letters', '(a', '[a')); - $this->assertSame(array('c', 'd', 'e'), $redis->zrangebylex('letters', '[c', '(f')); - $this->assertSame(array('d', 'e', 'f'), $redis->zrangebylex('letters', '(c', '[f')); - $this->assertSame(array(), $redis->zrangebylex('unknown', '[0', '(5')); + $this->assertSame([], $redis->zrangebylex('letters', '[a', '(a')); + $this->assertSame([], $redis->zrangebylex('letters', '(a', '[a')); + $this->assertSame(['c', 'd', 'e'], $redis->zrangebylex('letters', '[c', '(f')); + $this->assertSame(['d', 'e', 'f'], $redis->zrangebylex('letters', '(c', '[f')); + $this->assertSame([], $redis->zrangebylex('unknown', '[0', '(5')); } /** @@ -158,11 +158,11 @@ class ZRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array('c', 'd', 'e'), $redis->zrangebylex('letters', '-', '+', 'LIMIT', '2', '3')); - $this->assertSame(array('c', 'd', 'e'), $redis->zrangebylex('letters', '-', '+', array('limit' => array(2, 3)))); - $this->assertSame(array('c', 'd', 'e'), $redis->zrangebylex('letters', '-', '+', array('limit' => array('offset' => 2, 'count' => 3)))); - $this->assertSame(array(), $redis->zrangebylex('letters', '[a', '[f', 'LIMIT', '2', '0')); - $this->assertSame(array(), $redis->zrangebylex('letters', '[a', '[f', 'LIMIT', '-4', '2')); + $this->assertSame(['c', 'd', 'e'], $redis->zrangebylex('letters', '-', '+', 'LIMIT', '2', '3')); + $this->assertSame(['c', 'd', 'e'], $redis->zrangebylex('letters', '-', '+', ['limit' => [2, 3]])); + $this->assertSame(['c', 'd', 'e'], $redis->zrangebylex('letters', '-', '+', ['limit' => ['offset' => 2, 'count' => 3]])); + $this->assertSame([], $redis->zrangebylex('letters', '[a', '[f', 'LIMIT', '2', '0')); + $this->assertSame([], $redis->zrangebylex('letters', '[a', '[f', 'LIMIT', '-4', '2')); } /** diff --git a/tests/Predis/Command/Redis/ZRANGEBYSCORE_Test.php b/tests/Predis/Command/Redis/ZRANGEBYSCORE_Test.php index 754ab886..8d370062 100644 --- a/tests/Predis/Command/Redis/ZRANGEBYSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZRANGEBYSCORE_Test.php @@ -39,13 +39,13 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $modifiers = array( + $modifiers = [ 'withscores' => true, - 'limit' => array(0, 100), - ); + 'limit' => [0, 100], + ]; - $arguments = array('zset', 0, 100, $modifiers); - $expected = array('zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, $modifiers]; + $expected = ['zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -58,8 +58,8 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithStringWithscores(): void { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, 'withscores']; + $expected = ['zset', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -72,8 +72,8 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithNamedLimit(): void { - $arguments = array('zset', 0, 100, array('limit' => array('offset' => 1, 'count' => 2))); - $expected = array('zset', 0, 100, 'LIMIT', 1, 2); + $arguments = ['zset', 0, 100, ['limit' => ['offset' => 1, 'count' => 2]]]; + $expected = ['zset', 0, 100, 'LIMIT', 1, 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -86,8 +86,8 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); + $raw = ['element1', 'element2', 'element3']; + $expected = ['element1', 'element2', 'element3']; $command = $this->getCommand(); @@ -99,10 +99,10 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testParseResponseWithScores(): void { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array('element1' => '1', 'element2' => '2', 'element3' => '3'); + $raw = ['element1', '1', 'element2', '2', 'element3', '3']; + $expected = ['element1' => '1', 'element2' => '2', 'element3' => '3']; - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + $command = $this->getCommandWithArgumentsArray(['zset', 0, 1, 'withscores']); $this->assertSame($expected, $command->parseResponse($raw)); } @@ -112,17 +112,17 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue(): void { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => true]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 1]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => false]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 0]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); } /** @@ -134,12 +134,12 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('a'), $redis->zrangebyscore('letters', -10, -10)); - $this->assertSame(array('c', 'd', 'e', 'f'), $redis->zrangebyscore('letters', 10, 30)); - $this->assertSame(array('d', 'e'), $redis->zrangebyscore('letters', 20, 20)); - $this->assertSame(array(), $redis->zrangebyscore('letters', 30, 0)); + $this->assertSame(['a'], $redis->zrangebyscore('letters', -10, -10)); + $this->assertSame(['c', 'd', 'e', 'f'], $redis->zrangebyscore('letters', 10, 30)); + $this->assertSame(['d', 'e'], $redis->zrangebyscore('letters', 20, 20)); + $this->assertSame([], $redis->zrangebyscore('letters', 30, 0)); - $this->assertSame(array(), $redis->zrangebyscore('unknown', 0, 30)); + $this->assertSame([], $redis->zrangebyscore('unknown', 0, 30)); } /** @@ -151,9 +151,9 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('a', 'b', 'c'), $redis->zrangebyscore('letters', '-inf', 15)); - $this->assertSame(array('d', 'e', 'f'), $redis->zrangebyscore('letters', 15, '+inf')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrangebyscore('letters', '-inf', '+inf')); + $this->assertSame(['a', 'b', 'c'], $redis->zrangebyscore('letters', '-inf', 15)); + $this->assertSame(['d', 'e', 'f'], $redis->zrangebyscore('letters', 15, '+inf')); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f'], $redis->zrangebyscore('letters', '-inf', '+inf')); } /** @@ -165,9 +165,9 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('c', 'd', 'e'), $redis->zrangebyscore('letters', 10, '(30')); - $this->assertSame(array('d', 'e', 'f'), $redis->zrangebyscore('letters', '(10', 30)); - $this->assertSame(array('d', 'e'), $redis->zrangebyscore('letters', '(10', '(30')); + $this->assertSame(['c', 'd', 'e'], $redis->zrangebyscore('letters', 10, '(30')); + $this->assertSame(['d', 'e', 'f'], $redis->zrangebyscore('letters', '(10', 30)); + $this->assertSame(['d', 'e'], $redis->zrangebyscore('letters', '(10', '(30')); } /** @@ -178,10 +178,10 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('c' => '10', 'd' => '20', 'e' => '20'); + $expected = ['c' => '10', 'd' => '20', 'e' => '20']; $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, 'withscores')); - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('withscores' => true))); + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, ['withscores' => true])); } /** @@ -192,10 +192,10 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('d', 'e'); + $expected = ['d', 'e']; - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('limit' => array(1, 2)))); - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('limit' => array('offset' => 1, 'count' => 2)))); + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, ['limit' => [1, 2]])); + $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, ['limit' => ['offset' => 1, 'count' => 2]])); } /** @@ -207,8 +207,8 @@ class ZRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $options = array('limit' => array(1, 2), 'withscores' => true); - $expected = array('d' => '20', 'e' => '20'); + $options = ['limit' => [1, 2], 'withscores' => true]; + $expected = ['d' => '20', 'e' => '20']; $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, $options)); } diff --git a/tests/Predis/Command/Redis/ZRANGE_Test.php b/tests/Predis/Command/Redis/ZRANGE_Test.php index 38a3100c..9c63ca3e 100644 --- a/tests/Predis/Command/Redis/ZRANGE_Test.php +++ b/tests/Predis/Command/Redis/ZRANGE_Test.php @@ -39,8 +39,8 @@ class ZRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('zset', 0, 100, array('withscores' => true)); - $expected = array('zset', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, ['withscores' => true]]; + $expected = ['zset', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class ZRANGE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithStringWithscores(): void { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, 'withscores']; + $expected = ['zset', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class ZRANGE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); + $raw = ['element1', 'element2', 'element3']; + $expected = ['element1', 'element2', 'element3']; $command = $this->getCommand(); @@ -80,10 +80,10 @@ class ZRANGE_Test extends PredisCommandTestCase */ public function testParseResponseWithScores(): void { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array('element1' => '1', 'element2' => '2', 'element3' => '3'); + $raw = ['element1', '1', 'element2', '2', 'element3', '3']; + $expected = ['element1' => '1', 'element2' => '2', 'element3' => '3']; - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + $command = $this->getCommandWithArgumentsArray(['zset', 0, 1, 'withscores']); $this->assertSame($expected, $command->parseResponse($raw)); } @@ -93,17 +93,17 @@ class ZRANGE_Test extends PredisCommandTestCase */ public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue(): void { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => true]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 1]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => false]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 0]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); } /** @@ -115,16 +115,16 @@ class ZRANGE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array(), $redis->zrange('letters', 1, 0)); - $this->assertSame(array('a'), $redis->zrange('letters', 0, 0)); - $this->assertSame(array('a', 'b', 'c', 'd'), $redis->zrange('letters', 0, 3)); + $this->assertSame([], $redis->zrange('letters', 1, 0)); + $this->assertSame(['a'], $redis->zrange('letters', 0, 0)); + $this->assertSame(['a', 'b', 'c', 'd'], $redis->zrange('letters', 0, 3)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrange('letters', 0, -1)); - $this->assertSame(array('a', 'b', 'c'), $redis->zrange('letters', 0, -4)); - $this->assertSame(array('c'), $redis->zrange('letters', 2, -4)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrange('letters', -100, 100)); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f'], $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c'], $redis->zrange('letters', 0, -4)); + $this->assertSame(['c'], $redis->zrange('letters', 2, -4)); + $this->assertSame(['a', 'b', 'c', 'd', 'e', 'f'], $redis->zrange('letters', -100, 100)); - $this->assertSame(array(), $redis->zrange('unknown', 0, 30)); + $this->assertSame([], $redis->zrange('unknown', 0, 30)); } /** @@ -135,10 +135,10 @@ class ZRANGE_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('c' => '10', 'd' => '20', 'e' => '20'); + $expected = ['c' => '10', 'd' => '20', 'e' => '20']; $this->assertSame($expected, $redis->zrange('letters', 2, 4, 'withscores')); - $this->assertSame($expected, $redis->zrange('letters', 2, 4, array('withscores' => true))); + $this->assertSame($expected, $redis->zrange('letters', 2, 4, ['withscores' => true])); } /** diff --git a/tests/Predis/Command/Redis/ZRANK_Test.php b/tests/Predis/Command/Redis/ZRANK_Test.php index f4b5b72b..8092479a 100644 --- a/tests/Predis/Command/Redis/ZRANK_Test.php +++ b/tests/Predis/Command/Redis/ZRANK_Test.php @@ -39,8 +39,8 @@ class ZRANK_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); + $arguments = ['key', 'member']; + $expected = ['key', 'member']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ZREMRANGEBYLEX_Test.php b/tests/Predis/Command/Redis/ZREMRANGEBYLEX_Test.php index 422be79f..0dcd08b2 100644 --- a/tests/Predis/Command/Redis/ZREMRANGEBYLEX_Test.php +++ b/tests/Predis/Command/Redis/ZREMRANGEBYLEX_Test.php @@ -39,8 +39,8 @@ class ZREMRANGEBYLEX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', '[a', '[b'); - $expected = array('key', '[a', '[b'); + $arguments = ['key', '[a', '[b']; + $expected = ['key', '[a', '[b']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -69,7 +69,7 @@ class ZREMRANGEBYLEX_Test extends PredisCommandTestCase $this->assertSame(0, $redis->zremrangebylex('letters', '+', '-')); $this->assertSame(7, $redis->zremrangebylex('letters', '-', '+')); - $this->assertSame(array(), $redis->zrange('letters', 0, -1)); + $this->assertSame([], $redis->zrange('letters', 0, -1)); } /** @@ -83,7 +83,7 @@ class ZREMRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); $this->assertSame(3, $redis->zremrangebylex('letters', '[b', '[d')); - $this->assertSame(array('a', 'e', 'f', 'g'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'e', 'f', 'g'], $redis->zrange('letters', 0, -1)); } /** @@ -97,7 +97,7 @@ class ZREMRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); $this->assertSame(3, $redis->zremrangebylex('letters', '(a', '(e')); - $this->assertSame(array('a', 'e', 'f', 'g'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'e', 'f', 'g'], $redis->zrange('letters', 0, -1)); } /** @@ -111,7 +111,7 @@ class ZREMRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); $this->assertSame(3, $redis->zremrangebylex('letters', '[b', '(e')); - $this->assertSame(array('a', 'e', 'f', 'g'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'e', 'f', 'g'], $redis->zrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/ZREMRANGEBYRANK_Test.php b/tests/Predis/Command/Redis/ZREMRANGEBYRANK_Test.php index bc3ee42a..b45ade5c 100644 --- a/tests/Predis/Command/Redis/ZREMRANGEBYRANK_Test.php +++ b/tests/Predis/Command/Redis/ZREMRANGEBYRANK_Test.php @@ -39,8 +39,8 @@ class ZREMRANGEBYRANK_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); + $arguments = ['key', 0, 10]; + $expected = ['key', 0, 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,7 +67,7 @@ class ZREMRANGEBYRANK_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); $this->assertSame(3, $redis->zremrangebyrank('letters', 2, 4)); - $this->assertSame(array('a', 'b', 'f'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'f'], $redis->zrange('letters', 0, -1)); $this->assertSame(0, $redis->zremrangebyrank('unknown', 0, 30)); } @@ -83,7 +83,7 @@ class ZREMRANGEBYRANK_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); $this->assertSame(3, $redis->zremrangebyrank('letters', -5, 3)); - $this->assertSame(array('a', 'e', 'f'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'e', 'f'], $redis->zrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/ZREMRANGEBYSCORE_Test.php b/tests/Predis/Command/Redis/ZREMRANGEBYSCORE_Test.php index a947c9ab..3e944229 100644 --- a/tests/Predis/Command/Redis/ZREMRANGEBYSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZREMRANGEBYSCORE_Test.php @@ -39,8 +39,8 @@ class ZREMRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); + $arguments = ['key', 0, 10]; + $expected = ['key', 0, 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -66,7 +66,7 @@ class ZREMRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); $this->assertSame(3, $redis->zremrangebyscore('letters', 5, 20)); - $this->assertSame(array('a', 'b', 'f'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'f'], $redis->zrange('letters', 0, -1)); $this->assertSame(0, $redis->zremrangebyscore('unknown', 0, 30)); } @@ -81,7 +81,7 @@ class ZREMRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); $this->assertSame(2, $redis->zremrangebyscore('letters', '(10', '(30')); - $this->assertSame(array('a', 'b', 'c', 'f'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'b', 'c', 'f'], $redis->zrange('letters', 0, -1)); } /** diff --git a/tests/Predis/Command/Redis/ZREM_Test.php b/tests/Predis/Command/Redis/ZREM_Test.php index 86cb4265..04ac2f83 100644 --- a/tests/Predis/Command/Redis/ZREM_Test.php +++ b/tests/Predis/Command/Redis/ZREM_Test.php @@ -39,8 +39,8 @@ class ZREM_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('zset', 'member1', 'member2', 'member3'); - $expected = array('zset', 'member1', 'member2', 'member3'); + $arguments = ['zset', 'member1', 'member2', 'member3']; + $expected = ['zset', 'member1', 'member2', 'member3']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -66,7 +66,7 @@ class ZREM_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); $this->assertSame(3, $redis->zrem('letters', 'b', 'd', 'f', 'z')); - $this->assertSame(array('a', 'c', 'e'), $redis->zrange('letters', 0, -1)); + $this->assertSame(['a', 'c', 'e'], $redis->zrange('letters', 0, -1)); $this->assertSame(0, $redis->zrem('unknown', 'a')); } diff --git a/tests/Predis/Command/Redis/ZREVRANGEBYLEX_Test.php b/tests/Predis/Command/Redis/ZREVRANGEBYLEX_Test.php index 0a54768d..9c4ba0e5 100644 --- a/tests/Predis/Command/Redis/ZREVRANGEBYLEX_Test.php +++ b/tests/Predis/Command/Redis/ZREVRANGEBYLEX_Test.php @@ -39,12 +39,12 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $modifiers = array( - 'limit' => array(0, 100), - ); + $modifiers = [ + 'limit' => [0, 100], + ]; - $arguments = array('zset', '[a', '[z', $modifiers); - $expected = array('zset', '[a', '[z', 'LIMIT', 0, 100); + $arguments = ['zset', '[a', '[z', $modifiers]; + $expected = ['zset', '[a', '[z', 'LIMIT', 0, 100]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -57,8 +57,8 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithNamedLimit(): void { - $arguments = array('zset', '[a', '[z', array('limit' => array('offset' => 1, 'count' => 2))); - $expected = array('zset', '[a', '[z', 'LIMIT', 1, 2); + $arguments = ['zset', '[a', '[z', ['limit' => ['offset' => 1, 'count' => 2]]]; + $expected = ['zset', '[a', '[z', 'LIMIT', 1, 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -71,8 +71,8 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('a', 'b', 'c'); - $expected = array('a', 'b', 'c'); + $raw = ['a', 'b', 'c']; + $expected = ['a', 'b', 'c']; $command = $this->getCommand(); @@ -89,10 +89,10 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array('g', 'f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrangebylex('letters', '+', '-')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '-', '+')); - $this->assertSame(array(), $redis->zrevrangebylex('unknown', '-', '+')); - $this->assertSame(array(), $redis->zrevrangebylex('unknown', '+', '-')); + $this->assertSame(['g', 'f', 'e', 'd', 'c', 'b', 'a'], $redis->zrevrangebylex('letters', '+', '-')); + $this->assertSame([], $redis->zrevrangebylex('letters', '-', '+')); + $this->assertSame([], $redis->zrevrangebylex('unknown', '-', '+')); + $this->assertSame([], $redis->zrevrangebylex('unknown', '+', '-')); } /** @@ -105,12 +105,12 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array('a'), $redis->zrevrangebylex('letters', '[a', '[a')); - $this->assertSame(array('f', 'e', 'd', 'c'), $redis->zrevrangebylex('letters', '[f', '[c')); - $this->assertSame(array('g', 'f', 'e'), $redis->zrevrangebylex('letters', '+', '[e')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '-', '[c')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '[z', '[x')); - $this->assertSame(array(), $redis->zrevrangebylex('unknown', '[1', '[0')); + $this->assertSame(['a'], $redis->zrevrangebylex('letters', '[a', '[a')); + $this->assertSame(['f', 'e', 'd', 'c'], $redis->zrevrangebylex('letters', '[f', '[c')); + $this->assertSame(['g', 'f', 'e'], $redis->zrevrangebylex('letters', '+', '[e')); + $this->assertSame([], $redis->zrevrangebylex('letters', '-', '[c')); + $this->assertSame([], $redis->zrevrangebylex('letters', '[z', '[x')); + $this->assertSame([], $redis->zrevrangebylex('unknown', '[1', '[0')); } /** @@ -123,12 +123,12 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '(a', '(a')); - $this->assertSame(array('e', 'd'), $redis->zrevrangebylex('letters', '(f', '(c')); - $this->assertSame(array('g', 'f'), $redis->zrevrangebylex('letters', '+', '(e')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '-', '(c')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '(z', '(x')); - $this->assertSame(array(), $redis->zrevrangebylex('unknown', '(1', '(0')); + $this->assertSame([], $redis->zrevrangebylex('letters', '(a', '(a')); + $this->assertSame(['e', 'd'], $redis->zrevrangebylex('letters', '(f', '(c')); + $this->assertSame(['g', 'f'], $redis->zrevrangebylex('letters', '+', '(e')); + $this->assertSame([], $redis->zrevrangebylex('letters', '-', '(c')); + $this->assertSame([], $redis->zrevrangebylex('letters', '(z', '(x')); + $this->assertSame([], $redis->zrevrangebylex('unknown', '(1', '(0')); } /** @@ -141,11 +141,11 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '[a', '(a')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '(a', '[a')); - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebylex('letters', '[f', '(c')); - $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '(f', '[c')); - $this->assertSame(array(), $redis->zrevrangebylex('unknown', '[5', '(0')); + $this->assertSame([], $redis->zrevrangebylex('letters', '[a', '(a')); + $this->assertSame([], $redis->zrevrangebylex('letters', '(a', '[a')); + $this->assertSame(['f', 'e', 'd'], $redis->zrevrangebylex('letters', '[f', '(c')); + $this->assertSame(['e', 'd', 'c'], $redis->zrevrangebylex('letters', '(f', '[c')); + $this->assertSame([], $redis->zrevrangebylex('unknown', '[5', '(0')); } /** @@ -158,11 +158,11 @@ class ZREVRANGEBYLEX_Test extends PredisCommandTestCase $redis->zadd('letters', 0, 'a', 0, 'b', 0, 'c', 0, 'd', 0, 'e', 0, 'f', 0, 'g'); - $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '+', '-', 'LIMIT', '2', '3')); - $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '+', '-', array('limit' => array(2, 3)))); - $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebylex('letters', '+', '-', array('limit' => array('offset' => 2, 'count' => 3)))); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '[f', '[a', 'LIMIT', '2', '0')); - $this->assertSame(array(), $redis->zrevrangebylex('letters', '[f', '[a', 'LIMIT', '-4', '2')); + $this->assertSame(['e', 'd', 'c'], $redis->zrevrangebylex('letters', '+', '-', 'LIMIT', '2', '3')); + $this->assertSame(['e', 'd', 'c'], $redis->zrevrangebylex('letters', '+', '-', ['limit' => [2, 3]])); + $this->assertSame(['e', 'd', 'c'], $redis->zrevrangebylex('letters', '+', '-', ['limit' => ['offset' => 2, 'count' => 3]])); + $this->assertSame([], $redis->zrevrangebylex('letters', '[f', '[a', 'LIMIT', '2', '0')); + $this->assertSame([], $redis->zrevrangebylex('letters', '[f', '[a', 'LIMIT', '-4', '2')); } /** diff --git a/tests/Predis/Command/Redis/ZREVRANGEBYSCORE_Test.php b/tests/Predis/Command/Redis/ZREVRANGEBYSCORE_Test.php index a52ea79b..f8a2a319 100644 --- a/tests/Predis/Command/Redis/ZREVRANGEBYSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZREVRANGEBYSCORE_Test.php @@ -39,13 +39,13 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $modifiers = array( + $modifiers = [ 'withscores' => true, - 'limit' => array(0, 100), - ); + 'limit' => [0, 100], + ]; - $arguments = array('zset', 0, 100, $modifiers); - $expected = array('zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, $modifiers]; + $expected = ['zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -58,8 +58,8 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithStringWithscores(): void { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, 'withscores']; + $expected = ['zset', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -72,8 +72,8 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithNamedLimit(): void { - $arguments = array('zset', 0, 100, array('limit' => array('offset' => 1, 'count' => 2))); - $expected = array('zset', 0, 100, 'LIMIT', 1, 2); + $arguments = ['zset', 0, 100, ['limit' => ['offset' => 1, 'count' => 2]]]; + $expected = ['zset', 0, 100, 'LIMIT', 1, 2]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -86,8 +86,8 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); + $raw = ['element1', 'element2', 'element3']; + $expected = ['element1', 'element2', 'element3']; $command = $this->getCommand(); @@ -99,10 +99,10 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testParseResponseWithScores(): void { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array('element1' => '1', 'element2' => '2', 'element3' => '3'); + $raw = ['element1', '1', 'element2', '2', 'element3', '3']; + $expected = ['element1' => '1', 'element2' => '2', 'element3' => '3']; - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + $command = $this->getCommandWithArgumentsArray(['zset', 0, 1, 'withscores']); $this->assertSame($expected, $command->parseResponse($raw)); } @@ -112,17 +112,17 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase */ public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue(): void { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => true]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 1]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => false]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 0]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); } /** @@ -135,12 +135,12 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('a'), $redis->zrevrangebyscore('letters', -10, -10)); - $this->assertSame(array(), $redis->zrevrangebyscore('letters', 10, 30)); - $this->assertSame(array('e', 'd'), $redis->zrevrangebyscore('letters', 20, 20)); - $this->assertSame(array('f', 'e', 'd', 'c', 'b'), $redis->zrevrangebyscore('letters', 30, 0)); + $this->assertSame(['a'], $redis->zrevrangebyscore('letters', -10, -10)); + $this->assertSame([], $redis->zrevrangebyscore('letters', 10, 30)); + $this->assertSame(['e', 'd'], $redis->zrevrangebyscore('letters', 20, 20)); + $this->assertSame(['f', 'e', 'd', 'c', 'b'], $redis->zrevrangebyscore('letters', 30, 0)); - $this->assertSame(array(), $redis->zrevrangebyscore('unknown', 0, 30)); + $this->assertSame([], $redis->zrevrangebyscore('unknown', 0, 30)); } /** @@ -153,9 +153,9 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebyscore('letters', '+inf', 15)); - $this->assertSame(array('c', 'b', 'a'), $redis->zrevrangebyscore('letters', 15, '-inf')); - $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrangebyscore('letters', '+inf', '-inf')); + $this->assertSame(['f', 'e', 'd'], $redis->zrevrangebyscore('letters', '+inf', 15)); + $this->assertSame(['c', 'b', 'a'], $redis->zrevrangebyscore('letters', 15, '-inf')); + $this->assertSame(['f', 'e', 'd', 'c', 'b', 'a'], $redis->zrevrangebyscore('letters', '+inf', '-inf')); } /** @@ -168,9 +168,9 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebyscore('letters', '(30', 10)); - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebyscore('letters', 30, '(10')); - $this->assertSame(array('e', 'd'), $redis->zrevrangebyscore('letters', '(30', '(10')); + $this->assertSame(['e', 'd', 'c'], $redis->zrevrangebyscore('letters', '(30', 10)); + $this->assertSame(['f', 'e', 'd'], $redis->zrevrangebyscore('letters', 30, '(10')); + $this->assertSame(['e', 'd'], $redis->zrevrangebyscore('letters', '(30', '(10')); } /** @@ -182,10 +182,10 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('e' => '20', 'd' => '20', 'c' => '10'); + $expected = ['e' => '20', 'd' => '20', 'c' => '10']; $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, 'withscores')); - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('withscores' => true))); + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, ['withscores' => true])); } /** @@ -197,10 +197,10 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('d', 'c'); + $expected = ['d', 'c']; - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('limit' => array(1, 2)))); - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('limit' => array('offset' => 1, 'count' => 2)))); + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, ['limit' => [1, 2]])); + $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, ['limit' => ['offset' => 1, 'count' => 2]])); } /** @@ -213,8 +213,8 @@ class ZREVRANGEBYSCORE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $options = array('limit' => array(1, 2), 'withscores' => true); - $expected = array('d' => '20', 'c' => '10'); + $options = ['limit' => [1, 2], 'withscores' => true]; + $expected = ['d' => '20', 'c' => '10']; $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, $options)); } diff --git a/tests/Predis/Command/Redis/ZREVRANGE_Test.php b/tests/Predis/Command/Redis/ZREVRANGE_Test.php index d67fd936..8ae88d78 100644 --- a/tests/Predis/Command/Redis/ZREVRANGE_Test.php +++ b/tests/Predis/Command/Redis/ZREVRANGE_Test.php @@ -39,8 +39,8 @@ class ZREVRANGE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('zset', 0, 100, array('withscores' => true)); - $expected = array('zset', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, ['withscores' => true]]; + $expected = ['zset', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class ZREVRANGE_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithStringWithscores(): void { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); + $arguments = ['zset', 0, 100, 'withscores']; + $expected = ['zset', 0, 100, 'WITHSCORES']; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class ZREVRANGE_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); + $raw = ['element1', 'element2', 'element3']; + $expected = ['element1', 'element2', 'element3']; $command = $this->getCommand(); @@ -80,10 +80,10 @@ class ZREVRANGE_Test extends PredisCommandTestCase */ public function testParseResponseWithScores(): void { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array('element1' => '1', 'element2' => '2', 'element3' => '3'); + $raw = ['element1', '1', 'element2', '2', 'element3', '3']; + $expected = ['element1' => '1', 'element2' => '2', 'element3' => '3']; - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); + $command = $this->getCommandWithArgumentsArray(['zset', 0, 1, 'withscores']); $this->assertSame($expected, $command->parseResponse($raw)); } @@ -93,17 +93,17 @@ class ZREVRANGE_Test extends PredisCommandTestCase */ public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue(): void { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => true]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 1]); + $this->assertSame(['zset', 0, 100, 'WITHSCORES'], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => false]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); + $command = $this->getCommandWithArguments('zset', 0, 100, ['withscores' => 0]); + $this->assertSame(['zset', 0, 100], $command->getArguments()); } /** @@ -115,16 +115,16 @@ class ZREVRANGE_Test extends PredisCommandTestCase $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $this->assertSame(array(), $redis->zrevrange('letters', 1, 0)); - $this->assertSame(array('f'), $redis->zrevrange('letters', 0, 0)); - $this->assertSame(array('f', 'e', 'd', 'c'), $redis->zrevrange('letters', 0, 3)); + $this->assertSame([], $redis->zrevrange('letters', 1, 0)); + $this->assertSame(['f'], $redis->zrevrange('letters', 0, 0)); + $this->assertSame(['f', 'e', 'd', 'c'], $redis->zrevrange('letters', 0, 3)); - $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrange('letters', 0, -1)); - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrange('letters', 0, -4)); - $this->assertSame(array('d'), $redis->zrevrange('letters', 2, -4)); - $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrange('letters', -100, 100)); + $this->assertSame(['f', 'e', 'd', 'c', 'b', 'a'], $redis->zrevrange('letters', 0, -1)); + $this->assertSame(['f', 'e', 'd'], $redis->zrevrange('letters', 0, -4)); + $this->assertSame(['d'], $redis->zrevrange('letters', 2, -4)); + $this->assertSame(['f', 'e', 'd', 'c', 'b', 'a'], $redis->zrevrange('letters', -100, 100)); - $this->assertSame(array(), $redis->zrevrange('unknown', 0, 30)); + $this->assertSame([], $redis->zrevrange('unknown', 0, 30)); } /** @@ -135,10 +135,10 @@ class ZREVRANGE_Test extends PredisCommandTestCase $redis = $this->getClient(); $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('d' => '20', 'c' => '10', 'b' => '0'); + $expected = ['d' => '20', 'c' => '10', 'b' => '0']; $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, 'withscores')); - $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, array('withscores' => true))); + $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, ['withscores' => true])); } /** diff --git a/tests/Predis/Command/Redis/ZREVRANK_Test.php b/tests/Predis/Command/Redis/ZREVRANK_Test.php index aaefe194..97c0bdbe 100644 --- a/tests/Predis/Command/Redis/ZREVRANK_Test.php +++ b/tests/Predis/Command/Redis/ZREVRANK_Test.php @@ -39,8 +39,8 @@ class ZREVRANK_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); + $arguments = ['key', 'member']; + $expected = ['key', 'member']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/Redis/ZSCAN_Test.php b/tests/Predis/Command/Redis/ZSCAN_Test.php index 0a594dc5..a68f2ca5 100644 --- a/tests/Predis/Command/Redis/ZSCAN_Test.php +++ b/tests/Predis/Command/Redis/ZSCAN_Test.php @@ -39,8 +39,8 @@ class ZSCAN_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + $arguments = ['key', 0, 'MATCH', 'member:*', 'COUNT', 10]; + $expected = ['key', 0, 'MATCH', 'member:*', 'COUNT', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -53,8 +53,8 @@ class ZSCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsBasicUsage(): void { - $arguments = array('key', 0); - $expected = array('key', 0); + $arguments = ['key', 0]; + $expected = ['key', 0]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -67,8 +67,8 @@ class ZSCAN_Test extends PredisCommandTestCase */ public function testFilterArgumentsWithOptionsArray(): void { - $arguments = array('key', 0, array('match' => 'member:*', 'count' => 10)); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); + $arguments = ['key', 0, ['match' => 'member:*', 'count' => 10]]; + $expected = ['key', 0, 'MATCH', 'member:*', 'COUNT', 10]; $command = $this->getCommand(); $command->setArguments($arguments); @@ -81,8 +81,8 @@ class ZSCAN_Test extends PredisCommandTestCase */ public function testParseResponse(): void { - $raw = array('3', array('member:1', '1', 'member:2', '2', 'member:3', '3')); - $expected = array('3', array('member:1' => 1.0, 'member:2' => 2.0, 'member:3' => 3.0)); + $raw = ['3', ['member:1', '1', 'member:2', '2', 'member:3', '3']]; + $expected = ['3', ['member:1' => 1.0, 'member:2' => 2.0, 'member:3' => 3.0]]; $command = $this->getCommand(); @@ -95,8 +95,8 @@ class ZSCAN_Test extends PredisCommandTestCase */ public function testScanWithoutMatch(): void { - $expectedMembers = array('member:one', 'member:two', 'member:three', 'member:four'); - $expectedScores = array(1.0, 2.0, 3.0, 4.0); + $expectedMembers = ['member:one', 'member:two', 'member:three', 'member:four']; + $expectedScores = [1.0, 2.0, 3.0, 4.0]; $redis = $this->getClient(); $redis->zadd('key', array_combine($expectedMembers, $expectedScores)); @@ -115,12 +115,12 @@ class ZSCAN_Test extends PredisCommandTestCase public function testScanWithMatchingMembers(): void { $redis = $this->getClient(); - $redis->zadd('key', array('member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0)); + $redis->zadd('key', ['member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0]); $response = $redis->zscan('key', 0, 'MATCH', 'member:t*'); - $this->assertSame(array('member:two', 'member:three'), array_keys($response[1])); - $this->assertSame(array(2.0, 3.0), array_values($response[1])); + $this->assertSame(['member:two', 'member:three'], array_keys($response[1])); + $this->assertSame([2.0, 3.0], array_values($response[1])); } /** @@ -130,7 +130,7 @@ class ZSCAN_Test extends PredisCommandTestCase public function testScanWithNoMatchingMembers(): void { $redis = $this->getClient(); - $redis->zadd('key', $members = array('member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0)); + $redis->zadd('key', $members = ['member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0]); $response = $redis->zscan('key', 0, 'MATCH', 'nomember:*'); diff --git a/tests/Predis/Command/Redis/ZSCORE_Test.php b/tests/Predis/Command/Redis/ZSCORE_Test.php index f6ee0d7d..dc50820c 100644 --- a/tests/Predis/Command/Redis/ZSCORE_Test.php +++ b/tests/Predis/Command/Redis/ZSCORE_Test.php @@ -39,8 +39,8 @@ class ZSCORE_Test extends PredisCommandTestCase */ public function testFilterArguments(): void { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); + $arguments = ['key', 'member']; + $expected = ['key', 'member']; $command = $this->getCommand(); $command->setArguments($arguments); diff --git a/tests/Predis/Command/RedisFactoryTest.php b/tests/Predis/Command/RedisFactoryTest.php index 233d29c3..04e97a49 100644 --- a/tests/Predis/Command/RedisFactoryTest.php +++ b/tests/Predis/Command/RedisFactoryTest.php @@ -153,7 +153,7 @@ class RedisFactoryTest extends PredisTestCase $this->assertInstanceOf('Predis\Command\CommandInterface', $command); $this->assertEquals('INFO', $command->getId()); - $this->assertEquals(array(), $command->getArguments()); + $this->assertEquals([], $command->getArguments()); } /** @@ -163,7 +163,7 @@ class RedisFactoryTest extends PredisTestCase { $factory = new RedisFactory(); - $arguments = array('foo', 'bar'); + $arguments = ['foo', 'bar']; $command = $factory->create('set', $arguments); $this->assertInstanceOf('Predis\Command\CommandInterface', $command); @@ -254,9 +254,9 @@ class RedisFactoryTest extends PredisTestCase $factory = new RedisFactory(); $factory->setProcessor($processor); - $factory->create('set', array('foo', 'bar')); + $factory->create('set', ['foo', 'bar']); - $this->assertSame(array('FOO', 'BAR'), $argsRef); + $this->assertSame(['FOO', 'BAR'], $argsRef); } /** @@ -293,7 +293,7 @@ class RedisFactoryTest extends PredisTestCase */ protected function getExpectedCommands(): array { - return array( + return [ 0 => 'EXISTS', 1 => 'DEL', 2 => 'TYPE', @@ -453,6 +453,6 @@ class RedisFactoryTest extends PredisTestCase 156 => 'GEODIST', 157 => 'GEORADIUS', 158 => 'GEORADIUSBYMEMBER', - ); + ]; } } diff --git a/tests/Predis/Command/ScriptCommandTest.php b/tests/Predis/Command/ScriptCommandTest.php index 97b9d136..2d189518 100644 --- a/tests/Predis/Command/ScriptCommandTest.php +++ b/tests/Predis/Command/ScriptCommandTest.php @@ -30,7 +30,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var CommandInterface */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript')) + ->onlyMethods(['getScript']) ->getMock(); $this->assertSame('EVALSHA', $command->getId()); @@ -43,7 +43,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->exactly(2)) @@ -54,7 +54,7 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); $this->assertSame(self::LUA_SCRIPT_SHA1, $command->getScriptHash()); } @@ -66,7 +66,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) @@ -77,9 +77,9 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $this->assertSame(array('key1', 'key2'), $command->getKeys()); + $this->assertSame(['key1', 'key2'], $command->getKeys()); } /** @@ -89,16 +89,16 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript')) + ->onlyMethods(['getScript']) ->getMock(); $command ->expects($this->once()) ->method('getScript') ->willReturn(self::LUA_SCRIPT); - $command->setArguments($arguments = array('value1', 'value2', 'value3')); + $command->setArguments($arguments = ['value1', 'value2', 'value3']); - $this->assertSame(array(), $command->getKeys()); + $this->assertSame([], $command->getKeys()); } /** @@ -108,7 +108,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) @@ -119,9 +119,9 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(-2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $this->assertSame(array('key1', 'key2'), $command->getKeys()); + $this->assertSame(['key1', 'key2'], $command->getKeys()); } /** @@ -131,7 +131,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) @@ -142,9 +142,9 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments()); + $this->assertSame(array_merge([self::LUA_SCRIPT_SHA1, 2], $arguments), $command->getArguments()); } /** @@ -154,16 +154,16 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) ->method('getScript') ->willReturn(self::LUA_SCRIPT); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 0), $arguments), $command->getArguments()); + $this->assertSame(array_merge([self::LUA_SCRIPT_SHA1, 0], $arguments), $command->getArguments()); } /** @@ -173,7 +173,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->once()) @@ -184,9 +184,9 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(-2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments()); + $this->assertSame(array_merge([self::LUA_SCRIPT_SHA1, 2], $arguments), $command->getArguments()); } /** @@ -196,7 +196,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->exactly(2)) @@ -207,9 +207,9 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $this->assertSame(array_merge(array(self::LUA_SCRIPT, 2), $arguments), $command->getEvalArguments()); + $this->assertSame(array_merge([self::LUA_SCRIPT, 2], $arguments), $command->getEvalArguments()); } /** @@ -219,7 +219,7 @@ class ScriptCommandTest extends PredisTestCase { /** @var ScriptCommand|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript', 'getKeysCount')) + ->onlyMethods(['getScript', 'getKeysCount']) ->getMock(); $command ->expects($this->exactly(2)) @@ -230,9 +230,9 @@ class ScriptCommandTest extends PredisTestCase ->method('getKeysCount') ->willReturn(2); - $command->setArguments($arguments = array('key1', 'key2', 'value1', 'value2')); + $command->setArguments($arguments = ['key1', 'key2', 'value1', 'value2']); - $evalCMD = new RawCommand('EVAL', array_merge(array(self::LUA_SCRIPT, 2), $arguments)); + $evalCMD = new RawCommand('EVAL', array_merge([self::LUA_SCRIPT, 2], $arguments)); $this->assertRedisCommand($evalCMD, $command->getEvalCommand()); } diff --git a/tests/Predis/CommunicationExceptionTest.php b/tests/Predis/CommunicationExceptionTest.php index 503ae9b7..052ebb50 100644 --- a/tests/Predis/CommunicationExceptionTest.php +++ b/tests/Predis/CommunicationExceptionTest.php @@ -93,8 +93,8 @@ class CommunicationExceptionTest extends PredisTestCase /** @var CommunicationException|MockObject */ $exception = $this->getMockBuilder('Predis\CommunicationException') - ->setConstructorArgs(array($connection, 'Communication error message')) - ->onlyMethods(array('shouldResetConnection')) + ->setConstructorArgs([$connection, 'Communication error message']) + ->onlyMethods(['shouldResetConnection']) ->getMockForAbstractClass(); $exception ->expects($this->once()) @@ -128,7 +128,7 @@ class CommunicationExceptionTest extends PredisTestCase \Exception $inner = null ) { return $this->getMockBuilder('Predis\CommunicationException') - ->setConstructorArgs(array($connection, $message, $code, $inner)) + ->setConstructorArgs([$connection, $message, $code, $inner]) ->getMockForAbstractClass(); } } diff --git a/tests/Predis/Configuration/Option/AggregateTest.php b/tests/Predis/Configuration/Option/AggregateTest.php index 3f4cc387..cdd24348 100644 --- a/tests/Predis/Configuration/Option/AggregateTest.php +++ b/tests/Predis/Configuration/Option/AggregateTest.php @@ -49,7 +49,7 @@ class AggregateTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -82,7 +82,7 @@ class AggregateTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -115,7 +115,7 @@ class AggregateTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -167,7 +167,7 @@ class AggregateTest extends PredisTestCase ); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -200,7 +200,7 @@ class AggregateTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -230,7 +230,7 @@ class AggregateTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -276,13 +276,13 @@ class AggregateTest extends PredisTestCase /** @var Factory|MockObject */ $factory = $this->getMockBuilder('Predis\Connection\Factory') - ->onlyMethods(array('create')) + ->onlyMethods(['create']) ->getMock(); $factory ->expects($this->never()) ->method('create'); - $factory->aggregate($cluster, array(new $connectionClass(), new $connectionClass())); + $factory->aggregate($cluster, [new $connectionClass(), new $connectionClass()]); } /** @@ -301,7 +301,7 @@ class AggregateTest extends PredisTestCase /** @var Factory|MockObject */ $factory = $this->getMockBuilder('Predis\Connection\Factory') - ->onlyMethods(array('create')) + ->onlyMethods(['create']) ->getMock(); $factory ->expects($this->exactly(3)) @@ -310,7 +310,7 @@ class AggregateTest extends PredisTestCase return new $connectionClass(); }); - $factory->aggregate($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass())); + $factory->aggregate($cluster, [null, 'tcp://127.0.0.1', ['scheme' => 'tcp'], new $connectionClass()]); } /** @@ -326,12 +326,12 @@ class AggregateTest extends PredisTestCase /** @var Factory|MockObject */ $factory = $this->getMockBuilder('Predis\Connection\Factory') - ->onlyMethods(array('create')) + ->onlyMethods(['create']) ->getMock(); $factory ->expects($this->never()) ->method('create'); - $factory->aggregate($cluster, array()); + $factory->aggregate($cluster, []); } } diff --git a/tests/Predis/Configuration/Option/CRC16Test.php b/tests/Predis/Configuration/Option/CRC16Test.php index 1e601e99..d9b2a6d6 100644 --- a/tests/Predis/Configuration/Option/CRC16Test.php +++ b/tests/Predis/Configuration/Option/CRC16Test.php @@ -66,7 +66,7 @@ class CRC16Test extends PredisTestCase $hashGenerator = $this->getMockBuilder('Predis\Cluster\Hash\HashGeneratorInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -92,7 +92,7 @@ class CRC16Test extends PredisTestCase $wrongValue = $this->getMockBuilder('stdClass')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) diff --git a/tests/Predis/Configuration/Option/ClusterTest.php b/tests/Predis/Configuration/Option/ClusterTest.php index e3cc0833..abbd8b7f 100644 --- a/tests/Predis/Configuration/Option/ClusterTest.php +++ b/tests/Predis/Configuration/Option/ClusterTest.php @@ -48,7 +48,7 @@ class ClusterTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -99,7 +99,7 @@ class ClusterTest extends PredisTestCase ); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -132,7 +132,7 @@ class ClusterTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -183,7 +183,7 @@ class ClusterTest extends PredisTestCase ); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -216,7 +216,7 @@ class ClusterTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -246,7 +246,7 @@ class ClusterTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -274,7 +274,7 @@ class ClusterTest extends PredisTestCase ->with('connections'); $this->assertInstanceOf('closure', $initializer = $option->filter($options, 'predis')); - $this->assertInstanceOf('Predis\Connection\Cluster\PredisCluster', $initializer($parameters = array())); + $this->assertInstanceOf('Predis\Connection\Cluster\PredisCluster', $initializer($parameters = [])); } /** @@ -291,8 +291,8 @@ class ClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('__get') ->withConsecutive( - array('connections'), - array('crc16') + ['connections'], + ['crc16'] ) ->willReturnOnConsecutiveCalls( $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(), @@ -300,7 +300,7 @@ class ClusterTest extends PredisTestCase ); $this->assertInstanceOf('closure', $initializer = $option->filter($options, 'redis')); - $this->assertInstanceOf('Predis\Connection\Cluster\RedisCluster', $initializer($parameters = array())); + $this->assertInstanceOf('Predis\Connection\Cluster\RedisCluster', $initializer($parameters = [])); } /** @@ -317,8 +317,8 @@ class ClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('__get') ->withConsecutive( - array('connections'), - array('crc16') + ['connections'], + ['crc16'] ) ->willReturnOnConsecutiveCalls( $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(), @@ -326,7 +326,7 @@ class ClusterTest extends PredisTestCase ); $this->assertInstanceOf('closure', $initializer = $option->filter($options, 'redis-cluster')); - $this->assertInstanceOf('Predis\Connection\Cluster\RedisCluster', $initializer($parameters = array())); + $this->assertInstanceOf('Predis\Connection\Cluster\RedisCluster', $initializer($parameters = [])); } /** diff --git a/tests/Predis/Configuration/Option/CommandsTest.php b/tests/Predis/Configuration/Option/CommandsTest.php index 632088f5..165c2adb 100644 --- a/tests/Predis/Configuration/Option/CommandsTest.php +++ b/tests/Predis/Configuration/Option/CommandsTest.php @@ -96,10 +96,10 @@ class CommandsTest extends PredisTestCase /** @var OptionsInterface */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); - $input = array( + $input = [ 'FOO' => 'Predis\Command\RawCommand', 'BAR' => 'Predis\Command\RawCommand', - ); + ]; $commands = $option->filter($options, $input); @@ -118,11 +118,11 @@ class CommandsTest extends PredisTestCase /** @var OptionsInterface */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); - $input = array( + $input = [ 'ECHO' => null, 'EVAL' => null, 'FOO' => null, - ); + ]; $commands = $option->filter($options, $input); @@ -144,7 +144,7 @@ class CommandsTest extends PredisTestCase $commands = $this->getMockBuilder('Predis\Command\FactoryInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -165,13 +165,13 @@ class CommandsTest extends PredisTestCase /** @var OptionsInterface */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); - $dictionary = array( + $dictionary = [ 'FOO' => 'Predis\Command\RawCommand', 'BAR' => 'Predis\Command\RawCommand', - ); + ]; $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -264,7 +264,7 @@ class CommandsTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) diff --git a/tests/Predis/Configuration/Option/ConnectionsTest.php b/tests/Predis/Configuration/Option/ConnectionsTest.php index 510ca844..e196802a 100644 --- a/tests/Predis/Configuration/Option/ConnectionsTest.php +++ b/tests/Predis/Configuration/Option/ConnectionsTest.php @@ -43,7 +43,7 @@ class ConnectionsTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $class = get_class($this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock()); - $value = array('tcp' => $class, 'redis' => $class); + $value = ['tcp' => $class, 'redis' => $class]; $default = $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock(); $default @@ -53,7 +53,7 @@ class ConnectionsTest extends PredisTestCase /** @var OptionInterface */ $option = $this->getMockBuilder('Predis\Configuration\Option\Connections') - ->onlyMethods(array('getDefault')) + ->onlyMethods(['getDefault']) ->getMock(); $option ->expects($this->once()) @@ -80,7 +80,7 @@ class ConnectionsTest extends PredisTestCase ->with($this->matchesRegularExpression('/^tcp|unix|redis$/'), $classFQCN); $option = $this->getMockBuilder('Predis\Configuration\Option\Connections') - ->setMethods(array('getDefault')) + ->setMethods(['getDefault']) ->getMock(); $option ->expects($this->once()) @@ -107,7 +107,7 @@ class ConnectionsTest extends PredisTestCase ->method('define'); $option = $this->getMockBuilder('Predis\Configuration\Option\Connections') - ->setMethods(array('getDefault')) + ->setMethods(['getDefault']) ->getMock(); $option ->expects($this->once()) @@ -140,7 +140,7 @@ class ConnectionsTest extends PredisTestCase */ public function testUsesParametersOptionToSetDefaultParameters(): void { - $parameters = array('database' => 5, 'password' => 'mypassword'); + $parameters = ['database' => 5, 'password' => 'mypassword']; /** @var OptionsInterface|MockObject */ $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); @@ -168,7 +168,7 @@ class ConnectionsTest extends PredisTestCase { /** @var OptionInterface */ $option = $this->getMockBuilder('Predis\Configuration\Option\Connections') - ->onlyMethods(array('getDefault')) + ->onlyMethods(['getDefault']) ->getMock(); $option ->expects($this->never()) @@ -191,7 +191,7 @@ class ConnectionsTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -231,10 +231,10 @@ class ConnectionsTest extends PredisTestCase */ public function provideSupportedStringValuesForOption() { - return array( - array('phpiredis-stream', 'Predis\Connection\PhpiredisStreamConnection'), - array('phpiredis-socket', 'Predis\Connection\PhpiredisSocketConnection'), - array('phpiredis', 'Predis\Connection\PhpiredisStreamConnection'), - ); + return [ + ['phpiredis-stream', 'Predis\Connection\PhpiredisStreamConnection'], + ['phpiredis-socket', 'Predis\Connection\PhpiredisSocketConnection'], + ['phpiredis', 'Predis\Connection\PhpiredisStreamConnection'], + ]; } } diff --git a/tests/Predis/Configuration/Option/PrefixTest.php b/tests/Predis/Configuration/Option/PrefixTest.php index 17eb095e..4f2e494b 100644 --- a/tests/Predis/Configuration/Option/PrefixTest.php +++ b/tests/Predis/Configuration/Option/PrefixTest.php @@ -77,7 +77,7 @@ class PrefixTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -103,7 +103,7 @@ class PrefixTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -129,7 +129,7 @@ class PrefixTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $input = $this->getMockBuilder('stdClass') - ->addMethods(array('__toString')) + ->addMethods(['__toString']) ->getMock(); $input ->expects($this->once()) diff --git a/tests/Predis/Configuration/Option/ReplicationTest.php b/tests/Predis/Configuration/Option/ReplicationTest.php index 2293de38..95feecff 100644 --- a/tests/Predis/Configuration/Option/ReplicationTest.php +++ b/tests/Predis/Configuration/Option/ReplicationTest.php @@ -50,8 +50,8 @@ class ReplicationTest extends PredisTestCase ->expects($this->exactly(2)) ->method('__get') ->withConsecutive( - array('autodiscovery'), - array('connections') + ['autodiscovery'], + ['connections'] ) ->willReturnOnConsecutiveCalls( true, @@ -81,7 +81,7 @@ class ReplicationTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -132,7 +132,7 @@ class ReplicationTest extends PredisTestCase ); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -165,7 +165,7 @@ class ReplicationTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -216,7 +216,7 @@ class ReplicationTest extends PredisTestCase ); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -249,7 +249,7 @@ class ReplicationTest extends PredisTestCase ->method('add'); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -279,7 +279,7 @@ class ReplicationTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -303,7 +303,7 @@ class ReplicationTest extends PredisTestCase $options = $this->getMockBuilder('Predis\Configuration\OptionsInterface')->getMock(); $this->assertInstanceOf('closure', $initializer = $option->filter($options, 'predis')); - $this->assertInstanceOf('Predis\Connection\Replication\MasterSlaveReplication', $initializer($parameters = array())); + $this->assertInstanceOf('Predis\Connection\Replication\MasterSlaveReplication', $initializer($parameters = [])); } /** @@ -319,17 +319,17 @@ class ReplicationTest extends PredisTestCase ->expects($this->exactly(2)) ->method('__get') ->withConsecutive( - array('service'), - array('connections') + ['service'], + ['connections'] ) ->willReturnOnConsecutiveCalls( 'mymaster', $this->getMockBuilder('Predis\Connection\FactoryInterface')->getMock() ); - $parameters = array( + $parameters = [ $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(), - ); + ]; $this->assertInstanceOf('closure', $initializer = $option->filter($options, 'sentinel')); $this->assertInstanceOf('Predis\Connection\Replication\SentinelReplication', $connection = $initializer($parameters)); diff --git a/tests/Predis/Configuration/OptionsTest.php b/tests/Predis/Configuration/OptionsTest.php index 1de309af..abd0adfa 100644 --- a/tests/Predis/Configuration/OptionsTest.php +++ b/tests/Predis/Configuration/OptionsTest.php @@ -43,7 +43,7 @@ class OptionsTest extends PredisTestCase $connection = $this->getMockBuilder('Predis\Connection\AggregateConnectionInterface')->getMock(); $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->any()) @@ -51,7 +51,7 @@ class OptionsTest extends PredisTestCase ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface')) ->willReturn($connection); - $options = new Options(array( + $options = new Options([ 'exceptions' => false, 'prefix' => 'prefix:', 'commands' => $this->getMockBuilder('Predis\Command\FactoryInterface')->getMock(), @@ -59,7 +59,7 @@ class OptionsTest extends PredisTestCase 'cluster' => $callable, 'replication' => $callable, 'aggregate' => $callable, - )); + ]); $this->assertIsBool($options->exceptions); $this->assertInstanceOf('Predis\Command\Processor\ProcessorInterface', $options->prefix); @@ -67,13 +67,13 @@ class OptionsTest extends PredisTestCase $this->assertInstanceOf('Predis\Connection\FactoryInterface', $options->connections); $this->assertInstanceOf('Closure', $initializer = $options->aggregate); - $this->assertSame($connection, $initializer($options, array())); + $this->assertSame($connection, $initializer($options, [])); $this->assertInstanceOf('Closure', $initializer = $options->cluster); - $this->assertSame($connection, $initializer($options, array())); + $this->assertSame($connection, $initializer($options, [])); $this->assertInstanceOf('Closure', $initializer = $options->replication); - $this->assertSame($connection, $initializer($options, array())); + $this->assertSame($connection, $initializer($options, [])); } /** @@ -81,9 +81,9 @@ class OptionsTest extends PredisTestCase */ public function testSupportsCustomOptions(): void { - $options = new Options(array( + $options = new Options([ 'custom' => 'foobar', - )); + ]); $this->assertSame('foobar', $options->custom); } @@ -105,11 +105,11 @@ class OptionsTest extends PredisTestCase */ public function testCanCheckOptionsIfDefinedByUser(): void { - $options = new Options(array( + $options = new Options([ 'prefix' => 'prefix:', 'custom' => 'foobar', 'void' => null, - )); + ]); $this->assertTrue($options->defined('prefix')); $this->assertTrue($options->defined('custom')); @@ -122,11 +122,11 @@ class OptionsTest extends PredisTestCase */ public function testIsSetReplicatesPHPBehavior(): void { - $options = new Options(array( + $options = new Options([ 'prefix' => 'prefix:', 'custom' => 'foobar', 'void' => null, - )); + ]); $this->assertTrue(isset($options->prefix)); $this->assertTrue(isset($options->custom)); @@ -163,7 +163,7 @@ class OptionsTest extends PredisTestCase // NOTE: closure values are covered by this test since they define __invoke(). $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -171,9 +171,9 @@ class OptionsTest extends PredisTestCase ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface')) ->willReturn($commands); - $options = new Options(array( + $options = new Options([ 'commands' => $callable, - )); + ]); $this->assertSame($commands, $options->commands); $this->assertSame($commands, $options->commands); @@ -188,7 +188,7 @@ class OptionsTest extends PredisTestCase // NOTE: closure values are covered by this test since they define __invoke(). $callable = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callable ->expects($this->once()) @@ -196,9 +196,9 @@ class OptionsTest extends PredisTestCase ->with($this->isInstanceOf('Predis\Configuration\OptionsInterface')) ->willReturn($custom); - $options = new Options(array( + $options = new Options([ 'custom' => $callable, - )); + ]); $this->assertSame($custom, $options->custom); $this->assertSame($custom, $options->custom); @@ -210,7 +210,7 @@ class OptionsTest extends PredisTestCase public function testChecksForInvokeMagicMethodDoesNotTriggerAutoloader(): void { $trigger = $this->getMockBuilder('stdClass') - ->addMethods(array('autoload')) + ->addMethods(['autoload']) ->getMock(); $trigger ->expects($this->never()) @@ -221,7 +221,7 @@ class OptionsTest extends PredisTestCase }, true, false); try { - $options = new Options(array('custom' => 'value')); + $options = new Options(['custom' => 'value']); $pfx = $options->prefix; } catch (\Exception $_) { spl_autoload_unregister($autoload); diff --git a/tests/Predis/Connection/Cluster/PredisClusterTest.php b/tests/Predis/Connection/Cluster/PredisClusterTest.php index 3e57114c..7cbc431d 100644 --- a/tests/Predis/Connection/Cluster/PredisClusterTest.php +++ b/tests/Predis/Connection/Cluster/PredisClusterTest.php @@ -198,10 +198,10 @@ class PredisClusterTest extends PredisTestCase $this->assertInstanceOf('Iterator', $iterator = $cluster->getIterator()); $connections = iterator_to_array($iterator); - $this->assertSame(array( + $this->assertSame([ '127.0.0.1:7001' => $connection1, '127.0.0.1:7002' => $connection2, - ), iterator_to_array($iterator)); + ], iterator_to_array($iterator)); } /** @@ -255,23 +255,23 @@ class PredisClusterTest extends PredisTestCase $cluster->add($connection1); $cluster->add($connection2); - $set = $commands->create('set', array('node01:5431', 'foobar')); - $get = $commands->create('get', array('node01:5431')); + $set = $commands->create('set', ['node01:5431', 'foobar']); + $get = $commands->create('get', ['node01:5431']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('prefix:{node01:5431}', 'foobar')); - $get = $commands->create('get', array('prefix:{node01:5431}')); + $set = $commands->create('set', ['prefix:{node01:5431}', 'foobar']); + $get = $commands->create('get', ['prefix:{node01:5431}']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('node02:3212', 'foobar')); - $get = $commands->create('get', array('node02:3212')); + $set = $commands->create('set', ['node02:3212', 'foobar']); + $get = $commands->create('get', ['node02:3212']); $this->assertSame($connection2, $cluster->getConnectionByCommand($set)); $this->assertSame($connection2, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('prefix:{node02:3212}', 'foobar')); - $get = $commands->create('get', array('prefix:{node02:3212}')); + $set = $commands->create('set', ['prefix:{node02:3212}', 'foobar']); + $get = $commands->create('get', ['prefix:{node02:3212}']); $this->assertSame($connection2, $cluster->getConnectionByCommand($set)); $this->assertSame($connection2, $cluster->getConnectionByCommand($get)); } @@ -308,13 +308,13 @@ class PredisClusterTest extends PredisTestCase $cluster->add($connection1); $cluster->add($connection2); - $set = $commands->create('set', array('{node:1001}:foo', 'foobar')); - $get = $commands->create('get', array('{node:1001}:foo')); + $set = $commands->create('set', ['{node:1001}:foo', 'foobar']); + $get = $commands->create('get', ['{node:1001}:foo']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('{node:1001}:bar', 'foobar')); - $get = $commands->create('get', array('{node:1001}:bar')); + $set = $commands->create('set', ['{node:1001}:bar', 'foobar']); + $get = $commands->create('get', ['{node:1001}:bar']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); } @@ -324,7 +324,7 @@ class PredisClusterTest extends PredisTestCase */ public function testWritesCommandToCorrectConnection(): void { - $command = $this->getCommandFactory()->create('get', array('node01:5431')); + $command = $this->getCommandFactory()->create('get', ['node01:5431']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:7001'); $connection1 @@ -350,7 +350,7 @@ class PredisClusterTest extends PredisTestCase */ public function testReadsCommandFromCorrectConnection(): void { - $command = $this->getCommandFactory()->create('get', array('node02:3212')); + $command = $this->getCommandFactory()->create('get', ['node02:3212']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:7001'); $connection1 @@ -376,7 +376,7 @@ class PredisClusterTest extends PredisTestCase */ public function testExecutesCommandOnCorrectConnection(): void { - $command = $this->getCommandFactory()->create('get', array('node01:5431')); + $command = $this->getCommandFactory()->create('get', ['node01:5431']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:7001'); $connection1 diff --git a/tests/Predis/Connection/Cluster/RedisClusterTest.php b/tests/Predis/Connection/Cluster/RedisClusterTest.php index 6668f89e..3473dbee 100644 --- a/tests/Predis/Connection/Cluster/RedisClusterTest.php +++ b/tests/Predis/Connection/Cluster/RedisClusterTest.php @@ -295,18 +295,18 @@ class RedisClusterTest extends PredisTestCase */ public function testGetIteratorReturnsConnectionsMappedInSlotsMapFetchedFromRedisCluster(): void { - $slotsmap = array( - array(0, 5460, array('127.0.0.1', 6381), array()), - array(5461, 10922, array('127.0.0.1', 6383), array()), - array(10923, 16383, array('127.0.0.1', 6384), array()), - ); + $slotsmap = [ + [0, 5460, ['127.0.0.1', 6381], []], + [5461, 10922, ['127.0.0.1', 6383], []], + [10923, 16383, ['127.0.0.1', 6384], []], + ]; $connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460'); $connection1 ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willReturn($slotsmap); @@ -319,18 +319,18 @@ class RedisClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('create') ->withConsecutive( - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6383', - ) - ), - array( - array( + ] + ], + [ + [ 'host' => '127.0.0.1', 'port' => '6384', - ) - ) + ] + ] ) ->willReturnOnConsecutiveCalls( $connection3, @@ -340,8 +340,8 @@ class RedisClusterTest extends PredisTestCase // TODO: I'm not sure about mocking a protected method, but it'll do for now /** @var Connection\Cluster\RedisCluster|MockObject */ $cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster') - ->onlyMethods(array('getRandomConnection')) - ->setConstructorArgs(array($factory)) + ->onlyMethods(['getRandomConnection']) + ->setConstructorArgs([$factory]) ->getMock(); $cluster ->expects($this->once()) @@ -517,18 +517,18 @@ class RedisClusterTest extends PredisTestCase $cluster->add($connection2); $cluster->add($connection3); - $set = $commands->create('set', array('node:1001', 'foobar')); - $get = $commands->create('get', array('node:1001')); + $set = $commands->create('set', ['node:1001', 'foobar']); + $get = $commands->create('get', ['node:1001']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('node:1048', 'foobar')); - $get = $commands->create('get', array('node:1048')); + $set = $commands->create('set', ['node:1048', 'foobar']); + $get = $commands->create('get', ['node:1048']); $this->assertSame($connection2, $cluster->getConnectionByCommand($set)); $this->assertSame($connection2, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('node:1082', 'foobar')); - $get = $commands->create('get', array('node:1082')); + $set = $commands->create('set', ['node:1082', 'foobar']); + $get = $commands->create('get', ['node:1082']); $this->assertSame($connection3, $cluster->getConnectionByCommand($set)); $this->assertSame($connection3, $cluster->getConnectionByCommand($get)); } @@ -538,7 +538,7 @@ class RedisClusterTest extends PredisTestCase */ public function testWritesCommandToCorrectConnection(): void { - $command = $this->getCommandFactory()->create('get', array('node:1001')); + $command = $this->getCommandFactory()->create('get', ['node:1001']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -565,7 +565,7 @@ class RedisClusterTest extends PredisTestCase */ public function testReadsCommandFromCorrectConnection(): void { - $command = $this->getCommandFactory()->create('get', array('node:1050')); + $command = $this->getCommandFactory()->create('get', ['node:1050']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -592,18 +592,18 @@ class RedisClusterTest extends PredisTestCase */ public function testRetriesExecutingCommandOnConnectionFailureOnlyAfterFetchingNewSlotsMap(): void { - $slotsmap = array( - array(0, 5460, array('127.0.0.1', 9381), array()), - array(5461, 10922, array('127.0.0.1', 6382), array()), - array(10923, 16383, array('127.0.0.1', 6383), array()), - ); + $slotsmap = [ + [0, 5460, ['127.0.0.1', 9381], []], + [5461, 10922, ['127.0.0.1', 6382], []], + [10923, 16383, ['127.0.0.1', 6383], []], + ]; $connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460'); $connection1 ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'GET', array('node:1001') + 'GET', ['node:1001'] )) ->willThrowException( new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]') @@ -614,7 +614,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willReturn($slotsmap); @@ -623,7 +623,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willReturn($slotsmap); @@ -632,8 +632,8 @@ class RedisClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('GET', array('node:1001'))), - array($this->isRedisCommand('GET', array('node:5001'))) + [$this->isRedisCommand('GET', ['node:1001'])], + [$this->isRedisCommand('GET', ['node:5001'])] ) ->willReturnOnConsecutiveCalls( 'value:1001', @@ -645,10 +645,10 @@ class RedisClusterTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '9381', - )) + ]) ->willReturn($connection4); $cluster = new RedisCluster($factory); @@ -676,7 +676,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'GET', array('node:1001') + 'GET', ['node:1001'] )) ->willThrowException( new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]') @@ -687,7 +687,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'GET', array('node:1001') + 'GET', ['node:1001'] )) ->willReturn( new Response\Error('MOVED 1970 127.0.0.1:9381') @@ -703,7 +703,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'GET', array('node:1001') + 'GET', ['node:1001'] )) ->willReturn('value:1001'); @@ -711,17 +711,17 @@ class RedisClusterTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '9381', - )) + ]) ->willReturn($connection4); // TODO: I'm not sure about mocking a protected method, but it'll do for now /** @var Connection\Cluster\RedisCluster|MockObject */ $cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster') - ->onlyMethods(array('getRandomConnection')) - ->setConstructorArgs(array($factory)) + ->onlyMethods(['getRandomConnection']) + ->setConstructorArgs([$factory]) ->getMock(); $cluster ->expects($this->never()) @@ -781,18 +781,18 @@ class RedisClusterTest extends PredisTestCase */ public function testAskSlotMapRetriesOnDifferentNodeOnConnectionFailure(): void { - $slotsmap = array( - array(0, 5460, array('127.0.0.1', 9381), array()), - array(5461, 10922, array('127.0.0.1', 6382), array()), - array(10923, 16383, array('127.0.0.1', 6383), array()), - ); + $slotsmap = [ + [0, 5460, ['127.0.0.1', 9381], []], + [5461, 10922, ['127.0.0.1', 6382], []], + [10923, 16383, ['127.0.0.1', 6383], []], + ]; $connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460'); $connection1 ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willThrowException( new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]') @@ -803,7 +803,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willThrowException( new Connection\ConnectionException($connection2, 'Unknown connection error [127.0.0.1:6383]') @@ -814,7 +814,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willReturn($slotsmap); @@ -826,8 +826,8 @@ class RedisClusterTest extends PredisTestCase // TODO: I'm not sure about mocking a protected method, but it'll do for now /** @var Connection\Cluster\RedisCluster|MockObject */ $cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster') - ->onlyMethods(array('getRandomConnection')) - ->setConstructorArgs(array($factory)) + ->onlyMethods(['getRandomConnection']) + ->setConstructorArgs([$factory]) ->getMock(); $cluster ->expects($this->exactly(3)) @@ -851,18 +851,18 @@ class RedisClusterTest extends PredisTestCase $this->expectException('Predis\Connection\ConnectionException'); $this->expectExceptionMessage("Unknown connection error [127.0.0.1:6382]"); - $slotsmap = array( - array(0, 5460, array('127.0.0.1', 9381), array()), - array(5461, 10922, array('127.0.0.1', 6382), array()), - array(10923, 16383, array('127.0.0.1', 6383), array()), - ); + $slotsmap = [ + [0, 5460, ['127.0.0.1', 9381], []], + [5461, 10922, ['127.0.0.1', 6382], []], + [10923, 16383, ['127.0.0.1', 6383], []], + ]; $connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460'); $connection1 ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willThrowException( new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]') @@ -873,7 +873,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willThrowException( new Connection\ConnectionException($connection2, 'Unknown connection error [127.0.0.1:6382]') @@ -892,8 +892,8 @@ class RedisClusterTest extends PredisTestCase // TODO: I'm not sure about mocking a protected method, but it'll do for now /** @var Connection\Cluster\RedisCluster|MockObject */ $cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster') - ->onlyMethods(array('getRandomConnection')) - ->setConstructorArgs(array($factory)) + ->onlyMethods(['getRandomConnection']) + ->setConstructorArgs([$factory]) ->getMock(); $cluster ->expects($this->exactly(2)) @@ -924,13 +924,13 @@ class RedisClusterTest extends PredisTestCase $cluster->add($connection1); $cluster->add($connection2); - $set = $commands->create('set', array('{node:1001}:foo', 'foobar')); - $get = $commands->create('get', array('{node:1001}:foo')); + $set = $commands->create('set', ['{node:1001}:foo', 'foobar']); + $get = $commands->create('get', ['{node:1001}:foo']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); - $set = $commands->create('set', array('{node:1001}:bar', 'foobar')); - $get = $commands->create('get', array('{node:1001}:bar')); + $set = $commands->create('set', ['{node:1001}:bar', 'foobar']); + $get = $commands->create('get', ['{node:1001}:bar']); $this->assertSame($connection1, $cluster->getConnectionByCommand($set)); $this->assertSame($connection1, $cluster->getConnectionByCommand($get)); } @@ -942,7 +942,7 @@ class RedisClusterTest extends PredisTestCase { $askResponse = new Response\Error('ASK 1970 127.0.0.1:6380'); - $command = $this->getCommandFactory()->create('get', array('node:1001')); + $command = $this->getCommandFactory()->create('get', ['node:1001']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -956,8 +956,8 @@ class RedisClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ASKING')), - array($this->isRedisCommand($command)) + [$this->isRedisCommand('ASKING')], + [$this->isRedisCommand($command)] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), @@ -988,7 +988,7 @@ class RedisClusterTest extends PredisTestCase { $askResponse = new Response\Error('ASK 1970 127.0.0.1:6381'); - $command = $this->getCommandFactory()->create('get', array('node:1001')); + $command = $this->getCommandFactory()->create('get', ['node:1001']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -1007,8 +1007,8 @@ class RedisClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ASKING')), - array($this->isRedisCommand($command)) + [$this->isRedisCommand('ASKING')], + [$this->isRedisCommand($command)] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), @@ -1020,10 +1020,10 @@ class RedisClusterTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6381', - )) + ]) ->willReturn($connection3); $cluster = new RedisCluster($factory); @@ -1044,7 +1044,7 @@ class RedisClusterTest extends PredisTestCase { $movedResponse = new Response\Error('MOVED 1970 127.0.0.1:6380'); - $command = $this->getCommandFactory()->create('get', array('node:1001')); + $command = $this->getCommandFactory()->create('get', ['node:1001']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -1082,7 +1082,7 @@ class RedisClusterTest extends PredisTestCase { $movedResponse = new Response\Error('MOVED 1970 127.0.0.1:6381'); - $command = $this->getCommandFactory()->create('get', array('node:1001')); + $command = $this->getCommandFactory()->create('get', ['node:1001']); $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -1108,10 +1108,10 @@ class RedisClusterTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6381', - )) + ]) ->willReturn($connection3); $cluster = new RedisCluster($factory); @@ -1132,7 +1132,7 @@ class RedisClusterTest extends PredisTestCase { $movedResponse = new Response\Error('MOVED 1970 2001:db8:0:f101::2:6379'); - $command = $this->getCommandFactory()->create('get', array('node:1001')); + $command = $this->getCommandFactory()->create('get', ['node:1001']); $connection1 = $this->getMockConnection('tcp://[2001:db8:0:f101::1]:6379'); $connection1 @@ -1153,10 +1153,10 @@ class RedisClusterTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '2001:db8:0:f101::2', 'port' => '6379', - )) + ]) ->willReturn($connection2); $cluster = new RedisCluster($factory); @@ -1172,31 +1172,31 @@ class RedisClusterTest extends PredisTestCase */ public function testFetchSlotsMapFromClusterWithClusterSlotsCommand(): void { - $response = array( - array(12288, 13311, array('10.1.0.51', 6387), array('10.1.0.52', 6387)), - array(3072, 4095, array('10.1.0.52', 6392), array('10.1.0.51', 6392)), - array(6144, 7167, array('', 6384), array('10.1.0.52', 6384)), - array(14336, 15359, array('10.1.0.51', 6388), array('10.1.0.52', 6388)), - array(15360, 16383, array('10.1.0.52', 6398), array('10.1.0.51', 6398)), - array(1024, 2047, array('10.1.0.52', 6391), array('10.1.0.51', 6391)), - array(11264, 12287, array('10.1.0.52', 6396), array('10.1.0.51', 6396)), - array(5120, 6143, array('10.1.0.52', 6393), array('10.1.0.51', 6393)), - array(0, 1023, array('10.1.0.51', 6381), array('10.1.0.52', 6381)), - array(13312, 14335, array('10.1.0.52', 6397), array('10.1.0.51', 6397)), - array(4096, 5119, array('10.1.0.51', 6383), array('10.1.0.52', 6383)), - array(9216, 10239, array('10.1.0.52', 6395), array('10.1.0.51', 6395)), - array(8192, 9215, array('10.1.0.51', 6385), array('10.1.0.52', 6385)), - array(10240, 11263, array('10.1.0.51', 6386), array('10.1.0.52', 6386)), - array(2048, 3071, array('10.1.0.51', 6382), array('10.1.0.52', 6382)), - array(7168, 8191, array('10.1.0.52', 6394), array('10.1.0.51', 6394)), - ); + $response = [ + [12288, 13311, ['10.1.0.51', 6387], ['10.1.0.52', 6387]], + [3072, 4095, ['10.1.0.52', 6392], ['10.1.0.51', 6392]], + [6144, 7167, ['', 6384], ['10.1.0.52', 6384]], + [14336, 15359, ['10.1.0.51', 6388], ['10.1.0.52', 6388]], + [15360, 16383, ['10.1.0.52', 6398], ['10.1.0.51', 6398]], + [1024, 2047, ['10.1.0.52', 6391], ['10.1.0.51', 6391]], + [11264, 12287, ['10.1.0.52', 6396], ['10.1.0.51', 6396]], + [5120, 6143, ['10.1.0.52', 6393], ['10.1.0.51', 6393]], + [0, 1023, ['10.1.0.51', 6381], ['10.1.0.52', 6381]], + [13312, 14335, ['10.1.0.52', 6397], ['10.1.0.51', 6397]], + [4096, 5119, ['10.1.0.51', 6383], ['10.1.0.52', 6383]], + [9216, 10239, ['10.1.0.52', 6395], ['10.1.0.51', 6395]], + [8192, 9215, ['10.1.0.51', 6385], ['10.1.0.52', 6385]], + [10240, 11263, ['10.1.0.51', 6386], ['10.1.0.52', 6386]], + [2048, 3071, ['10.1.0.51', 6382], ['10.1.0.52', 6382]], + [7168, 8191, ['10.1.0.52', 6394], ['10.1.0.51', 6394]], + ]; $connection1 = $this->getMockConnection('tcp://10.1.0.51:6384'); $connection1 ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willReturn($response); @@ -1219,10 +1219,10 @@ class RedisClusterTest extends PredisTestCase { $cmdGET = Command\RawCommand::create('GET', 'node:1001'); $rspMOVED = new Response\Error('MOVED 1970 127.0.0.1:6380'); - $rspSlotsArray = array( - array(0, 8191, array('127.0.0.1', 6379)), - array(8192, 16383, array('127.0.0.1', 6380)), - ); + $rspSlotsArray = [ + [0, 8191, ['127.0.0.1', 6379]], + [8192, 16383, ['127.0.0.1', 6380]], + ]; $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); $connection1 @@ -1236,8 +1236,8 @@ class RedisClusterTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('CLUSTER', array('SLOTS'))), - array($this->isRedisCommand($cmdGET)) + [$this->isRedisCommand('CLUSTER', ['SLOTS'])], + [$this->isRedisCommand($cmdGET)] ) ->willReturnOnConsecutiveCalls( $rspSlotsArray, @@ -1249,10 +1249,10 @@ class RedisClusterTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6380', - )) + ]) ->willReturn($connection2); $cluster = new RedisCluster($factory); @@ -1371,18 +1371,18 @@ class RedisClusterTest extends PredisTestCase */ public function testQueryClusterNodeForSlotMapPauseDurationOnRetry() { - $slotsmap = array( - array(0, 5460, array('127.0.0.1', 9381), array()), - array(5461, 10922, array('127.0.0.1', 6382), array()), - array(10923, 16383, array('127.0.0.1', 6383), array()), - ); + $slotsmap = [ + [0, 5460, ['127.0.0.1', 9381], []], + [5461, 10922, ['127.0.0.1', 6382], []], + [10923, 16383, ['127.0.0.1', 6383], []], + ]; $connection1 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=0-5460'); $connection1 ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willThrowException( new Connection\ConnectionException($connection1, 'Unknown connection error [127.0.0.1:6381]') @@ -1393,7 +1393,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willThrowException( new Connection\ConnectionException($connection2, 'Unknown connection error [127.0.0.1:6383]') @@ -1404,7 +1404,7 @@ class RedisClusterTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'CLUSTER', array('SLOTS') + 'CLUSTER', ['SLOTS'] )) ->willReturn($slotsmap); @@ -1416,8 +1416,8 @@ class RedisClusterTest extends PredisTestCase // TODO: I'm not sure about mocking a protected method, but it'll do for now /** @var Connection\Cluster\RedisCluster|MockObject */ $cluster = $this->getMockBuilder('Predis\Connection\Cluster\RedisCluster') - ->onlyMethods(array('getRandomConnection')) - ->setConstructorArgs(array($factory)) + ->onlyMethods(['getRandomConnection']) + ->setConstructorArgs([$factory]) ->getMock(); $cluster ->expects($this->exactly(3)) diff --git a/tests/Predis/Connection/CompositeStreamConnectionTest.php b/tests/Predis/Connection/CompositeStreamConnectionTest.php index f6959364..20bbc200 100644 --- a/tests/Predis/Connection/CompositeStreamConnectionTest.php +++ b/tests/Predis/Connection/CompositeStreamConnectionTest.php @@ -42,8 +42,8 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase /** @var NodeConnectionInterface|MockObject */ $connection = $this ->getMockBuilder($this->getConnectionClass()) - ->onlyMethods(array('executeCommand', 'createResource')) - ->setConstructorArgs(array(new Parameters())) + ->onlyMethods(['executeCommand', 'createResource']) + ->setConstructorArgs([new Parameters()]) ->getMock(); $connection ->method('executeCommand') @@ -73,11 +73,11 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase $connection->getProtocol()->useIterableMultibulk(true); - $connection->executeCommand($commands->create('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeRequest($commands->create('lrange', array('metavars', 0, -1))); + $connection->executeCommand($commands->create('rpush', ['metavars', 'foo', 'hoge', 'lol'])); + $connection->writeRequest($commands->create('lrange', ['metavars', 0, -1])); $this->assertInstanceOf('Predis\Response\Iterator\MultiBulkIterator', $iterator = $connection->read()); - $this->assertSame(array('foo', 'hoge', 'lol'), iterator_to_array($iterator)); + $this->assertSame(['foo', 'hoge', 'lol'], iterator_to_array($iterator)); } /** @@ -86,16 +86,16 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentParameterWithFalseLikeValues(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 0)); + $connection1 = $this->createConnectionWithParams(['persistent' => 0]); $this->assertNonPersistentConnection($connection1); - $connection2 = $this->createConnectionWithParams(array('persistent' => false)); + $connection2 = $this->createConnectionWithParams(['persistent' => false]); $this->assertNonPersistentConnection($connection2); - $connection3 = $this->createConnectionWithParams(array('persistent' => '0')); + $connection3 = $this->createConnectionWithParams(['persistent' => '0']); $this->assertNonPersistentConnection($connection3); - $connection4 = $this->createConnectionWithParams(array('persistent' => 'false')); + $connection4 = $this->createConnectionWithParams(['persistent' => 'false']); $this->assertNonPersistentConnection($connection4); } @@ -105,16 +105,16 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentParameterWithTrueLikeValues(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 1)); + $connection1 = $this->createConnectionWithParams(['persistent' => 1]); $this->assertPersistentConnection($connection1); - $connection2 = $this->createConnectionWithParams(array('persistent' => true)); + $connection2 = $this->createConnectionWithParams(['persistent' => true]); $this->assertPersistentConnection($connection2); - $connection3 = $this->createConnectionWithParams(array('persistent' => '1')); + $connection3 = $this->createConnectionWithParams(['persistent' => '1']); $this->assertPersistentConnection($connection3); - $connection4 = $this->createConnectionWithParams(array('persistent' => 'true')); + $connection4 = $this->createConnectionWithParams(['persistent' => 'true']); $this->assertPersistentConnection($connection4); $connection1->disconnect(); @@ -126,8 +126,8 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentConnectionsToSameNodeShareResource(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => true)); - $connection2 = $this->createConnectionWithParams(array('persistent' => true)); + $connection1 = $this->createConnectionWithParams(['persistent' => true]); + $connection2 = $this->createConnectionWithParams(['persistent' => true]); $this->assertPersistentConnection($connection1); $this->assertPersistentConnection($connection2); @@ -143,8 +143,8 @@ class CompositeStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentConnectionsToSameNodeDoNotShareResourceUsingDifferentPersistentID(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 'conn1')); - $connection2 = $this->createConnectionWithParams(array('persistent' => 'conn2')); + $connection1 = $this->createConnectionWithParams(['persistent' => 'conn1']); + $connection2 = $this->createConnectionWithParams(['persistent' => 'conn2']); $this->assertPersistentConnection($connection1); $this->assertPersistentConnection($connection2); diff --git a/tests/Predis/Connection/FactoryTest.php b/tests/Predis/Connection/FactoryTest.php index 3be52020..a3ed02d4 100644 --- a/tests/Predis/Connection/FactoryTest.php +++ b/tests/Predis/Connection/FactoryTest.php @@ -38,15 +38,15 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $factory->setDefaultParameters($defaults = array( + $factory->setDefaultParameters($defaults = [ 'password' => 'secret', 'database' => 10, 'custom' => 'foobar', - )); + ]); $this->assertSame($defaults, $factory->getDefaultParameters()); - $parameters = array('database' => 10, 'persistent' => true); + $parameters = ['database' => 10, 'persistent' => true]; } /** @@ -56,13 +56,13 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $parameters = new Parameters(array('scheme' => 'tcp')); + $parameters = new Parameters(['scheme' => 'tcp']); $connection = $factory->create($parameters); $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); $this->assertSame($parameters, $connection->getParameters()); - $parameters = new Parameters(array('scheme' => 'redis')); + $parameters = new Parameters(['scheme' => 'redis']); $connection = $factory->create($parameters); $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); @@ -76,13 +76,13 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $parameters = new Parameters(array('scheme' => 'tls')); + $parameters = new Parameters(['scheme' => 'tls']); $connection = $factory->create($parameters); $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); $this->assertSame($parameters, $connection->getParameters()); - $parameters = new Parameters(array('scheme' => 'rediss')); + $parameters = new Parameters(['scheme' => 'rediss']); $connection = $factory->create($parameters); $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); @@ -96,7 +96,7 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $parameters = new Parameters(array('scheme' => 'unix', 'path' => '/tmp/redis.sock')); + $parameters = new Parameters(['scheme' => 'unix', 'path' => '/tmp/redis.sock']); $connection = $factory->create($parameters); $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); @@ -110,17 +110,17 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $factory->setDefaultParameters($defaultParams = array( + $factory->setDefaultParameters($defaultParams = [ 'port' => 7000, 'password' => 'secret', 'database' => 10, 'custom' => 'foobar', - )); + ]); - $inputParams = new Parameters(array( + $inputParams = new Parameters([ 'host' => 'localhost', 'database' => 5, - )); + ]); $connection = $factory->create($inputParams); $parameters = $connection->getParameters(); @@ -159,11 +159,11 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $factory->setDefaultParameters($defaultParams = array( + $factory->setDefaultParameters($defaultParams = [ 'port' => 7000, 'password' => 'secret', 'custom' => 'foobar', - )); + ]); $connection = $factory->create(null); $parameters = $connection->getParameters(); @@ -183,7 +183,7 @@ class FactoryTest extends PredisTestCase public function testCreateConnectionWithArrayParameters(): void { $factory = new Factory(); - $connection = $factory->create(array('scheme' => 'tcp', 'custom' => 'foobar')); + $connection = $factory->create(['scheme' => 'tcp', 'custom' => 'foobar']); $parameters = $connection->getParameters(); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); @@ -200,17 +200,17 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $factory->setDefaultParameters($defaultParams = array( + $factory->setDefaultParameters($defaultParams = [ 'port' => 7000, 'password' => 'secret', 'custom' => 'foobar', - )); + ]); - $connection = $factory->create($inputParams = array( + $connection = $factory->create($inputParams = [ 'host' => 'localhost', 'port' => 8000, 'persistent' => true, - )); + ]); $parameters = $connection->getParameters(); @@ -247,11 +247,11 @@ class FactoryTest extends PredisTestCase { $factory = new Factory(); - $factory->setDefaultParameters($defaultParams = array( + $factory->setDefaultParameters($defaultParams = [ 'port' => 7000, 'password' => 'secret', 'custom' => 'foobar', - )); + ]); $connection = $factory->create('tcp://localhost:8000?persistent=1'); $parameters = $connection->getParameters(); @@ -276,7 +276,7 @@ class FactoryTest extends PredisTestCase ->expects($this->never()) ->method('addConnectCommand'); - $parameters = new Parameters(array('scheme' => 'test')); + $parameters = new Parameters(['scheme' => 'test']); $factory = new Factory(); $factory->define('test', function ($_parameters, $_factory) use ($connection, $parameters, $factory) { @@ -294,10 +294,10 @@ class FactoryTest extends PredisTestCase */ public function testCreateConnectionWithInitializationCommands(): void { - $parameters = new Parameters(array( + $parameters = new Parameters([ 'database' => '0', 'password' => 'foobar', - )); + ]); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -308,8 +308,8 @@ class FactoryTest extends PredisTestCase ->expects($this->exactly(2)) ->method('addConnectCommand') ->withConsecutive( - array($this->isRedisCommand('AUTH', array('foobar'))), - array($this->isRedisCommand('SELECT', array('0'))) + [$this->isRedisCommand('AUTH', ['foobar'])], + [$this->isRedisCommand('SELECT', ['0'])] ); $factory = new Factory(); @@ -326,9 +326,9 @@ class FactoryTest extends PredisTestCase */ public function testCreateConnectionWithPasswordAndNoUsernameAddsInitializationCommandAuthWithOneArgument() { - $parameters = new Parameters(array( + $parameters = new Parameters([ 'password' => 'foobar', - )); + ]); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection->expects($this->once()) @@ -336,7 +336,7 @@ class FactoryTest extends PredisTestCase ->will($this->returnValue($parameters)); $connection->expects($this->once(1)) ->method('addConnectCommand') - ->with($this->isRedisCommand('AUTH', array('foobar'))); + ->with($this->isRedisCommand('AUTH', ['foobar'])); $factory = new Factory(); @@ -352,10 +352,10 @@ class FactoryTest extends PredisTestCase */ public function testCreateConnectionWithPasswordAndUsernameAddsInitializationCommandAuthWithTwoArguments() { - $parameters = new Parameters(array( + $parameters = new Parameters([ 'username' => 'myusername', 'password' => 'foobar', - )); + ]); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection->expects($this->once()) @@ -363,7 +363,7 @@ class FactoryTest extends PredisTestCase ->will($this->returnValue($parameters)); $connection->expects($this->once(1)) ->method('addConnectCommand') - ->with($this->isRedisCommand('AUTH', array('myusername', 'foobar'))); + ->with($this->isRedisCommand('AUTH', ['myusername', 'foobar'])); $factory = new Factory(); @@ -379,9 +379,9 @@ class FactoryTest extends PredisTestCase */ public function testCreateConnectionWithUsernameAndNoPasswordDoesNotAddInitializationCommands() { - $parameters = new Parameters(array( + $parameters = new Parameters([ 'username' => 'myusername', - )); + ]); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection->expects($this->once()) @@ -405,9 +405,9 @@ class FactoryTest extends PredisTestCase */ public function testCreateConnectionWithEmptyParametersDoesNotAddInitializationCommands($parameter, $value) { - $parameters = new Parameters(array( + $parameters = new Parameters([ $parameter => $value, - )); + ]); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection->expects($this->once()) @@ -434,7 +434,7 @@ class FactoryTest extends PredisTestCase $this->expectExceptionMessage("Unknown connection scheme: 'unknown'"); $factory = new Factory(); - $factory->create(new Parameters(array('scheme' => 'unknown'))); + $factory->create(new Parameters(['scheme' => 'unknown'])); } /** @@ -444,7 +444,7 @@ class FactoryTest extends PredisTestCase { list(, $connectionClass) = $this->getMockConnectionClass(); - $parameters = new Parameters(array('scheme' => 'foobar')); + $parameters = new Parameters(['scheme' => 'foobar']); $factory = new Factory(); $factory->define($parameters->scheme, $connectionClass); @@ -460,7 +460,7 @@ class FactoryTest extends PredisTestCase { list(, $connectionClass) = $this->getMockConnectionClass(); - $parameters = new Parameters(array('scheme' => 'foobar')); + $parameters = new Parameters(['scheme' => 'foobar']); $factory = new Factory(); $initializer = function ($parameters) use ($connectionClass) { @@ -468,7 +468,7 @@ class FactoryTest extends PredisTestCase }; $initializerMock = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $initializerMock ->expects($this->exactly(2)) @@ -554,7 +554,7 @@ class FactoryTest extends PredisTestCase { $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); - return array($connection, get_class($connection)); + return [$connection, get_class($connection)]; } /** @@ -568,16 +568,16 @@ class FactoryTest extends PredisTestCase */ public function provideEmptyParametersForInitializationCommands() { - return array( + return [ // AUTH - array('username', ''), - array('username', null), - array('password', ''), - array('password', null), + ['username', ''], + ['username', null], + ['password', ''], + ['password', null], // SELECT - array('database', ''), - array('database', null), - ); + ['database', ''], + ['database', null], + ]; } } diff --git a/tests/Predis/Connection/ParametersTest.php b/tests/Predis/Connection/ParametersTest.php index a688c987..eaeef2ba 100644 --- a/tests/Predis/Connection/ParametersTest.php +++ b/tests/Predis/Connection/ParametersTest.php @@ -69,12 +69,12 @@ class ParametersTest extends PredisTestCase */ public function testConstructWithArrayParameters(): void { - $parameters = new Parameters(array( + $parameters = new Parameters([ 'port' => 7000, 'custom' => 'foobar', 'setnull' => null, 'setemptystring' => '', - )); + ]); $this->sharedTestsWithArrayParameters($parameters); } @@ -84,12 +84,12 @@ class ParametersTest extends PredisTestCase */ public function testCreateWithArrayParameters(): void { - $parameters = new Parameters(array( + $parameters = new Parameters([ 'port' => 7000, 'custom' => 'foobar', 'setnull' => null, 'setemptystring' => '', - )); + ]); $this->sharedTestsWithArrayParameters($parameters); } @@ -99,13 +99,13 @@ class ParametersTest extends PredisTestCase */ public function testCreateWithUriString(): void { - $overrides = array( + $overrides = [ 'port' => 7000, 'database' => 5, 'custom' => 'foobar', 'setnull' => null, 'setemptystring' => '', - ); + ]; $uriString = $this->getParametersString($overrides); $parameters = Parameters::create($uriString); @@ -119,7 +119,7 @@ class ParametersTest extends PredisTestCase */ public function testToArray(): void { - $additional = array('port' => 7000, 'custom' => 'foobar'); + $additional = ['port' => 7000, 'custom' => 'foobar']; $parameters = new Parameters($additional); $this->assertEquals($this->getParametersArray($additional), $parameters->toArray()); @@ -130,7 +130,7 @@ class ParametersTest extends PredisTestCase */ public function testSerialization(): void { - $parameters = new Parameters(array('port' => 7000, 'custom' => 'foobar')); + $parameters = new Parameters(['port' => 7000, 'custom' => 'foobar']); $unserialized = unserialize(serialize($parameters)); $this->assertEquals($parameters->scheme, $unserialized->scheme); @@ -150,7 +150,7 @@ class ParametersTest extends PredisTestCase { $uri = 'tcp://10.10.10.10:6400?timeout=0.5&persistent=1&database=5&password=secret'; - $expected = array( + $expected = [ 'scheme' => 'tcp', 'host' => '10.10.10.10', 'port' => 6400, @@ -158,7 +158,7 @@ class ParametersTest extends PredisTestCase 'persistent' => '1', 'database' => '5', 'password' => 'secret', - ); + ]; $this->assertSame($expected, Parameters::parse($uri)); } @@ -170,7 +170,7 @@ class ParametersTest extends PredisTestCase { $uri = 'redis://predis:secret@10.10.10.10:6400/5?timeout=0.5&persistent=1'; - $expected = array( + $expected = [ 'scheme' => 'redis', 'host' => '10.10.10.10', 'port' => 6400, @@ -179,7 +179,7 @@ class ParametersTest extends PredisTestCase 'username' => 'predis', 'password' => 'secret', 'database' => '5', - ); + ]; $parameters = Parameters::parse($uri); @@ -225,12 +225,12 @@ class ParametersTest extends PredisTestCase { $uri = 'redis://10.10.10.10/5/rest/of/path'; - $expected = array( + $expected = [ 'scheme' => 'redis', 'host' => '10.10.10.10', 'path' => '/rest/of/path', 'database' => '5', - ); + ]; $parameters = Parameters::parse($uri); @@ -244,12 +244,12 @@ class ParametersTest extends PredisTestCase { $uri = 'unix:///tmp/redis.sock?timeout=0.5&persistent=1'; - $expected = array( + $expected = [ 'scheme' => 'unix', 'path' => '/tmp/redis.sock', 'timeout' => '0.5', 'persistent' => '1', - ); + ]; $this->assertSame($expected, Parameters::parse($uri)); } @@ -261,12 +261,12 @@ class ParametersTest extends PredisTestCase { $uri = 'unix:/tmp/redis.sock?timeout=0.5&persistent=1'; - $expected = array( + $expected = [ 'scheme' => 'unix', 'path' => '/tmp/redis.sock', 'timeout' => '0.5', 'persistent' => '1', - ); + ]; $this->assertSame($expected, Parameters::parse($uri)); } @@ -278,13 +278,13 @@ class ParametersTest extends PredisTestCase { $uri = 'tcp://10.10.10.10?persistent=1&foo=&bar'; - $expected = array( + $expected = [ 'scheme' => 'tcp', 'host' => '10.10.10.10', 'persistent' => '1', 'foo' => '', 'bar' => '', - ); + ]; $this->assertSame($expected, Parameters::parse($uri)); } @@ -296,12 +296,12 @@ class ParametersTest extends PredisTestCase { $uri = 'tcp://10.10.10.10?foobar=a=b=c&persistent=1'; - $expected = array( + $expected = [ 'scheme' => 'tcp', 'host' => '10.10.10.10', 'foobar' => 'a=b=c', 'persistent' => '1', - ); + ]; $this->assertSame($expected, Parameters::parse($uri)); } @@ -313,12 +313,12 @@ class ParametersTest extends PredisTestCase { $uri = 'tcp://10.10.10.10?persistent=1&metavars[]=foo&metavars[]=hoge'; - $expected = array( + $expected = [ 'scheme' => 'tcp', 'host' => '10.10.10.10', 'persistent' => '1', - 'metavars' => array('foo', 'hoge'), - ); + 'metavars' => ['foo', 'hoge'], + ]; $this->assertSame($expected, Parameters::parse($uri)); } @@ -328,10 +328,10 @@ class ParametersTest extends PredisTestCase */ public function testParsingURIWithEmbeddedIPV6AddressShouldStripBracketsFromHost(): void { - $expected = array('scheme' => 'tcp', 'host' => '::1', 'port' => 7000); + $expected = ['scheme' => 'tcp', 'host' => '::1', 'port' => 7000]; $this->assertSame($expected, Parameters::parse('tcp://[::1]:7000')); - $expected = array('scheme' => 'tcp', 'host' => '2001:db8:0:f101::1', 'port' => 7000); + $expected = ['scheme' => 'tcp', 'host' => '2001:db8:0:f101::1', 'port' => 7000]; $this->assertSame($expected, Parameters::parse('tcp://[2001:db8:0:f101::1]:7000')); } @@ -400,11 +400,11 @@ class ParametersTest extends PredisTestCase */ protected function getDefaultParametersArray(): array { - return array( + return [ 'scheme' => 'tcp', 'host' => '127.0.0.1', 'port' => 6379, - ); + ]; } /** diff --git a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php index 04dee579..062e6df5 100644 --- a/tests/Predis/Connection/PhpiredisSocketConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisSocketConnectionTest.php @@ -38,7 +38,7 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Invalid scheme: 'tls'"); - $connection = $this->createConnectionWithParams(array('scheme' => 'tls')); + $connection = $this->createConnectionWithParams(['scheme' => 'tls']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -51,7 +51,7 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Invalid scheme: 'rediss'"); - $connection = $this->createConnectionWithParams(array('scheme' => 'rediss')); + $connection = $this->createConnectionWithParams(['scheme' => 'rediss']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -69,8 +69,8 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase /** @var NodeConnectionInterface|MockObject */ $connection = $this ->getMockBuilder($this->getConnectionClass()) - ->onlyMethods(array('executeCommand', 'createResource')) - ->setConstructorArgs(array(new Parameters())) + ->onlyMethods(['executeCommand', 'createResource']) + ->setConstructorArgs([new Parameters()]) ->getMock(); $connection ->method('executeCommand') @@ -97,7 +97,7 @@ class PhpiredisSocketConnectionTest extends PredisConnectionTestCase $this->expectException('Predis\Connection\ConnectionException'); $this->expectExceptionMessage("Cannot resolve the address of 'bogus.tld'"); - $connection = $this->createConnectionWithParams(array('host' => 'bogus.tld')); + $connection = $this->createConnectionWithParams(['host' => 'bogus.tld']); $connection->connect(); } diff --git a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php index 868c7944..0e36816e 100644 --- a/tests/Predis/Connection/PhpiredisStreamConnectionTest.php +++ b/tests/Predis/Connection/PhpiredisStreamConnectionTest.php @@ -38,7 +38,7 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('SSL encryption is not supported by this connection backend'); - $connection = $this->createConnectionWithParams(array('scheme' => 'tls')); + $connection = $this->createConnectionWithParams(['scheme' => 'tls']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -51,7 +51,7 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage('SSL encryption is not supported by this connection backend'); - $connection = $this->createConnectionWithParams(array('scheme' => 'rediss')); + $connection = $this->createConnectionWithParams(['scheme' => 'rediss']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -69,8 +69,8 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase /** @var NodeConnectionInterface|MockObject */ $connection = $this ->getMockBuilder($this->getConnectionClass()) - ->onlyMethods(array('executeCommand', 'createResource')) - ->setConstructorArgs(array(new Parameters())) + ->onlyMethods(['executeCommand', 'createResource']) + ->setConstructorArgs([new Parameters()]) ->getMock(); $connection ->method('executeCommand') @@ -98,12 +98,12 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase { $this->expectException('Predis\Connection\ConnectionException'); - $connection = $this->createConnectionWithParams(array( + $connection = $this->createConnectionWithParams([ 'read_write_timeout' => 0.5, - ), true); + ], true); $connection->executeCommand( - $this->getCommandFactory()->create('brpop', array('foo', 3)) + $this->getCommandFactory()->create('brpop', ['foo', 3]) ); } @@ -130,16 +130,16 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentParameterWithFalseLikeValues(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 0)); + $connection1 = $this->createConnectionWithParams(['persistent' => 0]); $this->assertNonPersistentConnection($connection1); - $connection2 = $this->createConnectionWithParams(array('persistent' => false)); + $connection2 = $this->createConnectionWithParams(['persistent' => false]); $this->assertNonPersistentConnection($connection2); - $connection3 = $this->createConnectionWithParams(array('persistent' => '0')); + $connection3 = $this->createConnectionWithParams(['persistent' => '0']); $this->assertNonPersistentConnection($connection3); - $connection4 = $this->createConnectionWithParams(array('persistent' => 'false')); + $connection4 = $this->createConnectionWithParams(['persistent' => 'false']); $this->assertNonPersistentConnection($connection4); } @@ -149,16 +149,16 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentParameterWithTrueLikeValues(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 1)); + $connection1 = $this->createConnectionWithParams(['persistent' => 1]); $this->assertPersistentConnection($connection1); - $connection2 = $this->createConnectionWithParams(array('persistent' => true)); + $connection2 = $this->createConnectionWithParams(['persistent' => true]); $this->assertPersistentConnection($connection2); - $connection3 = $this->createConnectionWithParams(array('persistent' => '1')); + $connection3 = $this->createConnectionWithParams(['persistent' => '1']); $this->assertPersistentConnection($connection3); - $connection4 = $this->createConnectionWithParams(array('persistent' => 'true')); + $connection4 = $this->createConnectionWithParams(['persistent' => 'true']); $this->assertPersistentConnection($connection4); $connection1->disconnect(); @@ -170,8 +170,8 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentConnectionsToSameNodeShareResource(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => true)); - $connection2 = $this->createConnectionWithParams(array('persistent' => true)); + $connection1 = $this->createConnectionWithParams(['persistent' => true]); + $connection2 = $this->createConnectionWithParams(['persistent' => true]); $this->assertPersistentConnection($connection1); $this->assertPersistentConnection($connection2); @@ -187,8 +187,8 @@ class PhpiredisStreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentConnectionsToSameNodeDoNotShareResourceUsingDifferentPersistentID(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 'conn1')); - $connection2 = $this->createConnectionWithParams(array('persistent' => 'conn2')); + $connection1 = $this->createConnectionWithParams(['persistent' => 'conn1']); + $connection2 = $this->createConnectionWithParams(['persistent' => 'conn2']); $this->assertPersistentConnection($connection1); $this->assertPersistentConnection($connection2); diff --git a/tests/Predis/Connection/Replication/MasterSlaveReplicationTest.php b/tests/Predis/Connection/Replication/MasterSlaveReplicationTest.php index 7150152b..19e50a63 100644 --- a/tests/Predis/Connection/Replication/MasterSlaveReplicationTest.php +++ b/tests/Predis/Connection/Replication/MasterSlaveReplicationTest.php @@ -43,7 +43,7 @@ class MasterSlaveReplicationTest extends PredisTestCase $this->assertSame($slave2, $replication->getConnectionById('127.0.0.1:6381')); $this->assertSame($master, $replication->getMaster()); - $this->assertSame(array($slave1, $slave2), $replication->getSlaves()); + $this->assertSame([$slave1, $slave2], $replication->getSlaves()); } /** @@ -58,7 +58,7 @@ class MasterSlaveReplicationTest extends PredisTestCase $replication->add($slave1); $replication->add($slave2); - $this->assertSame(array($slave1, $slave2), $replication->getSlaves()); + $this->assertSame([$slave1, $slave2], $replication->getSlaves()); } /** @@ -78,7 +78,7 @@ class MasterSlaveReplicationTest extends PredisTestCase $this->assertFalse($replication->remove($slave2)); $this->assertSame($master, $replication->getMaster()); - $this->assertSame(array(), $replication->getSlaves()); + $this->assertSame([], $replication->getSlaves()); } /** @@ -453,10 +453,10 @@ class MasterSlaveReplicationTest extends PredisTestCase $replication->add($master); $replication->add($slave1); - $cmd = $commands->create('exists', array('foo')); + $cmd = $commands->create('exists', ['foo']); $this->assertSame($slave1, $replication->getConnectionByCommand($cmd)); - $cmd = $commands->create('get', array('foo')); + $cmd = $commands->create('get', ['foo']); $this->assertSame($slave1, $replication->getConnectionByCommand($cmd)); } @@ -475,10 +475,10 @@ class MasterSlaveReplicationTest extends PredisTestCase $replication->add($master); $replication->add($slave1); - $cmd = $commands->create('set', array('foo', 'bar')); + $cmd = $commands->create('set', ['foo', 'bar']); $this->assertSame($master, $replication->getConnectionByCommand($cmd)); - $cmd = $commands->create('get', array('foo')); + $cmd = $commands->create('get', ['foo']); $this->assertSame($master, $replication->getConnectionByCommand($cmd)); } @@ -495,10 +495,10 @@ class MasterSlaveReplicationTest extends PredisTestCase $replication->add($master); - $cmd = $commands->create('exists', array('foo')); + $cmd = $commands->create('exists', ['foo']); $this->assertSame($master, $replication->getConnectionByCommand($cmd)); - $cmd = $commands->create('set', array('foo', 'bar')); + $cmd = $commands->create('set', ['foo', 'bar']); $this->assertSame($master, $replication->getConnectionByCommand($cmd)); } @@ -517,13 +517,13 @@ class MasterSlaveReplicationTest extends PredisTestCase $replication->add($master); $replication->add($slave1); - $cmd = $commands->create('exists', array('foo')); + $cmd = $commands->create('exists', ['foo']); $this->assertSame($slave1, $replication->getConnectionByCommand($cmd)); - $cmd = $commands->create('set', array('foo', 'bar')); + $cmd = $commands->create('set', ['foo', 'bar']); $this->assertSame($master, $replication->getConnectionByCommand($cmd)); - $cmd = $commands->create('exists', array('foo')); + $cmd = $commands->create('exists', ['foo']); $this->assertSame($master, $replication->getConnectionByCommand($cmd)); } @@ -533,8 +533,8 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testWritesCommandToCorrectConnection(): void { $commands = $this->getCommandFactory(); - $cmdExists = $commands->create('exists', array('foo')); - $cmdSet = $commands->create('set', array('foo', 'bar')); + $cmdExists = $commands->create('exists', ['foo']); + $cmdSet = $commands->create('set', ['foo', 'bar']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -562,8 +562,8 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testReadsCommandFromCorrectConnection(): void { $commands = $this->getCommandFactory(); - $cmdExists = $commands->create('exists', array('foo')); - $cmdSet = $commands->create('set', array('foo', 'bar')); + $cmdExists = $commands->create('exists', ['foo']); + $cmdSet = $commands->create('set', ['foo', 'bar']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -592,8 +592,8 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testExecutesCommandOnCorrectConnection(): void { $commands = $this->getCommandFactory(); - $cmdExists = $commands->create('exists', array('foo')); - $cmdSet = $commands->create('set', array('foo', 'bar')); + $cmdExists = $commands->create('exists', ['foo']); + $cmdSet = $commands->create('set', ['foo', 'bar']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -622,7 +622,7 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testWatchTriggersSwitchToMasterConnection(): void { $commands = $this->getCommandFactory(); - $cmdWatch = $commands->create('watch', array('foo')); + $cmdWatch = $commands->create('watch', ['foo']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -676,7 +676,7 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testEvalTriggersSwitchToMasterConnection(): void { $commands = $this->getCommandFactory(); - $cmdEval = $commands->create('eval', array("return redis.call('info')")); + $cmdEval = $commands->create('eval', ["return redis.call('info')"]); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -703,7 +703,7 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testDiscardsUnreachableSlaveAndExecutesReadOnlyCommandOnNextSlave(): void { $commands = $this->getCommandFactory(); - $cmdExists = $commands->create('exists', array('key')); + $cmdExists = $commands->create('exists', ['key']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -747,7 +747,7 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testDiscardsUnreachableSlavesAndExecutesReadOnlyCommandOnMaster(): void { $commands = $this->getCommandFactory(); - $cmdExists = $commands->create('exists', array('key')); + $cmdExists = $commands->create('exists', ['key']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -793,7 +793,7 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testSucceedOnReadOnlyCommandAndNoConnectionSetAsMaster(): void { $commands = $this->getCommandFactory(); - $cmdExists = $commands->create('exists', array('key')); + $cmdExists = $commands->create('exists', ['key']); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6379?role=slave'); $slave1 @@ -820,7 +820,7 @@ class MasterSlaveReplicationTest extends PredisTestCase $this->expectExceptionMessage('No master server available for replication'); $commands = $this->getCommandFactory(); - $cmdSet = $commands->create('set', array('key', 'value')); + $cmdSet = $commands->create('set', ['key', 'value']); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6379?role=slave'); $slave1 @@ -848,7 +848,7 @@ class MasterSlaveReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'EXISTS', array('key') + 'EXISTS', ['key'] )) ->willReturn( new Response\Error('LOADING') @@ -859,7 +859,7 @@ class MasterSlaveReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'EXISTS', array('key') + 'EXISTS', ['key'] )) ->willReturn(1); @@ -888,7 +888,7 @@ class MasterSlaveReplicationTest extends PredisTestCase $this->expectException('Predis\Connection\ConnectionException'); $commands = $this->getCommandFactory(); - $cmdSet = $commands->create('set', array('key', 'value')); + $cmdSet = $commands->create('set', ['key', 'value']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -936,8 +936,8 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testCanOverrideReadOnlyFlagForCommands(): void { $commands = $this->getCommandFactory(); - $cmdSet = $commands->create('set', array('foo', 'bar')); - $cmdGet = $commands->create('get', array('foo')); + $cmdSet = $commands->create('set', ['foo', 'bar']); + $cmdGet = $commands->create('get', ['foo']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -969,8 +969,8 @@ class MasterSlaveReplicationTest extends PredisTestCase public function testAcceptsCallableToOverrideReadOnlyFlagForCommands(): void { $commands = $this->getCommandFactory(); - $cmdExistsFoo = $commands->create('exists', array('foo')); - $cmdExistsBar = $commands->create('exists', array('bar')); + $cmdExistsFoo = $commands->create('exists', ['foo']); + $cmdExistsBar = $commands->create('exists', ['bar']); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -1008,8 +1008,8 @@ class MasterSlaveReplicationTest extends PredisTestCase { $commands = $this->getCommandFactory(); - $cmdEval = $commands->create('eval', array($script = "return redis.call('info');")); - $cmdEvalSha = $commands->create('evalsha', array($scriptSHA1 = sha1($script))); + $cmdEval = $commands->create('eval', [$script = "return redis.call('info');"]); + $cmdEvalSha = $commands->create('evalsha', [$scriptSHA1 = sha1($script)]); $master = $this->getMockConnection('tcp://127.0.0.1:6379?role=master'); $master @@ -1021,8 +1021,8 @@ class MasterSlaveReplicationTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand($cmdEval)), - array($this->isRedisCommand($cmdEvalSha)) + [$this->isRedisCommand($cmdEval)], + [$this->isRedisCommand($cmdEvalSha)] ); $replication = new MasterSlaveReplication(); @@ -1115,31 +1115,31 @@ repl_backlog_histlen:12978 ->method('create') ->withConsecutive( # Connection to master node - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6381', 'role' => 'master', - ) - ), + ] + ], # Connection to first slave - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6382', 'role' => 'slave', - ) - ), + ] + ], # Connection to second slave - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6383', 'role' => 'slave', - ) - ) + ] + ] ) ->willReturnOnConsecutiveCalls( $master, @@ -1223,31 +1223,31 @@ repl_backlog_histlen:12978 ->method('create') ->withConsecutive( # Connection to master node - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6381', 'role' => 'master', - ) - ), + ] + ], # Connection to first slave - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6382', 'role' => 'slave', - ) - ), + ] + ], # Connection to second slave - array( - array( + [ + [ 'host' => '127.0.0.1', 'port' => '6383', 'role' => 'slave', - ) - ) + ] + ] ) ->willReturnOnConsecutiveCalls( $master, @@ -1359,11 +1359,11 @@ repl_backlog_histlen:12978 $connFactory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6382', 'role' => 'slave', - )) + ]) ->willReturn($slave1); $slaveKO diff --git a/tests/Predis/Connection/Replication/SentinelReplicationTest.php b/tests/Predis/Connection/Replication/SentinelReplicationTest.php index 333c7f13..40f47ce0 100644 --- a/tests/Predis/Connection/Replication/SentinelReplicationTest.php +++ b/tests/Predis/Connection/Replication/SentinelReplicationTest.php @@ -32,7 +32,7 @@ class SentinelReplicationTest extends PredisTestCase $this->expectException('Predis\ClientException'); $this->expectExceptionMessage('No sentinel server available for autodiscovery.'); - $replication = $this->getReplicationConnection('svc', array()); + $replication = $this->getReplicationConnection('svc', []); $replication->getSentinelConnection(); } @@ -41,9 +41,9 @@ class SentinelReplicationTest extends PredisTestCase */ public function testParametersForSentinelConnectionShouldUsePasswordForAuthentication(): void { - $replication = $this->getReplicationConnection('svc', array( + $replication = $this->getReplicationConnection('svc', [ 'tcp://127.0.0.1:5381?alias=sentinel1&password=secret', - )); + ]); $parameters = $replication->getSentinelConnection()->getParameters()->toArray(); @@ -55,9 +55,9 @@ class SentinelReplicationTest extends PredisTestCase */ public function testParametersForSentinelConnectionShouldIgnoreDatabaseAndPassword(): void { - $replication = $this->getReplicationConnection('svc', array( + $replication = $this->getReplicationConnection('svc', [ 'tcp://127.0.0.1:5381?role=sentinel&database=1&username=myusername', - )); + ]); $parameters = $replication->getSentinelConnection()->getParameters()->toArray(); @@ -71,9 +71,9 @@ class SentinelReplicationTest extends PredisTestCase */ public function testParametersForSentinelConnectionHaveDefaultTimeout(): void { - $replication = $this->getReplicationConnection('svc', array( + $replication = $this->getReplicationConnection('svc', [ 'tcp://127.0.0.1:5381?role=sentinel', - )); + ]); $parameters = $replication->getSentinelConnection()->getParameters()->toArray(); @@ -86,9 +86,9 @@ class SentinelReplicationTest extends PredisTestCase */ public function testParametersForSentinelConnectionCanOverrideDefaultTimeout(): void { - $replication = $this->getReplicationConnection('svc', array( + $replication = $this->getReplicationConnection('svc', [ 'tcp://127.0.0.1:5381?role=sentinel&timeout=1', - )); + ]); $parameters = $replication ->getSentinelConnection() @@ -108,7 +108,7 @@ class SentinelReplicationTest extends PredisTestCase 'tcp://127.0.0.1:5381?role=sentinel&database=1&password=secret' ); - $replication = $this->getReplicationConnection('svc', array($originalParameters)); + $replication = $this->getReplicationConnection('svc', [$originalParameters]); $parameters = $replication ->getSentinelConnection() @@ -127,8 +127,8 @@ class SentinelReplicationTest extends PredisTestCase $sentinel1 = Connection\Parameters::create('tcp://127.0.0.1:5381?role=sentinel&database=1&password='); $sentinel2 = Connection\Parameters::create('tcp://127.0.0.1:5381?role=sentinel&database=1'); - $replication1 = $this->getReplicationConnection('svc', array($sentinel1)); - $replication2 = $this->getReplicationConnection('svc', array($sentinel2)); + $replication1 = $this->getReplicationConnection('svc', [$sentinel1]); + $replication2 = $this->getReplicationConnection('svc', [$sentinel2]); $parameters1 = $replication1->getSentinelConnection()->getParameters(); $parameters2 = $replication2->getSentinelConnection()->getParameters(); @@ -152,7 +152,7 @@ class SentinelReplicationTest extends PredisTestCase $sentinel2 = $this->getMockSentinelConnection('tcp://127.0.0.1:5382?role=sentinel&alias=sentinel2'); $sentinel3 = $this->getMockSentinelConnection('tcp://127.0.0.1:5383?role=sentinel&alias=sentinel3'); - $replication = $this->getReplicationConnection('svc', array($sentinel1, $sentinel2, $sentinel3)); + $replication = $this->getReplicationConnection('svc', [$sentinel1, $sentinel2, $sentinel3]); $this->assertSame($sentinel1, $replication->getSentinelConnection()); } @@ -168,7 +168,7 @@ class SentinelReplicationTest extends PredisTestCase $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); $slave2 = $this->getMockConnection('tcp://127.0.0.1:6383?role=slave'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -179,7 +179,7 @@ class SentinelReplicationTest extends PredisTestCase $this->assertSame($slave2, $replication->getConnectionById('127.0.0.1:6383')); $this->assertSame($master, $replication->getMaster()); - $this->assertSame(array($slave1, $slave2), $replication->getSlaves()); + $this->assertSame([$slave1, $slave2], $replication->getSlaves()); } /** @@ -194,7 +194,7 @@ class SentinelReplicationTest extends PredisTestCase $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); $slave2 = $this->getMockConnection('tcp://127.0.0.1:6383?role=slave'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -213,7 +213,7 @@ class SentinelReplicationTest extends PredisTestCase */ public function testMethodGetConnectionByIdOnEmptyReplication(): void { - $replication = $this->getReplicationConnection('svc', array()); + $replication = $this->getReplicationConnection('svc', []); $this->assertNull($replication->getConnectionById('127.0.0.1:6381')); } @@ -227,7 +227,7 @@ class SentinelReplicationTest extends PredisTestCase $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); - $replication = $this->getReplicationConnection('svc', array()); + $replication = $this->getReplicationConnection('svc', []); $replication->add($master); $replication->add($slave1); @@ -248,16 +248,16 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SENTINEL', array('get-master-addr-by-name', 'svc'))), - array($this->isRedisCommand('SENTINEL', array('slaves', 'svc'))) + [$this->isRedisCommand('SENTINEL', ['get-master-addr-by-name', 'svc'])], + [$this->isRedisCommand('SENTINEL', ['slaves', 'svc'])] ) ->willReturnOnConsecutiveCalls( // SENTINEL get-master-addr-by-name svc - array('127.0.0.1', '6381'), + ['127.0.0.1', '6381'], // SENTINEL slaves svc - array( - array( + [ + [ 'name', '127.0.0.1:6382', 'ip', '127.0.0.1', 'port', '6382', @@ -265,11 +265,11 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - ) + ], + ] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $this->assertSame($sentinel1, $replication->getConnectionByRole('sentinel')); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $replication->getConnectionByRole('master')); @@ -285,7 +285,7 @@ class SentinelReplicationTest extends PredisTestCase $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); - $replication = $this->getReplicationConnection('svc', array()); + $replication = $this->getReplicationConnection('svc', []); $replication->add($master); $replication->add($slave1); @@ -304,39 +304,39 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('sentinels', 'svc') + 'SENTINEL', ['sentinels', 'svc'] )) ->willReturn( - array( - array( + [ + [ 'name', '127.0.0.1:5382', 'ip', '127.0.0.1', 'port', '5382', 'runid', 'a113aa7a0d4870a85bb22b4b605fd26eb93ed40e', 'flags', 'sentinel', - ), - array( + ], + [ 'name', '127.0.0.1:5383', 'ip', '127.0.0.1', 'port', '5383', 'runid', 'f53b52d281be5cdd4873700c94846af8dbe47209', 'flags', 'sentinel', - ), - ) + ], + ] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->updateSentinels(); // TODO: sorry for the smell... $reflection = new \ReflectionProperty($replication, 'sentinels'); $reflection->setAccessible(true); - $expected = array( - array('host' => '127.0.0.1', 'port' => '5381'), - array('host' => '127.0.0.1', 'port' => '5382'), - array('host' => '127.0.0.1', 'port' => '5383'), - ); + $expected = [ + ['host' => '127.0.0.1', 'port' => '5381'], + ['host' => '127.0.0.1', 'port' => '5382'], + ['host' => '127.0.0.1', 'port' => '5383'], + ]; $this->assertSame($sentinel1, $replication->getSentinelConnection()); $this->assertSame($expected, array_intersect_key($expected, $reflection->getValue($replication))); @@ -352,7 +352,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('sentinels', 'svc') + 'SENTINEL', ['sentinels', 'svc'] )) ->willThrowException( new Connection\ConnectionException($sentinel1, 'Unknown connection error [127.0.0.1:5381]') @@ -363,31 +363,31 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('sentinels', 'svc') + 'SENTINEL', ['sentinels', 'svc'] )) ->willReturn( - array( - array( + [ + [ 'name', '127.0.0.1:5383', 'ip', '127.0.0.1', 'port', '5383', 'runid', 'f53b52d281be5cdd4873700c94846af8dbe47209', 'flags', 'sentinel', - ), - ) + ], + ] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1, $sentinel2)); + $replication = $this->getReplicationConnection('svc', [$sentinel1, $sentinel2]); $replication->updateSentinels(); // TODO: sorry for the smell... $reflection = new \ReflectionProperty($replication, 'sentinels'); $reflection->setAccessible(true); - $expected = array( - array('host' => '127.0.0.1', 'port' => '5382'), - array('host' => '127.0.0.1', 'port' => '5383'), - ); + $expected = [ + ['host' => '127.0.0.1', 'port' => '5382'], + ['host' => '127.0.0.1', 'port' => '5383'], + ]; $this->assertSame($sentinel2, $replication->getSentinelConnection()); $this->assertSame($expected, array_intersect_key($expected, $reflection->getValue($replication))); @@ -406,13 +406,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('sentinels', 'svc') + 'SENTINEL', ['sentinels', 'svc'] )) ->willThrowException( new Connection\ConnectionException($sentinel1, 'Unknown connection error [127.0.0.1:5381]') ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->updateSentinels(); } @@ -426,28 +426,28 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->exactly(3)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SENTINEL', array('sentinels', 'svc'))), - array($this->isRedisCommand('SENTINEL', array('get-master-addr-by-name', 'svc'))), - array($this->isRedisCommand('SENTINEL', array('slaves', 'svc'))) + [$this->isRedisCommand('SENTINEL', ['sentinels', 'svc'])], + [$this->isRedisCommand('SENTINEL', ['get-master-addr-by-name', 'svc'])], + [$this->isRedisCommand('SENTINEL', ['slaves', 'svc'])] ) ->willReturnOnConsecutiveCalls( // SENTINEL sentinels svc - array( - array( + [ + [ 'name', '127.0.0.1:5382', 'ip', '127.0.0.1', 'port', '5382', 'runid', 'a113aa7a0d4870a85bb22b4b605fd26eb93ed40e', 'flags', 'sentinel', - ), - ), + ], + ], // SENTINEL get-master-addr-by-name svc - array('127.0.0.1', '6381'), + ['127.0.0.1', '6381'], // SENTINEL slaves svc - array( - array( + [ + [ 'name', '127.0.0.1:6382', 'ip', '127.0.0.1', 'port', '6382', @@ -455,8 +455,8 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - array( + ], + [ 'name', '127.0.0.1:6383', 'ip', '127.0.0.1', 'port', '6383', @@ -464,8 +464,8 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - ) + ], + ] ); $sentinel2 = $this->getMockSentinelConnection('tcp://127.0.0.1:5382?role=sentinel&alias=sentinel2'); @@ -474,17 +474,17 @@ class SentinelReplicationTest extends PredisTestCase $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); $slave2 = $this->getMockConnection('tcp://127.0.0.1:6383?role=slave'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->querySentinel(); // TODO: sorry for the smell... $reflection = new \ReflectionProperty($replication, 'sentinels'); $reflection->setAccessible(true); - $sentinels = array( - array('host' => '127.0.0.1', 'port' => '5381'), - array('host' => '127.0.0.1', 'port' => '5382'), - ); + $sentinels = [ + ['host' => '127.0.0.1', 'port' => '5381'], + ['host' => '127.0.0.1', 'port' => '5382'], + ]; $this->assertSame($sentinel1, $replication->getSentinelConnection()); $this->assertSame($sentinels, array_intersect_key($sentinels, $reflection->getValue($replication))); @@ -509,13 +509,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SENTINEL', array('get-master-addr-by-name', 'svc'))) + [$this->isRedisCommand('SENTINEL', ['get-master-addr-by-name', 'svc'])] ) ->willReturnOnConsecutiveCalls( - array('127.0.0.1', '6381') + ['127.0.0.1', '6381'] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $this->assertSame('127.0.0.1:6381', (string) $replication->getMaster()); } @@ -533,13 +533,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('get-master-addr-by-name', 'svc') + 'SENTINEL', ['get-master-addr-by-name', 'svc'] )) ->willThrowException( new Connection\ConnectionException($sentinel1, 'Unknown connection error [127.0.0.1:5381]') ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->getMaster(); } @@ -554,11 +554,11 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SENTINEL', array('slaves', 'svc'))) + [$this->isRedisCommand('SENTINEL', ['slaves', 'svc'])] ) ->willReturnOnConsecutiveCalls( - array( - array( + [ + [ 'name', '127.0.0.1:6382', 'ip', '127.0.0.1', 'port', '6382', @@ -566,8 +566,8 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - array( + ], + [ 'name', '127.0.0.1:6383', 'ip', '127.0.0.1', 'port', '6383', @@ -575,11 +575,11 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - ) + ], + ] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $slaves = $replication->getSlaves(); @@ -600,13 +600,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('slaves', 'svc') + 'SENTINEL', ['slaves', 'svc'] )) ->willThrowException( new Connection\ConnectionException($sentinel1, 'Unknown connection error [127.0.0.1:5381]') ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->getSlaves(); } @@ -619,7 +619,7 @@ class SentinelReplicationTest extends PredisTestCase $this->expectException('Predis\ClientException'); $this->expectExceptionMessage('No sentinel server available for autodiscovery.'); - $replication = $this->getReplicationConnection('svc', array()); + $replication = $this->getReplicationConnection('svc', []); $replication->connect(); } @@ -640,7 +640,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('connect'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -658,11 +658,11 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('slaves', 'svc') + 'SENTINEL', ['slaves', 'svc'] )) ->willReturn( - array( - array( + [ + [ 'name', '127.0.0.1:6382', 'ip', '127.0.0.1', 'port', '6382', @@ -670,8 +670,8 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - ) + ], + ] ); $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); @@ -689,14 +689,14 @@ class SentinelReplicationTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6382', 'role' => 'slave', - )) + ]) ->willReturn($slave1); - $replication = $this->getReplicationConnection('svc', array($sentinel1), $factory); + $replication = $this->getReplicationConnection('svc', [$sentinel1], $factory); $replication->add($master); @@ -713,12 +713,12 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SENTINEL', array('slaves', 'svc'))), - array($this->isRedisCommand('SENTINEL', array('get-master-addr-by-name', 'svc'))) + [$this->isRedisCommand('SENTINEL', ['slaves', 'svc'])], + [$this->isRedisCommand('SENTINEL', ['get-master-addr-by-name', 'svc'])] ) ->willReturnOnConsecutiveCalls( - array(), - array('127.0.0.1', '6381') + [], + ['127.0.0.1', '6381'] ); $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); @@ -731,14 +731,14 @@ class SentinelReplicationTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6381', 'role' => 'master', - )) + ]) ->willReturn($master); - $replication = $this->getReplicationConnection('svc', array($sentinel1), $factory); + $replication = $this->getReplicationConnection('svc', [$sentinel1], $factory); $replication->connect(); } @@ -768,7 +768,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('disconnect'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -790,7 +790,7 @@ class SentinelReplicationTest extends PredisTestCase ->method('isConnected') ->willReturnOnConsecutiveCalls(true, false); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($slave1); @@ -811,7 +811,7 @@ class SentinelReplicationTest extends PredisTestCase $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -843,7 +843,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('connect'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -870,7 +870,7 @@ class SentinelReplicationTest extends PredisTestCase $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); $slave2 = $this->getMockConnection('tcp://127.0.0.1:6383?role=slave'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -895,7 +895,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->never()) ->method('connect'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -922,7 +922,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('connect'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -948,15 +948,15 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ROLE')) + [$this->isRedisCommand('ROLE')] ) ->willReturnOnConsecutiveCalls( - array('master', 3129659, array(array('127.0.0.1', 6382, 3129242))) + ['master', 3129659, [['127.0.0.1', 6382, 3129242]]] ); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -988,13 +988,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ROLE')) + [$this->isRedisCommand('ROLE')] ) ->willReturnOnConsecutiveCalls( - array('slave', '127.0.0.1', 9000, 'connected', 3167038) + ['slave', '127.0.0.1', 9000, 'connected', 3167038] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -1024,10 +1024,10 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ROLE')) + [$this->isRedisCommand('ROLE')] ) ->willReturnOnConsecutiveCalls( - array('master', 3129659, array(array('127.0.0.1', 6382, 3129242))) + ['master', 3129659, [['127.0.0.1', 6382, 3129242]]] ); $slave1 = $this->getMockConnection('tcp://127.0.0.1:6382?role=slave'); @@ -1039,13 +1039,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ROLE')) + [$this->isRedisCommand('ROLE')] ) ->willReturnOnConsecutiveCalls( - array('slave', '127.0.0.1', 9000, 'connected', 3167038) + ['slave', '127.0.0.1', 9000, 'connected', 3167038] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -1082,13 +1082,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ROLE')) + [$this->isRedisCommand('ROLE')] ) ->willReturnOnConsecutiveCalls( - array('slave', '127.0.0.1', 9000, 'connected', 3167038) + ['slave', '127.0.0.1', 9000, 'connected', 3167038] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); @@ -1105,11 +1105,11 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SENTINEL', array('slaves', 'svc'))) + [$this->isRedisCommand('SENTINEL', ['slaves', 'svc'])] ) ->willReturnOnConsecutiveCalls( - array( - array( + [ + [ 'name', '127.0.0.1:6382', 'ip', '127.0.0.1', 'port', '6382', @@ -1117,8 +1117,8 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave,s_down,disconnected', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - ) + ], + ] ); $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); @@ -1130,13 +1130,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('ROLE')) + [$this->isRedisCommand('ROLE')] ) ->willReturnOnConsecutiveCalls( - array('master', '0', array()) + ['master', '0', []] ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); @@ -1165,7 +1165,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('SET', array('key', $cmdGetResponse))) + [$this->isRedisCommand('SET', ['key', $cmdGetResponse])] ) ->willReturnOnConsecutiveCalls( $cmdSetResponse @@ -1180,13 +1180,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('GET', array('key'))) + [$this->isRedisCommand('GET', ['key'])] ) ->willReturnOnConsecutiveCalls( $cmdGetResponse ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); $replication->add($slave1); @@ -1205,11 +1205,11 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('slaves', 'svc') + 'SENTINEL', ['slaves', 'svc'] )) ->willReturn( - array( - array( + [ + [ 'name', '127.0.0.1:6383', 'ip', '127.0.0.1', 'port', '6383', @@ -1217,8 +1217,8 @@ class SentinelReplicationTest extends PredisTestCase 'flags', 'slave', 'master-host', '127.0.0.1', 'master-port', '6381', - ), - ) + ], + ] ); $master = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); @@ -1236,7 +1236,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with( - $this->isRedisCommand('GET', array('key')) + $this->isRedisCommand('GET', ['key']) ) ->willThrowException( new Connection\ConnectionException($slave1, 'Unknown connection error [127.0.0.1:6382]') @@ -1251,7 +1251,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('GET', array('key'))) + [$this->isRedisCommand('GET', ['key'])] ) ->willReturnOnConsecutiveCalls( 'value' @@ -1262,14 +1262,14 @@ class SentinelReplicationTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6383', 'role' => 'slave', - )) + ]) ->willReturn($slave2); - $replication = $this->getReplicationConnection('svc', array($sentinel1), $factory); + $replication = $this->getReplicationConnection('svc', [$sentinel1], $factory); $replication->add($master); $replication->add($slave1); @@ -1289,10 +1289,10 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('get-master-addr-by-name', 'svc') + 'SENTINEL', ['get-master-addr-by-name', 'svc'] )) ->willReturn( - array('127.0.0.1', '6391') + ['127.0.0.1', '6391'] ); $masterOld = $this->getMockConnection('tcp://127.0.0.1:6381?role=master'); @@ -1304,7 +1304,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with( - $this->isRedisCommand('DEL', array('key')) + $this->isRedisCommand('DEL', ['key']) ) ->willThrowException( new Connection\ConnectionException($masterOld, 'Unknown connection error [127.0.0.1:6381]') @@ -1319,7 +1319,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('DEL', array('key'))) + [$this->isRedisCommand('DEL', ['key'])] ) ->willReturnOnConsecutiveCalls( 1 @@ -1330,14 +1330,14 @@ class SentinelReplicationTest extends PredisTestCase $factory ->expects($this->once()) ->method('create') - ->with(array( + ->with([ 'host' => '127.0.0.1', 'port' => '6391', 'role' => 'master', - )) + ]) ->willReturn($masterNew); - $replication = $this->getReplicationConnection('svc', array($sentinel1), $factory); + $replication = $this->getReplicationConnection('svc', [$sentinel1], $factory); $replication->add($masterOld); @@ -1359,7 +1359,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('get-master-addr-by-name', 'svc') + 'SENTINEL', ['get-master-addr-by-name', 'svc'] )) ->willReturn(null); @@ -1372,13 +1372,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with( - $this->isRedisCommand('DEL', array('key')) + $this->isRedisCommand('DEL', ['key']) ) ->willThrowException( new Connection\ConnectionException($masterOld, 'Unknown connection error [127.0.0.1:6381]') ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($masterOld); @@ -1400,7 +1400,7 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->any()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('get-master-addr-by-name', 'svc') + 'SENTINEL', ['get-master-addr-by-name', 'svc'] )) ->willThrowException( new Connection\ConnectionException($sentinel1, 'Unknown connection error [127.0.0.1:5381]') @@ -1415,13 +1415,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with( - $this->isRedisCommand('DEL', array('key')) + $this->isRedisCommand('DEL', ['key']) ) ->willThrowException( new Connection\ConnectionException($master, 'Unknown connection error [127.0.0.1:6381]') ); - $replication = $this->getReplicationConnection('svc', array($sentinel1)); + $replication = $this->getReplicationConnection('svc', [$sentinel1]); $replication->add($master); @@ -1439,7 +1439,7 @@ class SentinelReplicationTest extends PredisTestCase $factory = new Connection\Factory(); $replication = new SentinelReplication( - 'svc', array('tcp://127.0.0.1:5381?role=sentinel'), $factory, $strategy + 'svc', ['tcp://127.0.0.1:5381?role=sentinel'], $factory, $strategy ); $this->assertSame($strategy, $replication->getReplicationStrategy()); @@ -1459,7 +1459,7 @@ class SentinelReplicationTest extends PredisTestCase $strategy = new Replication\ReplicationStrategy(); $factory = new Connection\Factory(); - $replication = new SentinelReplication('svc', array($sentinel1), $factory, $strategy); + $replication = new SentinelReplication('svc', [$sentinel1], $factory, $strategy); $replication->add($master); $replication->add($slave1); @@ -1483,19 +1483,19 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('sentinels', 'svc') + 'SENTINEL', ['sentinels', 'svc'] )) ->willReturnOnConsecutiveCalls( $this->throwException(new Connection\ConnectionException($sentinel1, 'Unknown connection error [127.0.0.1:5381]')), - array( - array( + [ + [ 'name', '127.0.0.1:5382', 'ip', '127.0.0.1', 'port', '5382', 'runid', 'f53b52d281be5cdd4873700c94846af8dbe47209', 'flags', 'sentinel', - ) - ) + ] + ] ); $sentinel2 = $this->getMockSentinelConnection('tcp://127.0.0.1:5382?role=sentinel&alias=sentinel2'); @@ -1503,13 +1503,13 @@ class SentinelReplicationTest extends PredisTestCase ->expects($this->once()) ->method('executeCommand') ->with($this->isRedisCommand( - 'SENTINEL', array('sentinels', 'svc') + 'SENTINEL', ['sentinels', 'svc'] )) ->willThrowException( new Connection\ConnectionException($sentinel2, 'Unknown connection error [127.0.0.1:5382]') ); - $replication = $this->getReplicationConnection('svc', array($sentinel1, $sentinel2)); + $replication = $this->getReplicationConnection('svc', [$sentinel1, $sentinel2]); try { $replication->updateSentinels(); } catch (\Predis\ClientException $exception){ diff --git a/tests/Predis/Connection/StreamConnectionTest.php b/tests/Predis/Connection/StreamConnectionTest.php index 79206c78..a40363bc 100644 --- a/tests/Predis/Connection/StreamConnectionTest.php +++ b/tests/Predis/Connection/StreamConnectionTest.php @@ -42,8 +42,8 @@ class StreamConnectionTest extends PredisConnectionTestCase /** @var NodeConnectionInterface|MockObject */ $connection = $this ->getMockBuilder($this->getConnectionClass()) - ->onlyMethods(array('executeCommand', 'createResource')) - ->setConstructorArgs(array(new Parameters())) + ->onlyMethods(['executeCommand', 'createResource']) + ->setConstructorArgs([new Parameters()]) ->getMock(); $connection ->method('executeCommand') @@ -71,8 +71,8 @@ class StreamConnectionTest extends PredisConnectionTestCase /** @var NodeConnectionInterface|MockObject */ $connection = $this ->getMockBuilder($this->getConnectionClass()) - ->onlyMethods(array('getResource')) - ->setConstructorArgs(array(new Parameters())) + ->onlyMethods(['getResource']) + ->setConstructorArgs([new Parameters()]) ->getMock(); $connection ->method('getResource') @@ -91,16 +91,16 @@ class StreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentParameterWithFalseLikeValues(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 0)); + $connection1 = $this->createConnectionWithParams(['persistent' => 0]); $this->assertNonPersistentConnection($connection1); - $connection2 = $this->createConnectionWithParams(array('persistent' => false)); + $connection2 = $this->createConnectionWithParams(['persistent' => false]); $this->assertNonPersistentConnection($connection2); - $connection3 = $this->createConnectionWithParams(array('persistent' => '0')); + $connection3 = $this->createConnectionWithParams(['persistent' => '0']); $this->assertNonPersistentConnection($connection3); - $connection4 = $this->createConnectionWithParams(array('persistent' => 'false')); + $connection4 = $this->createConnectionWithParams(['persistent' => 'false']); $this->assertNonPersistentConnection($connection4); } @@ -110,16 +110,16 @@ class StreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentParameterWithTrueLikeValues(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 1)); + $connection1 = $this->createConnectionWithParams(['persistent' => 1]); $this->assertPersistentConnection($connection1); - $connection2 = $this->createConnectionWithParams(array('persistent' => true)); + $connection2 = $this->createConnectionWithParams(['persistent' => true]); $this->assertPersistentConnection($connection2); - $connection3 = $this->createConnectionWithParams(array('persistent' => '1')); + $connection3 = $this->createConnectionWithParams(['persistent' => '1']); $this->assertPersistentConnection($connection3); - $connection4 = $this->createConnectionWithParams(array('persistent' => 'true')); + $connection4 = $this->createConnectionWithParams(['persistent' => 'true']); $this->assertPersistentConnection($connection4); $connection1->disconnect(); @@ -131,8 +131,8 @@ class StreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentConnectionsToSameNodeShareResource(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => true)); - $connection2 = $this->createConnectionWithParams(array('persistent' => true)); + $connection1 = $this->createConnectionWithParams(['persistent' => true]); + $connection2 = $this->createConnectionWithParams(['persistent' => true]); $this->assertPersistentConnection($connection1); $this->assertPersistentConnection($connection2); @@ -148,8 +148,8 @@ class StreamConnectionTest extends PredisConnectionTestCase */ public function testPersistentConnectionsToSameNodeDoNotShareResourceUsingDifferentPersistentID(): void { - $connection1 = $this->createConnectionWithParams(array('persistent' => 'conn1')); - $connection2 = $this->createConnectionWithParams(array('persistent' => 'conn2')); + $connection1 = $this->createConnectionWithParams(['persistent' => 'conn1']); + $connection2 = $this->createConnectionWithParams(['persistent' => 'conn2']); $this->assertPersistentConnection($connection1); $this->assertPersistentConnection($connection2); diff --git a/tests/Predis/Connection/WebdisConnectionTest.php b/tests/Predis/Connection/WebdisConnectionTest.php index 35fb495e..e0d6797e 100644 --- a/tests/Predis/Connection/WebdisConnectionTest.php +++ b/tests/Predis/Connection/WebdisConnectionTest.php @@ -39,7 +39,7 @@ class WebdisConnectionTest extends PredisTestCase */ public function testSupportsSchemeUnix(): void { - $connection = $this->createConnectionWithParams(array('scheme' => 'http')); + $connection = $this->createConnectionWithParams(['scheme' => 'http']); $this->assertInstanceOf('Predis\Connection\NodeConnectionInterface', $connection); } @@ -52,7 +52,7 @@ class WebdisConnectionTest extends PredisTestCase $this->expectException('InvalidArgumentException'); $this->expectExceptionMessage("Invalid scheme: 'tcp'"); - $connection = $this->createConnectionWithParams(array('scheme' => 'tcp')); + $connection = $this->createConnectionWithParams(['scheme' => 'tcp']); } /** @@ -112,7 +112,7 @@ class WebdisConnectionTest extends PredisTestCase $this->expectExceptionMessage("Command 'SELECT' is not allowed by Webdis"); $connection = $this->createConnection(); - $connection->executeCommand($this->getCommandFactory()->create('select', array(0))); + $connection->executeCommand($this->getCommandFactory()->create('select', [0])); } /** @@ -124,7 +124,7 @@ class WebdisConnectionTest extends PredisTestCase $this->expectExceptionMessage("Command 'AUTH' is not allowed by Webdis"); $connection = $this->createConnection(); - $connection->executeCommand($this->getCommandFactory()->create('auth', array('foobar'))); + $connection->executeCommand($this->getCommandFactory()->create('auth', ['foobar'])); } /** @@ -132,10 +132,10 @@ class WebdisConnectionTest extends PredisTestCase */ public function testCanBeSerialized(): void { - $parameters = $this->getParameters(array( + $parameters = $this->getParameters([ 'alias' => 'redis', 'read_write_timeout' => 10, - )); + ]); $connection = $this->createConnectionWithParams($parameters); @@ -157,10 +157,10 @@ class WebdisConnectionTest extends PredisTestCase $commands = $this->getCommandFactory(); $cmdPing = $commands->create('ping'); - $cmdEcho = $commands->create('echo', array('echoed')); - $cmdGet = $commands->create('get', array('foobar')); - $cmdRpush = $commands->create('rpush', array('metavars', 'foo', 'hoge', 'lol')); - $cmdLrange = $commands->create('lrange', array('metavars', 0, -1)); + $cmdEcho = $commands->create('echo', ['echoed']); + $cmdGet = $commands->create('get', ['foobar']); + $cmdRpush = $commands->create('rpush', ['metavars', 'foo', 'hoge', 'lol']); + $cmdLrange = $commands->create('lrange', ['metavars', 0, -1]); $connection = $this->createConnection(true); @@ -168,7 +168,7 @@ class WebdisConnectionTest extends PredisTestCase $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); $this->assertNull($connection->executeCommand($cmdGet)); $this->assertSame(3, $connection->executeCommand($cmdRpush)); - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); + $this->assertSame(['foo', 'hoge', 'lol'], $connection->executeCommand($cmdLrange)); } /** @@ -180,7 +180,7 @@ class WebdisConnectionTest extends PredisTestCase { $this->expectException('Predis\Connection\ConnectionException'); - $connection = $this->createConnectionWithParams(array('host' => '169.254.10.10')); + $connection = $this->createConnectionWithParams(['host' => '169.254.10.10']); $connection->executeCommand($this->getCommandFactory()->create('ping')); } @@ -195,11 +195,11 @@ class WebdisConnectionTest extends PredisTestCase */ protected function getDefaultParametersArray(): array { - return array( + return [ 'scheme' => 'http', 'host' => constant('WEBDIS_SERVER_HOST'), 'port' => constant('WEBDIS_SERVER_PORT'), - ); + ]; } /** @@ -207,7 +207,7 @@ class WebdisConnectionTest extends PredisTestCase */ protected function createConnection(): NodeConnectionInterface { - return $this->createConnectionWithParams(array()); + return $this->createConnectionWithParams([]); } /** diff --git a/tests/Predis/Monitor/ConsumerTest.php b/tests/Predis/Monitor/ConsumerTest.php index 2239ebec..1493923b 100644 --- a/tests/Predis/Monitor/ConsumerTest.php +++ b/tests/Predis/Monitor/ConsumerTest.php @@ -36,7 +36,7 @@ class ConsumerTest extends PredisTestCase ->with('MONITOR') ->willReturn(false); - $client = new Client(null, array('commands' => $commands)); + $client = new Client(null, ['commands' => $commands]); new MonitorConsumer($client); } @@ -65,13 +65,13 @@ class ConsumerTest extends PredisTestCase /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('createCommand', 'executeCommand')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['createCommand', 'executeCommand']) + ->setConstructorArgs([$connection]) ->getMock(); $client ->expects($this->once()) ->method('createCommand') - ->with('MONITOR', array()) + ->with('MONITOR', []) ->willReturn($cmdMonitor); $client ->expects($this->once()) @@ -94,8 +94,8 @@ class ConsumerTest extends PredisTestCase /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('disconnect')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['disconnect']) + ->setConstructorArgs([$connection]) ->getMock(); $client ->expects($this->exactly(2)) @@ -115,8 +115,8 @@ class ConsumerTest extends PredisTestCase /** @var \Predis\ClientInterface */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('disconnect')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['disconnect']) + ->setConstructorArgs([$connection]) ->getMock(); $client ->expects($this->once()) @@ -186,15 +186,15 @@ class ConsumerTest extends PredisTestCase */ public function testMonitorAgainstRedisServer(): void { - $parameters = array( + $parameters = [ 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), // Prevents suite from handing on broken test 'read_write_timeout' => 2, - ); + ]; - $echoed = array(); + $echoed = []; $producer = new Client($parameters); $producer->connect(); @@ -217,7 +217,7 @@ class ConsumerTest extends PredisTestCase } } - $this->assertSame(array('message1', 'message2', 'QUIT'), $echoed); + $this->assertSame(['message1', 'message2', 'QUIT'], $echoed); $this->assertFalse($monitor->valid()); $this->assertEquals('PONG', $consumer->ping()); } diff --git a/tests/Predis/Pipeline/AtomicTest.php b/tests/Predis/Pipeline/AtomicTest.php index efb95dc9..cf44eb50 100644 --- a/tests/Predis/Pipeline/AtomicTest.php +++ b/tests/Predis/Pipeline/AtomicTest.php @@ -34,20 +34,20 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('MULTI')), - array($this->isRedisCommand('EXEC')) + [$this->isRedisCommand('MULTI')], + [$this->isRedisCommand('EXEC')] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), - array($pong, $pong, $pong) + [$pong, $pong, $pong] ); $connection ->expects($this->exactly(3)) ->method('writeRequest') ->withConsecutive( - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')) + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')] ); $connection ->expects($this->exactly(3)) @@ -64,7 +64,7 @@ class AtomicTest extends PredisTestCase $pipeline->ping(); $pipeline->ping(); - $this->assertSame(array($pong, $pong, $pong), $pipeline->execute()); + $this->assertSame([$pong, $pong, $pong], $pipeline->execute()); } /** @@ -82,8 +82,8 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('MULTI')), - array($this->isRedisCommand('EXEC')) + [$this->isRedisCommand('MULTI')], + [$this->isRedisCommand('EXEC')] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), @@ -93,9 +93,9 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(3)) ->method('writeRequest') ->withConsecutive( - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')) + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')] ); $connection ->expects($this->exactly(3)) @@ -131,8 +131,8 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('MULTI')), - array($this->isRedisCommand('DISCARD')) + [$this->isRedisCommand('MULTI')], + [$this->isRedisCommand('DISCARD')] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), @@ -142,9 +142,9 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(3)) ->method('writeRequest') ->withConsecutive( - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')) + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')] ); $connection ->expects($this->exactly(3)) @@ -177,8 +177,8 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('MULTI')), - array($this->isRedisCommand('DISCARD')) + [$this->isRedisCommand('MULTI')], + [$this->isRedisCommand('DISCARD')] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), @@ -188,8 +188,8 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(2)) ->method('writeRequest') ->withConsecutive( - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')) + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')] ); $connection ->expects($this->once()) @@ -220,20 +220,20 @@ class AtomicTest extends PredisTestCase ->expects($this->exactly(2)) ->method('executeCommand') ->withConsecutive( - array($this->isRedisCommand('MULTI')), - array($this->isRedisCommand('EXEC')) + [$this->isRedisCommand('MULTI')], + [$this->isRedisCommand('EXEC')] ) ->willReturnOnConsecutiveCalls( new Response\Status('OK'), - array($pong, $pong, $error) + [$pong, $pong, $error] ); $connection ->expects($this->exactly(3)) ->method('writeRequest') ->withConsecutive( - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')), - array($this->isRedisCommand('PING')) + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')], + [$this->isRedisCommand('PING')] ); $connection ->expects($this->exactly(3)) @@ -244,13 +244,13 @@ class AtomicTest extends PredisTestCase $queued ); - $pipeline = new Atomic(new Client($connection, array('exceptions' => false))); + $pipeline = new Atomic(new Client($connection, ['exceptions' => false])); $pipeline->ping(); $pipeline->ping(); $pipeline->ping(); - $this->assertSame(array($pong, $pong, $error), $pipeline->execute()); + $this->assertSame([$pong, $pong, $error], $pipeline->execute()); } /** diff --git a/tests/Predis/Pipeline/PipelineTest.php b/tests/Predis/Pipeline/PipelineTest.php index dc05fadf..5e1bb0d9 100644 --- a/tests/Predis/Pipeline/PipelineTest.php +++ b/tests/Predis/Pipeline/PipelineTest.php @@ -91,7 +91,7 @@ class PipelineTest extends PredisTestCase $pipeline->ping(); - $this->assertSame(array($object), $pipeline->execute()); + $this->assertSame([$object], $pipeline->execute()); } /** @@ -131,14 +131,14 @@ class PipelineTest extends PredisTestCase ->method('readResponse') ->willReturn($error); - $client = new Client($connection, array('exceptions' => false)); + $client = new Client($connection, ['exceptions' => false]); $pipeline = new Pipeline($client); $pipeline->ping(); $pipeline->ping(); - $this->assertSame(array($error, $error), $pipeline->execute()); + $this->assertSame([$error, $error], $pipeline->execute()); } /** @@ -147,7 +147,7 @@ class PipelineTest extends PredisTestCase public function testExecuteReturnsPipelineForFluentInterface(): void { $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); - $command = $this->getCommandFactory()->create('echo', array('one')); + $command = $this->getCommandFactory()->create('echo', ['one']); $pipeline = new Pipeline(new Client($connection)); @@ -171,9 +171,9 @@ class PipelineTest extends PredisTestCase $pipeline = new Pipeline(new Client($connection)); - $pipeline->executeCommand($commands->create('echo', array('one'))); - $pipeline->executeCommand($commands->create('echo', array('two'))); - $pipeline->executeCommand($commands->create('echo', array('three'))); + $pipeline->executeCommand($commands->create('echo', ['one'])); + $pipeline->executeCommand($commands->create('echo', ['two'])); + $pipeline->executeCommand($commands->create('echo', ['three'])); } /** @@ -191,7 +191,7 @@ class PipelineTest extends PredisTestCase $pipeline = new Pipeline(new Client($connection)); - $this->assertSame(array(), $pipeline->execute()); + $this->assertSame([], $pipeline->execute()); } /** @@ -216,7 +216,7 @@ class PipelineTest extends PredisTestCase $pipeline->flushPipeline(); - $this->assertSame(array('one', 'two', 'three'), $pipeline->execute()); + $this->assertSame(['one', 'two', 'three'], $pipeline->execute()); } /** @@ -232,7 +232,7 @@ class PipelineTest extends PredisTestCase $pipeline->flushPipeline(false); - $this->assertSame(array(), $pipeline->execute()); + $this->assertSame([], $pipeline->execute()); } /** @@ -257,7 +257,7 @@ class PipelineTest extends PredisTestCase $pipeline->echo('three'); $pipeline->echo('four'); - $this->assertSame(array('one', 'two', 'three', 'four'), $pipeline->execute()); + $this->assertSame(['one', 'two', 'three', 'four'], $pipeline->execute()); } /** @@ -285,7 +285,7 @@ class PipelineTest extends PredisTestCase $pipeline->ping(); $pipeline->ping(); - $this->assertSame(array($pong, $pong, $pong), $pipeline->execute()); + $this->assertSame([$pong, $pong, $pong], $pipeline->execute()); } /** @@ -354,7 +354,7 @@ class PipelineTest extends PredisTestCase $pipe->echo('four'); }); - $this->assertSame(array('one', 'two', 'three', 'four'), $responses); + $this->assertSame(['one', 'two', 'three', 'four'], $responses); } /** @@ -407,7 +407,7 @@ class PipelineTest extends PredisTestCase ->echo('three') ->execute(); - $this->assertSame(array('one', 'two', 'three'), $results); + $this->assertSame(['one', 'two', 'three'], $results); } /** @@ -422,7 +422,7 @@ class PipelineTest extends PredisTestCase $pipe->get('foo'); }); - $this->assertEquals(array('OK', 'bar'), $results); + $this->assertEquals(['OK', 'bar'], $results); $this->assertSame(1, $client->exists('foo')); } @@ -440,7 +440,7 @@ class PipelineTest extends PredisTestCase $pipe->get('foo'); }); - $this->assertEquals(array('OK', 'bar'), $results); + $this->assertEquals(['OK', 'bar'], $results); $this->assertSame('oob message', $oob); $this->assertSame(1, $client->exists('foo')); } @@ -499,7 +499,7 @@ class PipelineTest extends PredisTestCase */ public function testIntegrationWithServerErrorInCallableBlock(): void { - $client = $this->getClient(array(), array('exceptions' => false)); + $client = $this->getClient([], ['exceptions' => false]); $results = $client->pipeline(function (Pipeline $pipe) { $pipe->set('foo', 'bar'); @@ -524,7 +524,7 @@ class PipelineTest extends PredisTestCase * * @return ClientInterface */ - protected function getClient(array $parameters = array(), array $options = array()): ClientInterface + protected function getClient(array $parameters = [], array $options = []): ClientInterface { return $this->createClient($parameters, $options); } diff --git a/tests/Predis/PredisExceptionTest.php b/tests/Predis/PredisExceptionTest.php index 03293f8f..80abf4e4 100644 --- a/tests/Predis/PredisExceptionTest.php +++ b/tests/Predis/PredisExceptionTest.php @@ -25,7 +25,7 @@ class PredisExceptionTest extends PredisTestCase public function testExceptionMessage(): void { $message = 'Predis exception message'; - $exception = $this->getMockForAbstractClass('Predis\PredisException', array($message)); + $exception = $this->getMockForAbstractClass('Predis\PredisException', [$message]); $this->expectException('Predis\PredisException'); $this->expectExceptionMessage($message); diff --git a/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php b/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php index f3a5d82d..bb1873ae 100644 --- a/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php +++ b/tests/Predis/Protocol/Text/Handler/MultiBulkResponseTest.php @@ -48,7 +48,7 @@ class MultiBulkResponseTest extends PredisTestCase $handler = new Handler\MultiBulkResponse(); - $this->assertSame(array('foo', 'bar'), $handler->handle($connection, '2')); + $this->assertSame(['foo', 'bar'], $handler->handle($connection, '2')); } /** diff --git a/tests/Predis/Protocol/Text/ProtocolProcessorTest.php b/tests/Predis/Protocol/Text/ProtocolProcessorTest.php index f187ed05..bfc0d528 100644 --- a/tests/Predis/Protocol/Text/ProtocolProcessorTest.php +++ b/tests/Predis/Protocol/Text/ProtocolProcessorTest.php @@ -38,7 +38,7 @@ class ProtocolProcessorTest extends PredisTestCase $command ->expects($this->once()) ->method('getArguments') - ->willReturn(array()); + ->willReturn([]); $connection = $this->getMockConnectionOfType('Predis\Connection\CompositeConnectionInterface'); $connection diff --git a/tests/Predis/Protocol/Text/RequestSerializerTest.php b/tests/Predis/Protocol/Text/RequestSerializerTest.php index e67dc0f7..d9f4614e 100644 --- a/tests/Predis/Protocol/Text/RequestSerializerTest.php +++ b/tests/Predis/Protocol/Text/RequestSerializerTest.php @@ -37,7 +37,7 @@ class RequestSerializerTest extends PredisTestCase $command ->expects($this->once()) ->method('getArguments') - ->willReturn(array()); + ->willReturn([]); $result = $serializer->serialize($command); @@ -60,7 +60,7 @@ class RequestSerializerTest extends PredisTestCase $command ->expects($this->once()) ->method('getArguments') - ->willReturn(array('key', 'value')); + ->willReturn(['key', 'value']); $result = $serializer->serialize($command); @@ -83,7 +83,7 @@ class RequestSerializerTest extends PredisTestCase $command ->expects($this->once()) ->method('getArguments') - ->willReturn(array(0 => 'key:1', 2 => 'key:2')); + ->willReturn([0 => 'key:1', 2 => 'key:2']); $result = $serializer->serialize($command); diff --git a/tests/Predis/PubSub/ConsumerTest.php b/tests/Predis/PubSub/ConsumerTest.php index 3726aa62..2787cafa 100644 --- a/tests/Predis/PubSub/ConsumerTest.php +++ b/tests/Predis/PubSub/ConsumerTest.php @@ -35,7 +35,7 @@ class ConsumerTest extends PredisTestCase ->method('supports') ->willReturn(false); - $client = new Client(null, array('commands' => $commands)); + $client = new Client(null, ['commands' => $commands]); new PubSubConsumer($client); } @@ -63,8 +63,8 @@ class ConsumerTest extends PredisTestCase /** @var Client */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('executeCommand')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['executeCommand']) + ->setConstructorArgs([$connection]) ->getMock(); $client->expects($this->never()) @@ -85,9 +85,9 @@ class ConsumerTest extends PredisTestCase /** @var Client */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('createCommand')) - ->addMethods(array('writeRequest')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['createCommand']) + ->addMethods(['writeRequest']) + ->setConstructorArgs([$connection]) ->getMock(); $client ->expects($this->exactly(2)) @@ -97,7 +97,7 @@ class ConsumerTest extends PredisTestCase return $commands->create($id, $args); }); - $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); + $options = ['subscribe' => 'channel:foo', 'psubscribe' => 'channels:*']; new PubSubConsumer($client, $options); } @@ -111,14 +111,14 @@ class ConsumerTest extends PredisTestCase /** @var Client */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('disconnect')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['disconnect']) + ->setConstructorArgs([$connection]) ->getMock(); $client ->expects($this->once()) ->method('disconnect'); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $connection->expects($this->never())->method('writeRequest'); @@ -138,11 +138,11 @@ class ConsumerTest extends PredisTestCase /** @var Client */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('disconnect')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['disconnect']) + ->setConstructorArgs([$connection]) ->getMock(); - $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); + $options = ['subscribe' => 'channel:foo', 'psubscribe' => 'channels:*']; $pubsub = new PubSubConsumer($client, $options); $connection @@ -165,8 +165,8 @@ class ConsumerTest extends PredisTestCase /** @var Client */ $client = $this->getMockBuilder('Predis\Client') - ->onlyMethods(array('disconnect')) - ->setConstructorArgs(array($connection)) + ->onlyMethods(['disconnect']) + ->setConstructorArgs([$connection]) ->getMock(); $pubsub = new PubSubConsumer($client); @@ -180,7 +180,7 @@ class ConsumerTest extends PredisTestCase */ public function testHandlesPongMessages(): void { - $rawmessage = array('pong', ''); + $rawmessage = ['pong', '']; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -189,7 +189,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $message = $pubsub->current(); $this->assertSame('pong', $message->kind); @@ -201,7 +201,7 @@ class ConsumerTest extends PredisTestCase */ public function testHandlesPongMessagesWithPayload(): void { - $rawmessage = array('pong', 'foobar'); + $rawmessage = ['pong', 'foobar']; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -210,7 +210,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $message = $pubsub->current(); $this->assertSame('pong', $message->kind); @@ -222,7 +222,7 @@ class ConsumerTest extends PredisTestCase */ public function testReadsMessageFromConnection(): void { - $rawmessage = array('message', 'channel:foo', 'message from channel'); + $rawmessage = ['message', 'channel:foo', 'message from channel']; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -231,7 +231,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $message = $pubsub->current(); $this->assertSame('message', $message->kind); @@ -244,7 +244,7 @@ class ConsumerTest extends PredisTestCase */ public function testReadsPmessageFromConnection(): void { - $rawmessage = array('pmessage', 'channel:*', 'channel:foo', 'message from channel'); + $rawmessage = ['pmessage', 'channel:*', 'channel:foo', 'message from channel']; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -253,7 +253,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('psubscribe' => 'channel:*')); + $pubsub = new PubSubConsumer($client, ['psubscribe' => 'channel:*']); $message = $pubsub->current(); $this->assertSame('pmessage', $message->kind); @@ -267,7 +267,7 @@ class ConsumerTest extends PredisTestCase */ public function testReadsSubscriptionMessageFromConnection(): void { - $rawmessage = array('subscribe', 'channel:foo', 1); + $rawmessage = ['subscribe', 'channel:foo', 1]; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -276,7 +276,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $message = $pubsub->current(); $this->assertSame('subscribe', $message->kind); @@ -289,7 +289,7 @@ class ConsumerTest extends PredisTestCase */ public function testReadsUnsubscriptionMessageFromConnection(): void { - $rawmessage = array('unsubscribe', 'channel:foo', 1); + $rawmessage = ['unsubscribe', 'channel:foo', 1]; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -298,7 +298,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $message = $pubsub->current(); $this->assertSame('unsubscribe', $message->kind); @@ -311,7 +311,7 @@ class ConsumerTest extends PredisTestCase */ public function testUnsubscriptionMessageWithZeroChannelCountInvalidatesConsumer(): void { - $rawmessage = array('unsubscribe', 'channel:foo', 0); + $rawmessage = ['unsubscribe', 'channel:foo', 0]; $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); $connection @@ -320,7 +320,7 @@ class ConsumerTest extends PredisTestCase ->willReturn($rawmessage); $client = new Client($connection); - $pubsub = new PubSubConsumer($client, array('subscribe' => 'channel:foo')); + $pubsub = new PubSubConsumer($client, ['subscribe' => 'channel:foo']); $this->assertTrue($pubsub->valid()); @@ -369,15 +369,15 @@ class ConsumerTest extends PredisTestCase 'Test temporarily skipped on CI environments, see note in the body of the test' // TODO ); - $parameters = array( + $parameters = [ 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), // Prevents suite from handing on broken test 'read_write_timeout' => 2, - ); + ]; - $messages = array(); + $messages = []; $producer = new Client($parameters); $producer->connect(); @@ -402,7 +402,7 @@ class ConsumerTest extends PredisTestCase } } - $this->assertSame(array('message1', 'message2', 'QUIT'), $messages); + $this->assertSame(['message1', 'message2', 'QUIT'], $messages); $this->assertFalse($pubsub->valid()); $this->assertEquals('ECHO', $consumer->echo('ECHO')); } @@ -418,12 +418,12 @@ class ConsumerTest extends PredisTestCase 'Test temporarily skipped on CI environments, see note in the body of the test' // TODO ); - $parameters = array( + $parameters = [ 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), 'read_write_timeout' => -1, // -1 to set blocking reads - ); + ]; // create consumer before forking so the child can disconnect it $consumer = new Client($parameters); @@ -435,7 +435,7 @@ class ConsumerTest extends PredisTestCase * child: producer */ if ($childPID = pcntl_fork()) { - $messages = array(); + $messages = []; $pubsub = new PubSubConsumer($consumer); $pubsub->subscribe('channel:foo'); @@ -450,7 +450,7 @@ class ConsumerTest extends PredisTestCase } } - $this->assertSame(array('message1', 'message2', 'QUIT'), $messages); + $this->assertSame(['message1', 'message2', 'QUIT'], $messages); $this->assertFalse($pubsub->valid()); $this->assertEquals('ECHO', $consumer->echo('ECHO')); @@ -458,7 +458,7 @@ class ConsumerTest extends PredisTestCase posix_kill($childPID, SIGKILL); } else { // create producer, read_write_timeout = 2 because it doesn't do blocking reads anyway - $producer = new Client(array_replace($parameters, array('read_write_timeout' => 2))); + $producer = new Client(array_replace($parameters, ['read_write_timeout' => 2])); $producer->connect(); $producer->publish('channel:foo', 'message1'); diff --git a/tests/Predis/PubSub/DispatcherLoopTest.php b/tests/Predis/PubSub/DispatcherLoopTest.php index 4fafba3c..4aa7d676 100644 --- a/tests/Predis/PubSub/DispatcherLoopTest.php +++ b/tests/Predis/PubSub/DispatcherLoopTest.php @@ -44,13 +44,13 @@ class DispatcherLoopTest extends PredisTestCase 'Test temporarily skipped on CI environments, see note in the body of the test' // TODO ); - $parameters = array( + $parameters = [ 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), // Prevents suite from hanging on broken test 'read_write_timeout' => 2, - ); + ]; $producer = new Client($parameters); $producer->connect(); @@ -62,7 +62,7 @@ class DispatcherLoopTest extends PredisTestCase $dispatcher = new DispatcherLoop($pubsub); $function01 = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $function01 ->expects($this->exactly(2)) @@ -78,7 +78,7 @@ class DispatcherLoopTest extends PredisTestCase }); $function02 = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $function02 ->expects($this->once()) @@ -86,7 +86,7 @@ class DispatcherLoopTest extends PredisTestCase ->with('02:argument'); $function03 = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $function03 ->expects($this->never()) @@ -115,27 +115,27 @@ class DispatcherLoopTest extends PredisTestCase 'Test temporarily skipped on CI environments, see note in the body of the test' // TODO ); - $parameters = array( + $parameters = [ 'host' => constant('REDIS_SERVER_HOST'), 'port' => constant('REDIS_SERVER_PORT'), 'database' => constant('REDIS_SERVER_DBNUM'), // Prevents suite from handing on broken test 'read_write_timeout' => 2, - ); + ]; $producerNonPfx = new Client($parameters); $producerNonPfx->connect(); - $producerPfx = new Client($parameters, array('prefix' => 'foobar')); + $producerPfx = new Client($parameters, ['prefix' => 'foobar']); $producerPfx->connect(); - $consumer = new Client($parameters, array('prefix' => 'foobar')); + $consumer = new Client($parameters, ['prefix' => 'foobar']); $pubsub = new Consumer($consumer); $dispatcher = new DispatcherLoop($pubsub); $callback = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $callback ->expects($this->exactly(1)) diff --git a/tests/Predis/Replication/ReplicationStrategyTest.php b/tests/Predis/Replication/ReplicationStrategyTest.php index 493fb94f..d7e65a2f 100644 --- a/tests/Predis/Replication/ReplicationStrategyTest.php +++ b/tests/Predis/Replication/ReplicationStrategyTest.php @@ -83,13 +83,13 @@ class ReplicationStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); $strategy = new ReplicationStrategy(); - $cmdReturnSort = $commands->create('SORT', array('key:list')); + $cmdReturnSort = $commands->create('SORT', ['key:list']); $this->assertFalse( $strategy->isReadOperation($cmdReturnSort), 'SORT is expected to be a write operation.' ); - $cmdStoreSort = $commands->create('SORT', array('key:list', array('store' => 'key:stored'))); + $cmdStoreSort = $commands->create('SORT', ['key:list', ['store' => 'key:stored']]); $this->assertFalse( $strategy->isReadOperation($cmdStoreSort), 'SORT with STORE is expected to be a write operation.' @@ -104,37 +104,37 @@ class ReplicationStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); $strategy = new ReplicationStrategy(); - $command = $commands->create('BITFIELD', array('key')); + $command = $commands->create('BITFIELD', ['key']); $this->assertTrue( $strategy->isReadOperation($command), 'BITFIELD with no modifiers is expected to be a read operation.' ); - $command = $commands->create('BITFIELD', array('key', 'GET', 'u4', '0')); + $command = $commands->create('BITFIELD', ['key', 'GET', 'u4', '0']); $this->assertTrue( $strategy->isReadOperation($command), 'BITFIELD with GET only is expected to be a read operation.' ); - $command = $commands->create('BITFIELD', array('key', 'SET', 'u4', '0', 1)); + $command = $commands->create('BITFIELD', ['key', 'SET', 'u4', '0', 1]); $this->assertFalse( $strategy->isReadOperation($command), 'BITFIELD with SET is expected to be a write operation.' ); - $command = $commands->create('BITFIELD', array('key', 'INCRBY', 'u4', '0', 1)); + $command = $commands->create('BITFIELD', ['key', 'INCRBY', 'u4', '0', 1]); $this->assertFalse( $strategy->isReadOperation($command), 'BITFIELD with INCRBY is expected to be a write operation.' ); - $command = $commands->create('BITFIELD', array('key', 'GET', 'u4', '0', 'INCRBY', 'u4', '0', 1)); + $command = $commands->create('BITFIELD', ['key', 'GET', 'u4', '0', 'INCRBY', 'u4', '0', 1]); $this->assertFalse( $strategy->isReadOperation($command), 'BITFIELD with GET and INCRBY is expected to be a write operation.' ); - $command = $commands->create('BITFIELD', array('key', 'GET', 'u4', '0', 'SET', 'u4', '0', 1)); + $command = $commands->create('BITFIELD', ['key', 'GET', 'u4', '0', 'SET', 'u4', '0', 1]); $this->assertFalse( $strategy->isReadOperation($command), 'BITFIELD with GET and SET is expected to be a write operation.' @@ -149,19 +149,19 @@ class ReplicationStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); $strategy = new ReplicationStrategy(); - $command = $commands->create('GEORADIUS', array('key:geo', 15, 37, 200, 'km')); + $command = $commands->create('GEORADIUS', ['key:geo', 15, 37, 200, 'km']); $this->assertTrue( $strategy->isReadOperation($command), 'GEORADIUS is expected to be a read operation.' ); - $command = $commands->create('GEORADIUS', array('key:geo', 15, 37, 200, 'km', 'store', 'key:store')); + $command = $commands->create('GEORADIUS', ['key:geo', 15, 37, 200, 'km', 'store', 'key:store']); $this->assertFalse( $strategy->isReadOperation($command), 'GEORADIUS with STORE is expected to be a write operation.' ); - $command = $commands->create('GEORADIUS', array('key:geo', 15, 37, 200, 'km', 'storedist', 'key:storedist')); + $command = $commands->create('GEORADIUS', ['key:geo', 15, 37, 200, 'km', 'storedist', 'key:storedist']); $this->assertFalse( $strategy->isReadOperation($command), 'GEORADIUS with STOREDIST is expected to be a write operation.' @@ -176,19 +176,19 @@ class ReplicationStrategyTest extends PredisTestCase $commands = $this->getCommandFactory(); $strategy = new ReplicationStrategy(); - $command = $commands->create('GEORADIUSBYMEMBER', array('key:geo', 15, 37, 200, 'km')); + $command = $commands->create('GEORADIUSBYMEMBER', ['key:geo', 15, 37, 200, 'km']); $this->assertTrue( $strategy->isReadOperation($command), 'GEORADIUSBYMEMBER is expected to be a read operation.' ); - $command = $commands->create('GEORADIUSBYMEMBER', array('key:geo', 15, 37, 200, 'km', 'store', 'key:store')); + $command = $commands->create('GEORADIUSBYMEMBER', ['key:geo', 15, 37, 200, 'km', 'store', 'key:store']); $this->assertFalse( $strategy->isReadOperation($command), 'GEORADIUSBYMEMBER with STORE is expected to be a write operation.' ); - $command = $commands->create('GEORADIUSBYMEMBER', array('key:geo', 15, 37, 200, 'km', 'storedist', 'key:storedist')); + $command = $commands->create('GEORADIUSBYMEMBER', ['key:geo', 15, 37, 200, 'km', 'storedist', 'key:storedist']); $this->assertFalse( $strategy->isReadOperation($command), 'GEORADIUSBYMEMBER with STOREDIST is expected to be a write operation.' @@ -278,10 +278,10 @@ class ReplicationStrategyTest extends PredisTestCase return $command->getArgument(1) === true; }); - $command = $commands->create('SET', array('trigger', false)); + $command = $commands->create('SET', ['trigger', false]); $this->assertFalse($strategy->isReadOperation($command)); - $command = $commands->create('SET', array('trigger', true)); + $command = $commands->create('SET', ['trigger', true]); $this->assertTrue($strategy->isReadOperation($command)); } @@ -298,13 +298,13 @@ class ReplicationStrategyTest extends PredisTestCase $strategy->setScriptReadOnly($readScript, true); - $cmdEval = $commands->create('EVAL', array($writeScript)); - $cmdEvalSHA = $commands->create('EVALSHA', array(sha1($writeScript))); + $cmdEval = $commands->create('EVAL', [$writeScript]); + $cmdEvalSHA = $commands->create('EVALSHA', [sha1($writeScript)]); $this->assertFalse($strategy->isReadOperation($cmdEval)); $this->assertFalse($strategy->isReadOperation($cmdEvalSHA)); - $cmdEval = $commands->create('EVAL', array($readScript)); - $cmdEvalSHA = $commands->create('EVALSHA', array(sha1($readScript))); + $cmdEval = $commands->create('EVAL', [$readScript]); + $cmdEvalSHA = $commands->create('EVALSHA', [sha1($readScript)]); $this->assertTrue($strategy->isReadOperation($cmdEval)); $this->assertTrue($strategy->isReadOperation($cmdEvalSHA)); } @@ -318,7 +318,7 @@ class ReplicationStrategyTest extends PredisTestCase /** @var CommandInterface|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript')) + ->onlyMethods(['getScript']) ->getMock(); $command ->expects($this->any()) @@ -329,10 +329,10 @@ class ReplicationStrategyTest extends PredisTestCase return $command->getArgument(2) === true; }); - $command->setArguments(array(false)); + $command->setArguments([false]); $this->assertFalse($strategy->isReadOperation($command)); - $command->setArguments(array(true)); + $command->setArguments([true]); $this->assertTrue($strategy->isReadOperation($command)); } @@ -345,14 +345,14 @@ class ReplicationStrategyTest extends PredisTestCase /** @var CommandInterface|MockObject */ $command = $this->getMockBuilder('Predis\Command\ScriptCommand') - ->onlyMethods(array('getScript')) - ->getMock(array('getScript')); + ->onlyMethods(['getScript']) + ->getMock(['getScript']); $command ->expects($this->any()) ->method('getScript') ->willReturn($script = 'return true'); - $command->setArguments(array('trigger', false)); + $command->setArguments(['trigger', false]); $strategy->setScriptReadOnly($script, true); @@ -372,7 +372,7 @@ class ReplicationStrategyTest extends PredisTestCase */ protected function getExpectedCommands(?string $type = null): array { - $commands = array( + $commands = [ /* commands operating on the connection */ 'AUTH' => 'read', 'SELECT' => 'read', @@ -517,7 +517,7 @@ class ReplicationStrategyTest extends PredisTestCase 'GEODIST' => 'read', 'GEORADIUS' => 'variable', 'GEORADIUSBYMEMBER' => 'variable', - ); + ]; if (isset($type)) { $commands = array_filter($commands, function (string $expectedType) use ($type) { diff --git a/tests/Predis/Response/Iterator/MultiBulkTest.php b/tests/Predis/Response/Iterator/MultiBulkTest.php index 4aaa50b6..4ce761be 100644 --- a/tests/Predis/Response/Iterator/MultiBulkTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTest.php @@ -113,7 +113,7 @@ class MultiBulkTest extends PredisTestCase */ protected function getClient(): ClientInterface { - $parameters = $this->getParameters(array('read_write_timeout' => 2)); + $parameters = $this->getParameters(['read_write_timeout' => 2]); $protocol = new TextProtocolProcessor(); $protocol->useIterableMultibulk(true); diff --git a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php index cf845af0..4af597f8 100644 --- a/tests/Predis/Response/Iterator/MultiBulkTupleTest.php +++ b/tests/Predis/Response/Iterator/MultiBulkTupleTest.php @@ -75,15 +75,15 @@ class MultiBulkTupleTest extends PredisTestCase $this->assertTrue($iterator->valid()); $this->assertSame(3, $iterator->count()); - $this->assertSame(array('foo', '1'), $iterator->current()); + $this->assertSame(['foo', '1'], $iterator->current()); $iterator->next(); $this->assertTrue($iterator->valid()); - $this->assertSame(array('hoge', '2'), $iterator->current()); + $this->assertSame(['hoge', '2'], $iterator->current()); $iterator->next(); $this->assertTrue($iterator->valid()); - $this->assertSame(array('lol', '3'), $iterator->current()); + $this->assertSame(['lol', '3'], $iterator->current()); $iterator->next(); $this->assertFalse($iterator->valid()); @@ -119,7 +119,7 @@ class MultiBulkTupleTest extends PredisTestCase */ protected function getClient(): ClientInterface { - $parameters = $this->getParameters(array('read_write_timeout' => 2)); + $parameters = $this->getParameters(['read_write_timeout' => 2]); $protocol = new TextProtocolProcessor(); $protocol->useIterableMultibulk(true); diff --git a/tests/Predis/Transaction/MultiExecTest.php b/tests/Predis/Transaction/MultiExecTest.php index b4e2ec2a..650484f6 100644 --- a/tests/Predis/Transaction/MultiExecTest.php +++ b/tests/Predis/Transaction/MultiExecTest.php @@ -41,7 +41,7 @@ class MultiExecTest extends PredisTestCase ->willReturn(false); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); - $client = new Client($connection, array('commands' => $commands)); + $client = new Client($connection, ['commands' => $commands]); new MultiExec($client); } @@ -59,8 +59,8 @@ class MultiExecTest extends PredisTestCase ->expects($this->exactly(2)) ->method('supports') ->withConsecutive( - array('MULTI', 'EXEC', 'DISCARD'), - array('WATCH') + ['MULTI', 'EXEC', 'DISCARD'], + ['WATCH'] ) ->willReturnOnConsecutiveCalls( true, @@ -68,9 +68,9 @@ class MultiExecTest extends PredisTestCase ); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); - $client = new Client($connection, array('commands' => $commands)); + $client = new Client($connection, ['commands' => $commands]); - $tx = new MultiExec($client, array('options' => 'cas')); + $tx = new MultiExec($client, ['options' => 'cas']); $tx->watch('foo'); } @@ -89,8 +89,8 @@ class MultiExecTest extends PredisTestCase ->expects($this->exactly(2)) ->method('supports') ->withConsecutive( - array('MULTI', 'EXEC', 'DISCARD'), - array('UNWATCH') + ['MULTI', 'EXEC', 'DISCARD'], + ['UNWATCH'] ) ->willReturnOnConsecutiveCalls( true, @@ -98,9 +98,9 @@ class MultiExecTest extends PredisTestCase ); $connection = $this->getMockBuilder('Predis\Connection\NodeConnectionInterface')->getMock(); - $client = new Client($connection, array('commands' => $commands)); + $client = new Client($connection, ['commands' => $commands]); - $tx = new MultiExec($client, array('options' => 'cas')); + $tx = new MultiExec($client, ['options' => 'cas']); $tx->unwatch('foo'); } @@ -110,14 +110,14 @@ class MultiExecTest extends PredisTestCase */ public function testExecutionWithFluentInterface(): void { - $commands = array(); - $expected = array('one', 'two', 'three'); + $commands = []; + $expected = ['one', 'two', 'three']; $callback = $this->getExecuteCallback($expected, $commands); $tx = $this->getMockedTransaction($callback); $this->assertSame($expected, $tx->echo('one')->echo('two')->echo('three')->execute()); - $this->assertSame(array('MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'], self::commandsToIDs($commands)); } /** @@ -125,8 +125,8 @@ class MultiExecTest extends PredisTestCase */ public function testExecutionWithCallable(): void { - $commands = array(); - $expected = array('one', 'two', 'three'); + $commands = []; + $expected = ['one', 'two', 'three']; $callback = $this->getExecuteCallback($expected, $commands); $tx = $this->getMockedTransaction($callback); @@ -138,7 +138,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertSame($expected, $responses); - $this->assertSame(array('MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'], self::commandsToIDs($commands)); } /** @@ -146,7 +146,7 @@ class MultiExecTest extends PredisTestCase */ public function testCannotMixExecutionWithFluentInterfaceAndCallable(): void { - $commands = array(); + $commands = []; $callback = $this->getExecuteCallback(null, $commands); $tx = $this->getMockedTransaction($callback); @@ -162,7 +162,7 @@ class MultiExecTest extends PredisTestCase } $this->assertInstanceOf('Predis\ClientException', $exception); - $this->assertSame(array('MULTI', 'ECHO', 'DISCARD'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'ECHO', 'DISCARD'], self::commandsToIDs($commands)); } /** @@ -170,7 +170,7 @@ class MultiExecTest extends PredisTestCase */ public function testEmptyTransactionDoesNotSendMultiExecCommands(): void { - $commands = array(); + $commands = []; $callback = $this->getExecuteCallback(null, $commands); $tx = $this->getMockedTransaction($callback); @@ -180,7 +180,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertNull($responses); - $this->assertSame(array(), self::commandsToIDs($commands)); + $this->assertSame([], self::commandsToIDs($commands)); } /** @@ -191,7 +191,7 @@ class MultiExecTest extends PredisTestCase $this->expectException('Predis\ClientException'); $this->expectExceptionMessage('Cannot invoke "execute" or "exec" inside an active transaction context'); - $commands = array(); + $commands = []; $callback = $this->getExecuteCallback(null, $commands); $tx = $this->getMockedTransaction($callback); @@ -201,7 +201,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertNull($responses); - $this->assertSame(array(), self::commandsToIDs($commands)); + $this->assertSame([], self::commandsToIDs($commands)); } /** @@ -209,7 +209,7 @@ class MultiExecTest extends PredisTestCase */ public function testEmptyTransactionIgnoresDiscard(): void { - $commands = array(); + $commands = []; $callback = $this->getExecuteCallback(null, $commands); $tx = $this->getMockedTransaction($callback); @@ -219,7 +219,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertNull($responses); - $this->assertSame(array(), self::commandsToIDs($commands)); + $this->assertSame([], self::commandsToIDs($commands)); } /** @@ -227,7 +227,7 @@ class MultiExecTest extends PredisTestCase */ public function testTransactionWithCommandsSendsDiscard(): void { - $commands = array(); + $commands = []; $callback = $this->getExecuteCallback(null, $commands); $tx = $this->getMockedTransaction($callback); @@ -239,7 +239,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertNull($responses); - $this->assertSame(array('MULTI', 'SET', 'GET', 'DISCARD'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'SET', 'GET', 'DISCARD'], self::commandsToIDs($commands)); } /** @@ -247,8 +247,8 @@ class MultiExecTest extends PredisTestCase */ public function testSendMultiOnCommandsFollowingDiscard(): void { - $commands = array(); - $expected = array('after DISCARD'); + $commands = []; + $expected = ['after DISCARD']; $callback = $this->getExecuteCallback($expected, $commands); $tx = $this->getMockedTransaction($callback); @@ -260,7 +260,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertSame($responses, $expected); - $this->assertSame(array('MULTI', 'ECHO', 'DISCARD', 'MULTI', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'ECHO', 'DISCARD', 'MULTI', 'ECHO', 'EXEC'], self::commandsToIDs($commands)); } /** * @group disconnected @@ -280,8 +280,8 @@ class MultiExecTest extends PredisTestCase */ public function testUnwatchInsideMulti(): void { - $commands = array(); - $expected = array('foobar', true); + $commands = []; + $expected = ['foobar', true]; $callback = $this->getExecuteCallback($expected, $commands); $tx = $this->getMockedTransaction($callback); @@ -289,7 +289,7 @@ class MultiExecTest extends PredisTestCase $responses = $tx->echo('foobar')->unwatch('foo')->execute(); $this->assertSame($responses, $expected); - $this->assertSame(array('MULTI', 'ECHO', 'UNWATCH', 'EXEC'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'ECHO', 'UNWATCH', 'EXEC'], self::commandsToIDs($commands)); } /** @@ -297,9 +297,9 @@ class MultiExecTest extends PredisTestCase */ public function testAutomaticWatchInOptions(): void { - $txCommands = $casCommands = array(); - $expected = array('bar', 'piyo'); - $options = array('watch' => array('foo', 'hoge')); + $txCommands = $casCommands = []; + $expected = ['bar', 'piyo']; + $options = ['watch' => ['foo', 'hoge']]; $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); $tx = $this->getMockedTransaction($callback, $options); @@ -310,18 +310,18 @@ class MultiExecTest extends PredisTestCase }); $this->assertSame($responses, $expected); - $this->assertSame(array('WATCH'), self::commandsToIDs($casCommands)); - $this->assertSame(array('foo', 'hoge'), $casCommands[0]->getArguments()); - $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + $this->assertSame(['WATCH'], self::commandsToIDs($casCommands)); + $this->assertSame(['foo', 'hoge'], $casCommands[0]->getArguments()); + $this->assertSame(['MULTI', 'GET', 'GET', 'EXEC'], self::commandsToIDs($txCommands)); } /** * @group disconnected */ public function testCheckAndSetWithFluentInterface(): void { - $txCommands = $casCommands = array(); - $expected = array('bar', 'piyo'); - $options = array('cas' => true, 'watch' => array('foo', 'hoge')); + $txCommands = $casCommands = []; + $expected = ['bar', 'piyo']; + $options = ['cas' => true, 'watch' => ['foo', 'hoge']]; $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); $tx = $this->getMockedTransaction($callback, $options); @@ -337,8 +337,8 @@ class MultiExecTest extends PredisTestCase ->execute(); $this->assertSame($responses, $expected); - $this->assertSame(array('WATCH', 'WATCH', 'GET', 'GET'), self::commandsToIDs($casCommands)); - $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + $this->assertSame(['WATCH', 'WATCH', 'GET', 'GET'], self::commandsToIDs($casCommands)); + $this->assertSame(['MULTI', 'GET', 'GET', 'EXEC'], self::commandsToIDs($txCommands)); } /** @@ -346,9 +346,9 @@ class MultiExecTest extends PredisTestCase */ public function testCheckAndSetWithBlock(): void { - $txCommands = $casCommands = array(); - $expected = array('bar', 'piyo'); - $options = array('cas' => true, 'watch' => array('foo', 'hoge')); + $txCommands = $casCommands = []; + $expected = ['bar', 'piyo']; + $options = ['cas' => true, 'watch' => ['foo', 'hoge']]; $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); $tx = $this->getMockedTransaction($callback, $options); @@ -370,8 +370,8 @@ class MultiExecTest extends PredisTestCase }); $this->assertSame($responses, $expected); - $this->assertSame(array('WATCH', 'WATCH', 'GET', 'GET'), self::commandsToIDs($casCommands)); - $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + $this->assertSame(['WATCH', 'WATCH', 'GET', 'GET'], self::commandsToIDs($casCommands)); + $this->assertSame(['MULTI', 'GET', 'GET', 'EXEC'], self::commandsToIDs($txCommands)); } /** @@ -379,18 +379,18 @@ class MultiExecTest extends PredisTestCase */ public function testCheckAndSetWithEmptyBlock(): void { - $txCommands = $casCommands = array(); - $options = array('cas' => true); + $txCommands = $casCommands = []; + $options = ['cas' => true]; - $callback = $this->getExecuteCallback(array(), $txCommands, $casCommands); + $callback = $this->getExecuteCallback([], $txCommands, $casCommands); $tx = $this->getMockedTransaction($callback, $options); $tx->execute(function ($tx) { $tx->multi(); }); - $this->assertSame(array(), self::commandsToIDs($casCommands)); - $this->assertSame(array(), self::commandsToIDs($txCommands)); + $this->assertSame([], self::commandsToIDs($casCommands)); + $this->assertSame([], self::commandsToIDs($txCommands)); } /** @@ -398,10 +398,10 @@ class MultiExecTest extends PredisTestCase */ public function testCheckAndSetWithoutExec(): void { - $txCommands = $casCommands = array(); - $options = array('cas' => true); + $txCommands = $casCommands = []; + $options = ['cas' => true]; - $callback = $this->getExecuteCallback(array(), $txCommands, $casCommands); + $callback = $this->getExecuteCallback([], $txCommands, $casCommands); $tx = $this->getMockedTransaction($callback, $options); $tx->execute(function ($tx) { @@ -409,8 +409,8 @@ class MultiExecTest extends PredisTestCase $tx->set('hoge', 'piyo'); }); - $this->assertSame(array('GET', 'SET'), self::commandsToIDs($casCommands)); - $this->assertSame(array(), self::commandsToIDs($txCommands)); + $this->assertSame(['GET', 'SET'], self::commandsToIDs($casCommands)); + $this->assertSame([], self::commandsToIDs($txCommands)); } /** @@ -422,7 +422,7 @@ class MultiExecTest extends PredisTestCase $this->expectExceptionMessage('Automatic retries are supported only when a callable block is provided'); - $options = array('retry' => 1); + $options = ['retry' => 1]; $callback = $this->getExecuteCallback(); $tx = $this->getMockedTransaction($callback, $options); @@ -435,12 +435,12 @@ class MultiExecTest extends PredisTestCase */ public function testAutomaticRetryOnServerSideTransactionAbort(): void { - $casCommands = $txCommands = array(); - $expected = array('bar'); - $options = array('watch' => array('foo', 'bar'), 'retry' => ($attempts = 2) + 1); + $casCommands = $txCommands = []; + $expected = ['bar']; + $options = ['watch' => ['foo', 'bar'], 'retry' => ($attempts = 2) + 1]; $signal = $this->getMockBuilder('stdClass') - ->addMethods(array('__invoke')) + ->addMethods(['__invoke']) ->getMock(); $signal ->expects($this->exactly($attempts)) @@ -461,9 +461,9 @@ class MultiExecTest extends PredisTestCase }); $this->assertSame($responses, $expected); - $this->assertSame(array('WATCH'), self::commandsToIDs($casCommands)); - $this->assertSame(array('foo', 'bar'), $casCommands[0]->getArguments()); - $this->assertSame(array('MULTI', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); + $this->assertSame(['WATCH'], self::commandsToIDs($casCommands)); + $this->assertSame(['foo', 'bar'], $casCommands[0]->getArguments()); + $this->assertSame(['MULTI', 'GET', 'EXEC'], self::commandsToIDs($txCommands)); } /** @@ -486,8 +486,8 @@ class MultiExecTest extends PredisTestCase */ public function testHandlesStandardExceptionsInBlock(): void { - $commands = array(); - $expected = array('foobar', true); + $commands = []; + $expected = ['foobar', true]; $callback = $this->getExecuteCallback($expected, $commands); $tx = $this->getMockedTransaction($callback); @@ -507,7 +507,7 @@ class MultiExecTest extends PredisTestCase $this->assertNull($responses); $this->assertIsArray($expected); - $this->assertSame(array('MULTI', 'SET', 'GET', 'DISCARD'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'SET', 'GET', 'DISCARD'], self::commandsToIDs($commands)); } /** @@ -515,8 +515,8 @@ class MultiExecTest extends PredisTestCase */ public function testHandlesServerExceptionsInBlock(): void { - $commands = array(); - $expected = array('foobar', true); + $commands = []; + $expected = ['foobar', true]; $callback = $this->getExecuteCallback($expected, $commands); $tx = $this->getMockedTransaction($callback); @@ -534,7 +534,7 @@ class MultiExecTest extends PredisTestCase } $this->assertNull($responses); - $this->assertSame(array('MULTI', 'SET', 'ECHO', 'DISCARD'), self::commandsToIDs($commands)); + $this->assertSame(['MULTI', 'SET', 'ECHO', 'DISCARD'], self::commandsToIDs($commands)); } /** @@ -586,7 +586,7 @@ class MultiExecTest extends PredisTestCase */ public function testExceptionsOptionTakesPrecedenceOverClientOptionsWhenFalse(): void { - $expected = array('before', new Response\Error('ERR simulated error'), 'after'); + $expected = ['before', new Response\Error('ERR simulated error'), 'after']; $connection = $this->getMockedConnection(function (CommandInterface $command) use ($expected) { switch ($command->getId()) { @@ -601,8 +601,8 @@ class MultiExecTest extends PredisTestCase } }); - $client = new Client($connection, array('exceptions' => true)); - $tx = new MultiExec($client, array('exceptions' => false)); + $client = new Client($connection, ['exceptions' => true]); + $tx = new MultiExec($client, ['exceptions' => false]); $result = $tx ->multi() @@ -622,7 +622,7 @@ class MultiExecTest extends PredisTestCase $this->expectException('Predis\Response\ServerException'); $this->expectExceptionMessage('ERR simulated error'); - $expected = array('before', new Response\Error('ERR simulated error'), 'after'); + $expected = ['before', new Response\Error('ERR simulated error'), 'after']; $connection = $this->getMockedConnection(function (CommandInterface $command) use ($expected) { switch ($command->getId()) { @@ -637,8 +637,8 @@ class MultiExecTest extends PredisTestCase } }); - $client = new Client($connection, array('exceptions' => false)); - $tx = new MultiExec($client, array('exceptions' => true)); + $client = new Client($connection, ['exceptions' => false]); + $tx = new MultiExec($client, ['exceptions' => true]); $tx->multi()->echo('before')->echo('ERROR PLEASE!')->echo('after')->exec(); } @@ -664,7 +664,7 @@ class MultiExecTest extends PredisTestCase } }); - $client = new Client($connection, array('exceptions' => false)); + $client = new Client($connection, ['exceptions' => false]); $tx = new MultiExec($client); $tx->multi()->echo('test')->exec(); @@ -723,7 +723,7 @@ class MultiExecTest extends PredisTestCase */ public function testIntegrationReturnsErrorObjectOnRedisErrorInBlock(): void { - $client = $this->getClient(array(), array('exceptions' => false)); + $client = $this->getClient([], ['exceptions' => false]); $responses = $client->transaction(function (MultiExec $tx) { $tx->set('foo', 'bar'); @@ -766,7 +766,7 @@ class MultiExecTest extends PredisTestCase $client2 = $this->getClient(); try { - $client1->transaction(array('watch' => 'sentinel'), function ($tx) use ($client2) { + $client1->transaction(['watch' => 'sentinel'], function ($tx) use ($client2) { $tx->set('sentinel', 'client1'); $tx->get('sentinel'); $client2->set('sentinel', 'client2'); @@ -788,7 +788,7 @@ class MultiExecTest extends PredisTestCase $client = $this->getClient(); $client->set('foo', 'bar'); - $options = array('watch' => 'foo', 'cas' => true); + $options = ['watch' => 'foo', 'cas' => true]; $responses = $client->transaction($options, function ($tx) { $tx->watch('foobar'); @@ -801,13 +801,13 @@ class MultiExecTest extends PredisTestCase }); $this->assertIsArray($responses); - $this->assertSame(array(array('bar', null)), $responses); + $this->assertSame([['bar', null]], $responses); $hijack = true; $client2 = $this->getClient(); $client->set('foo', 'bar'); - $options = array('watch' => 'foo', 'cas' => true, 'retry' => 1); + $options = ['watch' => 'foo', 'cas' => true, 'retry' => 1]; $responses = $client->transaction($options, function ($tx) use ($client2, &$hijack) { $foo = $tx->get('foo'); $tx->multi(); @@ -824,7 +824,7 @@ class MultiExecTest extends PredisTestCase }); $this->assertIsArray($responses); - $this->assertSame(array(array('hijacked!', null)), $responses); + $this->assertSame([['hijacked!', null]], $responses); } // ******************************************************************** // @@ -864,8 +864,8 @@ class MultiExecTest extends PredisTestCase protected function getMockedTransaction($executeCallback, $txOpts = null, $clientOpts = null): MultiExec { $connection = $this->getMockedConnection($executeCallback); - $client = new Client($connection, $clientOpts ?: array()); - $transaction = new MultiExec($client, $txOpts ?: array()); + $client = new Client($connection, $clientOpts ?: []); + $transaction = new MultiExec($client, $txOpts ?: []); return $transaction; } @@ -880,9 +880,9 @@ class MultiExecTest extends PredisTestCase * @return callable */ protected function getExecuteCallback( - ?array $expected = array(), - ?array &$commands = array(), - ?array &$cas = array() + ?array $expected = [], + ?array &$commands = [], + ?array &$cas = [] ): callable { $multi = $watch = $abort = false; @@ -918,7 +918,7 @@ class MultiExecTest extends PredisTestCase $watch = $multi = false; if ($abort) { - $commands = $cas = array(); + $commands = $cas = []; $abort = false; return; @@ -978,7 +978,7 @@ class MultiExecTest extends PredisTestCase * * @return ClientInterface */ - protected function getClient(array $parameters = array(), array $options = array()): ClientInterface + protected function getClient(array $parameters = [], array $options = []): ClientInterface { return $this->createClient($parameters, $options); }