From f96e6a91b02fbd423bbb3f79add5cf42dfffe553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20L=C3=BCck?= Date: Tue, 14 May 2024 12:22:26 +0200 Subject: [PATCH] Improve PHP 8.4+ support by avoiding implicitly nullable types --- composer.json | 10 +++++----- src/Connector.php | 2 +- src/FdServer.php | 2 +- src/SecureConnector.php | 2 +- src/SecureServer.php | 2 +- src/SocketServer.php | 2 +- src/TcpConnector.php | 2 +- src/TcpServer.php | 2 +- src/TimeoutConnector.php | 2 +- src/UnixConnector.php | 2 +- src/UnixServer.php | 2 +- 11 files changed, 15 insertions(+), 15 deletions(-) diff --git a/composer.json b/composer.json index 3c7690a..5ff904e 100644 --- a/composer.json +++ b/composer.json @@ -28,16 +28,16 @@ "require": { "php": ">=7.1", "evenement/evenement": "^3.0 || ^2.0 || ^1.0", - "react/dns": "^1.11", + "react/dns": "^1.13", "react/event-loop": "^1.2", - "react/promise": "^3 || ^2.6 || ^1.2.1", - "react/stream": "^1.2" + "react/promise": "^3.2 || ^2.6 || ^1.2.1", + "react/stream": "^1.4" }, "require-dev": { "phpunit/phpunit": "^9.6 || ^7.5", - "react/async": "^4 || ^3", + "react/async": "^4.3 || ^3", "react/promise-stream": "^1.4", - "react/promise-timer": "^1.10" + "react/promise-timer": "^1.11" }, "autoload": { "psr-4": { diff --git a/src/Connector.php b/src/Connector.php index 40d8ebb..8a5e994 100644 --- a/src/Connector.php +++ b/src/Connector.php @@ -50,7 +50,7 @@ final class Connector implements ConnectorInterface * @param ?LoopInterface $loop * @throws \InvalidArgumentException for invalid arguments */ - public function __construct(array $context = array(), LoopInterface $loop = null) + public function __construct(array $context = [], ?LoopInterface $loop = null) { // apply default options if not explicitly given $context += [ diff --git a/src/FdServer.php b/src/FdServer.php index 43a95b7..b00681c 100644 --- a/src/FdServer.php +++ b/src/FdServer.php @@ -75,7 +75,7 @@ final class FdServer extends EventEmitter implements ServerInterface * @throws \InvalidArgumentException if the listening address is invalid * @throws \RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($fd, LoopInterface $loop = null) + public function __construct($fd, ?LoopInterface $loop = null) { if (\preg_match('#^php://fd/(\d+)$#', $fd, $m)) { $fd = (int) $m[1]; diff --git a/src/SecureConnector.php b/src/SecureConnector.php index e3ff1ce..b7dd5fd 100644 --- a/src/SecureConnector.php +++ b/src/SecureConnector.php @@ -13,7 +13,7 @@ final class SecureConnector implements ConnectorInterface private $streamEncryption; private $context; - public function __construct(ConnectorInterface $connector, LoopInterface $loop = null, array $context = []) + public function __construct(ConnectorInterface $connector, ?LoopInterface $loop = null, array $context = []) { $this->connector = $connector; $this->streamEncryption = new StreamEncryption($loop ?? Loop::get(), false); diff --git a/src/SecureServer.php b/src/SecureServer.php index 29c9866..7ef5d94 100644 --- a/src/SecureServer.php +++ b/src/SecureServer.php @@ -119,7 +119,7 @@ final class SecureServer extends EventEmitter implements ServerInterface * @see TcpServer * @link https://www.php.net/manual/en/context.ssl.php for TLS context options */ - public function __construct(ServerInterface $tcp, LoopInterface $loop = null, array $context = []) + public function __construct(ServerInterface $tcp, ?LoopInterface $loop = null, array $context = []) { // default to empty passphrase to suppress blocking passphrase prompt $context += [ diff --git a/src/SocketServer.php b/src/SocketServer.php index 10c4338..2106ff3 100644 --- a/src/SocketServer.php +++ b/src/SocketServer.php @@ -31,7 +31,7 @@ final class SocketServer extends EventEmitter implements ServerInterface * @throws \InvalidArgumentException if the listening address is invalid * @throws \RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($uri, array $context = [], LoopInterface $loop = null) + public function __construct($uri, array $context = [], ?LoopInterface $loop = null) { // apply default options if not explicitly given $context += [ diff --git a/src/TcpConnector.php b/src/TcpConnector.php index 1f17c0e..0949184 100644 --- a/src/TcpConnector.php +++ b/src/TcpConnector.php @@ -12,7 +12,7 @@ final class TcpConnector implements ConnectorInterface private $loop; private $context; - public function __construct(LoopInterface $loop = null, array $context = []) + public function __construct(?LoopInterface $loop = null, array $context = []) { $this->loop = $loop ?? Loop::get(); $this->context = $context; diff --git a/src/TcpServer.php b/src/TcpServer.php index 42f86d6..a49ca9d 100644 --- a/src/TcpServer.php +++ b/src/TcpServer.php @@ -126,7 +126,7 @@ final class TcpServer extends EventEmitter implements ServerInterface * @throws \InvalidArgumentException if the listening address is invalid * @throws \RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($uri, LoopInterface $loop = null, array $context = []) + public function __construct($uri, ?LoopInterface $loop = null, array $context = []) { $this->loop = $loop ?? Loop::get(); diff --git a/src/TimeoutConnector.php b/src/TimeoutConnector.php index 75414b6..5031a0b 100644 --- a/src/TimeoutConnector.php +++ b/src/TimeoutConnector.php @@ -12,7 +12,7 @@ final class TimeoutConnector implements ConnectorInterface private $timeout; private $loop; - public function __construct(ConnectorInterface $connector, $timeout, LoopInterface $loop = null) + public function __construct(ConnectorInterface $connector, $timeout, ?LoopInterface $loop = null) { $this->connector = $connector; $this->timeout = $timeout; diff --git a/src/UnixConnector.php b/src/UnixConnector.php index eb3f18e..ecc6262 100644 --- a/src/UnixConnector.php +++ b/src/UnixConnector.php @@ -17,7 +17,7 @@ final class UnixConnector implements ConnectorInterface { private $loop; - public function __construct(LoopInterface $loop = null) + public function __construct(?LoopInterface $loop = null) { $this->loop = $loop ?? Loop::get(); } diff --git a/src/UnixServer.php b/src/UnixServer.php index d16502d..8b4e416 100644 --- a/src/UnixServer.php +++ b/src/UnixServer.php @@ -48,7 +48,7 @@ final class UnixServer extends EventEmitter implements ServerInterface * @throws \InvalidArgumentException if the listening address is invalid * @throws \RuntimeException if listening on this address fails (already in use etc.) */ - public function __construct($path, LoopInterface $loop = null, array $context = []) + public function __construct($path, ?LoopInterface $loop = null, array $context = []) { $this->loop = $loop ?? Loop::get();