Skip to content

Commit

Permalink
Merge pull request #536 from clue-labs/nullable-v3
Browse files Browse the repository at this point in the history
[3.x] Improve PHP 8.4+ support by avoiding implicitly nullable types
  • Loading branch information
WyriHaximus authored Aug 18, 2024
2 parents 212382c + f1a0406 commit cd24a5b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
"fig/http-message-util": "^1.1",
"psr/http-message": "^1.0",
"react/event-loop": "^1.2",
"react/promise": "^3 || ^2.3 || ^1.2.1",
"react/socket": "^1.12",
"react/stream": "^1.2"
"react/promise": "^3.2 || ^2.3 || ^1.2.1",
"react/socket": "^1.16",
"react/stream": "^1.4"
},
"require-dev": {
"clue/http-proxy-react": "^1.8",
"clue/reactphp-ssh-proxy": "^1.4",
"clue/socks-react": "^1.4",
"phpunit/phpunit": "^9.6 || ^7.5",
"react/async": "^4 || ^3",
"react/async": "^4.2 || ^3",
"react/promise-stream": "^1.4",
"react/promise-timer": "^1.9"
"react/promise-timer": "^1.11"
},
"autoload": {
"psr-4": {
Expand Down
5 changes: 3 additions & 2 deletions src/Browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use React\Http\Message\Request;
use React\Http\Message\Uri;
use React\Promise\PromiseInterface;
use React\Socket\Connector;
use React\Socket\ConnectorInterface;
use React\Stream\ReadableStreamInterface;
use InvalidArgumentException;
Expand Down Expand Up @@ -68,11 +69,11 @@ class Browser
* @param ?ConnectorInterface $connector
* @param ?LoopInterface $loop
*/
public function __construct(ConnectorInterface $connector = null, LoopInterface $loop = null)
public function __construct(?ConnectorInterface $connector = null, ?LoopInterface $loop = null)
{
$loop = $loop ?? Loop::get();
$this->transaction = new Transaction(
Sender::createFromLoop($loop, $connector),
Sender::createFromLoop($loop, $connector ?? new Connector([], $loop)),
$loop
);
}
Expand Down
9 changes: 2 additions & 7 deletions src/Io/Sender.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use React\Http\Client\Client as HttpClient;
use React\Promise\PromiseInterface;
use React\Promise\Deferred;
use React\Socket\Connector;
use React\Socket\ConnectorInterface;
use React\Stream\ReadableStreamInterface;

Expand Down Expand Up @@ -45,15 +44,11 @@ class Sender
* ```
*
* @param LoopInterface $loop
* @param ConnectorInterface|null $connector
* @param ConnectorInterface $connector
* @return self
*/
public static function createFromLoop(LoopInterface $loop, ConnectorInterface $connector = null)
public static function createFromLoop(LoopInterface $loop, ConnectorInterface $connector)
{
if ($connector === null) {
$connector = new Connector([], $loop);
}

return new self(new HttpClient(new ClientConnectionManager($connector, $loop)));
}

Expand Down
4 changes: 3 additions & 1 deletion tests/Io/SenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ public function setUpLoop()

public function testCreateFromLoop()
{
$sender = Sender::createFromLoop($this->loop, null);
$connector = $this->createMock(ConnectorInterface::class);

$sender = Sender::createFromLoop($this->loop, $connector);

$this->assertInstanceOf(Sender::class, $sender);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Io/StreamingServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setUpConnectionMockAndSocket()
}


private function mockConnection(array $additionalMethods = null)
private function mockConnection(array $additionalMethods = [])
{
$connection = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
Expand All @@ -53,7 +53,7 @@ private function mockConnection(array $additionalMethods = null)
'getLocalAddress',
'pipe'
],
(is_array($additionalMethods) ? $additionalMethods : [])
$additionalMethods
))
->getMock();

Expand Down

0 comments on commit cd24a5b

Please sign in to comment.