diff --git a/src/Connection/AsyncTcpConnection.php b/src/Connection/AsyncTcpConnection.php index 14ff8a46..3757003a 100644 --- a/src/Connection/AsyncTcpConnection.php +++ b/src/Connection/AsyncTcpConnection.php @@ -154,7 +154,6 @@ class AsyncTcpConnection extends TcpConnection * * @param string $remoteAddress * @param array $socketContext - * @throws Exception */ public function __construct(string $remoteAddress, array $socketContext = []) { @@ -195,7 +194,7 @@ public function __construct(string $remoteAddress, array $socketContext = []) if (!class_exists($this->protocol)) { $this->protocol = "\\Workerman\\Protocols\\$scheme"; if (!class_exists($this->protocol)) { - throw new Exception("class \\Protocols\\$scheme not exist"); + throw new RuntimeException("class \\Protocols\\$scheme not exist"); } } } else { @@ -216,7 +215,6 @@ public function __construct(string $remoteAddress, array $socketContext = []) * * @param int $after * @return void - * @throws Throwable */ public function reconnect(int $after = 0): void { @@ -236,7 +234,6 @@ public function reconnect(int $after = 0): void * Do connect. * * @return void - * @throws Throwable */ public function connect(): void { @@ -302,7 +299,6 @@ public function connect(): void * @param int $code * @param mixed $msg * @return void - * @throws Throwable */ protected function emitError(int $code, mixed $msg): void { @@ -351,7 +347,6 @@ public function getRemoteURI(): string * Check connection is successfully established or failed. * * @return void - * @throws Throwable */ public function checkConnection(): void { diff --git a/src/Connection/AsyncUdpConnection.php b/src/Connection/AsyncUdpConnection.php index 512ab187..d17fa5b3 100644 --- a/src/Connection/AsyncUdpConnection.php +++ b/src/Connection/AsyncUdpConnection.php @@ -17,6 +17,7 @@ namespace Workerman\Connection; use Exception; +use RuntimeException; use Throwable; use Workerman\Protocols\ProtocolInterface; use Workerman\Worker; @@ -70,7 +71,7 @@ class AsyncUdpConnection extends UdpConnection * Construct. * * @param string $remoteAddress - * @throws Exception + * @throws Throwable */ public function __construct($remoteAddress, $contextOption = []) { @@ -83,7 +84,7 @@ public function __construct($remoteAddress, $contextOption = []) if (!class_exists($this->protocol)) { $this->protocol = "\\Workerman\\Protocols\\$scheme"; if (!class_exists($this->protocol)) { - throw new Exception("class \\Protocols\\$scheme not exist"); + throw new RuntimeException("class \\Protocols\\$scheme not exist"); } } } @@ -97,7 +98,6 @@ public function __construct($remoteAddress, $contextOption = []) * * @param resource $socket * @return void - * @throws Throwable */ public function baseRead($socket): void { @@ -127,7 +127,6 @@ public function baseRead($socket): void * @param mixed $data * @param bool $raw * @return void - * @throws Throwable */ public function close(mixed $data = null, bool $raw = false): void { @@ -154,7 +153,6 @@ public function close(mixed $data = null, bool $raw = false): void * @param mixed $sendBuffer * @param bool $raw * @return bool|null - * @throws Throwable */ public function send(mixed $sendBuffer, bool $raw = false): bool|null { @@ -176,7 +174,6 @@ public function send(mixed $sendBuffer, bool $raw = false): bool|null * Connect. * * @return void - * @throws Throwable */ public function connect(): void { diff --git a/src/Connection/ConnectionInterface.php b/src/Connection/ConnectionInterface.php index f496adaf..a1204427 100644 --- a/src/Connection/ConnectionInterface.php +++ b/src/Connection/ConnectionInterface.php @@ -170,7 +170,6 @@ abstract public function isIpV6(): bool; /** * @param Throwable $exception * @return void - * @throws Throwable */ public function error(Throwable $exception): void { @@ -181,11 +180,8 @@ public function error(Throwable $exception): void try { ($this->errorHandler)($exception); } catch (Throwable $exception) { - if ($this->eventLoop instanceof Event) { - echo $exception; - return; - } - throw $exception; + Worker::stopAll(250, $exception); + return; } } } diff --git a/src/Connection/TcpConnection.php b/src/Connection/TcpConnection.php index 6c640a5d..87bd56b5 100644 --- a/src/Connection/TcpConnection.php +++ b/src/Connection/TcpConnection.php @@ -400,7 +400,6 @@ public function getStatus(bool $rawOutput = true): int|string * @param mixed $sendBuffer * @param bool $raw * @return bool|null - * @throws Throwable */ public function send(mixed $sendBuffer, bool $raw = false): bool|null { @@ -414,7 +413,7 @@ public function send(mixed $sendBuffer, bool $raw = false): bool|null $parser = $this->protocol; try { $sendBuffer = $parser::encode($sendBuffer, $this); - } catch(\Throwable $e) { + } catch(Throwable $e) { $this->error($e); } if ($sendBuffer === '') { @@ -605,7 +604,6 @@ public function pauseRecv(): void * Resumes reading after a call to pauseRecv. * * @return void - * @throws Throwable */ public function resumeRecv(): void { @@ -623,7 +621,6 @@ public function resumeRecv(): void * @param resource $socket * @param bool $checkEof * @return void - * @throws Throwable */ public function baseRead($socket, bool $checkEof = true): void { @@ -764,7 +761,6 @@ public function baseRead($socket, bool $checkEof = true): void * Base write handler. * * @return void - * @throws Throwable */ public function baseWrite(): void { @@ -811,7 +807,6 @@ public function baseWrite(): void * * @param resource $socket * @return bool|int - * @throws Throwable */ public function doSslHandshake($socket): bool|int { @@ -898,7 +893,6 @@ public function consumeRecvBuffer(int $length): void * @param mixed $data * @param bool $raw * @return void - * @throws Throwable */ public function close(mixed $data = null, bool $raw = false): void { @@ -964,7 +958,6 @@ public function getSocket() * Check whether send buffer will be full. * * @return void - * @throws Throwable */ protected function checkBufferWillFull(): void { @@ -981,7 +974,6 @@ protected function checkBufferWillFull(): void * Whether send buffer is full. * * @return bool - * @throws Throwable */ protected function bufferIsFull(): bool { @@ -1013,7 +1005,6 @@ public function bufferIsEmpty(): bool * Destroy connection. * * @return void - * @throws Throwable */ public function destroy(): void { @@ -1101,7 +1092,6 @@ public function jsonSerialize(): array * Destruct. * * @return void - * @throws Throwable */ public function __destruct() { diff --git a/src/Events/Select.php b/src/Events/Select.php index 95f2fa77..8467f6bf 100644 --- a/src/Events/Select.php +++ b/src/Events/Select.php @@ -16,6 +16,8 @@ namespace Workerman\Events; +use SplPriorityQueue; +use Throwable; use function count; use function max; use function microtime; @@ -86,9 +88,9 @@ final class Select implements EventInterface * Timer scheduler. * {['data':timer_id, 'priority':run_timestamp], ..} * - * @var \SplPriorityQueue + * @var SplPriorityQueue */ - private \SplPriorityQueue $scheduler; + private SplPriorityQueue $scheduler; /** * All timer event listeners. @@ -122,8 +124,8 @@ final class Select implements EventInterface */ public function __construct() { - $this->scheduler = new \SplPriorityQueue(); - $this->scheduler->setExtractFlags(\SplPriorityQueue::EXTR_BOTH); + $this->scheduler = new SplPriorityQueue(); + $this->scheduler->setExtractFlags(SplPriorityQueue::EXTR_BOTH); } /** @@ -299,7 +301,6 @@ public function offSignal(int $signal): bool * Tick for timer. * * @return void - * @throws \Throwable */ protected function tick(): void { @@ -349,8 +350,8 @@ protected function tick(): void */ public function deleteAllTimer(): void { - $this->scheduler = new \SplPriorityQueue(); - $this->scheduler->setExtractFlags(\SplPriorityQueue::EXTR_BOTH); + $this->scheduler = new SplPriorityQueue(); + $this->scheduler->setExtractFlags(SplPriorityQueue::EXTR_BOTH); $this->eventTimer = []; } @@ -367,7 +368,7 @@ public function run(): void // Waiting read/write/signal/timeout events. try { @stream_select($read, $write, $except, 0, $this->selectTimeout); - } catch (\Throwable) { + } catch (Throwable) { // do nothing } } else { @@ -450,7 +451,7 @@ private function safeCall(callable $func, array $args = []): void { try { $func(...$args); - } catch (\Throwable $e) { + } catch (Throwable $e) { if ($this->errorHandler === null) { echo $e; } else { diff --git a/src/Protocols/Http.php b/src/Protocols/Http.php index 5eb3f095..ddc1ccfe 100644 --- a/src/Protocols/Http.php +++ b/src/Protocols/Http.php @@ -86,7 +86,7 @@ public static function requestClass(?string $className = null): string * * @param bool $value */ - public static function enableCache(bool $value) + public static function enableCache(bool $value): void { static::$enableCache = $value; } @@ -97,7 +97,6 @@ public static function enableCache(bool $value) * @param string $buffer * @param TcpConnection $connection * @return int - * @throws Throwable */ public static function input(string $buffer, TcpConnection $connection): int { @@ -194,7 +193,6 @@ public static function decode(string $buffer, TcpConnection $connection): Reques * @param string|Response $response * @param TcpConnection $connection * @return string - * @throws Throwable */ public static function encode(mixed $response, TcpConnection $connection): string { @@ -266,7 +264,6 @@ public static function encode(mixed $response, TcpConnection $connection): strin * @param resource $handler * @param int $offset * @param int $length - * @throws Throwable */ protected static function sendStream(TcpConnection $connection, $handler, int $offset = 0, int $length = 0): void { diff --git a/src/Protocols/Http/Request.php b/src/Protocols/Http/Request.php index 7cc3ab0d..b2331c5a 100644 --- a/src/Protocols/Http/Request.php +++ b/src/Protocols/Http/Request.php @@ -226,7 +226,7 @@ public function cookie(string $name = null, mixed $default = null): mixed $mapped = array(); foreach ($cookies as $cookie) { - $cookie = explode('=', $cookie); + $cookie = explode('=', $cookie, 2); if (count($cookie) !== 2) { continue; } @@ -678,7 +678,7 @@ protected function parseUploadFile(string $boundary, int $sectionStartOffset, st break; case "webkitrelativepath": - $file['full_path'] = \trim($value); + $file['full_path'] = trim($value); break; } } diff --git a/src/Protocols/Http/Session.php b/src/Protocols/Http/Session.php index c463630e..5d92f0b8 100644 --- a/src/Protocols/Http/Session.php +++ b/src/Protocols/Http/Session.php @@ -17,6 +17,7 @@ namespace Workerman\Protocols\Http; use Exception; +use Random\RandomException; use RuntimeException; use Workerman\Protocols\Http\Session\FileSessionHandler; use Workerman\Protocols\Http\Session\SessionHandlerInterface; @@ -153,7 +154,7 @@ class Session * * @var bool */ - protected $isSafe = true; + protected bool $isSafe = true; /** * Session constructor. @@ -437,7 +438,7 @@ public function __wakeup() * __destruct. * * @return void - * @throws Exception + * @throws RandomException */ public function __destruct() { diff --git a/src/Protocols/Websocket.php b/src/Protocols/Websocket.php index f4d08661..bf31ad46 100644 --- a/src/Protocols/Websocket.php +++ b/src/Protocols/Websocket.php @@ -16,7 +16,6 @@ namespace Workerman\Protocols; -use Exception; use Throwable; use Workerman\Connection\ConnectionInterface; use Workerman\Connection\TcpConnection; @@ -24,8 +23,11 @@ use Workerman\Worker; use function base64_encode; use function chr; +use function deflate_add; +use function deflate_init; use function floor; -use function gettype; +use function inflate_add; +use function inflate_init; use function is_scalar; use function ord; use function pack; @@ -37,6 +39,8 @@ use function strpos; use function substr; use function unpack; +use const ZLIB_DEFAULT_STRATEGY; +use const ZLIB_ENCODING_RAW; /** * WebSocket protocol. @@ -77,7 +81,6 @@ class Websocket * @param string $buffer * @param TcpConnection $connection * @return int - * @throws Throwable */ public static function input(string $buffer, TcpConnection $connection): int { @@ -256,19 +259,18 @@ public static function input(string $buffer, TcpConnection $connection): int * @param mixed $buffer * @param TcpConnection $connection * @return string - * @throws Throwable */ public static function encode(mixed $buffer, TcpConnection $connection): string { if (!is_scalar($buffer)) { - throw new Exception("You can't send(" . gettype($buffer) . ") to client, you need to convert it to string. "); + $buffer = json_encode($buffer, JSON_UNESCAPED_UNICODE); } if (empty($connection->websocketType)) { $connection->websocketType = static::BINARY_TYPE_BLOB; } - if (\ord($connection->websocketType) & 64) { + if (ord($connection->websocketType) & 64) { $buffer = static::deflate($connection, $buffer); } @@ -372,23 +374,23 @@ public static function decode(string $buffer, TcpConnection $connection): string * @param bool $isFinFrame * @return false|string */ - protected static function inflate(TcpConnection $connection, string $buffer, bool $isFinFrame) + protected static function inflate(TcpConnection $connection, string $buffer, bool $isFinFrame): bool|string { if (!isset($connection->context->inflator)) { - $connection->context->inflator = \inflate_init( - \ZLIB_ENCODING_RAW, + $connection->context->inflator = inflate_init( + ZLIB_ENCODING_RAW, [ 'level' => -1, 'memory' => 8, 'window' => 15, - 'strategy' => \ZLIB_DEFAULT_STRATEGY + 'strategy' => ZLIB_DEFAULT_STRATEGY ] ); } if ($isFinFrame) { $buffer .= "\x00\x00\xff\xff"; } - return \inflate_add($connection->context->inflator, $buffer); + return inflate_add($connection->context->inflator, $buffer); } /** @@ -398,20 +400,20 @@ protected static function inflate(TcpConnection $connection, string $buffer, boo * @param string $buffer * @return false|string */ - protected static function deflate(TcpConnection $connection, string $buffer) + protected static function deflate(TcpConnection $connection, string $buffer): bool|string { if (!isset($connection->context->deflator)) { - $connection->context->deflator = \deflate_init( - \ZLIB_ENCODING_RAW, + $connection->context->deflator = deflate_init( + ZLIB_ENCODING_RAW, [ 'level' => -1, 'memory' => 8, 'window' => 15, - 'strategy' => \ZLIB_DEFAULT_STRATEGY + 'strategy' => ZLIB_DEFAULT_STRATEGY ] ); } - return \substr(\deflate_add($connection->context->deflator, $buffer), 0, -4); + return substr(deflate_add($connection->context->deflator, $buffer), 0, -4); } /** @@ -420,7 +422,6 @@ protected static function deflate(TcpConnection $connection, string $buffer) * @param string $buffer * @param TcpConnection $connection * @return int - * @throws Throwable */ public static function dealHandshake(string $buffer, TcpConnection $connection): int { diff --git a/src/Protocols/Ws.php b/src/Protocols/Ws.php index 565f8476..91c4e079 100644 --- a/src/Protocols/Ws.php +++ b/src/Protocols/Ws.php @@ -16,7 +16,6 @@ namespace Workerman\Protocols; -use Exception; use Throwable; use Workerman\Connection\AsyncTcpConnection; use Workerman\Connection\ConnectionInterface; @@ -25,10 +24,8 @@ use Workerman\Worker; use function base64_encode; use function bin2hex; +use function explode; use function floor; -use function gettype; -use function is_array; -use function is_scalar; use function ord; use function pack; use function preg_match; @@ -65,7 +62,6 @@ class Ws * @param string $buffer * @param AsyncTcpConnection $connection * @return int|false - * @throws Throwable */ public static function input(string $buffer, AsyncTcpConnection $connection): bool|int { @@ -393,7 +389,6 @@ public static function sendHandshake(AsyncTcpConnection $connection): void * @param string $buffer * @param AsyncTcpConnection $connection * @return bool|int - * @throws Throwable */ public static function dealHandshake(string $buffer, AsyncTcpConnection $connection): bool|int { @@ -455,9 +450,9 @@ public static function dealHandshake(string $buffer, AsyncTcpConnection $connect */ protected static function parseResponse(string $buffer): Response { - [$http_header, ] = \explode("\r\n\r\n", $buffer, 2); - $header_data = \explode("\r\n", $http_header); - [$protocol, $status, $phrase] = \explode(' ', $header_data[0], 3); + [$http_header, ] = explode("\r\n\r\n", $buffer, 2); + $header_data = explode("\r\n", $http_header); + [$protocol, $status, $phrase] = explode(' ', $header_data[0], 3); $protocolVersion = substr($protocol, 5); unset($header_data[0]); $headers = []; @@ -466,8 +461,8 @@ protected static function parseResponse(string $buffer): Response if (empty($content)) { continue; } - list($key, $value) = \explode(':', $content, 2); - $value = \trim($value); + list($key, $value) = explode(':', $content, 2); + $value = trim($value); $headers[$key] = $value; } return (new Response())->withStatus((int)$status, $phrase)->withHeaders($headers)->withProtocolVersion($protocolVersion); diff --git a/src/Worker.php b/src/Worker.php index 2c37b494..9663b0b7 100644 --- a/src/Worker.php +++ b/src/Worker.php @@ -21,6 +21,7 @@ use Revolt\EventLoop; use RuntimeException; use stdClass; +use Stringable; use Throwable; use Workerman\Connection\ConnectionInterface; use Workerman\Connection\TcpConnection; @@ -30,6 +31,9 @@ use Workerman\Events\Revolt; use Workerman\Events\Select; use Workerman\Protocols\ProtocolInterface; +use function defined; +use function function_exists; +use function is_resource; use function method_exists; use function restore_error_handler; use function set_error_handler; @@ -38,6 +42,10 @@ use function substr; use function array_walk; use function get_class; +use const DIRECTORY_SEPARATOR; +use const PHP_SAPI; +use const PHP_VERSION; +use const STDOUT; /** * Worker class @@ -368,14 +376,6 @@ class Worker */ protected string $socketName = ''; - /** - * parse from socketName avoid parse again in master or worker - * LocalSocket The format is like tcp://0.0.0.0:8080 - * - * @var ?string - */ - protected ?string $localSocket = null; - /** * Context of socket. * @@ -566,7 +566,6 @@ class Worker * Run all worker instances. * * @return void - * @throws Throwable */ public static function runAll(): void { @@ -585,7 +584,7 @@ public static function runAll(): void static::forkWorkers(); static::resetStd(); static::monitorWorkers(); - } catch (\Throwable $e) { + } catch (Throwable $e) { static::log($e); } } @@ -598,19 +597,19 @@ public static function runAll(): void protected static function checkSapiEnv(): void { // Only for cli and micro. - if (!in_array(\PHP_SAPI, ['cli', 'micro'])) { + if (!in_array(PHP_SAPI, ['cli', 'micro'])) { exit("Only run in command line mode\n"); } } private static function initStdOut(): void { - $defaultStream = fn () => \defined('STDOUT') ? \STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w')); + $defaultStream = fn () => defined('STDOUT') ? STDOUT : (@fopen('php://stdout', 'w') ?: fopen('php://output', 'w')); static::$outputStream ??= $defaultStream(); //@phpstan-ignore-line - if (!\is_resource(self::$outputStream) || get_resource_type(self::$outputStream) !== 'stream') { + if (!is_resource(self::$outputStream) || get_resource_type(self::$outputStream) !== 'stream') { $type = get_debug_type(self::$outputStream); static::$outputStream = $defaultStream(); - throw new \RuntimeException(sprintf('The $outputStream must to be a stream, %s given', $type)); + throw new RuntimeException(sprintf('The $outputStream must to be a stream, %s given', $type)); } static::$outputDecorated ??= self::hasColorSupport(); @@ -631,8 +630,8 @@ private static function hasColorSupport(): bool return true; } - if (\DIRECTORY_SEPARATOR === '\\') { - return (\function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(self::$outputStream)) + if (DIRECTORY_SEPARATOR === '\\') { + return (function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support(self::$outputStream)) || getenv('ANSICON') !== false || getenv('ConEmuANSI') === 'ON' || getenv('TERM') === 'xterm'; @@ -755,7 +754,6 @@ protected static function lock(int $flag = LOCK_EX): void * Init All worker instances. * * @return void - * @throws Exception */ protected static function initWorkers(): void { @@ -871,7 +869,7 @@ protected static function displayUI(): void $jitStatus = function_exists('opcache_get_status') && (opcache_get_status()['jit']['on'] ?? false) === true ? 'on' : 'off'; if (DIRECTORY_SEPARATOR !== '/') { static::safeEcho("---------------------------------------------- WORKERMAN -----------------------------------------------\r\n"); - static::safeEcho('Workerman version:'. static::VERSION. ' PHP version:'. \PHP_VERSION . " (Jit $jitStatus)\r\n"); + static::safeEcho('Workerman version:'. static::VERSION. ' PHP version:'. PHP_VERSION . " (Jit $jitStatus)\r\n"); static::safeEcho("----------------------------------------------- WORKERS ------------------------------------------------\r\n"); static::safeEcho("worker listen processes status\r\n"); return; @@ -1244,7 +1242,6 @@ protected static function installSignal(): void * Reinstall signal handler. * * @return void - * @throws Throwable */ protected static function reinstallSignal(): void { @@ -1262,7 +1259,6 @@ protected static function reinstallSignal(): void * Signal handler. * * @param int $signal - * @throws Throwable */ protected static function signalHandler(int $signal): void { @@ -1303,8 +1299,6 @@ protected static function signalHandler(int $signal): void /** * Run as daemon mode. - * - * @throws Exception */ protected static function daemonize(): void { @@ -1373,8 +1367,6 @@ public static function resetStd(): void /** * Save pid. - * - * @throws Exception */ protected static function saveMasterPid(): void { @@ -1418,7 +1410,6 @@ protected static function getAllWorkerPids(): array * Fork some worker processes. * * @return void - * @throws Throwable */ protected static function forkWorkers(): void { @@ -1433,7 +1424,6 @@ protected static function forkWorkers(): void * Fork some worker processes. * * @return void - * @throws Throwable */ protected static function forkWorkersForLinux(): void { @@ -1458,7 +1448,6 @@ protected static function forkWorkersForLinux(): void * Fork some worker processes. * * @return void - * @throws Throwable */ protected static function forkWorkersForWindows(): void { @@ -1509,7 +1498,7 @@ protected static function forkWorkersForWindows(): void $worker->run(); static::$globalEvent->run(); if (static::$status !== self::STATUS_SHUTDOWN) { - $err = new Exception('event-loop exited'); + $err = new RuntimeException('event-loop exited'); static::log($err); exit(250); } @@ -1589,7 +1578,6 @@ protected static function checkWorkerStatusForWindows(): void * Fork one worker process. * * @param self $worker - * @throws Exception|Throwable */ protected static function forkOneWorkerForLinux(self $worker): void { @@ -1736,7 +1724,6 @@ protected static function monitorWorkers(): void * Monitor all child processes. * * @return void - * @throws Throwable */ protected static function monitorWorkersForLinux(): void { @@ -1810,7 +1797,6 @@ protected static function monitorWorkersForLinux(): void * Monitor all child processes. * * @return void - * @throws Throwable */ protected static function monitorWorkersForWindows(): void { @@ -1844,7 +1830,6 @@ protected static function exitAndClearAll(): void * Execute reload. * * @return void - * @throws Throwable */ protected static function reload(): void { @@ -1923,7 +1908,6 @@ protected static function reload(): void * * @param int $code * @param mixed $log - * @throws Throwable */ public static function stopAll(int $code = 0, mixed $log = ''): void { @@ -1966,7 +1950,7 @@ public static function stopAll(int $code = 0, mixed $log = ''): void // Ignore Swoole ExitException: Swoole exit. exit($code); /** @phpstan-ignore-next-line */ - } catch (\Exception) { + } catch (Throwable) { // do nothing } } @@ -2202,11 +2186,11 @@ protected static function getErrorType(int $type): string /** * Log. * - * @param \Stringable|string $msg + * @param Stringable|string $msg * @param bool $decorated * @return void */ - public static function log(\Stringable|string $msg, bool $decorated = false): void + public static function log(Stringable|string $msg, bool $decorated = false): void { $msg = trim((string)$msg); @@ -2298,8 +2282,6 @@ public function __construct(string $socketName = null, array $socketContext = [] /** * Listen. - * - * @throws Exception */ public function listen(): void { @@ -2323,7 +2305,7 @@ public function listen(): void // Create an Internet or Unix domain server socket. $this->mainSocket = stream_socket_server($localSocket, $errno, $errmsg, $flags, $this->socketContext); if (!$this->mainSocket) { - throw new Exception($errmsg); + throw new RuntimeException($errmsg); } if ($this->transport === 'ssl') { @@ -2372,8 +2354,6 @@ public function unlisten(): void /** * Parse local socket address. - * - * @throws Exception */ protected function parseSocketAddress(): ?string { @@ -2448,7 +2428,6 @@ public function getSocketName(): string * Run worker instance. * * @return void - * @throws Throwable */ public function run(): void { @@ -2470,7 +2449,6 @@ public function run(): void * Stop current worker instance. * * @return void - * @throws Throwable */ public function stop(): void { @@ -2509,7 +2487,6 @@ public function stop(): void * * @param resource $socket * @return void - * @throws Throwable */ protected function acceptTcpConnection(mixed $socket): void { @@ -2550,7 +2527,6 @@ protected function acceptTcpConnection(mixed $socket): void * * @param resource $socket * @return void - * @throws Throwable */ protected function acceptUdpConnection(mixed $socket): void {