Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 8.3 fixes #22

Merged
merged 3 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
strategy:
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
php:
- 8.3
- 8.2
- 8.1
- 8.0
- 7.4
- 7.3
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
},
"require": {
"react/http": "1.5.* | 1.6.* | 1.7.* | 1.8.*",
"voryx/event-loop": "^3.0 || ^2.0.2",
"ratchet/rfc6455": "^0.3",
"reactivex/rxphp": "^2.0.1"
"reactivex/rxphp": "^2.0.1",
"react/event-loop": "^1.2"
},
"require-dev": {
"phpunit/phpunit": "^9"
"phpunit/phpunit": "^9 | ^10"
}
}
26 changes: 8 additions & 18 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
bootstrap="test/bootstrap.php">
<testsuites>
<testsuite name="RxWebsocket Test">
<directory>test/</directory>
</testsuite>
</testsuites>

</phpunit>
<?xml version="1.0" encoding="utf-8"?>
<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">
<testsuites>
<testsuite name="RxWebsocket Test">
<directory>test/</directory>
</testsuite>
</testsuites>
</phpunit>
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(string $url, bool $useMessageObject = false, array $
$this->url = $url;
$this->useMessageObject = $useMessageObject;
$this->subProtocols = $subProtocols;
$this->loop = $loop ?: \EventLoop\getLoop();
$this->loop = $loop ?: \React\EventLoop\Loop::get();
$this->connector = $connector;
$this->keepAlive = $keepAlive;
$this->headers = $headers;
Expand Down
4 changes: 2 additions & 2 deletions src/MessageSubject.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ function (FrameInterface $frame) {
->merge($keepAliveObs)
->subscribe(
[$messageBuffer, 'onData'],
[$this, 'parent::onError'],
[$this, 'parent::onCompleted']
function (\Throwable $e) { parent::onError($e); },
function () { parent::onCompleted(); }
);

$this->subProtocol = $subProtocol;
Expand Down
2 changes: 1 addition & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(string $bindAddressOrPort, bool $useMessageObject =
$this->bindAddress = $bindAddressOrPort;
$this->useMessageObject = $useMessageObject;
$this->subProtocols = $subProtocols;
$this->loop = $loop ?: \EventLoop\getLoop();
$this->loop = $loop ?: \React\EventLoop\Loop::get();
$this->keepAlive = $keepAlive;
}

Expand Down
2 changes: 1 addition & 1 deletion test/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testPassthroughOfHeaders() {
->getMock();
$connection
->method('write')
->with($this->callback(function($data) use (&$writtenData) { $writtenData .= $data; }))
->with($this->callback(function($data) use (&$writtenData) { $writtenData .= $data; return true;}))
->willReturn(true);


Expand Down
11 changes: 6 additions & 5 deletions test/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Rx\Websocket\Test;

use React\EventLoop\Loop;
use function EventLoop\addTimer;
use function EventLoop\getLoop;
use Rx\Websocket\Client;
Expand All @@ -16,11 +17,11 @@ public function testServerShutsDown()

$serverDisp = $server->subscribe();

addTimer(0.1, function () use ($serverDisp) {
Loop::addTimer(0.1, function () use ($serverDisp) {
$serverDisp->dispose();
});

getLoop()->run();
Loop::get()->run();

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

$value = null;

addTimer(0.1, function () use (&$value) {
Loop::addTimer(0.1, function () use (&$value) {
$client = new Client('ws://127.0.0.1:1236');
$client
->flatMap(function (MessageSubject $ms) {
Expand All @@ -52,8 +53,8 @@ function (MessageSubject $ms) {
});
});

getLoop()->run();
Loop::get()->run();

$this->assertEquals('olleH', $value);
}
}
}
2 changes: 1 addition & 1 deletion test/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function resetScheduler()

foreach ($props as $prop) {
$prop->setAccessible(true);
$prop->setValue(null);
$prop->setValue($prop, null);
$prop->setAccessible(false);
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/ab/clientRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const AGENT = "Websocket/0.0.0";

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

$runReports = function () {
echo "Generating report.\n";
Expand Down Expand Up @@ -60,7 +60,7 @@ function ($error) use ($case, $deferred) {
},
function () use ($case, $deferred) {
echo "Finished " . $case . "\n";
$deferred->resolve();
$deferred->resolve(null);
}
);

Expand All @@ -77,7 +77,7 @@ function () use ($case, $deferred) {
$runNextCase = function () use (&$i, &$runNextCase, $testCount, $deferred, $runIndividualTest) {
$i++;
if ($i > $testCount) {
$deferred->resolve();
$deferred->resolve(null);
return;
}
$runIndividualTest($i, 60000)->then(function ($result) use ($runIndividualTest, &$i) {
Expand Down
2 changes: 1 addition & 1 deletion test/ab/testServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

$timerObservable = Observable::emptyObservable();
$timerObservable = Observable::empty();

if ($argc > 1 && is_numeric($argv[1])) {
echo "Setting test server to stop in " . $argv[1] . " seconds.\n";
Expand Down
2 changes: 2 additions & 0 deletions test/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
break;
}
}

Rx\Scheduler::setDefaultFactory(function () { return new \Rx\Scheduler\EventLoopScheduler(\React\EventLoop\Loop::get()); });