From eab09f30df36cf4425cacabadf3fd1308635a5f8 Mon Sep 17 00:00:00 2001 From: Mohamad Faeez Date: Wed, 9 Apr 2025 14:21:15 +0800 Subject: [PATCH] Minor update to cater php8 --- src/Ratchet/Server/IoServer.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index b3fb7e0..c89a85a 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -33,7 +33,7 @@ class IoServer { * @param \React\Socket\ServerInterface $socket The React socket server to run the Ratchet application off of * @param \React\EventLoop\LoopInterface|null $loop The React looper to run the Ratchet application off of */ - public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) { + public function __construct(MessageComponentInterface $app, ServerInterface $socket, ?LoopInterface $loop = null) { if (false === strpos(PHP_VERSION, "hiphop")) { gc_enable(); } @@ -54,7 +54,10 @@ class IoServer { * @param string $address The address to receive sockets on (0.0.0.0 means receive connections from any) * @return IoServer */ - public static function factory(MessageComponentInterface $component, $port = 80, $address = '0.0.0.0') { + public static function factory(MessageComponentInterface $component, integer|null $port = null, string|null $address = null) { + if ($port == null) $port = 80; + if ($address == null) $address = '0.0.0.0'; + $loop = LoopFactory::create(); $socket = new Reactor($address . ':' . $port, $loop);