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

@ -236,7 +236,7 @@ class GameQ_Buffer
{
// Get position of delimiters
$pos = array();
foreach ($delims as $delim) {
foreach ((array)$delims as $delim) {
if ($p = strpos($this->data, $delim, min($this->index, $this->length))) {
$pos[] = $p;
}

View file

@ -34,7 +34,7 @@ abstract class GameQ_Filters_Core
{
if(is_array($params))
{
foreach ($params as $key => $param)
foreach ((array)$params as $key => $param)
{
$this->params[$key] = $param;
}

View file

@ -90,12 +90,12 @@ class GameQ_Filters_Normalise extends GameQ_Filters
// Don't rename the players array
$result['players'] = $result['gq_players'];
foreach ($result['players'] as $key => $player)
foreach ((array)$result['players'] as $key => $player)
{
$result['players'][$key] = array_merge($player, $this->normalize($player, 'player'));
}
$result['gq_numplayers'] = count($result['players']);
$result['gq_numplayers'] = count((array)$result['players']);
}
else
{
@ -108,12 +108,12 @@ class GameQ_Filters_Normalise extends GameQ_Filters
// Don't rename the teams array
$result['teams'] = $result['gq_teams'];
foreach ($result['teams'] as $key => $team)
foreach ((array)$result['teams'] as $key => $team)
{
$result['teams'][$key] = array_merge($team, $this->normalize($team, 'team'));
}
$result['gq_numteams'] = count($result['teams']);
$result['gq_numteams'] = count((array)$result['teams']);
}
else
{
@ -153,12 +153,12 @@ class GameQ_Filters_Normalise extends GameQ_Filters
// Create a new array, with all the specified variables
$new = $this->fill($props);
foreach ($data as $var => $value)
foreach ((array)$data as $var => $value)
{
// normalize values
$stripped = strtolower(str_replace('_', '', $var));
foreach ($props as $target => $sources)
foreach ((array)$props as $target => $sources)
{
if ($target == $stripped or in_array($stripped, $sources))
{
@ -183,7 +183,7 @@ class GameQ_Filters_Normalise extends GameQ_Filters
{
$data = array();
foreach ($vars as $target => $source)
foreach ((array)$vars as $target => $source)
{
$data['gq_' . $target] = $val;
}

View file

@ -107,7 +107,7 @@ class GameQ_Protocols_Aa3pre32 extends GameQ_Protocols
}
// We only got one packet
if(count($packets) == 1)
if(count((array)$packets) == 1)
{
// @todo: Looking for example to test and verify
@ -228,7 +228,7 @@ class GameQ_Protocols_Aa3pre32 extends GameQ_Protocols
{
$team = $value;
}
elseif ($matches[1] == 'TeamIndex' && !array_key_exists($value, $teams))
elseif ($matches[1] == 'TeamIndex' && !array_key_exists($value, (array)$teams))
{
$teams[$value] = $team;
}

View file

@ -272,7 +272,7 @@ class GameQ_Protocols_Bf3 extends GameQ_Protocols
}
// Count the number of words and figure out the highest index.
$words_total = count($words)-1;
$words_total = count((array)$words)-1;
// The number of player info points
$num_tags = $words[1];

View file

@ -156,7 +156,7 @@ class GameQ_Protocols_Bf4 extends GameQ_Protocols_Bf3
}
// Count the number of words and figure out the highest index.
$words_total = count($words)-1;
$words_total = count((array)$words)-1;
// The number of player info points
$num_tags = $words[1];

View file

@ -610,7 +610,7 @@ abstract class GameQ_Protocols_Core
}
// Now add some default stuff
$results['gq_online'] = (count($results) > 0);
$results['gq_online'] = (count((array)$results) > 0);
$results['gq_address'] = $this->ip;
$results['gq_port'] = $this->port;
$results['gq_protocol'] = $this->protocol;

View file

@ -78,7 +78,7 @@ class GameQ_Protocols_Etqw extends GameQ_Protocols
protected function preProcess_status($packets)
{
// Should only be one packet
if (count($packets) > 1)
if (count((array)$packets) > 1)
{
throw new GameQ_ProtocolsException('Enemy Territor: Quake Wars status has more than 1 packet');
}

View file

@ -88,7 +88,7 @@ class GameQ_Protocols_Gamespy extends GameQ_Protocols
protected function preProcess($packets)
{
// Only one packet so its in order
if (count($packets) == 1)
if (count((array)$packets) == 1)
{
return $packets[0];
}
@ -97,7 +97,7 @@ class GameQ_Protocols_Gamespy extends GameQ_Protocols
$packets_ordered = array();
// Loop thru the packets
foreach ($packets as $packet)
foreach ((array)$packets as $packet)
{
// Check to see if we had a preg_match error
if(preg_match("#^(.*)\\\\queryid\\\\([^\\\\]+)(\\\\|$)#", $packet, $matches) === FALSE)
@ -173,7 +173,7 @@ class GameQ_Protocols_Gamespy extends GameQ_Protocols
$num_teams = 0;
// Now lets loop the array
for($x=0;$x<count($data);$x+=2)
for($x=0;$x<count((array)$data);$x+=2)
{
// Set some local vars
$key = $data[$x];

View file

@ -245,7 +245,7 @@ class GameQ_Protocols_Gamespy2 extends GameQ_Protocols
// Get the values
while ($buf->getLength() > 4)
{
foreach ($varnames as $varname)
foreach ((array)$varnames as $varname)
{
$result->addSub($type, $varname, $buf->readString());
}

View file

@ -115,7 +115,7 @@ class GameQ_Protocols_Gamespy3 extends GameQ_Protocols
$return = array();
// Get packet index, remove header
foreach ($packets as $index => $packet)
foreach ((array)$packets as $index => $packet)
{
// Make new buffer
$buf = new GameQ_Buffer($packet);
@ -138,7 +138,7 @@ class GameQ_Protocols_Gamespy3 extends GameQ_Protocols
// Compare last var of current packet with first var of next packet
// On a partial match, remove last var from current packet,
// variable header from next packet
for ($i = 0, $x = count($return); $i < $x - 1; $i++)
for ($i = 0, $x = count((array)$return); $i < $x - 1; $i++)
{
// First packet
$fst = substr($return[$i], 0, -1);
@ -162,7 +162,7 @@ class GameQ_Protocols_Gamespy3 extends GameQ_Protocols
}
// Now let's loop the return and remove any dupe prefixes
for($x = 1; $x < count($return); $x++)
for($x = 1; $x < count((array)$return); $x++)
{
$buf = new GameQ_Buffer($return[$x]);
@ -223,7 +223,7 @@ class GameQ_Protocols_Gamespy3 extends GameQ_Protocols
protected function delete_result(&$result, $array)
{
foreach($array as $key)
foreach ((array)$array as $key)
{
unset($result[$key]);
}
@ -268,7 +268,7 @@ class GameQ_Protocols_Gamespy3 extends GameQ_Protocols
$item_type = '';
// Loop through all of the $data for information and pull it out into the result
for($x=0; $x < count($data)-1; $x++)
for($x=0; $x < count((array)$data)-1; $x++)
{
// Pull out the item
$item = $data[$x];
@ -413,7 +413,7 @@ class GameQ_Protocols_Gamespy3 extends GameQ_Protocols
print_r($items);
// Loop through all of the items
for($x = 0; $x < count($items); $x += 2)
for($x = 0; $x < count((array)$items); $x += 2)
{
// $x is always the key for the item (i.e. player_, ping_, team_, score_, etc...)
$item_type = rtrim($items[$x], '_,_t');

View file

@ -81,7 +81,7 @@ class GameQ_Protocols_Quake2 extends GameQ_Protocols
protected function preProcess_status($packets)
{
// Should only be one packet
if (count($packets) > 1)
if (count((array)$packets) > 1)
{
throw new GameQ_ProtocolsException('Quake 2 status has more than 1 packet');
}
@ -175,7 +175,7 @@ class GameQ_Protocols_Quake2 extends GameQ_Protocols
array_pop($players);
// Add total number of players
$result->add('num_players', count($players));
$result->add('num_players', count((array)$players));
// Loop the players
foreach($players AS $player_info)

View file

@ -82,7 +82,7 @@ class GameQ_Protocols_Quake3 extends GameQ_Protocols
protected function preProcess_status($packets)
{
// Should only be one packet
if (count($packets) > 1)
if (count((array)$packets) > 1)
{
throw new GameQ_ProtocolsException('Quake 3 status has more than 1 packet');
}
@ -176,7 +176,7 @@ class GameQ_Protocols_Quake3 extends GameQ_Protocols
array_pop($players);
// Add total number of players
$result->add('num_players', count($players));
$result->add('num_players', count((array)$players));
// Loop the players
foreach($players AS $player_info)

View file

@ -374,13 +374,13 @@ class GameQ_Protocols_Teamspeak3 extends GameQ_Protocols
$return = array();
foreach ($data as $part)
foreach ((array)$data as $part)
{
$variables = explode (' ', $part);
$info = array();
foreach ($variables as $variable)
foreach ((array)$variables as $variable)
{
// Explode and make sure we always have 2 items in the array
list($key, $value) = array_pad(explode('=', $variable, 2), 2, '');

View file

@ -86,7 +86,7 @@ abstract class GameQ_Protocols_Unreal2 extends GameQ_Protocols
protected function preProcess_details($packets=array())
{
// Only one return so no need for work
if(count($packets) == 1)
if(count((array)$packets) == 1)
{
return substr($packets[0], 5);
}
@ -143,7 +143,7 @@ abstract class GameQ_Protocols_Unreal2 extends GameQ_Protocols
protected function preProcess_rules($packets=array())
{
// Only one return so no need for work
if(count($packets) == 1)
if(count((array)$packets) == 1)
{
return substr($packets[0], 5);
}
@ -207,7 +207,7 @@ abstract class GameQ_Protocols_Unreal2 extends GameQ_Protocols
protected function preProcess_players($packets=array())
{
// Only one return so no need for work
if(count($packets) == 1)
if(count((array)$packets) == 1)
{
return substr($packets[0], 5);
}

View file

@ -196,7 +196,7 @@ class GameQ_Protocols_Ventrilo extends GameQ_Protocols
$key = 0;
for( $i = 1; $i <= count( $chars ); $i++ )
for( $i = 1; $i <= count((array)$chars); $i++ )
{
$chars[$i] -= ( $table[$a2] + (( $i - 1 ) % 5 )) & 0xFF;
$a2 = ($a2 + $a1) & 0xFF;
@ -221,7 +221,7 @@ class GameQ_Protocols_Ventrilo extends GameQ_Protocols
), $header_items);
// Check to make sure the number of packets match
if ($header_items['totpck'] != count($packets))
if ($header_items['totpck'] != count((array)$packets))
{
throw new GameQ_ProtocolsException(__METHOD__.": Too less packets recieved");
}
@ -239,7 +239,7 @@ class GameQ_Protocols_Ventrilo extends GameQ_Protocols
$chars = unpack( "C*", substr ($packet, 20) );
$data = "";
for( $i = 1; $i <= count( $chars ); $i++ )
for( $i = 1; $i <= count((array)$chars); $i++ )
{
$chars[$i] -= ($table[$a2] + (( $i - 1 ) % 72 )) & 0xFF;
$a2 = ($a2 + $a1) & 0xFF;
@ -372,7 +372,7 @@ class GameQ_Protocols_Ventrilo extends GameQ_Protocols
protected function channel($data, GameQ_Result &$result)
{
$items = explode (",", $data);
foreach ($items as $item)
foreach ((array)$items as $item)
{
$temp = explode("=", $item);
$key = strtolower($temp[0]);
@ -391,7 +391,7 @@ class GameQ_Protocols_Ventrilo extends GameQ_Protocols
{
$items = explode(",", $data);
foreach ($items as $item)
foreach ((array)$items as $item)
{
$temp = explode("=", $item);
$key = strtolower($temp[0]);

View file

@ -41,7 +41,7 @@ class GameQ_Protocols_Warsow extends GameQ_Protocols_Quake3
array_pop($players);
// Add total number of players
$result->add('num_players', count($players));
$result->add('num_players', count((array)$players));
// Loop the players
foreach($players AS $player_info)