Skip to content

Commit

Permalink
Merge pull request #537 from clue-labs/nullable-v1
Browse files Browse the repository at this point in the history
[1.x] Improve PHP 8.4+ support by avoiding implicitly nullable types
  • Loading branch information
WyriHaximus authored Aug 18, 2024
2 parents 8111281 + 88128ac commit c4855ce
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 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 || ^5.7 || ^4.8.36",
"react/async": "^4 || ^3 || ^2",
"react/async": "^4.2 || ^3 || ^2",
"react/promise-stream": "^1.4",
"react/promise-timer": "^1.9"
"react/promise-timer": "^1.11"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 2 additions & 1 deletion 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 @@ -88,7 +89,7 @@ public function __construct($connector = null, $loop = null)

$loop = $loop ?: Loop::get();
$this->transaction = new Transaction(
Sender::createFromLoop($loop, $connector),
Sender::createFromLoop($loop, $connector ?: new Connector(array(), $loop)),
$loop
);
}
Expand Down
7 changes: 1 addition & 6 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 @@ -48,12 +47,8 @@ class Sender
* @param ConnectorInterface|null $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(array(), $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 @@ -28,7 +28,9 @@ public function setUpLoop()

public function testCreateFromLoop()
{
$sender = Sender::createFromLoop($this->loop, null);
$connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();

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

$this->assertInstanceOf('React\Http\Io\Sender', $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 @@ -32,7 +32,7 @@ public function setUpConnectionMockAndSocket()
}


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

Expand Down

0 comments on commit c4855ce

Please sign in to comment.