Skip to content

Commit ed73625

Browse files
committed
PHP8.5
1 parent cfc7ad3 commit ed73625

File tree

4 files changed

+55
-21
lines changed

4 files changed

+55
-21
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ jobs:
99
name: PHPUnit (PHP ${{ matrix.php }})
1010
runs-on: ubuntu-24.04
1111
strategy:
12+
fail-fast: false
1213
matrix:
1314
php:
15+
- 8.5
1416
- 8.4
1517
- 8.3
1618
- 8.2
@@ -47,8 +49,10 @@ jobs:
4749
runs-on: ubuntu-22.04
4850
continue-on-error: true
4951
strategy:
52+
fail-fast: false
5053
matrix:
5154
php:
55+
- 8.5
5256
- 8.4
5357
- 8.3
5458
- 8.2
@@ -111,8 +115,10 @@ jobs:
111115
runs-on: windows-2022
112116
continue-on-error: true
113117
strategy:
118+
fail-fast: false
114119
matrix:
115120
php:
121+
- 8.5
116122
- 8.4
117123
- 8.3
118124
- 8.2

src/ExtEvLoop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,13 @@ public function addTimer($interval, $callback)
143143
$callback = function () use ($timer, $timers, $that) {
144144
\call_user_func($timer->getCallback(), $timer);
145145

146-
if ($timers->contains($timer)) {
146+
if ($timers->offsetExists($timer)) {
147147
$that->cancelTimer($timer);
148148
}
149149
};
150150

151151
$event = $this->loop->timer($timer->getInterval(), 0.0, $callback);
152-
$this->timers->attach($timer, $event);
152+
$this->timers->offsetSet($timer, $event);
153153

154154
return $timer;
155155
}
@@ -163,7 +163,7 @@ public function addPeriodicTimer($interval, $callback)
163163
};
164164

165165
$event = $this->loop->timer($timer->getInterval(), $timer->getInterval(), $callback);
166-
$this->timers->attach($timer, $event);
166+
$this->timers->offsetSet($timer, $event);
167167

168168
return $timer;
169169
}
@@ -176,7 +176,7 @@ public function cancelTimer(TimerInterface $timer)
176176

177177
$event = $this->timers[$timer];
178178
$event->stop();
179-
$this->timers->detach($timer);
179+
$this->timers->offsetUnset($timer);
180180
}
181181

182182
public function futureTick($listener)

