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

@ -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);