From 460913945ab5da386e7b62f8a01da8a5ad786d8f Mon Sep 17 00:00:00 2001 From: Paul Vogel Date: Tue, 24 Oct 2023 12:14:48 +0200 Subject: [PATCH 1/2] Extract $socket from constructor property promotion --- src/Communication/Socket/Socket.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Communication/Socket/Socket.php b/src/Communication/Socket/Socket.php index ab98f86..fd5978b 100644 --- a/src/Communication/Socket/Socket.php +++ b/src/Communication/Socket/Socket.php @@ -16,13 +16,21 @@ */ class Socket implements SocketInterface, SelectableSocketInterface { + + /** + * @var resource + */ + protected $socket; + /** * @param resource|Socket $socket */ - public function __construct(protected mixed $socket) + public function __construct(mixed $socket) { - if ($this->socket instanceof Socket) { - $this->socket = $this->socket->getStream(); + if ($socket instanceof Socket) { + $this->socket = $socket->getStream(); + } else { + $this->socket = $socket; } stream_set_blocking($this->socket, false); } From c62649412fb2829a314d44f13b6df0cc0b0c3b69 Mon Sep 17 00:00:00 2001 From: Paul Vogel Date: Tue, 24 Oct 2023 13:28:43 +0200 Subject: [PATCH 2/2] add type to $socket Co-authored-by: Matthias Neid --- src/Communication/Socket/Socket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Communication/Socket/Socket.php b/src/Communication/Socket/Socket.php index fd5978b..d9a9a5f 100644 --- a/src/Communication/Socket/Socket.php +++ b/src/Communication/Socket/Socket.php @@ -20,7 +20,7 @@ class Socket implements SocketInterface, SelectableSocketInterface /** * @var resource */ - protected $socket; + protected mixed $socket; /** * @param resource|Socket $socket