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

@ -22,7 +22,7 @@ $input_separator = "A";
# value of the text control submitted for spell-checking
function print_textinputs_var() {
global $textinputs;
foreach( $textinputs as $key=>$val ) {
foreach ((array)$textinputs as $key=>$val ) {
# $val = str_replace( "'", "%27", $val );
echo "textinputs[$key] = decodeURIComponent(\"" . $val . "\");\n";
}
@ -43,10 +43,10 @@ function print_words_elem( $word, $index, $text_input_idx ) {
# set an element of the JavaScript 'suggs' array to a list of suggestions
function print_suggs_elem( $suggs, $index, $text_input_idx ) {
echo "suggs[$text_input_idx][$index] = [";
foreach( $suggs as $key=>$val ) {
foreach ((array)$suggs as $key=>$val ) {
if( $val ) {
echo "'" . escape_quote( $val ) . "'";
if ( $key+1 < count( $suggs )) {
if ( $key+1 < count((array)$suggs)) {
echo ", ";
}
}
@ -80,7 +80,7 @@ function print_checker_results() {
# open temp file, add the submitted text.
if( $fh = fopen( $tempfile, 'w' )) {
for( $i = 0; $i < count( $textinputs ); $i++ ) {
for( $i = 0; $i < count((array)$textinputs); $i++ ) {
$text = urldecode( $textinputs[$i] );
// Strip all tags for the text. (by FredCK - #339 / #681)
@ -90,7 +90,7 @@ function print_checker_results() {
fwrite ( $fh, "%\n" ); # exit terse mode
fwrite ( $fh, "^$input_separator\n" );
fwrite ( $fh, "!\n" ); # enter terse mode
foreach( $lines as $key=>$value ) {
foreach ((array)$lines as $key=>$value ) {
# use carat on each line to escape possible aspell commands
fwrite( $fh, "^$value\n" );
}
@ -104,7 +104,7 @@ function print_checker_results() {
$index = 0;
$text_input_index = -1;
# parse each line of aspell return
foreach( $linesout as $key=>$val ) {
foreach ((array)$linesout as $key=>$val ) {
$chardesc = substr( $val, 0, 1 );
# if '&', then not in dictionary but has suggestions
# if '#', then not in dictionary and no suggestions

View file

@ -44,7 +44,7 @@ function GetFolders( $resourceType, $currentFolder )
echo "<Folders>" ;
natcasesort( $aFolders ) ;
foreach ( $aFolders as $sFolder )
foreach ((array)$aFolders as $sFolder)
echo $sFolder ;
// Close the "Folders" node.
@ -89,7 +89,7 @@ function GetFoldersAndFiles( $resourceType, $currentFolder )
natcasesort( $aFolders ) ;
echo '<Folders>' ;
foreach ( $aFolders as $sFolder )
foreach ((array)$aFolders as $sFolder)
echo $sFolder ;
echo '</Folders>' ;
@ -98,7 +98,7 @@ function GetFoldersAndFiles( $resourceType, $currentFolder )
natcasesort( $aFiles ) ;
echo '<Files>' ;
foreach ( $aFiles as $sFiles )
foreach ((array)$aFiles as $sFiles)
echo $sFiles ;
echo '</Files>' ;

View file

@ -195,10 +195,10 @@ function IsAllowedExt( $sExtension, $resourceType )
$arAllowed = $Config['AllowedExtensions'][$resourceType] ;
$arDenied = $Config['DeniedExtensions'][$resourceType] ;
if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) )
if ( count((array)$arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) )
return false ;
if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) )
if ( count((array)$arDenied) > 0 && in_array( $sExtension, $arDenied ) )
return false ;
return true ;

View file

@ -92,7 +92,7 @@ function IsHtmlExtension( $ext, $htmlExtensions )
return false ;
}
$lcaseHtmlExtensions = array() ;
foreach ( $htmlExtensions as $key => $val )
foreach ((array)$htmlExtensions as $key => $val )
{
$lcaseHtmlExtensions[$key] = strtolower( $val ) ;
}
@ -137,7 +137,7 @@ function DetectHtml( $filePath )
$tags = array( '<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title' ) ;
foreach( $tags as $tag )
foreach ((array)$tags as $tag)
{
if( false !== strpos( $chunk, $tag ) )
{

View file

@ -455,7 +455,7 @@ class GeSHi {
'{LANGUAGE}' => $this->language,
'{PATH}' => $this->language_path
);
foreach ($debug_tpl_vars as $tpl => $var) {
foreach ((array)$debug_tpl_vars as $tpl => $var) {
$msg = str_replace($tpl, $var, $msg);
}
return "<br /><strong>GeSHi Error:</strong> $msg (code $this->error)<br />";
@ -1077,7 +1077,7 @@ class GeSHi {
$flag = $flag ? true : false;
foreach ($this->lexic_permissions as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
foreach ((array)$value as $k => $v) {
$this->lexic_permissions[$key][$k] = $flag;
}
}
@ -1101,7 +1101,7 @@ class GeSHi {
* @todo static?
*/
function get_language_name_from_extension( $extension, $lookup = array() ) {
if ( !is_array($lookup) || !count($lookup)) {
if ( !is_array($lookup) || !count((array)$lookup)) {
$lookup = array(
'actionscript' => array('as'),
'ada' => array('a', 'ada', 'adb', 'ads'),
@ -1143,8 +1143,8 @@ class GeSHi {
);
}
foreach ($lookup as $lang => $extensions) {
foreach ($extensions as $ext) {
foreach ((array)$lookup as $lang => $extensions) {
foreach ((array)$extensions as $ext) {
if ($ext == $extension) {
return $lang;
}
@ -1369,7 +1369,7 @@ class GeSHi {
*/
function highlight_lines_extra($lines, $style = null) {
if (is_array($lines)) {
foreach ($lines as $line) {
foreach ((array)$lines as $line) {
$this->highlight_lines_extra(line, $style);
}
}
@ -1508,7 +1508,7 @@ class GeSHi {
$char = substr($code, $i, 1);
if (!$HIGHLIGHTING_ON) {
foreach ($this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters) {
foreach ($delimiters as $open => $close) {
foreach ((array)$delimiters as $open => $close) {
// Get the next little bit for this opening string
$check = substr($code, $i, strlen($open));
// If it matches...
@ -1528,7 +1528,7 @@ class GeSHi {
}
else {
foreach ($this->language_data['SCRIPT_DELIMITERS'] as $key => $delimiters) {
foreach ($delimiters as $open => $close) {
foreach ((array)$delimiters as $open => $close) {
if ($open == $HIGHLIGHTING_ON) {
// Found the closing tag
break(2);
@ -1564,14 +1564,14 @@ class GeSHi {
// Now we go through each part. We know that even-indexed parts are
// code that shouldn't be highlighted, and odd-indexed parts should
// be highlighted
foreach ($parts as $key => $data) {
foreach ((array)$parts as $key => $data) {
$part = $data[1];
// If this block should be highlighted...
if ($key % 2) {
if ($this->strict_mode) {
// Find the class key for this block of code
foreach ($this->language_data['SCRIPT_DELIMITERS'] as $script_key => $script_data) {
foreach ($script_data as $open => $close) {
foreach ((array)$script_data as $open => $close) {
if ($data[0] == $open) {
break(2);
}
@ -1951,7 +1951,7 @@ class GeSHi {
if (false !== strpos($result, "\t")) {
$lines = explode("\n", $result);
$tab_width = $this->get_real_tab_width();
foreach ($lines as $key => $line) {
foreach ((array)$lines as $key => $line) {
if (false === strpos($line, "\t")) {
$lines[$key] = $line;
continue;
@ -2160,7 +2160,7 @@ class GeSHi {
if (preg_match('#[a-zA-Z]{2,}#', $stuff_to_parse)) {
foreach ($this->language_data['KEYWORDS'] as $k => $keywordset) {
if ($this->lexic_permissions['KEYWORDS'][$k]) {
foreach ($keywordset as $keyword) {
foreach ((array)$keywordset as $keyword) {
$keyword = preg_quote($keyword, '/');
//
// This replacement checks the word is on it's own (except if brackets etc
@ -2280,7 +2280,7 @@ class GeSHi {
$symbol_data = $symbol_preg = array();
foreach($this->language_data['SYMBOLS'] as $key => $symbols) {
if(is_array($symbols)) {
foreach($symbols as $sym) {
foreach ((array)$symbols as $sym) {
if(!isset($symbol_data[$sym])) {
$symbol_data[GeSHi::hsc($sym)] = $key;
$symbol_preg[] = preg_quote(GeSHi::hsc($sym), '/');
@ -2302,8 +2302,8 @@ class GeSHi {
preg_match_all("/(?:" . $sym_search . ")+/", $stuff_to_parse, $matches_in_stuff, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
//Match anything that is a highlighted block ...
preg_match_all("/<\|(?:<DOT>|[^>])+>(?:(?!\|>).*?)\|>|<\/a>/", $stuff_to_parse, $highlighted_in_stuff, PREG_OFFSET_CAPTURE);
foreach($matches_in_stuff as $stuff_match_id => $stuff_match_data) {
foreach($highlighted_in_stuff[0] as $highlight_id => $highlight_data) {
foreach ((array)$matches_in_stuff as $stuff_match_id => $stuff_match_data) {
foreach ((array)$highlighted_in_stuff[0] as $highlight_id => $highlight_data) {
//Do a range check of the found highlight identifier and the OOP match ...
if(($highlight_data[1] <= $stuff_match_data[0][1]) &&
($highlight_data[1] + strlen($highlight_data[0]) >= $stuff_match_data[0][1] + strlen($stuff_match_data[0][0])))
@ -2316,17 +2316,17 @@ class GeSHi {
}
//Rebuild the matches array to be ordered by offset ...
$symbol_offsets = array();
foreach($matches_in_stuff as $stuff_match_data) {
foreach ((array)$matches_in_stuff as $stuff_match_data) {
$symbol_offsets[$stuff_match_data[0][1]] = $stuff_match_data[0][0];
}
krsort($symbol_offsets);
//Perform the actual replacements ...
foreach($symbol_offsets as $symbol_offset => $symbol_match) {
foreach ((array)$symbol_offsets as $symbol_offset => $symbol_match) {
$symbol_hl = "";
$old_sym = -1;
//Split the current stuff to replace into its atomic symbols ...
preg_match_all("/$sym_search/", $symbol_match, $sym_match_syms, PREG_PATTERN_ORDER);
foreach($sym_match_syms[0] as $sym_ms) {
foreach ((array)$sym_match_syms[0] as $sym_ms) {
//Check if consequtive symbols belong to the same group to save output ...
if (isset($symbol_data[$sym_ms]) && ($symbol_data[$sym_ms] != $old_sym)) {
if(-1 != $old_sym) {
@ -2510,7 +2510,7 @@ class GeSHi {
$i = 0;
// Foreach line...
foreach ($code as $line) {
foreach ((array)$code as $line) {
//Reset the attributes for a new line ...
$attrs = array();
@ -2574,7 +2574,7 @@ class GeSHi {
// Add in the line surrounded by appropriate list HTML
$attr_string = '';
foreach ($attrs as $key => $attr) {
foreach ((array)$attrs as $key => $attr) {
$attr_string .= ' ' . $key . '="' . implode(' ', $attr) . '"';
}
$parsed_code .= "<li$attr_string>$start$line$end</li>$ls";
@ -2586,7 +2586,7 @@ class GeSHi {
$code = explode("\n", $parsed_code);
$parsed_code = '';
$i = 0;
foreach ($code as $line) {
foreach ((array)$code as $line) {
// Make lines have at least one space in them if they're empty
// BenBE: Checking emptiness using trim instead of relying on blanks
if ('' == trim($line)) {

View file

@ -146,7 +146,7 @@ class LuminousBashScanner extends LuminousScanner {
$this->record($m[2], 'VARIABLE');
}
elseif (($this->interpolated && count($stack) === 1 &&
elseif (($this->interpolated && count((array)$stack) === 1 &&
$this->scan('/(?<=\s|^)\#.*?(?=[)]|$)/m'))
|| $this->scan('/(?<=\s|^)\#.*/')) {
$this->record($this->match(), 'COMMENT');

View file

@ -121,7 +121,7 @@ class LuminousDiffScanner extends LuminousScanner {
$verbatim_ = '';
$types = array();
$prefixes = array();
foreach($lines as $l) {
foreach ((array)$lines as $l) {
if (!strlen($l) || $l[0] === ' ')
$types[]= 'DIFF_UNCHANGED';
elseif ($l[0] === '+' || $l[0] === '>')
@ -146,8 +146,8 @@ class LuminousDiffScanner extends LuminousScanner {
$tagged = $verbatim;
}
$exp = explode("\n", $tagged);
assert(count($exp) === count($prefixes));
foreach($exp as $i=>$v) {
assert(count((array)$exp) === count((array)$prefixes));
foreach ((array)$exp as $i=>$v) {
$t = $types[$i];
// if the sub-scanner escaped the line, we also need to escape the
// prefix for consistency
@ -158,7 +158,7 @@ class LuminousDiffScanner extends LuminousScanner {
$text,
$t,
$escaped);
if ($i < count($exp)-1) $this->record("\n", null);
if ($i < count((array)$exp)-1) $this->record("\n", null);
}
if ($this->eol()) $this->record($this->get(), null);
continue;

View file

@ -57,7 +57,7 @@ class LuminousErlangScanner extends LuminousSimpleScanner {
static function oo_stream_filter($tokens) {
$c = count($tokens)-1;
$c = count((array)$tokens)-1;
for($i=0; $i<$c; $i++) {
if ($tokens[$i][1] === ':') {
if ($i > 0) {

View file

@ -136,7 +136,7 @@ class LuminousSASSParser {
function next_sequence($sequence, $ignore=array()) {
$i = $this->index+1;
$len = count($this->tokens);
$seq_len = count($sequence);
$seq_len = count((array)$sequence);
$seq = 0;
$seq_start = 0;
while ($i<$len) {

View file

@ -187,7 +187,7 @@ see --help for help
// user provided language
$scanners = luminous::scanners();
$valid_scanner = false;
foreach($scanners as $lang=>$codes) {
foreach ((array)$scanners as $lang=>$codes) {
if (in_array($this->options['lang'], $codes)) {
$valid_scanner = true;
break;

View file

@ -96,7 +96,7 @@ class LuminousFilters {
$start = "$lead<DOCTAG>$tag_char$tag</DOCTAG><DOCPROPERTY>";
$j = 0;
$c = count($l);
$c = count((array)$l);
for($i=0; $j<$len && $i<$c; $i++)
{
$s = $l[$i];
@ -268,7 +268,7 @@ class LuminousFilters {
* This is a stream filter.
*/
static function oo_stream_filter($tokens) {
$c = count($tokens);
$c = count((array)$tokens);
for($i=0; $i<$c; $i++) {
if ($tokens[$i][0] !== 'IDENT') continue;
if ($i > 0) {

View file

@ -473,7 +473,7 @@ class Scanner {
$matches = null;
$name = null;
$m;
foreach($patterns as $name_=>$p) {
foreach ((array)$patterns as $name_=>$p) {
$index = $this->ss->match($p, $this->index, $m);
if ($index === false) continue;
if ($next === -1 || $index < $next) {
@ -500,7 +500,7 @@ class Scanner {
function get_next($patterns) {
$next = -1;
$matches = null;
foreach($patterns as $p) {
foreach ((array)$patterns as $p) {
$m;
$index = $this->ss->match($p, $this->index, $m);
if ($index === false) continue;
@ -524,7 +524,7 @@ class Scanner {
function get_next_strpos($patterns) {
$next = -1;
$match = null;
foreach($patterns as $p) {
foreach ((array)$patterns as $p) {
$index = strpos($this->src, $p, $this->index);
if ($index === false) continue;
if ($next === -1 || $index < $next) {
@ -802,7 +802,7 @@ class LuminousScanner extends Scanner {
* @internal
*/
protected function rule_mapper_filter($tokens) {
foreach($tokens as &$t) {
foreach ((array)$tokens as &$t) {
if (array_key_exists($t[0], $this->rule_tag_map))
$t[0] = $this->rule_tag_map[$t[0]];
}
@ -884,7 +884,7 @@ class LuminousScanner extends Scanner {
*/
public function remove_filter($name) {
foreach($this->filters as $token=>$filters) {
foreach($filters as $k=>$f) {
foreach ((array)$filters as $k=>$f) {
if ($f[0] === $name) unset($this->filters[$token][$k]);
}
}
@ -1057,7 +1057,7 @@ class LuminousScanner extends Scanner {
*/
function add_identifier_mapping($name, $matches) {
$array = array();
foreach($matches as $m) {
foreach ((array)$matches as $m) {
if (!$this->case_sensitive) $m = strtolower($m);
$array[$m] = true;
}
@ -1825,7 +1825,7 @@ class LuminousStatefulScanner extends LuminousSimpleScanner {
*/
protected function collapse_token_tree($node) {
$text = '';
foreach($node['children'] as $c) {
foreach ((array)$node['children'] as $c) {
if (is_string($c)) $text .= LuminousUtils::escape_string($c);
else $text .= $this->collapse_token_tree($c);
}

View file

@ -71,7 +71,7 @@ class LuminousStringSearch
$r = $matches_[0][1];
// strip the offsets from the match_groups
foreach($matches_ as $i=>&$v)
foreach ((array)$matches_ as $i=>&$v)
$v = $v[0];
$this->cache[$search] = array($r, $matches_);

View file

@ -104,7 +104,7 @@ abstract class LuminousFormatter {
$num_lines = 1;
$num_open = 0;
foreach($line_split as $l) {
foreach ((array)$line_split as $l) {
$l0 = $l[0];
if ($l0 === '<') {

View file

@ -90,7 +90,7 @@ class LuminousHTMLTemplates {
$template = self::_strip_template_whitespace($template);
}
foreach($variables as $search => $replace) {
foreach ((array)$variables as $search => $replace) {
$template = str_replace("{" . $search . "}", $replace, $template);
}
return $template;
@ -138,7 +138,7 @@ class LuminousFormatterHTML extends LuminousFormatter {
private function lines_numberless($src) {
$lines = array();
$lines_original = explode("\n", $src);
foreach($lines_original as $line) {
foreach ((array)$lines_original as $line) {
$l = $line;
$num = $this->wrap_line($l, $this->wrap_length);
// strip the newline if we're going to join it. Seems the easiest way to
@ -212,7 +212,7 @@ class LuminousFormatterHTML extends LuminousFormatter {
preg_match_all("/<\/([^\s>]*).*?>/", $matches[0], $close_tags,
PREG_SET_ORDER);
if (count($open_tags) != count($close_tags))
if (count((array)$open_tags) != count((array)$close_tags))
return $matches[0];
if (isset($open_tags[0])
&& trim($open_tags[0][1]) !== trim($close_tags[0][1])

View file

@ -116,7 +116,7 @@ EOF;
if ($this->wrap_length > 0) {
$str = '';
foreach($lines as $i=>$l) {
foreach ((array)$lines as $i=>$l) {
$this->wrap_line($l, $this->wrap_length);
$str .= $l;
}
@ -132,7 +132,7 @@ EOF;
return "{\\\textbackslash}";
return "\\\" . $matches[0];');
foreach($str_ as $s_) {
foreach ((array)$str_ as $s_) {
if ($s_[0] === '<') {
$s_ = preg_replace('%</[^>]+>%', '}', $s_);
$s_ = preg_replace_callback('%<([^>]+)>%', $f1
@ -167,7 +167,7 @@ EOF;
// NOTE: p being a reference is probably going to necessitate a lot of
// copying to pass through all these preg_* and str* calls.
// consider rewriting.
foreach($pieces as $k=>&$p) {
foreach ((array)$pieces as $k=>&$p) {
if (preg_match('/^\\\lms/', $p))
$stack[] = "" . $p;
elseif(preg_match('/^(\\\\\\\\)*\}/', $p)) {
@ -178,7 +178,7 @@ EOF;
elseif(strpos($p, "\n") !== false) {
$before = "";
$after = "";
foreach($stack as $st_) {
foreach ((array)$stack as $st_) {
$before .= $st_;
$after .= '}';
}

View file

@ -162,7 +162,7 @@ class _Luminous {
throw new Exception('Luminous internal error: Settings is not an array');
}
$old_settings = clone $this->settings;
foreach($settings as $k=>$v) {
foreach ((array)$settings as $k=>$v) {
$this->settings->set($k, $v);
}
}
@ -551,7 +551,7 @@ abstract class luminous {
$info = array(
'lines' => $lines,
'num_lines' => count($lines),
'num_lines' => count((array)$lines),
'trimmed' => trim($src),
'shebang' => $shebang
);

View file

@ -194,7 +194,7 @@ class LuminousOptions {
if (!is_array($array)) {
$array = array($nameOrArray => $value);
}
foreach($array as $option => $value) {
foreach ((array)$array as $option => $value) {
// for backwards compatibility we need to do this here
$option = str_replace('-', '_', $option);
$this->__set($option, $value);

View file

@ -74,7 +74,7 @@ class LuminousScanners
);
if (!is_array($language_name))
$language_name = array($language_name);
foreach($language_name as $l) {
foreach ((array)$language_name as $l) {
$this->lookup_table[$l] = $insert;
if (!$dummy)
$this->AddDescription($lang_description, $l);
@ -94,7 +94,7 @@ class LuminousScanners
{
foreach($this->descriptions as &$d)
{
foreach($d as $k=>$l)
foreach ((array)$d as $k=>$l)
{
if($l === $language_name)
unset($d[$k]);
@ -112,7 +112,7 @@ class LuminousScanners
{
if (is_array($language_name))
{
foreach($language_name as $l)
foreach ((array)$language_name as $l)
{
unset($this->lookup_table[$l]);
$this->UnsetDescription($l);
@ -160,7 +160,7 @@ class LuminousScanners
if (!isset($this->resolved_dependencies[$language_name]))
{
$this->resolved_dependencies[$language_name] = true;
foreach($g['dependencies'] as $d)
foreach ((array)$g['dependencies'] as $d)
{
$this->GetScannerArray($d, $default);
}

View file

@ -241,16 +241,16 @@ class LuminousCSSParser {
$css_ = array();
// now cleanup the array, drop !important
foreach($css as $selector=>$rules) {
foreach ((array)$css as $selector=>$rules) {
$rules_ = array();
foreach($rules as $prop=>$value) {
foreach ((array)$rules as $prop=>$value) {
list($prop, $value) = self::format_property_value($prop, $value);
$rules_[$prop] = $value;
}
// now split selector by comma
$selectors = preg_split('/\s*,\s*/', $selector);
foreach($selectors as $s) {
foreach ((array)$selectors as $s) {
// drop .luminous from the selector
$s = preg_replace('/^\.luminous\s*/', '', $s);
// now we assume that if something is in the form .classname then
@ -329,7 +329,7 @@ class LuminousCSSParser {
$css = array();
// array of selectors => rules, where rules is an array itself of (property, value)
// note this is going to get @font-face wrong, but we don't care about that.
for($i=0; $i<count($tokens); $i++) {
for($i=0; $i<count((array)$tokens); $i++) {
list($tok, $content, ) = $tokens[$i];
if ($tok === 'COMMENT') continue;
if (!$block) {

View file

@ -61,7 +61,7 @@ function getActivePlugins() {
// -------------------------------------------------------------------------
// Plugins to activate depending on other variables
// -------------------------------------------------------------------------
if ($net2ftp_globals["state"] == "edit" && isset($textareaType) == true && $textareaType != "" && array_key_exists($textareaType, $pluginProperties) == true) {
if ($net2ftp_globals["state"] == "edit" && isset($textareaType) == true && $textareaType != "" && array_key_exists($textareaType, (array)$pluginProperties) == true) {
if ($pluginProperties[$textareaType]["use"] == "yes") { $activePlugins[$plugincounter] = $textareaType; $plugincounter++; }
}