Skip to content

Commit d238022

Browse files
committed
[1.x] Fix reflection setAccessible deprecation warnings
In PHP8.1 ReflectionProperty::setAccessible was made a no-op through https://wiki.php.net/rfc/make-reflection-setaccessible-no-op in PHP8.5 it is now throwing a deprecation warning by: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_reflectionsetaccessible
1 parent aa908f9 commit d238022

File tree

1 file changed

+39
-13
lines changed

1 file changed

+39
-13
lines changed

tests/LoopTest.php

Lines changed: 39 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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
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 < 80100) {
377+
$ref->setAccessible(true);
378+
}
355379
$ref->setValue(null, null);
356380

357381
Loop::stop();
@@ -366,7 +390,9 @@ 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 < 80100) {
394+
$ref->setAccessible(true);
395+
}
370396
$ref->setValue(null, null);
371397
}
372398
}

0 commit comments

Comments
 (0)