Skip to content

Commit c527263

Browse files
committed
Replace array() with []
1 parent 3fb07dd commit c527263

16 files changed

+88
-88
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ proxy servers etc.), you can explicitly pass a custom instance of the
7474
[`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface):
7575

7676
```php
77-
$connector = new React\Socket\Connector(array(
77+
$connector = new React\Socket\Connector([
7878
'dns' => '127.0.0.1',
79-
'tcp' => array(
79+
'tcp' => [
8080
'bindto' => '192.168.10.1:0'
81-
),
82-
'tls' => array(
81+
],
82+
'tls' => [
8383
'verify_peer' => false,
8484
'verify_peer_name' => false
8585
)
86-
));
86+
]);
8787

8888
$factory = new React\MySQL\Factory(null, $connector);
8989
```
@@ -302,7 +302,7 @@ and sending your database queries.
302302

303303
#### query()
304304

305-
The `query(string $query, array $params = array()): PromiseInterface` method can be used to
305+
The `query(string $query, array $params = []): PromiseInterface` method can be used to
306306
perform an async query.
307307

308308
This method returns a promise that will resolve with a `QueryResult` on
@@ -358,7 +358,7 @@ suited for exposing multiple possible results.
358358

359359
#### queryStream()
360360

361-
The `queryStream(string $sql, array $params = array()): ReadableStreamInterface` method can be used to
361+
The `queryStream(string $sql, array $params = []): ReadableStreamInterface` method can be used to
362362
perform an async query and stream the rows of the result set.
363363

364364
This method returns a readable stream that will emit each row of the

src/Commands/AuthenticateCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AuthenticateCommand extends AbstractCommand
3333
* @see self::$charsetNumber
3434
* @see \React\MySQL\Io\Query::$escapeChars
3535
*/
36-
private static $charsetMap = array(
36+
private static $charsetMap = [
3737
'latin1' => 8,
3838
'latin2' => 9,
3939
'ascii' => 11,
@@ -42,7 +42,7 @@ class AuthenticateCommand extends AbstractCommand
4242
'latin7' => 41,
4343
'utf8mb4' => 45,
4444
'binary' => 63
45-
);
45+
];
4646

4747
/**
4848
* @param string $user

src/ConnectionInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ interface ConnectionInterface extends EventEmitterInterface
100100
* @param array $params Parameters which should be bound to query
101101
* @return PromiseInterface Returns a Promise<QueryResult,Exception>
102102
*/
103-
public function query($sql, array $params = array());
103+
public function query($sql, array $params = []);
104104

105105
/**
106106
* Performs an async query and streams the rows of the result set.
@@ -161,7 +161,7 @@ public function query($sql, array $params = array());
161161
* @param array $params Parameters which should be bound to query
162162
* @return ReadableStreamInterface
163163
*/
164-
public function queryStream($sql, $params = array());
164+
public function queryStream($sql, $params = []);
165165

166166
/**
167167
* Checks that the connection is alive.

src/Factory.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ class Factory
4242
* [`ConnectorInterface`](https://github.com/reactphp/socket#connectorinterface):
4343
*
4444
* ```php
45-
* $connector = new React\Socket\Connector(array(
45+
* $connector = new React\Socket\Connector([
4646
* 'dns' => '127.0.0.1',
47-
* 'tcp' => array(
47+
* 'tcp' => [
4848
* 'bindto' => '192.168.10.1:0'
49-
* ),
50-
* 'tls' => array(
49+
* ],
50+
* 'tls' => [
5151
* 'verify_peer' => false,
5252
* 'verify_peer_name' => false
53-
* )
54-
* ));
53+
* ]
54+
* ]);
5555
*
5656
* $factory = new React\MySQL\Factory(null, $connector);
5757
* ```
@@ -62,7 +62,7 @@ class Factory
6262
public function __construct(LoopInterface $loop = null, ConnectorInterface $connector = null)
6363
{
6464
$this->loop = $loop ?: Loop::get();
65-
$this->connector = $connector ?: new Connector(array(), $this->loop);
65+
$this->connector = $connector ?: new Connector([], $this->loop);
6666
}
6767

6868
/**

src/Io/Connection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct(SocketConnectionInterface $stream, Executor $executo
5757
/**
5858
* {@inheritdoc}
5959
*/
60-
public function query($sql, array $params = array())
60+
public function query($sql, array $params = [])
6161
{
6262
$query = new Query($sql);
6363
if ($params) {
@@ -75,7 +75,7 @@ public function query($sql, array $params = array())
7575
$deferred = new Deferred();
7676

7777
// store all result set rows until result set end
78-
$rows = array();
78+
$rows = [];
7979
$command->on('result', function ($row) use (&$rows) {
8080
$rows[] = $row;
8181
});
@@ -85,7 +85,7 @@ public function query($sql, array $params = array())
8585
$result->resultRows = $rows;
8686
$result->warningCount = $command->warningCount;
8787

88-
$rows = array();
88+
$rows = [];
8989

9090
$deferred->resolve($result);
9191
});
@@ -106,7 +106,7 @@ public function query($sql, array $params = array())
106106
return $deferred->promise();
107107
}
108108

109-
public function queryStream($sql, $params = array())
109+
public function queryStream($sql, $params = [])
110110
{
111111
$query = new Query($sql);
112112
if ($params) {
@@ -162,9 +162,9 @@ public function close()
162162
// reject all pending commands if connection is closed
163163
while (!$this->executor->isIdle()) {
164164
$command = $this->executor->dequeue();
165-
$command->emit('error', array(
165+
$command->emit('error', [
166166
new \RuntimeException('Connection lost')
167-
));
167+
]);
168168
}
169169

170170
$this->emit('close');

src/Io/LazyConnection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class LazyConnection extends EventEmitter implements ConnectionInterface
3333

3434
public function __construct(Factory $factory, $uri, LoopInterface $loop)
3535
{
36-
$args = array();
36+
$args = [];
3737
\parse_str(\parse_url($uri, \PHP_URL_QUERY), $args);
3838
if (isset($args['idle'])) {
3939
$this->idlePeriod = (float)$args['idle'];

src/Io/Parser.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ public function __construct(DuplexStreamInterface $stream, Executor $executor)
9797

9898
public function start()
9999
{
100-
$this->stream->on('data', array($this, 'parse'));
101-
$this->stream->on('close', array($this, 'onClose'));
100+
$this->stream->on('data', [$this, 'parse']);
101+
$this->stream->on('close', [$this, 'onClose']);
102102
}
103103

104104
public function debug($message)
@@ -221,7 +221,7 @@ public function parse($data)
221221
// Empty data packet during result set => row with only empty strings
222222
$this->debug('Result set empty row data');
223223

224-
$row = array();
224+
$row = [];
225225
foreach ($this->resultFields as $field) {
226226
$row[$field['name']] = '';
227227
}
@@ -272,7 +272,7 @@ private function onResultRow($row)
272272
{
273273
// $this->debug('row data: ' . json_encode($row));
274274
$command = $this->currCommand;
275-
$command->emit('result', array($row));
275+
$command->emit('result', [$row]);
276276
}
277277

278278
private function onError(Exception $error)
@@ -283,7 +283,7 @@ private function onError(Exception $error)
283283
$command = $this->currCommand;
284284
$this->currCommand = null;
285285

286-
$command->emit('error', array($error));
286+
$command->emit('error', [$error]);
287287
}
288288
}
289289

@@ -322,9 +322,9 @@ public function onClose()
322322
if ($command instanceof QuitCommand) {
323323
$command->emit('success');
324324
} else {
325-
$command->emit('error', array(
325+
$command->emit('error', [
326326
new \RuntimeException('Connection lost')
327-
));
327+
]);
328328
}
329329
}
330330
}

src/Io/Query.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Query
2222
* @var array<string,string>
2323
* @see \React\MySQL\Commands\AuthenticateCommand::$charsetMap
2424
*/
25-
private $escapeChars = array(
25+
private $escapeChars = [
2626
"\x00" => "\\0",
2727
"\r" => "\\r",
2828
"\n" => "\\n",
@@ -34,7 +34,7 @@ class Query
3434
"\\" => "\\\\",
3535
//"%" => "\\%",
3636
//"_" => "\\_",
37-
);
37+
];
3838

3939
public function __construct($sql)
4040
{
@@ -134,7 +134,7 @@ protected function buildSql()
134134

135135
return $sql;
136136
/*
137-
$names = array();
137+
$names = [];
138138
$inName = false;
139139
$currName = '';
140140
$currIdx = 0;
@@ -166,7 +166,7 @@ protected function buildSql()
166166
$names[$currIdx] = $currName;
167167
}
168168
169-
$namedMarks = $unnamedMarks = array();
169+
$namedMarks = $unnamedMarks = [];
170170
foreach ($this->params as $arg) {
171171
if (is_array($arg)) {
172172
$namedMarks += $arg;

src/Io/QueryStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function __construct(QueryCommand $command, ConnectionInterface $connecti
3333
}
3434
$this->started = true;
3535

36-
$this->emit('data', array($row));
36+
$this->emit('data', [$row]);
3737
});
3838
$command->on('end', function () {
3939
$this->emit('end');
@@ -46,7 +46,7 @@ public function __construct(QueryCommand $command, ConnectionInterface $connecti
4646
$this->close();
4747
});
4848
$command->on('error', function ($err) {
49-
$this->emit('error', array($err));
49+
$this->emit('error', [$err]);
5050
$this->close();
5151
});
5252
}

tests/BaseTestCase.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ protected function getConnectionOptions($debug = false)
2121
] + ($debug ? ['debug' => true] : []);
2222
}
2323

24-
protected function getConnectionString($params = array())
24+
protected function getConnectionString($params = [])
2525
{
2626
$parts = $params + $this->getConnectionOptions();
2727

@@ -56,23 +56,23 @@ protected function getDataTable()
5656

5757
protected function expectCallableOnce()
5858
{
59-
$mock = $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
59+
$mock = $this->getMockBuilder('stdClass')->setMethods(['__invoke'])->getMock();
6060
$mock->expects($this->once())->method('__invoke');
6161

6262
return $mock;
6363
}
6464

6565
protected function expectCallableOnceWith($value)
6666
{
67-
$mock = $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
67+
$mock = $this->getMockBuilder('stdClass')->setMethods(['__invoke'])->getMock();
6868
$mock->expects($this->once())->method('__invoke')->with($value);
6969

7070
return $mock;
7171
}
7272

7373
protected function expectCallableNever()
7474
{
75-
$mock = $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
75+
$mock = $this->getMockBuilder('stdClass')->setMethods(['__invoke'])->getMock();
7676
$mock->expects($this->never())->method('__invoke');
7777

7878
return $mock;

0 commit comments

Comments
 (0)