Skip to content

Commit 802ba09

Browse files
authored
Merge pull request #22 from mbonneau/ci-update
PHP 8.3 fixes
2 parents 9bcfbbb + 3f6c29c commit 802ba09

12 files changed

+33
-39
lines changed

.github/workflows/ci.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ jobs:
1111
strategy:
1212
matrix:
1313
os:
14-
- ubuntu-20.04
14+
- ubuntu-22.04
1515
php:
16+
- 8.3
17+
- 8.2
1618
- 8.1
1719
- 8.0
1820
- 7.4
19-
- 7.3
2021
steps:
21-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v4
2223
- uses: shivammathur/setup-php@v2
2324
with:
2425
php-version: ${{ matrix.php }}

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
},
3939
"require": {
4040
"react/http": "1.5.* | 1.6.* | 1.7.* | 1.8.*",
41-
"voryx/event-loop": "^3.0 || ^2.0.2",
4241
"ratchet/rfc6455": "^0.3",
43-
"reactivex/rxphp": "^2.0.1"
42+
"reactivex/rxphp": "^2.0.1",
43+
"react/event-loop": "^1.2"
4444
},
4545
"require-dev": {
46-
"phpunit/phpunit": "^9"
46+
"phpunit/phpunit": "^9 | ^10"
4747
}
4848
}

phpunit.xml

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
<?xml version="1.0" encoding="utf-8" ?>
2-
<phpunit
3-
backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
bootstrap="test/bootstrap.php">
12-
<testsuites>
13-
<testsuite name="RxWebsocket Test">
14-
<directory>test/</directory>
15-
</testsuite>
16-
</testsuites>
17-
18-
</phpunit>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="test/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
3+
<testsuites>
4+
<testsuite name="RxWebsocket Test">
5+
<directory>test/</directory>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

src/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(string $url, bool $useMessageObject = false, array $
4646
$this->url = $url;
4747
$this->useMessageObject = $useMessageObject;
4848
$this->subProtocols = $subProtocols;
49-
$this->loop = $loop ?: \EventLoop\getLoop();
49+
$this->loop = $loop ?: \React\EventLoop\Loop::get();
5050
$this->connector = $connector;
5151
$this->keepAlive = $keepAlive;
5252
$this->headers = $headers;

src/MessageSubject.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function (FrameInterface $frame) {
107107
->merge($keepAliveObs)
108108
->subscribe(
109109
[$messageBuffer, 'onData'],
110-
[$this, 'parent::onError'],
111-
[$this, 'parent::onCompleted']
110+
function (\Throwable $e) { parent::onError($e); },
111+
function () { parent::onCompleted(); }
112112
);
113113

114114
$this->subProtocol = $subProtocol;

src/Server.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function __construct(string $bindAddressOrPort, bool $useMessageObject =
3535
$this->bindAddress = $bindAddressOrPort;
3636
$this->useMessageObject = $useMessageObject;
3737
$this->subProtocols = $subProtocols;
38-
$this->loop = $loop ?: \EventLoop\getLoop();
38+
$this->loop = $loop ?: \React\EventLoop\Loop::get();
3939
$this->keepAlive = $keepAlive;
4040
}
4141

test/ClientTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testPassthroughOfHeaders() {
3838
->getMock();
3939
$connection
4040
->method('write')
41-
->with($this->callback(function($data) use (&$writtenData) { $writtenData .= $data; }))
41+
->with($this->callback(function($data) use (&$writtenData) { $writtenData .= $data; return true;}))
4242
->willReturn(true);
4343

4444

test/ServerTest.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Rx\Websocket\Test;
44

5+
use React\EventLoop\Loop;
56
use function EventLoop\addTimer;
67
use function EventLoop\getLoop;
78
use Rx\Websocket\Client;
@@ -16,11 +17,11 @@ public function testServerShutsDown()
1617

1718
$serverDisp = $server->subscribe();
1819

19-
addTimer(0.1, function () use ($serverDisp) {
20+
Loop::addTimer(0.1, function () use ($serverDisp) {
2021
$serverDisp->dispose();
2122
});
2223

23-
getLoop()->run();
24+
Loop::get()->run();
2425

2526
// we are making sure it is not hanging - if it gets here it worked
2627
$this->assertTrue(true);
@@ -38,7 +39,7 @@ function (MessageSubject $ms) {
3839

3940
$value = null;
4041

41-
addTimer(0.1, function () use (&$value) {
42+
Loop::addTimer(0.1, function () use (&$value) {
4243
$client = new Client('ws://127.0.0.1:1236');
4344
$client
4445
->flatMap(function (MessageSubject $ms) {
@@ -52,8 +53,8 @@ function (MessageSubject $ms) {
5253
});
5354
});
5455

55-
getLoop()->run();
56+
Loop::get()->run();
5657

5758
$this->assertEquals('olleH', $value);
5859
}
59-
}
60+
}

test/TestCase.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function resetScheduler()
2525

2626
foreach ($props as $prop) {
2727
$prop->setAccessible(true);
28-
$prop->setValue(null);
28+
$prop->setValue($prop, null);
2929
$prop->setAccessible(false);
3030
}
3131
}

test/ab/clientRunner.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const AGENT = "Websocket/0.0.0";
66

7-
echo "Using " . get_class(\EventLoop\getLoop()) . "\n";
7+
echo "Using " . get_class(\React\EventLoop\Loop::get()) . "\n";
88

99
$runReports = function () {
1010
echo "Generating report.\n";
@@ -60,7 +60,7 @@ function ($error) use ($case, $deferred) {
6060
},
6161
function () use ($case, $deferred) {
6262
echo "Finished " . $case . "\n";
63-
$deferred->resolve();
63+
$deferred->resolve(null);
6464
}
6565
);
6666

@@ -77,7 +77,7 @@ function () use ($case, $deferred) {
7777
$runNextCase = function () use (&$i, &$runNextCase, $testCount, $deferred, $runIndividualTest) {
7878
$i++;
7979
if ($i > $testCount) {
80-
$deferred->resolve();
80+
$deferred->resolve(null);
8181
return;
8282
}
8383
$runIndividualTest($i, 60000)->then(function ($result) use ($runIndividualTest, &$i) {

test/ab/testServer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
require_once __DIR__ . '/../bootstrap.php';
66

7-
$timerObservable = Observable::emptyObservable();
7+
$timerObservable = Observable::empty();
88

99
if ($argc > 1 && is_numeric($argv[1])) {
1010
echo "Setting test server to stop in " . $argv[1] . " seconds.\n";

test/bootstrap.php

+2
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@
1616
break;
1717
}
1818
}
19+
20+
Rx\Scheduler::setDefaultFactory(function () { return new \Rx\Scheduler\EventLoopScheduler(\React\EventLoop\Loop::get()); });

0 commit comments

Comments
 (0)