Apply automated PHP8 safety transforms

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/89922108-1604-44ae-949d-358d32b9d70a

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-04-23 14:01:37 +00:00 committed by GitHub
parent aca850b6cd
commit e44519c030
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
465 changed files with 1716 additions and 1716 deletions

View file

@ -109,7 +109,7 @@ class TeamSpeak3_Adapter_Blacklist extends TeamSpeak3_Adapter_Abstract
$repl = $this->getTransport()->read(1);
$this->getTransport()->disconnect();
if(!count($repl))
if(!count((array)$repl))
{
return FALSE;
}

View file

@ -141,7 +141,7 @@ class TeamSpeak3_Adapter_FileTransfer extends TeamSpeak3_Adapter_Abstract
$size = intval($size);
$pack = 4096;
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count($buff), $size);
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadStarted", $ftkey, count((array)$buff), $size);
for($seek = 0;$seek < $size;)
{
@ -152,16 +152,16 @@ class TeamSpeak3_Adapter_FileTransfer extends TeamSpeak3_Adapter_Abstract
$buff->append($data);
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count($buff), $size);
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadProgress", $ftkey, count((array)$buff), $size);
}
$this->getProfiler()->stop();
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count($buff), $size);
TeamSpeak3_Helper_Signal::getInstance()->emit("filetransferDownloadFinished", $ftkey, count((array)$buff), $size);
if(strlen($buff) != $size)
{
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file download (" . count($buff) . " of " . $size . " bytes)");
throw new TeamSpeak3_Adapter_FileTransfer_Exception("incomplete file download (" . count((array)$buff) . " of " . $size . " bytes)");
}
return $buff;

View file

