Skip to content

Commit 72de92f

Browse files
committed
Improve PHP 8.4+ support by avoiding implicitly nullable types
1 parent a2c4576 commit 72de92f

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ on:
77
jobs:
88
PHPUnit:
99
name: PHPUnit (PHP ${{ matrix.php }})
10-
runs-on: ubuntu-24.04
10+
runs-on: ubuntu-22.04
1111
strategy:
1212
matrix:
1313
php:
14-
- 8.4
1514
- 8.3
1615
- 8.2
1716
- 8.1
@@ -39,7 +38,7 @@ jobs:
3938

4039
PHPUnit-hhvm:
4140
name: PHPUnit (HHVM)
42-
runs-on: ubuntu-24.04
41+
runs-on: ubuntu-22.04
4342
continue-on-error: true
4443
steps:
4544
- uses: actions/checkout@v4

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
},
2323
"require": {
2424
"php": ">=5.3",
25-
"clue/multicast-react": "1.x-dev#f1bd5df0309b9f8b3486b09bf37aedfb042addb6",
25+
"clue/multicast-react": "^1.0 || ^0.2",
2626
"react/event-loop": "^1.2",
27-
"react/promise": "^3.2 || ^2.7 || ^1.2.1"
27+
"react/promise": "^2.0 || ^1.0"
2828
},
2929
"require-dev": {
3030
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"

src/Client.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ public function search($searchTarget = 'ssdp:all', $mx = 2)
5252
$socket = $this->multicast->createSender();
5353
// TODO: The TTL for the IP packet SHOULD default to 2 and SHOULD be configurable.
5454

55-
$messages = array();
55+
$timer = $this->loop->addTimer($mx, function() use ($socket, &$deferred) {
56+
$deferred->resolve();
57+
$socket->close();
58+
});
59+
5660
$loop = $this->loop;
5761
$deferred = new Deferred(function () use ($socket, &$timer, $loop) {
5862
// canceling resulting promise cancels timer and closes socket
@@ -61,15 +65,11 @@ public function search($searchTarget = 'ssdp:all', $mx = 2)
6165
throw new RuntimeException('Cancelled');
6266
});
6367

64-
$timer = $this->loop->addTimer($mx, function() use ($socket, &$deferred, &$messages) {
65-
$deferred->resolve($messages);
66-
$socket->close();
67-
});
68-
6968
$that = $this;
70-
$socket->on('message', function ($data, $remote) use (&$messages, $that) {
69+
$socket->on('message', function ($data, $remote) use ($deferred, $that) {
7170
$message = $that->parseMessage($data, $remote);
72-
$messages[] = $message;
71+
72+
$deferred->progress($message);
7373
});
7474

7575
$socket->send($data, self::ADDRESS);

0 commit comments

Comments
 (0)