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

[3.x] Improve PHP 8.4+ support by avoiding implicitly nullable types #536

Merged
merged 1 commit into from
Aug 18, 2024
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
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