mirror of
https://github.com/predis/predis.git
synced 2026-10-08 04:46:38 +00:00
use short array syntax
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user