Skip to content

Commit 8dfab30

Browse files
committed
Update PHP language syntax, documentation and tests
1 parent ec4145f commit 8dfab30

12 files changed

+80
-84
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"php": ">=7.1.0"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "^9.6 || ^5.7"
32+
"phpunit/phpunit": "^9.6 || ^7.5"
3333
},
3434
"suggest": {
3535
"ext-pcntl": "For signal handling support when using the StreamSelectLoop"

phpunit.xml.legacy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
77
colors="true">
88
<testsuites>

src/ExtEvLoop.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ class ExtEvLoop implements LoopInterface
4141
/**
4242
* @var EvIo[]
4343
*/
44-
private $readStreams = array();
44+
private $readStreams = [];
4545

4646
/**
4747
* @var EvIo[]
4848
*/
49-
private $writeStreams = array();
49+
private $writeStreams = [];
5050

5151
/**
5252
* @var bool
@@ -61,7 +61,7 @@ class ExtEvLoop implements LoopInterface
6161
/**
6262
* @var \EvSignal[]
6363
*/
64-
private $signalEvents = array();
64+
private $signalEvents = [];
6565

6666
public function __construct()
6767
{

src/ExtEventLoop.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ final class ExtEventLoop implements LoopInterface
2727
private $timerCallback;
2828
private $timerEvents;
2929
private $streamCallback;
30-
private $readEvents = array();
31-
private $writeEvents = array();
32-
private $readListeners = array();
33-
private $writeListeners = array();
34-
private $readRefs = array();
35-
private $writeRefs = array();
30+
private $readEvents = [];
31+
private $writeEvents = [];
32+
private $readListeners = [];
33+
private $writeListeners = [];
34+
private $readRefs = [];
35+
private $writeRefs = [];
3636
private $running;
3737
private $signals;
38-
private $signalEvents = array();
38+
private $signalEvents = [];
3939

4040
public function __construct()
4141
{
@@ -67,8 +67,8 @@ public function __destruct()
6767
$this->timerEvents->detach($timer);
6868
}
6969

70-
$this->readEvents = array();
71-
$this->writeEvents = array();
70+
$this->readEvents = [];
71+
$this->writeEvents = [];
7272
}
7373

7474
public function addReadStream($stream, $listener)
@@ -173,7 +173,7 @@ public function addSignal($signal, $listener)
173173
$this->signals->add($signal, $listener);
174174

175175
if (!isset($this->signalEvents[$signal])) {
176-
$this->signalEvents[$signal] = Event::signal($this->eventBase, $signal, array($this->signals, 'call'));
176+
$this->signalEvents[$signal] = Event::signal($this->eventBase, $signal, [$this->signals, 'call']);
177177
$this->signalEvents[$signal]->add();
178178
}
179179
}

src/ExtUvLoop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ final class ExtUvLoop implements LoopInterface
2222
private $uv;
2323
private $futureTickQueue;
2424
private $timers;
25-
private $streamEvents = array();
26-
private $readStreams = array();
27-
private $writeStreams = array();
25+
private $streamEvents = [];
26+
private $readStreams = [];
27+
private $writeStreams = [];
2828
private $running;
2929
private $signals;
30-
private $signalEvents = array();
30+
private $signalEvents = [];
3131
private $streamListener;
3232

3333
public function __construct()

src/SignalsHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
*/
88
final class SignalsHandler
99
{
10-
private $signals = array();
10+
private $signals = [];
1111

1212
public function add($signal, $listener)
1313
{
1414
if (!isset($this->signals[$signal])) {
15-
$this->signals[$signal] = array();
15+
$this->signals[$signal] = [];
1616
}
1717

1818
if (\in_array($listener, $this->signals[$signal])) {

src/StreamSelectLoop.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ final class StreamSelectLoop implements LoopInterface
5656

5757
private $futureTickQueue;
5858
private $timers;
59-
private $readStreams = array();
60-
private $readListeners = array();
61-
private $writeStreams = array();
62-
private $writeListeners = array();
59+
private $readStreams = [];
60+
private $readListeners = [];
61+
private $writeStreams = [];
62+
private $writeListeners = [];
6363
private $running;
6464
private $pcntl = false;
6565
private $pcntlPoll = false;
@@ -157,7 +157,7 @@ public function addSignal($signal, $listener)
157157
$this->signals->add($signal, $listener);
158158

159159
if ($first) {
160-
\pcntl_signal($signal, array($this->signals, 'call'));
160+
\pcntl_signal($signal, [$this->signals, 'call']);
161161
}
162162
}
163163

@@ -278,7 +278,7 @@ private function streamSelect(array &$read, array &$write, $timeout)
278278
// @link https://docs.microsoft.com/de-de/windows/win32/api/winsock2/nf-winsock2-select
279279
$except = null;
280280
if (\DIRECTORY_SEPARATOR === '\\') {
281-
$except = array();
281+
$except = [];
282282
foreach ($write as $key => $socket) {
283283
if (!isset($read[$key]) && @\ftell($socket) === 0) {
284284
$except[$key] = $socket;

src/Timer/Timers.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
final class Timers
1616
{
1717
private $time;
18-
private $timers = array();
19-
private $schedule = array();
18+
private $timers = [];
19+
private $schedule = [];
2020
private $sorted = true;
2121
private $useHighResolution;
2222

tests/ExtUvLoopTest.php

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -45,51 +45,49 @@ public function intervalProvider()
4545
$tenMillionsIntMax = PHP_INT_MAX + 10000000;
4646
$tenThousandsTimesIntMax = PHP_INT_MAX * 1000;
4747

48-
return array(
49-
array(
50-
$oversizeInterval,
51-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
52-
),
53-
array(
54-
$oneMaxValue,
55-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
56-
),
57-
array(
58-
$tenMaxValue,
59-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
60-
),
61-
array(
62-
$tenMillionsMaxValue,
63-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
64-
),
65-
array(
66-
$intMax,
67-
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
68-
),
69-
array(
70-
$oneIntMax,
71-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
72-
),
73-
array(
74-
$tenIntMax,
75-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
76-
),
77-
array(
78-
$oneHundredIntMax,
79-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
80-
),
81-
array(
82-
$oneThousandIntMax,
83-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
84-
),
85-
array(
86-
$tenMillionsIntMax,
87-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
88-
),
89-
array(
90-
$tenThousandsTimesIntMax,
91-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
92-
),
93-
);
48+
yield [
49+
$oversizeInterval,
50+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
51+
];
52+
yield [
53+
$oneMaxValue,
54+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
55+
];
56+
yield [
57+
$tenMaxValue,
58+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
59+
];
60+
yield [
61+
$tenMillionsMaxValue,
62+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
63+
];
64+
yield [
65+
$intMax,
66+
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
67+
];
68+
yield [
69+
$oneIntMax,
70+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
71+
];
72+
yield [
73+
$tenIntMax,
74+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
75+
];
76+
yield [
77+
$oneHundredIntMax,
78+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
79+
];
80+
yield [
81+
$oneThousandIntMax,
82+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
83+
];
84+
yield [
85+
$tenMillionsIntMax,
86+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
87+
];
88+
yield [
89+
$tenThousandsTimesIntMax,
90+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
91+
];
9492
}
9593
}

tests/LoopTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testCallingLoopGetShouldAlwaysReturnTheSameEventLoop()
4545
*/
4646
public function numberOfTests()
4747
{
48-
return array(array(), array(), array());
48+
return [[], [], []];
4949
}
5050

5151
public function testStaticAddReadStreamCallsAddReadStreamOnLoopInstance()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy