From 928c72c5010d316c4a91d78a78d54df0359b3a76 Mon Sep 17 00:00:00 2001 From: beu Date: Mon, 19 Jan 2026 21:22:47 +0100 Subject: [PATCH] add php 8.5 support --- core/Script/ScriptManager.php | 2 +- libs/FML/Script/Script.php | 3 ++- libs/FML/Script/ScriptInclude.php | 14 +++++--------- libs/Maniaplanet/DedicatedServer/Connection.php | 4 ++-- .../Maniaplanet/DedicatedServer/Xmlrpc/Request.php | 6 +++--- libs/curl-easy/cURL/Request.php | 6 +++++- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/core/Script/ScriptManager.php b/core/Script/ScriptManager.php index f35d8137..2f623c2b 100644 --- a/core/Script/ScriptManager.php +++ b/core/Script/ScriptManager.php @@ -109,7 +109,7 @@ class ScriptManager implements UsageInformationAble { * @param boolean $status */ private function setPauseStatus($status) { - $status = (boolean) $status; + $status = (bool) $status; if ($this->modeUsesPause != $status) { $this->modeUsesPause = $status; $this->maniaControl->getCallbackManager()->triggerCallback(self::CB_PAUSE_STATUS_CHANGED, $status); diff --git a/libs/FML/Script/Script.php b/libs/FML/Script/Script.php index 57c1027c..2d77714e 100644 --- a/libs/FML/Script/Script.php +++ b/libs/FML/Script/Script.php @@ -60,8 +60,9 @@ class Script * @param string $namespace Include namespace * @return static */ - public function setScriptInclude($file, $namespace = null) + public function setScriptInclude(string|ScriptInclude $file, string $namespace = '') { + if ($file instanceof ScriptInclude) { $scriptInclude = $file; } else { diff --git a/libs/FML/Script/ScriptInclude.php b/libs/FML/Script/ScriptInclude.php index c56695e2..9927d112 100644 --- a/libs/FML/Script/ScriptInclude.php +++ b/libs/FML/Script/ScriptInclude.php @@ -21,12 +21,12 @@ class ScriptInclude /** * @var string $file File name */ - protected $file = null; + protected $file = ''; /** * @var string $namespace Namespace */ - protected $namespace = null; + protected $namespace = ''; /** * Construct a new Script Include @@ -35,14 +35,10 @@ class ScriptInclude * @param string $file (optional) File name * @param string $namespace (optional) Namespace */ - public function __construct($file = null, $namespace = null) + public function __construct(string $file = '', string $namespace = '') { - if ($file) { - $this->setFile($file); - } - if ($namespace) { - $this->setNamespace($namespace); - } + $this->setFile($file); + $this->setNamespace($namespace); } /** diff --git a/libs/Maniaplanet/DedicatedServer/Connection.php b/libs/Maniaplanet/DedicatedServer/Connection.php index 4e6cc077..d8dacf6a 100644 --- a/libs/Maniaplanet/DedicatedServer/Connection.php +++ b/libs/Maniaplanet/DedicatedServer/Connection.php @@ -23,7 +23,7 @@ class Connection /** @var int[] */ private static $levels = [ - null => -1, + '' => -1, 'User' => 0, 'Admin' => 1, 'SuperAdmin' => 2 @@ -60,7 +60,7 @@ class Connection if (!is_string($user) || !isset(self::$levels[$user])) { throw new InvalidArgumentException('user = ' . print_r($user, true)); } - if (self::$levels[$this->user] >= self::$levels[$user]) { + if ($this->user !== null && self::$levels[$this->user] >= self::$levels[$user]) { return true; } diff --git a/libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php b/libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php index a70aba86..7172467e 100755 --- a/libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php +++ b/libs/Maniaplanet/DedicatedServer/Xmlrpc/Request.php @@ -180,11 +180,11 @@ if (extension_loaded('xmlrpc')) { return (bool)(int)$elt; case 'i4': case 'int': - return (int)$elt; + return (int) $elt; case 'double': - return (double)$elt; + return (float) $elt; case 'string': - return (string)$elt; + return (string) $elt; case 'base64': return new Base64(base64_decode($elt)); case 'dateTime.iso8601': diff --git a/libs/curl-easy/cURL/Request.php b/libs/curl-easy/cURL/Request.php index 3f9cf038..e9690d1a 100644 --- a/libs/curl-easy/cURL/Request.php +++ b/libs/curl-easy/cURL/Request.php @@ -99,7 +99,11 @@ class Request extends EventDispatcher implements RequestInterface */ public function __destruct() { if (isset($this->ch)) { - curl_close($this->ch); + if (PHP_VERSION_ID >= 80000) { + unset($this->ch); + } else { + curl_close($this->ch); + } } }