From f16af7dcefff67e1453b0be571451c91d0c890eb Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Fri, 3 Jan 2025 17:16:55 +0000 Subject: [PATCH] Fix PHPStan 2.x errors --- src/server/Server.php | 4 ++++ tools/proxy.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/server/Server.php b/src/server/Server.php index 359ca1d..1e749e7 100644 --- a/src/server/Server.php +++ b/src/server/Server.php @@ -30,6 +30,7 @@ use raklib\utils\ExceptionTraceCleaner; use raklib\utils\InternetAddress; use function asort; +use function assert; use function bin2hex; use function count; use function get_class; @@ -214,6 +215,9 @@ private function receivePacket() : bool{ if($buffer === null){ return false; //no data } + assert($addressIp !== null, "Can't be null if we got a buffer"); + assert($addressPort !== null, "Can't be null if we got a buffer"); + $len = strlen($buffer); $this->receiveBytes += $len; diff --git a/tools/proxy.php b/tools/proxy.php index 6ef9045..4d47658 100644 --- a/tools/proxy.php +++ b/tools/proxy.php @@ -170,6 +170,8 @@ function serverToClientRelay(ClientSession $client, ServerSocket $clientProxySoc if($buffer === null || $buffer === ""){ continue; } + assert($recvAddr !== null, "Can't be null if we got a buffer"); + assert($recvPort !== null, "Can't be null if we got a buffer"); if(isset($clients[$recvAddr][$recvPort])){ $client = $clients[$recvAddr][$recvPort]; $client->setActive();