Skip to content

Commit cd24a5b

Browse files
authored
Merge pull request #536 from clue-labs/nullable-v3
[3.x] Improve PHP 8.4+ support by avoiding implicitly nullable types
2 parents 212382c + f1a0406 commit cd24a5b

File tree

5 files changed

+15
-17
lines changed

5 files changed

+15
-17
lines changed

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@
3131
"fig/http-message-util": "^1.1",
3232
"psr/http-message": "^1.0",
3333
"react/event-loop": "^1.2",
34-
"react/promise": "^3 || ^2.3 || ^1.2.1",
35-
"react/socket": "^1.12",
36-
"react/stream": "^1.2"
34+
"react/promise": "^3.2 || ^2.3 || ^1.2.1",
35+
"react/socket": "^1.16",
36+
"react/stream": "^1.4"
3737
},
3838
"require-dev": {
3939
"clue/http-proxy-react": "^1.8",
4040
"clue/reactphp-ssh-proxy": "^1.4",
4141
"clue/socks-react": "^1.4",
4242
"phpunit/phpunit": "^9.6 || ^7.5",
43-
"react/async": "^4 || ^3",
43+
"react/async": "^4.2 || ^3",
4444
"react/promise-stream": "^1.4",
45-
"react/promise-timer": "^1.9"
45+
"react/promise-timer": "^1.11"
4646
},
4747
"autoload": {
4848
"psr-4": {

src/Browser.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use React\Http\Message\Request;
1111
use React\Http\Message\Uri;
1212
use React\Promise\PromiseInterface;
13+
use React\Socket\Connector;
1314
use React\Socket\ConnectorInterface;
1415
use React\Stream\ReadableStreamInterface;
1516
use InvalidArgumentException;
@@ -68,11 +69,11 @@ class Browser
6869
* @param ?ConnectorInterface $connector
6970
* @param ?LoopInterface $loop
7071
*/
71-
public function __construct(ConnectorInterface $connector = null, LoopInterface $loop = null)
72+
public function __construct(?ConnectorInterface $connector = null, ?LoopInterface $loop = null)
7273
{
7374
$loop = $loop ?? Loop::get();
7475
$this->transaction = new Transaction(
75-
Sender::createFromLoop($loop, $connector),
76+
Sender::createFromLoop($loop, $connector ?? new Connector([], $loop)),
7677
$loop
7778
);
7879
}

src/Io/Sender.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use React\Http\Client\Client as HttpClient;
99
use React\Promise\PromiseInterface;
1010
use React\Promise\Deferred;
11-
use React\Socket\Connector;
1211
use React\Socket\ConnectorInterface;
1312
use React\Stream\ReadableStreamInterface;
1413

@@ -45,15 +44,11 @@ class Sender
4544
* ```
4645
*
4746
* @param LoopInterface $loop
48-
* @param ConnectorInterface|null $connector
47+
* @param ConnectorInterface $connector
4948
* @return self
5049
*/
51-
public static function createFromLoop(LoopInterface $loop, ConnectorInterface $connector = null)
50+
public static function createFromLoop(LoopInterface $loop, ConnectorInterface $connector)
5251
{
53-
if ($connector === null) {
54-
$connector = new Connector([], $loop);
55-
}
56-
5752
return new self(new HttpClient(new ClientConnectionManager($connector, $loop)));
5853
}
5954

tests/Io/SenderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ public function setUpLoop()
3434

3535
public function testCreateFromLoop()
3636
{
37-
$sender = Sender::createFromLoop($this->loop, null);
37+
$connector = $this->createMock(ConnectorInterface::class);
38+
39+
$sender = Sender::createFromLoop($this->loop, $connector);
3840

3941
$this->assertInstanceOf(Sender::class, $sender);
4042
}

tests/Io/StreamingServerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function setUpConnectionMockAndSocket()
3636
}
3737

3838

39-
private function mockConnection(array $additionalMethods = null)
39+
private function mockConnection(array $additionalMethods = [])
4040
{
4141
$connection = $this->getMockBuilder(Connection::class)
4242
->disableOriginalConstructor()
@@ -53,7 +53,7 @@ private function mockConnection(array $additionalMethods = null)
5353
'getLocalAddress',
5454
'pipe'
5555
],
56-
(is_array($additionalMethods) ? $additionalMethods : [])
56+
$additionalMethods
5757
))
5858
->getMock();
5959

0 commit comments

Comments
 (0)