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

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

View file

@ -61,9 +61,9 @@ class Normalize extends Base
$result = array_merge($result, $this->check('general', $result));
// Do player information
if (isset($result['players']) && count($result['players']) > 0) {
if (isset($result['players']) && count((array)$result['players']) > 0) {
// Iterate
foreach ($result['players'] as $key => $player) {
foreach ((array)$result['players'] as $key => $player) {
$result['players'][$key] = array_merge($player, $this->check('player', $player));
}
} else {
@ -71,9 +71,9 @@ class Normalize extends Base
}
// Do team information
if (isset($result['teams']) && count($result['teams']) > 0) {
if (isset($result['teams']) && count((array)$result['teams']) > 0) {
// Iterate
foreach ($result['teams'] as $key => $team) {
foreach ((array)$result['teams'] as $key => $team) {
$result['teams'][$key] = array_merge($team, $this->check('team', $team));
}
} else {
@ -111,15 +111,15 @@ class Normalize extends Base
if (is_array($raw)) {
// Iterate over the raw property we want to use
foreach ($raw as $check) {
if (array_key_exists($check, $data)) {
foreach ((array)$raw as $check) {
if (array_key_exists($check, (array)$data)) {
$value = $data[$check];
break;
}
}
} else {
// String
if (array_key_exists($raw, $data)) {
if (array_key_exists($raw, (array)$data)) {
$value = $data[$raw];
}
}

View file

@ -59,7 +59,7 @@ class Secondstohuman extends Base
public function __construct(array $options = [])
{
// Check for passed keys
if (!array_key_exists(self::OPTION_TIMEKEYS, $options)) {
if (!array_key_exists(self::OPTION_TIMEKEYS, (array)$options)) {
// Use default
$options[self::OPTION_TIMEKEYS] = $this->timeKeysDefault;
} else {
@ -98,7 +98,7 @@ class Secondstohuman extends Base
protected function iterate(array &$result)
{
// Iterate over the results
foreach ($result as $key => $value) {
foreach ((array)$result as $key => $value) {
// Offload to itself if we have another array
if (is_array($value)) {
// Iterate and update the result

View file

@ -204,7 +204,7 @@ class GameQ
{
// Loop through all the servers and add them
foreach ($servers as $server_info) {
foreach ((array)$servers as $server_info) {
$this->addServer($server_info);
}
@ -230,7 +230,7 @@ class GameQ
}
// Iterate over the file(s) and add them
foreach ($files as $file) {
foreach ((array)$files as $file) {
// Check to make sure the file exists and we can read it
if (!file_exists($file) || !is_readable($file)) {
continue;
@ -442,7 +442,7 @@ class GameQ
);
// Iterate over the challenge responses
foreach ($responses as $socket_id => $response) {
foreach ((array)$responses as $socket_id => $response) {
// Back out the server_id we need to update the challenge response for
$server_id = $sockets[$socket_id]['server_id'];
@ -484,7 +484,7 @@ class GameQ
// Get all the non-challenge packets we need to send
$packets = $server->protocol()->getPacket('!' . Protocol::PACKET_CHALLENGE);
if (count($packets) == 0) {
if (count((array)$packets) == 0) {
// Skip nothing else to do for some reason.
continue;
}
@ -505,7 +505,7 @@ class GameQ
try {
// Iterate over all the packets we need to send
foreach ($packets as $packet_data) {
foreach ((array)$packets as $packet_data) {
// Now write the packet to the socket.
$socket->write($packet_data);
@ -540,7 +540,7 @@ class GameQ
);
// Iterate over the responses
foreach ($responses as $socket_id => $response) {
foreach ((array)$responses as $socket_id => $response) {
// Back out the server_id
$server_id = $sockets[$socket_id]['server_id'];
@ -555,7 +555,7 @@ class GameQ
}
// Now we need to close all of the sockets
foreach ($sockets as $socketInfo) {
foreach ((array)$sockets as $socketInfo) {
/* @var $socket \GameQ\Query\Core */
$socket = $socketInfo['socket'];
@ -594,7 +594,7 @@ class GameQ
$results = $server->protocol()->processResponse();
// Check for online before we do anything else
$results['gq_online'] = (count($results) > 0);
$results['gq_online'] = (count((array)$results) > 0);
} catch (ProtocolException $e) {
// Check to see if we are in debug, if so bubble up the exception
if ($this->debug) {

View file

@ -167,7 +167,7 @@ class Bf3 extends Protocol
unset($buffer, $sequence_id_last, $sequence_id);
// Iterate over the combined packets and do some work
foreach ($processed as $sequence_id => $data) {
foreach ((array)$processed as $sequence_id => $data) {
// Create a new buffer
$buffer = new Buffer($data);
@ -338,7 +338,7 @@ class Bf3 extends Protocol
// Iterate over the index until we run out of players
for ($i = 0, $x = $numTags + 3; $i < $playerCount; $i++, $x += $numTags) {
// Loop over the player tags and extract the info for that tag
foreach ($tags as $index => $tag) {
foreach ((array)$tags as $index => $tag) {
$result->addPlayer($tag, $items[($x + $index)]);
}
}

View file

@ -316,7 +316,7 @@ class Bfbc2 extends Protocol
// Iterate over the index until we run out of players
for ($i = 0, $x = $numTags + 3; $i < $playerCount; $i++, $x += $numTags) {
// Loop over the player tags and extract the info for that tag
foreach ($tags as $index => $tag) {
foreach ((array)$tags as $index => $tag) {
$result->addPlayer($tag, $items[($x + $index)]);
}
}

View file

@ -131,7 +131,7 @@ class Cs2d extends Protocol
$responses = explode(substr($this->packets[$packet], 2), $buffer->getData());
// Try to rebuild the second packet to the same as if it was sent as two separate responses
$responses[1] = $this->packets[$packet] . ((count($responses) === 2) ? $responses[1] : "");
$responses[1] = $this->packets[$packet] . ((count((array)$responses) === 2) ? $responses[1] : "");
unset($buffer);
} else {
@ -142,7 +142,7 @@ class Cs2d extends Protocol
$packets = [];
// We need to pre-sort these for split packets so we can do extra work where needed
foreach ($responses as $response) {
foreach ((array)$responses as $response) {
$buffer = new Buffer($response);
// Pull out the header
@ -157,7 +157,7 @@ class Cs2d extends Protocol
$results = [];
// Now let's iterate and process
foreach ($packets as $header => $packetGroup) {
foreach ((array)$packets as $header => $packetGroup) {
// Figure out which packet response this is
if (!array_key_exists($header, $this->responses)) {
throw new Exception(__METHOD__ . " response type '" . bin2hex($header) . "' is not valid");

View file

@ -138,10 +138,10 @@ class Gamespy extends Protocol
$numPlayers = 0;
$numTeams = 0;
$itemCount = count($data);
$itemCount = count((array)$data);
// Check to make sure we have more than 1 item in the array before trying to loop
if (count($data) > 1) {
if (count((array)$data) > 1) {
// Now lets loop the array since we have items
for ($x = 0; $x < $itemCount; $x += 2) {
// Set some local vars

View file

@ -140,7 +140,7 @@ class Gamespy2 extends Protocol
$results = [];
// Now let's iterate and process
foreach ($packets as $header => $packetGroup) {
foreach ((array)$packets as $header => $packetGroup) {
// Figure out which packet response this is
if (!array_key_exists($header, $this->responses)) {
throw new Exception(__METHOD__ . " response type '" . bin2hex($header) . "' is not valid");
@ -255,7 +255,7 @@ class Gamespy2 extends Protocol
// Get the values
while ($buffer->getLength() > 4) {
foreach ($varNames as $varName) {
foreach ((array)$varNames as $varName) {
$result->addSub($dataType, utf8_encode($varName), utf8_encode($buffer->readString()));
}
if ($buffer->lookAhead() === "\x00") {

View file

@ -169,7 +169,7 @@ class Gamespy3 extends Protocol
$this->processDetails($buffer, $result);
// The rest should be the player and team information, if it exists
if (array_key_exists(1, $split)) {
if (array_key_exists(1, (array)$split)) {
$buffer = new Buffer($split[1], Buffer::NUMBER_TYPE_BIGENDIAN);
$this->processPlayersAndTeams($buffer, $result);
}
@ -194,7 +194,7 @@ class Gamespy3 extends Protocol
{
// Get the number of packets
$packetCount = count($packets);
$packetCount = count((array)$packets);
// Compare last var of current packet with first var of next packet
// On a partial match, remove last var from current packet,
@ -282,7 +282,7 @@ class Gamespy3 extends Protocol
$item_type = '';
// Save count as variable
$count = count($data);
$count = count((array)$data);
// Loop through all of the $data for information and pull it out into the result
for ($x = 0; $x < $count - 1; $x++) {

View file

@ -147,7 +147,7 @@ class Gta5m extends Protocol
// No longer needed
unset($buffer);
$itemCount = count($data);
$itemCount = count((array)$data);
// Now lets loop the array
for ($x = 0; $x < $itemCount; $x += 2) {

View file

@ -131,7 +131,7 @@ class Lhmp extends Protocol
$results = [];
// Now let's iterate and process
foreach ($packets as $header => $packetGroup) {
foreach ((array)$packets as $header => $packetGroup) {
// Figure out which packet response this is
if (!array_key_exists($header, $this->responses)) {
throw new Exception(__METHOD__ . " response type '{$header}' is not valid");

View file

@ -133,7 +133,7 @@ class Mumble extends Protocol
$result->add('dedicated', 1);
// Let's iterate over the response items, there are a lot
foreach ($data as $key => $value) {
foreach ((array)$data as $key => $value) {
// Ignore root for now, that is where all of the channel/player info is housed
if (in_array($key, ['root'])) {
continue;
@ -168,7 +168,7 @@ class Mumble extends Protocol
{
// Let's add all of the channel information
foreach ($data as $key => $value) {
foreach ((array)$data as $key => $value) {
// We will handle these later
if (in_array($key, ['channels', 'users'])) {
// skip
@ -180,14 +180,14 @@ class Mumble extends Protocol
}
// Itereate over the users in this channel
foreach ($data['users'] as $user) {
foreach ($user as $key => $value) {
foreach ((array)$data['users'] as $user) {
foreach ((array)$user as $key => $value) {
$result->addPlayer($key, $value);
}
}
// Offload more channels to parse
foreach ($data['channels'] as $channel) {
foreach ((array)$data['channels'] as $channel) {
$this->processChannelsAndUsers($channel, $result);
}
}

View file

@ -191,7 +191,7 @@ class Source extends Protocol
unset($response, $packet_id, $buffer, $header);
// Now that we have the packets sorted we need to iterate and process them
foreach ($packets as $packet_id => $packet) {
foreach ((array)$packets as $packet_id => $packet) {
// We first need to off load split packets to combine them
if (is_array($packet)) {
$buffer = new Buffer($this->processPackets($packet_id, $packet));
@ -244,7 +244,7 @@ class Source extends Protocol
$packs = [];
// We have multiple packets so we need to get them and order them
foreach ($packets as $i => $packet) {
foreach ((array)$packets as $i => $packet) {
// Make a buffer so we can read this info
$buffer = new Buffer($packet);

View file

@ -167,7 +167,7 @@ class Teamspeak2 extends Protocol
$result = new Result();
// Now we need to iterate over the sections and off load the processing
foreach ($sections as $section) {
foreach ((array)$sections as $section) {
// Grab a snip of the data so we can figure out what it is
$check = substr($section, 0, 7);
@ -247,7 +247,7 @@ class Teamspeak2 extends Protocol
// Explode and merge the data with the columns, then parse
$data = array_combine($columns, explode("\t", $row, 9));
foreach ($data as $key => $value) {
foreach ((array)$data as $key => $value) {
// Now add the data to the result
$result->addTeam($key, utf8_encode($value));
}
@ -279,7 +279,7 @@ class Teamspeak2 extends Protocol
// Explode and merge the data with the columns, then parse
$data = array_combine($columns, explode("\t", $row, 16));
foreach ($data as $key => $value) {
foreach ((array)$data as $key => $value) {
// Now add the data to the result
$result->addPlayer($key, utf8_encode($value));
}

View file

@ -181,7 +181,7 @@ class Teamspeak3 extends Protocol
$result = new Result();
// Iterate over the sections and offload the parsing
foreach ($sections as $section) {
foreach ((array)$sections as $section) {
// Grab a snip of the data so we can figure out what it is
$check = substr(trim($section), 0, 4);
@ -226,7 +226,7 @@ class Teamspeak3 extends Protocol
$items = explode(' ', $data);
// Iterate over the items
foreach ($items as $item) {
foreach ((array)$items as $item) {
// Explode and make sure we always have 2 items in the array
list($key, $value) = array_pad(explode('=', $item, 2), 2, '');
@ -261,7 +261,7 @@ class Teamspeak3 extends Protocol
$result->add('dedicated', 1);
// Iterate over the properties
foreach ($properties as $key => $value) {
foreach ((array)$properties as $key => $value) {
$result->add($key, $value);
}
@ -287,12 +287,12 @@ class Teamspeak3 extends Protocol
$channels = explode('|', $data);
// Iterate over the channels
foreach ($channels as $channel) {
foreach ((array)$channels as $channel) {
// Offload the parsing for these values
$properties = $this->processProperties($channel);
// Iterate over the properties
foreach ($properties as $key => $value) {
foreach ((array)$properties as $key => $value) {
$result->addTeam($key, $value);
}
}
@ -313,12 +313,12 @@ class Teamspeak3 extends Protocol
$players = explode('|', $data);
// Iterate over the channels
foreach ($players as $player) {
foreach ((array)$players as $player) {
// Offload the parsing for these values
$properties = $this->processProperties($player);
// Iterate over the properties
foreach ($properties as $key => $value) {
foreach ((array)$properties as $key => $value) {
$result->addPlayer($key, $value);
}
}

View file

@ -127,7 +127,7 @@ class Unreal2 extends Protocol
$results = [];
// Now let's iterate and process
foreach ($packets as $header => $packetGroup) {
foreach ((array)$packets as $header => $packetGroup) {
// Figure out which packet response this is
if (!array_key_exists($header, $this->responses)) {
throw new Exception(__METHOD__ . " response type '" . bin2hex($header) . "' is not valid");

View file

@ -126,7 +126,7 @@ class Ut3 extends Gamespy3
protected function deleteResult(array &$result, array $array)
{
foreach ($array as $key) {
foreach ((array)$array as $key) {
unset($result[$key]);
}
}

View file

@ -667,7 +667,7 @@ class Ventrilo extends Protocol
$playerFields = 7;
// Iterate over the lines
foreach ($lines as $line) {
foreach ((array)$lines as $line) {
// Trim all the outlying space
$line = trim($line);
@ -754,7 +754,7 @@ class Ventrilo extends Protocol
// This will be returned
$decrypted = [];
foreach ($packets as $packet) {
foreach ((array)$packets as $packet) {
# Header :
$header = substr($packet, 0, 20);
@ -775,7 +775,7 @@ class Ventrilo extends Protocol
$table = $this->head_encrypt_table;
$characterCount = count($chars);
$characterCount = count((array)$chars);
$key = 0;
for ($i = 1; $i <= $characterCount; $i++) {
@ -801,7 +801,7 @@ class Ventrilo extends Protocol
], $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 Exception(__METHOD__ . ": Too few packets received");
}
@ -816,7 +816,7 @@ class Ventrilo extends Protocol
$chars = unpack("C*", substr($packet, 20));
$data = "";
$characterCount = count($chars);
$characterCount = count((array)$chars);
for ($i = 1; $i <= $characterCount; $i++) {
$chars[$i] -= ($table[$a2] + (($i - 1) % 72)) & 0xFF;
@ -845,7 +845,7 @@ class Ventrilo extends Protocol
$items = explode(",", $data, $fieldCount);
// Iterate over the items for this channel
foreach ($items as $item) {
foreach ((array)$items as $item) {
// Split the key=value pair
list($key, $value) = explode("=", $item, 2);
@ -867,7 +867,7 @@ class Ventrilo extends Protocol
$items = explode(",", $data, $fieldCount);
// Iterate over the items for this player
foreach ($items as $item) {
foreach ((array)$items as $item) {
// Split the key=value pair
list($key, $value) = explode("=", $item, 2);

View file

@ -149,7 +149,7 @@ class Native extends Core
$sockets_tmp = [];
// Loop and pull out all the actual sockets we need to listen on
foreach ($sockets as $socket_id => $socket_data) {
foreach ((array)$sockets as $socket_id => $socket_data) {
// Get the socket
/* @var $socket \GameQ\Query\Core */
$socket = $socket_data['socket'];
@ -189,7 +189,7 @@ class Native extends Core
}
// Loop the sockets that received data back
foreach ($read as $socket) {
foreach ((array)$read as $socket) {
/* @var $socket resource */
// See if we have a response

View file

@ -108,12 +108,12 @@ class Server
{
// Check for server type
if (!array_key_exists(self::SERVER_TYPE, $server_info) || empty($server_info[self::SERVER_TYPE])) {
if (!array_key_exists(self::SERVER_TYPE, (array)$server_info) || empty($server_info[self::SERVER_TYPE])) {
throw new Exception("Missing server info key '" . self::SERVER_TYPE . "'!");
}
// Check for server host
if (!array_key_exists(self::SERVER_HOST, $server_info) || empty($server_info[self::SERVER_HOST])) {
if (!array_key_exists(self::SERVER_HOST, (array)$server_info) || empty($server_info[self::SERVER_HOST])) {
throw new Exception("Missing server info key '" . self::SERVER_HOST . "'!");
}
@ -121,7 +121,7 @@ class Server
$this->checkAndSetIpPort($server_info[self::SERVER_HOST]);
// Check for server id
if (array_key_exists(self::SERVER_ID, $server_info) && !empty($server_info[self::SERVER_ID])) {
if (array_key_exists(self::SERVER_ID, (array)$server_info) && !empty($server_info[self::SERVER_ID])) {
// Set the server id
$this->id = $server_info[self::SERVER_ID];
} else {
@ -130,7 +130,7 @@ class Server
}
// Check and set server options
if (array_key_exists(self::SERVER_OPTIONS, $server_info)) {
if (array_key_exists(self::SERVER_OPTIONS, (array)$server_info)) {
// Set the options
$this->options = $server_info[self::SERVER_OPTIONS];
}

View file

@ -8,10 +8,10 @@ function print_player_list_gameq($player_list,$numplayers,$numplayersmax)
$data = "<table class='player_monitor'>";
$data .= "<thead><tr>";
foreach($player_list as $id => $player)
foreach ((array)$player_list as $id => $player)
{
$maxcount = 0;
foreach($player as $td => $column)
foreach ((array)$player as $td => $column)
{
if($column != null)
{
@ -43,7 +43,7 @@ function print_player_list_gameq($player_list,$numplayers,$numplayersmax)
}
}
foreach($player_list[$maxid] as $td => $column)
foreach ((array)$player_list[$maxid] as $td => $column)
{
if($column != "" )
{
@ -54,9 +54,9 @@ function print_player_list_gameq($player_list,$numplayers,$numplayersmax)
}
$data .= "</tr></thead>";
$data .= "<tbody>";
foreach ( $player_list as $player ){
foreach ((array)$player_list as $player){
$data .= "<tr>";
foreach($player_list[$maxid] as $maxtd => $maxcolumn)
foreach ((array)$player_list[$maxid] as $maxtd => $maxcolumn)
{
if(isset($player[$maxtd]))
$data .= "<td>".htmlentities($player[$maxtd])."</td>";

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)