@ -176,7 +176,7 @@ class TeamSpeak3_Adapter_ServerQuery extends TeamSpeak3_Adapter_Abstract
$args = array();
$cells = array();
foreach($params as $ident => $value)
foreach ((array)$params as $ident => $value)
{
$ident = is_numeric($ident) ? "" : strtolower($ident) . TeamSpeak3::SEPARATOR_PAIR;
@ -184,7 +184,7 @@ class TeamSpeak3_Adapter_ServerQuery extends TeamSpeak3_Adapter_Abstract
{
$value = array_values($value);
for($i = 0; $i < count($value); $i++)
for($i = 0; $i < count((array)$value); $i++)
{
if($value[$i] === null) continue;
elseif($value[$i] === FALSE) $value[$i] = 0x00;
@ -207,8 +207,8 @@ class TeamSpeak3_Adapter_ServerQuery extends TeamSpeak3_Adapter_Abstract
foreach(array_keys($cells) as $ident) $cells[$ident] = implode(TeamSpeak3::SEPARATOR_CELL, $cells[$ident]);
if(count($args)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_CELL, $args);
if(count($cells)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_LIST, $cells);
if(count((array)$args)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_CELL, $args);
if(count((array)$cells)) $cmd .= " " . implode(TeamSpeak3::SEPARATOR_LIST, $cells);
return trim($cmd);
}

View file

@ -112,7 +112,7 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
if(!func_num_args())
{
for($i = 0; $i < count($list); $i++) $list[$i]->unescape();
for($i = 0; $i < count((array)$list); $i++) $list[$i]->unescape();
}
return $list;
@ -133,7 +133,7 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
if(!func_num_args())
{
for($i = 0; $i < count($pairs); $i++) $pairs[$i]->unescape();
for($i = 0; $i < count((array)$pairs); $i++) $pairs[$i]->unescape();
}
$table[] = $pairs;
@ -152,11 +152,11 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
$array = array();
$table = $this->toTable(1);
for($i = 0; $i < count($table); $i++)
for($i = 0; $i < count((array)$table); $i++)
{
foreach($table[$i] as $pair)
foreach ((array)$table[$i] as $pair)
{
if(!count($pair))
if(!count((array)$pair))
{
continue;
}
@ -189,7 +189,7 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
$nodes = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();
$array = array();
foreach($nodes as $node)
foreach ((array)$nodes as $node)
{
if(isset($node[$ident]))
{
@ -213,7 +213,7 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
{
$array = func_num_args() ? $this->toArray(1) : $this->toArray();
if(count($array) == 1)
if(count((array)$array) == 1)
{
return array_shift($array);
}
@ -230,7 +230,7 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
{
$array = (func_num_args() > 1) ? $this->toArray(1) : $this->toArray();
for($i = 0; $i < count($array); $i++)
for($i = 0; $i < count((array)$array); $i++)
{
$array[$i] = (object) $array[$i];
}
@ -325,7 +325,7 @@ class TeamSpeak3_Adapter_ServerQuery_Reply
*/
protected function fetchReply($rpl)
{
foreach($rpl as $key => $val)
foreach ((array)$rpl as $key => $val)
{
if($val->startsWith(TeamSpeak3::TS3_MOTD_PREFIX) || $val->startsWith(TeamSpeak3::TEA_MOTD_PREFIX) || (defined("CUSTOM_MOTD_PREFIX") && $val->startsWith(CUSTOM_MOTD_PREFIX)))
{

View file

@ -255,7 +255,7 @@ class TeamSpeak3_Helper_Convert
$parts = explode("|", $entry, 5);
$array = array();
if(count($parts) != 5)
if(count((array)$parts) != 5)
{
$array["timestamp"] = 0;
$array["level"] = TeamSpeak3::LOGLEVEL_ERROR;
@ -324,7 +324,7 @@ class TeamSpeak3_Helper_Convert
$buildno = $version->section("[", 1)->filterDigits()->toInt();
return ($buildno <= 15001) ? $version : $version->section("[")->append("(" . date($format, $buildno) . ")");
return ($buildno <= 15001) ? $version : $version->section("[")->append("(" . date($format, is_numeric($buildno) ? (int)$buildno : strtotime($buildno)) . ")");
}
/**
@ -365,6 +365,6 @@ class TeamSpeak3_Helper_Convert
6 => "image/x-ilbm",
);
return $type[count($matches)-1];
return $type[count((array)$matches)-1];
}
}

View file

@ -95,7 +95,7 @@ class TeamSpeak3_Helper_String implements ArrayAccess, Iterator, Countable, Json
{
$args = array_reverse($args, TRUE);
foreach($args as $key => $val)
foreach ((array)$args as $key => $val)
{
$args[$char . $key] = $val;
unset($args[$key]);
@ -219,7 +219,7 @@ class TeamSpeak3_Helper_String implements ArrayAccess, Iterator, Countable, Json
{
$parts = explode($separator, $this->string, ($limit) ? intval($limit) : $this->count());
foreach($parts as $key => $val)
foreach ((array)$parts as $key => $val)
{
$parts[$key] = new self($val);
}
@ -265,7 +265,7 @@ class TeamSpeak3_Helper_String implements ArrayAccess, Iterator, Countable, Json
{
$sections = explode($separator, $this->string);
$total = count($sections);
$total = count((array)$sections);
$first = intval($first);
$last = intval($last);
@ -505,7 +505,7 @@ class TeamSpeak3_Helper_String implements ArrayAccess, Iterator, Countable, Json
{
$hex = "";
foreach($this as $char)
foreach ((array)$this as $char)
{
$hex .= $char->toHex();
}
@ -810,7 +810,7 @@ class TeamSpeak3_Helper_String implements ArrayAccess, Iterator, Countable, Json
throw new TeamSpeak3_Helper_Exception("cannot call undefined function '" . $function . "' on this object");
}
if(count($args))
if(count((array)$args))
{
if(($key = array_search($this, $args, TRUE)) !== FALSE)
{

View file

@ -519,7 +519,7 @@ class TeamSpeak3_Helper_Uri
parse_str($this->query, $queryArray);
return array_key_exists($key, $queryArray) ? TRUE : FALSE;
return array_key_exists($key, (array)$queryArray) ? TRUE : FALSE;
}
/**
@ -535,7 +535,7 @@ class TeamSpeak3_Helper_Uri
parse_str(rawurldecode($this->query), $queryArray);
if(array_key_exists($key, $queryArray))
if(array_key_exists($key, (array)$queryArray))
{
$val = $queryArray[$key];
@ -616,7 +616,7 @@ class TeamSpeak3_Helper_Uri
*/
public static function getUserParam($key, $default = null)
{
return (array_key_exists($key, $_REQUEST) && !empty($_REQUEST[$key])) ? self::stripslashesRecursive($_REQUEST[$key]) : $default;
return (array_key_exists($key, (array)$_REQUEST) && !empty($_REQUEST[$key])) ? self::stripslashesRecursive($_REQUEST[$key]) : $default;
}
/**
@ -628,7 +628,7 @@ class TeamSpeak3_Helper_Uri
*/
public static function getHostParam($key, $default = null)
{
return (array_key_exists($key, $_SERVER) && !empty($_SERVER[$key])) ? $_SERVER[$key] : $default;
return (array_key_exists($key, (array)$_SERVER) && !empty($_SERVER[$key])) ? $_SERVER[$key] : $default;
}
/**
@ -640,7 +640,7 @@ class TeamSpeak3_Helper_Uri
*/
public static function getSessParam($key, $default = null)
{
return (array_key_exists($key, $_SESSION) && !empty($_SESSION[$key])) ? $_SESSION[$key] : $default;
return (array_key_exists($key, (array)$_SESSION) && !empty($_SESSION[$key])) ? $_SESSION[$key] : $default;
}
/**
@ -710,7 +710,7 @@ class TeamSpeak3_Helper_Uri
return stripslashes(strval($var));
}
foreach($var as $key => $val)
foreach ((array)$var as $key => $val)
{
$var[$key] = (is_array($val)) ? stripslashesRecursive($val) : stripslashes(strval($val));
}

View file

@ -192,7 +192,7 @@ abstract class TeamSpeak3_Node_Abstract implements RecursiveIterator, ArrayAcces
$iterator = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::SELF_FIRST);
foreach($iterator as $node)
foreach ((array)$iterator as $node)
{
$siblings = array();
@ -225,14 +225,14 @@ abstract class TeamSpeak3_Node_Abstract implements RecursiveIterator, ArrayAcces
{
if(!empty($rules))
{
foreach($nodes as $node)
foreach ((array)$nodes as $node)
{
if(!$node instanceof TeamSpeak3_Node_Abstract) continue;
$props = $node->getInfo(FALSE);
$props = array_intersect_key($props, $rules);
foreach($props as $key => $val)
foreach ((array)$props as $key => $val)
{
if($val instanceof TeamSpeak3_Helper_String)
{
@ -273,7 +273,7 @@ abstract class TeamSpeak3_Node_Abstract implements RecursiveIterator, ArrayAcces
{
$info = $this->nodeInfo;
foreach($info as $key => $val)
foreach ((array)$info as $key => $val)
{
$key = TeamSpeak3_Helper_String::factory($key);

View file

@ -186,7 +186,7 @@ class TeamSpeak3_Node_Channelgroup extends TeamSpeak3_Node_Abstract
*/
public function message($msg)
{
foreach($this as $client)
foreach ((array)$this as $client)
{
try
{

View file

@ -425,7 +425,7 @@ class TeamSpeak3_Node_Host extends TeamSpeak3_Node_Abstract
$this->serverList = array();
foreach($servers as $sid => $server)
foreach ((array)$servers as $sid => $server)
{
$this->serverList[$sid] = new TeamSpeak3_Node_Server($this, $server);
}
@ -931,7 +931,7 @@ class TeamSpeak3_Node_Host extends TeamSpeak3_Node_Abstract
{
$servers = $this->serverList();
foreach($servers as $server)
foreach ((array)$servers as $server)
{
$this->nodeList[] = $server;
}
@ -959,9 +959,9 @@ class TeamSpeak3_Node_Host extends TeamSpeak3_Node_Abstract
$this->permissionEnds = array();
$this->permissionList = array();
foreach($reply as $line)
foreach ((array)$reply as $line)
{
if(array_key_exists("group_id_end", $line))
if(array_key_exists("group_id_end", (array)$line))
{
$this->permissionEnds[] = $line["group_id_end"];
}

View file

@ -101,7 +101,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$this->channelList = array();
foreach($channels as $cid => $channel)
foreach ((array)$channels as $cid => $channel)
{
$this->channelList[$cid] = new TeamSpeak3_Node_Channel($this, $channel);
}
@ -477,7 +477,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
public function channelFileList($cid, $cpw = "", $path = "/", $recursive = FALSE)
{
$files = $this->execute("ftgetfilelist", array("cid" => $cid, "cpw" => $cpw, "path" => $path))->toArray();
$count = count($files);
$count = count((array)$files);
for($i = 0; $i < $count; $i++)
{
@ -648,7 +648,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$this->clientList = array();
foreach($clients as $clid => $client)
foreach ((array)$clients as $clid => $client)
{
if($this->getParent()->getExcludeQueryClients() && $client["client_type"]) continue;
@ -1101,7 +1101,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$this->serverGroupRename($tsgid, $name);
}
return count($sgid) ? $sgid["sgid"] : intval($tsgid);
return count((array)$sgid) ? $sgid["sgid"] : intval($tsgid);
}
/**
@ -1322,7 +1322,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$grant = null;
}
foreach($perms as $permsid => $perm)
foreach ((array)$perms as $permsid => $perm)
{
if(in_array($permsid, array_keys($profiles[$sgid])))
{
@ -1429,7 +1429,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$this->channelGroupRename($tcgid, $name);
}
return count($cgid) ? $cgid["cgid"] : intval($tcgid);
return count((array)$cgid) ? $cgid["cgid"] : intval($tcgid);
}
/**
@ -1585,7 +1585,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
if($resolve)
{
foreach($result as $k => $v)
foreach ((array)$result as $k => $v)
{
$result[$k] = array_merge($v, $this->clientInfoDb($v["cldbid"]));
}
@ -1620,7 +1620,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
{
$assignments = $this->permissionFind($permid);
foreach($assignments as $assignment)
foreach ((array)$assignments as $assignment)
{
switch($assignment["t"])
{
@ -1649,7 +1649,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
}
}
return count($assignments);
return count((array)$assignments);
}
/**
@ -1669,7 +1669,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
{
$upload = $this->execute("ftinitupload", array("clientftfid" => $clientftfid, "cid" => $cid, "name" => $name, "cpw" => $cpw, "size" => $size, "overwrite" => $overwrite, "resume" => $resume))->toList();
if(array_key_exists("status", $upload) && $upload["status"] != 0x00)
if(array_key_exists("status", (array)$upload) && $upload["status"] != 0x00)
{
throw new TeamSpeak3_Adapter_ServerQuery_Exception($upload["msg"], $upload["status"]);
}
@ -1677,7 +1677,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$upload["cid"] = $cid;
$upload["file"] = $name;
if(!array_key_exists("ip", $upload) || $upload["ip"]->startsWith("0.0.0.0"))
if(!array_key_exists("ip", (array)$upload) || $upload["ip"]->startsWith("0.0.0.0"))
{
$upload["ip"] = $this->getParent()->getAdapterHost();
$upload["host"] = $upload["ip"];
@ -1708,7 +1708,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
{
$download = $this->execute("ftinitdownload", array("clientftfid" => $clientftfid, "cid" => $cid, "name" => $name, "cpw" => $cpw, "seekpos" => $seekpos))->toList();
if(array_key_exists("status", $download) && $download["status"] != 0x00)
if(array_key_exists("status", (array)$download) && $download["status"] != 0x00)
{
throw new TeamSpeak3_Adapter_ServerQuery_Exception($download["msg"], $download["status"]);
}
@ -1716,7 +1716,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
$download["cid"] = $cid;
$download["file"] = $name;
if(!array_key_exists("ip", $download) || $download["ip"]->startsWith("0.0.0.0"))
if(!array_key_exists("ip", (array)$download) || $download["ip"]->startsWith("0.0.0.0"))
{
$download["ip"] = $this->getParent()->getAdapterHost();
$download["host"] = $download["ip"];
@ -1984,7 +1984,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
if($resolve)
{
foreach($tokens as $token => $array)
foreach ((array)$tokens as $token => $array)
{
$func = $array["token_type"] ? "channelGroupGetById" : "serverGroupGetById";
@ -2242,7 +2242,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
if($resolve)
{
foreach($passwords as $password => $array)
foreach ((array)$passwords as $password => $array)
{
try
{
@ -2380,7 +2380,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
{
$this->execute("clientupdate", $properties);
foreach($properties as $ident => $value)
foreach ((array)$properties as $ident => $value)
{
$this->whoamiSet($ident, $value);
}
@ -2514,7 +2514,7 @@ class TeamSpeak3_Node_Server extends TeamSpeak3_Node_Abstract
*/
protected static function sortFileList(array $a, array $b)
{
if(!array_key_exists("src", $a) || !array_key_exists("src", $b) || !array_key_exists("type", $a) || !array_key_exists("type", $b))
if(!array_key_exists("src", (array)$a) || !array_key_exists("src", (array)$b) || !array_key_exists("type", (array)$a) || !array_key_exists("type", (array)$b))
{
return 0;

View file

@ -207,7 +207,7 @@ class TeamSpeak3_Node_Servergroup extends TeamSpeak3_Node_Abstract
*/
public function message($msg)
{
foreach($this as $client)
foreach ((array)$this as $client)
{
try
{

View file

@ -77,11 +77,11 @@ if(isset($server_home['control_password']) && $server_home['control_password'] !
$ts3['ip'] = $cfg["host"];
$ts3['port'] = $cfg["voice"];
$clients = $ts3_ServerInstance->clientList();
$ts3['players'] = count($clients);
$ts3['players'] = count((array)$clients);
if( $ts3['players'] >= 1 )
{
$i=0;
foreach($clients as $key => $value)
foreach ((array)$clients as $key => $value)
{
/* $playerarray[$i]= */
$ts3['playersList'][$i]['name'] = trim($value);

View file

@ -490,7 +490,7 @@ class TeamSpeak3
$path = self::getFilePath($namespace);
$scan = scandir($path);
foreach($scan as $node)
foreach ((array)$scan as $node)
{
$file = TeamSpeak3_Helper_String::factory($node)->toLower();
@ -686,7 +686,7 @@ class TeamSpeak3
* $arr_ClientList = $ts3_VirtualServer->clientList(array("client_platform" => "Android"));
*
* // walk through list of clients
* foreach($arr_ClientList as $ts3_Client)
* foreach ((array)$arr_ClientList as $ts3_Client)
* {
* echo $ts3_Client . " is using " . $ts3_Client["client_platform"] . "<br />\n";
* }
@ -701,7 +701,7 @@ class TeamSpeak3
* $ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/");
*
* // walk through list of virtual servers
* foreach($ts3_ServerInstance as $ts3_VirtualServer)
* foreach ((array)$ts3_ServerInstance as $ts3_VirtualServer)
* {
* // modify the virtual servers hostbanner URL only using the ArrayAccess interface
* $ts3_VirtualServer["virtualserver_hostbanner_gfx_url"] = "http://www.example.com/banners/banner01_468x60.jpg";
@ -742,7 +742,7 @@ class TeamSpeak3
* $ts3_ServerInstance = TeamSpeak3::factory("serverquery://username:password@127.0.0.1:10011/");
*
* // walk through list of virtual servers
* foreach($ts3_ServerInstance as $ts3_VirtualServer)
* foreach ((array)$ts3_ServerInstance as $ts3_VirtualServer)
* {
* // identify the most powerful group on the virtual server
* $ts3_ServerGroup = $ts3_VirtualServer->serverGroupIdentify();

View file

@ -65,22 +65,22 @@ abstract class TeamSpeak3_Transport_Abstract
*/
public function __construct(array $config)
{
if(!array_key_exists("host", $config))
if(!array_key_exists("host", (array)$config))
{
throw new TeamSpeak3_Transport_Exception("config must have a key for 'host' which specifies the server host name");
}
if(!array_key_exists("port", $config))
if(!array_key_exists("port", (array)$config))
{
throw new TeamSpeak3_Transport_Exception("config must have a key for 'port' which specifies the server port number");
}
if(!array_key_exists("timeout", $config))
if(!array_key_exists("timeout", (array)$config))
{
$config["timeout"] = 10;
}
if(!array_key_exists("blocking", $config))
if(!array_key_exists("blocking", (array)$config))
{
$config["blocking"] = 1;
}

View file

@ -165,7 +165,7 @@ try
<option>&nbsp;</option>";
$users = $db->getUserList();
foreach ( $users as $user )
foreach ((array)$users as $user)
{
$add_remove_virtual .= "<option value='".$user['user_id']."'>".$user['users_login']."</option>\n";
}
@ -178,7 +178,7 @@ try
if($ts3vservers != 0)
{
$ts3vuserlist = "<b>TeamSpeak 3</b><br>";
foreach($ts3vservers as $ts3vserver)
foreach ((array)$ts3vservers as $ts3vserver)
{
$ts3vuser = $db->getUserById($ts3vserver['user_id']);