Skip to content

Commit ad36197

Browse files
committed
Merge pull request #10 from Oefenweb/use-short-array-syntax
Use short array syntax
2 parents 333a926 + ba3a5e5 commit ad36197

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

Model/Datasource/RedisSource.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RedisSource extends DataSource {
1919
*
2020
* @var array
2121
*/
22-
protected $_baseConfig = array(
22+
protected $_baseConfig = [
2323
'host' => '127.0.0.1',
2424
'port' => 6379,
2525
'password' => '',
@@ -28,14 +28,14 @@ class RedisSource extends DataSource {
2828
'persistent' => false,
2929
'unix_socket' => '',
3030
'prefix' => '',
31-
);
31+
];
3232

3333
/**
3434
* Configuration.
3535
*
3636
* @var array
3737
*/
38-
public $config = array();
38+
public $config = [];
3939

4040
/**
4141
* A reference to the physical connection of this DataSource.
@@ -65,7 +65,7 @@ class RedisSource extends DataSource {
6565
* @return bool True if connecting to the DataSource succeeds, else false
6666
* @throws RedisSourceException
6767
*/
68-
public function __construct($config = array()) {
68+
public function __construct($config = []) {
6969
parent::__construct($config);
7070

7171
if (!$this->enabled()) {
@@ -105,7 +105,7 @@ public function __call($name, $arguments) {
105105
}
106106

107107
try {
108-
return call_user_func_array(array($this->_connection, $name), $arguments);
108+
return call_user_func_array([$this->_connection, $name], $arguments);
109109
} catch (RedisException $e) {
110110
throw new RedisSourceException(__d('redis', 'Method (%s) failed: %s.', $name, $e->getMessage()));
111111
}

Test/Case/Model/Datasource/RedisSourceTest.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -263,14 +263,14 @@ public function testConnectUnixSocket() {
263263
$port = 'bar';
264264
$timeout = 0;
265265

266-
$Source->config = array(
266+
$Source->config = [
267267
'unix_socket' => $unixSocket,
268268
'persistent' => $persistent,
269269
'host' => $host,
270270
'port' => $port,
271271
'timeout' => $timeout,
272-
);
273-
$Source->_connection = $this->getMock('Redis', array('connect'));
272+
];
273+
$Source->_connection = $this->getMock('Redis', ['connect']);
274274

275275
// Set expectations for connect calls
276276
$Source->_connection->expects($this->once())->method('connect')
@@ -299,14 +299,14 @@ public function testConnectTcp() {
299299
$port = 'bar';
300300
$timeout = 0;
301301

302-
$Source->config = array(
302+
$Source->config = [
303303
'unix_socket' => $unixSocket,
304304
'persistent' => $persistent,
305305
'host' => $host,
306306
'port' => $port,
307307
'timeout' => $timeout,
308-
);
309-
$Source->_connection = $this->getMock('Redis', array('connect'));
308+
];
309+
$Source->_connection = $this->getMock('Redis', ['connect']);
310310

311311
// Set expectations for connect calls
312312
$Source->_connection->expects($this->once())->method('connect')
@@ -336,14 +336,14 @@ public function testConnectTcpPersistent() {
336336
$port = 'bar';
337337
$timeout = 0;
338338

339-
$Source->config = array(
339+
$Source->config = [
340340
'unix_socket' => $unixSocket,
341341
'persistent' => $persistent,
342342
'host' => $host,
343343
'port' => $port,
344344
'timeout' => $timeout,
345-
);
346-
$Source->_connection = $this->getMock('Redis', array('pconnect'));
345+
];
346+
$Source->_connection = $this->getMock('Redis', ['pconnect']);
347347

348348
// Set expectations for pconnect calls
349349
$Source->_connection->expects($this->once())->method('pconnect')
@@ -419,8 +419,8 @@ public function testNoAuthenticate() {
419419

420420
$password = '';
421421

422-
$Source->config = array('password' => $password);
423-
$Source->_connection = $this->getMock('Redis', array('auth'));
422+
$Source->config = ['password' => $password];
423+
$Source->_connection = $this->getMock('Redis', ['auth']);
424424

425425
// Set expectations for constructor calls
426426
$Source->_connection->expects($this->never())->method('auth');
@@ -444,8 +444,8 @@ public function testSuccessfulAuthenticate() {
444444

445445
$password = 'foo';
446446

447-
$Source->config = array('password' => $password);
448-
$Source->_connection = $this->getMock('Redis', array('auth'));
447+
$Source->config = ['password' => $password];
448+
$Source->_connection = $this->getMock('Redis', ['auth']);
449449

450450
// Set expectations for auth calls
451451
$Source->_connection->expects($this->once())->method('auth')
@@ -470,8 +470,8 @@ public function testFailingAuthenticate() {
470470

471471
$password = 'foo';
472472

473-
$Source->config = array('password' => $password);
474-
$Source->_connection = $this->getMock('Redis', array('auth'));
473+
$Source->config = ['password' => $password];
474+
$Source->_connection = $this->getMock('Redis', ['auth']);
475475

476476
// Set expectations for auth calls
477477
$Source->_connection->expects($this->once())->method('auth')
@@ -496,8 +496,8 @@ public function testNoSelect() {
496496

497497
$database = '';
498498

499-
$Source->config = array('database' => $database);
500-
$Source->_connection = $this->getMock('Redis', array('select'));
499+
$Source->config = ['database' => $database];
500+
$Source->_connection = $this->getMock('Redis', ['select']);
501501

502502
// Set expectations for select calls
503503
$Source->_connection->expects($this->never())->method('select');
@@ -521,8 +521,8 @@ public function testSuccessfulSelect() {
521521

522522
$database = 'foo';
523523

524-
$Source->config = array('database' => $database);
525-
$Source->_connection = $this->getMock('Redis', array('select'));
524+
$Source->config = ['database' => $database];
525+
$Source->_connection = $this->getMock('Redis', ['select']);
526526

527527
// Set expectations for select calls
528528
$Source->_connection->expects($this->once())->method('select')
@@ -547,8 +547,8 @@ public function testFailingSelect() {
547547

548548
$database = 'foo';
549549

550-
$Source->config = array('database' => $database);
551-
$Source->_connection = $this->getMock('Redis', array('select'));
550+
$Source->config = ['database' => $database];
551+
$Source->_connection = $this->getMock('Redis', ['select']);
552552

553553
// Set expectations for select calls
554554
$Source->_connection->expects($this->once())->method('select')
@@ -573,8 +573,8 @@ public function testNoSetPrefix() {
573573

574574
$prefix = '';
575575

576-
$Source->config = array('prefix' => $prefix);
577-
$Source->_connection = $this->getMock('Redis', array('setOption'));
576+
$Source->config = ['prefix' => $prefix];
577+
$Source->_connection = $this->getMock('Redis', ['setOption']);
578578

579579
// Set expectations for setOption calls
580580
$Source->_connection->expects($this->never())->method('setOption');
@@ -598,8 +598,8 @@ public function testSuccessfulSetPrefix() {
598598

599599
$prefix = 'foo';
600600

601-
$Source->config = array('prefix' => $prefix);
602-
$Source->_connection = $this->getMock('Redis', array('setOption'));
601+
$Source->config = ['prefix' => $prefix];
602+
$Source->_connection = $this->getMock('Redis', ['setOption']);
603603

604604
// Set expectations for setOption calls
605605
$Source->_connection->expects($this->once())->method('setOption')
@@ -624,8 +624,8 @@ public function testFailingSetPrefix() {
624624

625625
$prefix = 'foo';
626626

627-
$Source->config = array('prefix' => $prefix);
628-
$Source->_connection = $this->getMock('Redis', array('setOption'));
627+
$Source->config = ['prefix' => $prefix];
628+
$Source->_connection = $this->getMock('Redis', ['setOption']);
629629

630630
// Set expectations for setOption calls
631631
$Source->_connection->expects($this->once())->method('setOption')
@@ -643,7 +643,7 @@ public function testCloseNotConnected() {
643643
$Source = new TestRedisSource();
644644

645645
$Source->connected = false;
646-
$Source->_connection = $this->getMock('Redis', array('close'));
646+
$Source->_connection = $this->getMock('Redis', ['close']);
647647

648648
// Set expectations for close calls
649649
$Source->_connection->expects($this->never())->method('close');
@@ -659,7 +659,7 @@ public function testCloseConnected() {
659659
$Source = new TestRedisSource();
660660

661661
$Source->connected = true;
662-
$Source->_connection = $this->getMock('Redis', array('close'));
662+
$Source->_connection = $this->getMock('Redis', ['close']);
663663

664664
// Set expectations for close calls
665665
$Source->_connection->expects($this->once())->method('close');

0 commit comments

Comments
 (0)