src/ExtUvLoop.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,13 @@ public function addTimer($interval, $callback)
119119
$callback = function () use ($timer, $timers, $that) {
120120
\call_user_func($timer->getCallback(), $timer);
121121

122-
if ($timers->contains($timer)) {
122+
if ($timers->offsetExists($timer)) {
123123
$that->cancelTimer($timer);
124124
}
125125
};
126126

127127
$event = \uv_timer_init($this->uv);
128-
$this->timers->attach($timer, $event);
128+
$this->timers->offsetSet($timer, $event);
129129
\uv_timer_start(
130130
$event,
131131
$this->convertFloatSecondsToMilliseconds($interval),
@@ -149,7 +149,7 @@ public function addPeriodicTimer($interval, $callback)
149149

150150
$interval = $this->convertFloatSecondsToMilliseconds($interval);
151151
$event = \uv_timer_init($this->uv);
152-
$this->timers->attach($timer, $event);
152+
$this->timers->offsetSet($timer, $event);
153153
\uv_timer_start(
154154
$event,
155155
$interval,
@@ -167,7 +167,7 @@ public function cancelTimer(TimerInterface $timer)
167167
{
168168
if (isset($this->timers[$timer])) {
169169
@\uv_timer_stop($this->timers[$timer]);
170-
$this->timers->detach($timer);
170+
$this->timers->offsetUnset($timer);
171171
}
172172
}
173173

tests/LoopTest.php

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ public function testStaticAddReadStreamCallsAddReadStreamOnLoopInstance()
6464
public function testStaticAddReadStreamWithNoDefaultLoopCallsAddReadStreamOnNewLoopInstance()
6565
{
6666
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
67-
$ref->setAccessible(true);
67+
if (PHP_VERSION_ID < 80500) {
68+
$ref->setAccessible(true);
69+
}
6870
$ref->setValue(null, null);
6971

7072
$stream = stream_socket_server('127.0.0.1:0');
@@ -90,7 +92,9 @@ public function testStaticAddWriteStreamCallsAddWriteStreamOnLoopInstance()
9092
public function testStaticAddWriteStreamWithNoDefaultLoopCallsAddWriteStreamOnNewLoopInstance()
9193
{
9294
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
93-
$ref->setAccessible(true);
95+
if (PHP_VERSION_ID < 80500) {
96+
$ref->setAccessible(true);
97+
}
9498
$ref->setValue(null, null);
9599

96100
$stream = stream_socket_server('127.0.0.1:0');
@@ -115,7 +119,9 @@ public function testStaticRemoveReadStreamCallsRemoveReadStreamOnLoopInstance()
115119
public function testStaticRemoveReadStreamWithNoDefaultLoopIsNoOp()
116120
{
117121
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
118-
$ref->setAccessible(true);
122+
if (PHP_VERSION_ID < 80500) {
123+
$ref->setAccessible(true);
124+
}
119125
$ref->setValue(null, null);
120126

121127
$stream = tmpfile();
@@ -139,7 +145,9 @@ public function testStaticRemoveWriteStreamCallsRemoveWriteStreamOnLoopInstance(
139145
public function testStaticRemoveWriteStreamWithNoDefaultLoopIsNoOp()
140146
{
141147
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
142-
$ref->setAccessible(true);
148+
if (PHP_VERSION_ID < 80500) {
149+
$ref->setAccessible(true);
150+
}
143151
$ref->setValue(null, null);
144152

145153
$stream = tmpfile();
@@ -167,7 +175,9 @@ public function testStaticAddTimerCallsAddTimerOnLoopInstanceAndReturnsTimerInst
167175
public function testStaticAddTimerWithNoDefaultLoopCallsAddTimerOnNewLoopInstance()
168176
{
169177
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
170-
$ref->setAccessible(true);
178+
if (PHP_VERSION_ID < 80500) {
179+
$ref->setAccessible(true);
180+
}
171181
$ref->setValue(null, null);
172182

173183
$interval = 1.0;
@@ -197,7 +207,9 @@ public function testStaticAddPeriodicTimerCallsAddPeriodicTimerOnLoopInstanceAnd
197207
public function testStaticAddPeriodicTimerWithNoDefaultLoopCallsAddPeriodicTimerOnNewLoopInstance()
198208
{
199209
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
200-
$ref->setAccessible(true);
210+
if (PHP_VERSION_ID < 80500) {
211+
$ref->setAccessible(true);
212+
}
201213
$ref->setValue(null, null);
202214

203215
$interval = 1.0;
@@ -224,7 +236,9 @@ public function testStaticCancelTimerCallsCancelTimerOnLoopInstance()
224236
public function testStaticCancelTimerWithNoDefaultLoopIsNoOp()
225237
{
226238
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
227-
$ref->setAccessible(true);
239+
if (PHP_VERSION_ID < 80500) {
240+
$ref->setAccessible(true);
241+
}
228242
$ref->setValue(null, null);
229243

230244
$timer = $this->getMockBuilder('React\EventLoop\TimerInterface')->getMock();
@@ -248,7 +262,9 @@ public function testStaticFutureTickCallsFutureTickOnLoopInstance()
248262
public function testStaticFutureTickWithNoDefaultLoopCallsFutureTickOnNewLoopInstance()
249263
{
250264
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
251-
$ref->setAccessible(true);
265+
if (PHP_VERSION_ID < 80500) {
266+
$ref->setAccessible(true);
267+
}
252268
$ref->setValue(null, null);
253269

254270
$listener = function () { };
@@ -277,7 +293,9 @@ public function testStaticAddSignalWithNoDefaultLoopCallsAddSignalOnNewLoopInsta
277293
}
278294

279295
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
280-
$ref->setAccessible(true);
296+
if (PHP_VERSION_ID < 80500) {
297+
$ref->setAccessible(true);
298+
}
281299
$ref->setValue(null, null);
282300

283301
$signal = 1;
@@ -307,7 +325,9 @@ public function testStaticRemoveSignalCallsRemoveSignalOnLoopInstance()
307325
public function testStaticRemoveSignalWithNoDefaultLoopIsNoOp()
308326
{
309327
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
310-
$ref->setAccessible(true);
328+
if (PHP_VERSION_ID < 80500) {
329+
$ref->setAccessible(true);
330+
}
311331
$ref->setValue(null, null);
312332

313333
$signal = 1;
@@ -330,7 +350,9 @@ public function testStaticRunCallsRunOnLoopInstance()
330350
public function testStaticRunWithNoDefaultLoopCallsRunsOnNewLoopInstance()
331351
{
332352
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
333-
$ref->setAccessible(true);
353+
if (PHP_VERSION_ID < 80500) {
354+
$ref->setAccessible(true);
355+
}
334356
$ref->setValue(null, null);
335357

336358
Loop::run();
@@ -351,7 +373,9 @@ public function testStaticStopCallsStopOnLoopInstance()
351373
public function testStaticStopCallWithNoDefaultLoopIsNoOp()
352374
{
353375
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
354-
$ref->setAccessible(true);
376+
if (PHP_VERSION_ID < 80500) {
377+
$ref->setAccessible(true);
378+
}
355379
$ref->setValue(null, null);
356380

357381
Loop::stop();
@@ -366,7 +390,11 @@ public function testStaticStopCallWithNoDefaultLoopIsNoOp()
366390
public function unsetLoopFromLoopAccessor()
367391
{
368392
$ref = new \ReflectionProperty('React\EventLoop\Loop', 'instance');
369-
$ref->setAccessible(true);
393+
if (PHP_VERSION_ID < 80500) {
394+
if (PHP_VERSION_ID < 80500) {
395+
$ref->setAccessible(true);
396+
}
397+
}
370398
$ref->setValue(null, null);
371399
}
372400
}

0 commit comments

Comments
 (0)