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

@ -437,7 +437,7 @@ class Smarty extends Smarty_Internal_Data {
// fill data if present
if (is_array($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
foreach ((array)$data as $_key => $_val) {
$tpl->tpl_vars[$_key] = new Smarty_variable($_val);
}
}
@ -524,7 +524,7 @@ class Smarty extends Smarty_Internal_Data {
$_plugin_name = strtolower($plugin_name);
$_name_parts = explode('_', $_plugin_name, 3);
// class name must have three parts to be valid plugin
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
if (count((array)$_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
return false;
}

View file

@ -47,7 +47,7 @@ function smarty_block_textformat($params, $content, $smarty, &$repeat, $template
$wrap_cut = false;
$assign = null;
foreach ($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch ($_key) {
case 'style':
case 'indent_char':
@ -78,7 +78,7 @@ function smarty_block_textformat($params, $content, $smarty, &$repeat, $template
$_paragraphs = preg_split('![\r\n][\r\n]!', $content);
$_output = '';
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
for($_x = 0, $_y = count((array)$_paragraphs); $_x < $_y; $_x++) {
if ($_paragraphs[$_x] == '') {
continue;
}

View file

@ -94,7 +94,7 @@ function smarty_function_cycle($params, $smarty, $template)
}
if($advance) {
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
if ( $cycle_vars[$name]['index'] >= count((array)$cycle_array) -1 ) {
$cycle_vars[$name]['index'] = 0;
} else {
$cycle_vars[$name]['index']++;

View file

@ -70,7 +70,7 @@ function smarty_function_fetch($params, $smarty, $template)
$pass = $uri_parts['pass'];
}
// loop through parameters, setup headers
foreach($params as $param_key => $param_value) {
foreach ((array)$params as $param_key => $param_value) {
switch($param_key) {
case "file":
case "assign":
@ -166,7 +166,7 @@ function smarty_function_fetch($params, $smarty, $template)
fputs($fp, "Referer: $referer\r\n");
}
if(isset($extra_headers) && is_array($extra_headers)) {
foreach($extra_headers as $curr_header) {
foreach ((array)$extra_headers as $curr_header) {
fputs($fp, $curr_header."\r\n");
}
}

View file

@ -54,7 +54,7 @@ function smarty_function_html_checkboxes($params, $smarty, $template)
$extra = '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch($_key) {
case 'name':
case 'separator':
@ -105,12 +105,12 @@ function smarty_function_html_checkboxes($params, $smarty, $template)
if (isset($options)) {
foreach ($options as $_key=>$_val)
foreach ((array)$options as $_key=>$_val)
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} else {
foreach ($values as $_i=>$_key) {
foreach ((array)$values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
}

View file

@ -49,7 +49,7 @@ function smarty_function_html_image($params, $smarty, $template)
$path_prefix = '';
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch ($_key) {
case 'file':
case 'height':

View file

@ -42,7 +42,7 @@ function smarty_function_html_options($params, $smarty, $template)
$extra = '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch ($_key) {
case 'name':
$$_key = (string)$_val;
@ -78,10 +78,10 @@ function smarty_function_html_options($params, $smarty, $template)
$_html_result = '';
if (isset($options)) {
foreach ($options as $_key => $_val)
foreach ((array)$options as $_key => $_val)
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
} else {
foreach ($values as $_i => $_key) {
foreach ((array)$values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
}
@ -111,7 +111,7 @@ function smarty_function_html_options_optoutput($key, $value, $selected)
function smarty_function_html_options_optgroup($key, $values, $selected)
{
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
foreach ($values as $key => $value) {
foreach ((array)$values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected);
}
$optgroup_html .= "</optgroup>\n";

View file

@ -55,7 +55,7 @@ function smarty_function_html_radios($params, $smarty, $template)
$output = null;
$extra = '';
foreach($params as $_key => $_val) {
foreach ((array)$params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
@ -110,10 +110,10 @@ function smarty_function_html_radios($params, $smarty, $template)
$_html_result = array();
if (isset($options)) {
foreach ($options as $_key => $_val)
foreach ((array)$options as $_key => $_val)
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
} else {
foreach ($values as $_i => $_key) {
foreach ((array)$values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
}

View file

@ -91,7 +91,7 @@ function smarty_function_html_select_date($params, $smarty, $template)
$year_empty = null;
$extra_attrs = '';
foreach ($params as $_key => $_value) {
foreach ((array)$params as $_key => $_value) {
switch ($_key) {
case 'prefix':
case 'time':
@ -142,7 +142,7 @@ function smarty_function_html_select_date($params, $smarty, $template)
if (preg_match('!^-\d+$!', $time)) {
// negative timestamp, use date()
$time = date('Y-m-d', $time);
$time = date('Y-m-d', is_numeric($time) ? (int)$time : strtotime($time));
}
// If $time is not in format yyyy-mm-dd
if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {

View file

@ -51,7 +51,7 @@ function smarty_function_html_select_time($params, $smarty, $template)
$second_extra = null;
$meridian_extra = null;
foreach ($params as $_key => $_value) {
foreach ((array)$params as $_key => $_value) {
switch ($_key) {
case 'prefix':
case 'time':
@ -89,7 +89,7 @@ function smarty_function_html_select_time($params, $smarty, $template)
if ($display_hours) {
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
$hour_fmt = $use_24_hours ? '%H' : '%I';
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
for ($i = 0, $for_max = count((array)$hours); $i < $for_max; $i++)
$hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
@ -114,7 +114,7 @@ function smarty_function_html_select_time($params, $smarty, $template)
if ($display_minutes) {
$all_minutes = range(0, 59);
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i += $minute_interval)
for ($i = 0, $for_max = count((array)$all_minutes); $i < $for_max; $i += $minute_interval)
$minutes[] = sprintf('%02d', $all_minutes[$i]);
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
$html_result .= '<select name=';
@ -141,7 +141,7 @@ function smarty_function_html_select_time($params, $smarty, $template)
if ($display_seconds) {
$all_seconds = range(0, 59);
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i += $second_interval)
for ($i = 0, $for_max = count((array)$all_seconds); $i < $for_max; $i += $second_interval)
$seconds[] = sprintf('%02d', $all_seconds[$i]);
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
$html_result .= '<select name=';

View file

@ -68,7 +68,7 @@ function smarty_function_html_table($params, $smarty, $template)
return;
}
foreach ($params as $_key => $_value) {
foreach ((array)$params as $_key => $_value) {
switch ($_key) {
case 'loop':
$$_key = (array)$_value;
@ -77,10 +77,10 @@ function smarty_function_html_table($params, $smarty, $template)
case 'cols':
if (is_array($_value) && !empty($_value)) {
$cols = $_value;
$cols_count = count($_value);
$cols_count = count((array)$_value);
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
$cols = explode(',', $_value);
$cols_count = count($cols);
$cols_count = count((array)$cols);
} elseif (!empty($_value)) {
$cols_count = (int)$_value;
} else {
@ -109,7 +109,7 @@ function smarty_function_html_table($params, $smarty, $template)
}
}
$loop_count = count($loop);
$loop_count = count((array)$loop);
if (empty($params['rows'])) {
/* no rows specified */
$rows = ceil($loop_count / $cols_count);
@ -169,7 +169,7 @@ function smarty_function_html_table_cycle($name, $var, $no)
if (!is_array($var)) {
$ret = $var;
} else {
$ret = $var[$no % count($var)];
$ret = $var[$no % count((array)$var)];
}
return ($ret) ? ' ' . $ret : '';

View file

@ -66,7 +66,7 @@ function smarty_function_mailto($params, $smarty, $template)
$search = array('%40', '%2C');
$replace = array('@', ',');
$mail_parms = array();
foreach ($params as $var => $value) {
foreach ((array)$params as $var => $value) {
switch ($var) {
case 'cc':
case 'bcc':
@ -89,7 +89,7 @@ function smarty_function_mailto($params, $smarty, $template)
}
$mail_parm_vals = '';
for ($i = 0; $i < count($mail_parms); $i++) {
for ($i = 0; $i < count((array)$mail_parms); $i++) {
$mail_parm_vals .= (0 == $i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
}

View file

@ -42,14 +42,14 @@ function smarty_function_math($params, $smarty, $template)
$allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
foreach($match[1] as $curr_var) {
foreach ((array)$match[1] as $curr_var) {
if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
return;
}
}
foreach($params as $key => $val) {
foreach ((array)$params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val)==0) {

View file

@ -23,7 +23,7 @@
function smarty_function_popup($params, $smarty, $template)
{
$append = '';
foreach ($params as $_key=>$_value) {
foreach ((array)$params as $_key=>$_value) {
switch ($_key) {
case 'text':
case 'trigger':

View file

@ -27,7 +27,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false)
// check uc_digits case
if (!$uc_digits) {
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) {
foreach($matches[1] as $match)
foreach ((array)$matches[1] as $match)
$upper_string = substr_replace($upper_string, $match[0], $match[1], strlen($match[0]));
}
}

View file

@ -44,17 +44,17 @@ function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FOR
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
$_win_to[] = sprintf('%\' 2d', date('j', is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp)));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
$_win_to[] = sprintf('%\' 2d', date('h', is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp)));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);
return date($format, is_numeric($timestamp) ? (int)$timestamp : strtotime($timestamp));
}
}

View file

@ -29,8 +29,8 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
switch (gettype($var)) {
case 'array' :
$results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) {
$results = '<b>Array (' . count((array)$var) . ')</b>';
foreach ((array)$var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
@ -39,8 +39,8 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
break;
case 'object' :
$object_vars = get_object_vars($var);
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
foreach ($object_vars as $curr_key => $curr_val) {
$results = '<b>' . get_class($var) . ' Object (' . count((array)$object_vars) . ')</b>';
foreach ((array)$object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);

View file

@ -23,7 +23,7 @@
function smarty_modifier_regex_replace($string, $search, $replace)
{
if(is_array($search)) {
foreach($search as $idx => $s)
foreach ((array)$search as $idx => $s)
$search[$idx] = _smarty_regex_replace_check($s);
} else {
$search = _smarty_regex_replace_check($search);

View file

@ -24,7 +24,7 @@ function smarty_modifiercompiler_default ($params, $compiler)
if (!isset($params[1])) {
$params[1] = "''";
}
for ($i = 1, $cnt = count($params); $i < $cnt; $i++) {
for ($i = 1, $cnt = count((array)$params); $i < $cnt; $i++) {
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $params[$i] . ' : $tmp)';
}
return $output;

View file

@ -66,7 +66,7 @@ function smarty_outputfilter_trimwhitespace($source, $smarty)
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
$_len = strlen($search_str);
$_pos = 0;
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
for ($_i=0, $_count=count((array)$replace); $_i<$_count; $_i++)
if (($_pos=strpos($subject, $search_str, $_pos))!==false)
$subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
else

View file

@ -133,9 +133,9 @@ class Smarty_Internal_CacheResource_File {
$_dir_length = strlen($_dir);
if (isset($_cache_id)) {
$_cache_id_parts = explode('|', $_cache_id);
$_cache_id_parts_count = count($_cache_id_parts);
$_cache_id_parts_count = count((array)$_cache_id_parts);
if ($this->smarty->use_sub_dirs) {
foreach ($_cache_id_parts as $id_part) {
foreach ((array)$_cache_id_parts as $id_part) {
$_dir .= $id_part . DS;
}
}
@ -157,7 +157,7 @@ class Smarty_Internal_CacheResource_File {
if (file_exists($_dir)) {
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) {
foreach ((array)$_cache as $_file) {
if (strpos($_file, '.svn') !== false) continue;
// directory ?
if ($_file->isDir()) {
@ -167,7 +167,7 @@ class Smarty_Internal_CacheResource_File {
}
} else {
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string)$_file, $_dir_length)));
$_parts_count = count($_parts);
$_parts_count = count((array)$_parts);
// check name
if (isset($resource_name)) {
if ($_parts[$_parts_count-1] != $_resourcename_parts) {

View file

@ -96,8 +96,8 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase {
$compiler->template->has_nocache_code = true;
}
foreach($_tpl->required_plugins as $code => $tmp1) {
foreach($tmp1 as $name => $tmp) {
foreach($tmp as $type => $data) {
foreach ((array)$tmp1 as $name => $tmp) {
foreach ((array)$tmp as $type => $data) {
$compiler->template->required_plugins[$code][$name][$type] = $data;
}
}

View file

@ -43,7 +43,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase {
$_nocache = 'false';
}
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -47,7 +47,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
$this->compiler->trigger_template_error('unmatched {block} {/block} pairs');
}
preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block(.*?){$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
$_result_count = count($_result[0]);
$_result_count = count((array)$_result[0]);
$_start = 0;
while ($_start < $_result_count) {
$_end = 0;

View file

@ -48,7 +48,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase {
$output = "<?php ";
if (isset($_attr['ifexp'])) {
foreach ($_attr['start'] as $_statement) {
foreach ((array)$_attr['start'] as $_statement) {
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]] = new Smarty_Variable;";
$output .= " \$_smarty_tpl->tpl_vars[$_statement[var]]->value = $_statement[value];\n";
$compiler->local_var[$_statement['var']] = true;
@ -131,7 +131,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase {
list($_open_tag, $this->compiler->nocache, $local_vars) = $this->_close_tag(array('for', 'forelse'));
foreach ($local_vars as $var) {
foreach ((array)$local_vars as $var) {
unset($compiler->local_var[$var]);
}
if ($_open_tag == 'forelse')

View file

@ -33,7 +33,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
$_name = trim($_attr['name'], "'\"");
unset($_attr['name']);
$compiler->template->properties['function'][$_name]['parameter'] = array();
foreach ($_attr as $_key => $_data) {
foreach ((array)$_attr as $_key => $_data) {
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
}
$compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
@ -78,7 +78,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
if (!empty($compiler->template->required_plugins['compiled'])) {
$plugins_string = '<?php ';
foreach($compiler->template->required_plugins['compiled'] as $tmp) {
foreach($tmp as $data) {
foreach ((array)$tmp as $data) {
$plugins_string .= "if (!is_callable('{$data['function']}')) include '{$data['file']}';\n";
}
}
@ -87,7 +87,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
if (!empty($compiler->template->required_plugins['nocache'])) {
$plugins_string .= "<?php echo '/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php ";
foreach($compiler->template->required_plugins['nocache'] as $tmp) {
foreach($tmp as $data) {
foreach ((array)$tmp as $data) {
$plugins_string .= "if (!is_callable(\'{$data['function']}\')) include \'{$data['file']}\';\n";
}
}

View file

@ -137,7 +137,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase {
if (!empty($_attr)) {
if ($_parent_scope == SMARTY_LOCAL_SCOPE) {
// create variables
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
$_output .= "\$_template->assign('$_key',$_value);";
}
} else {

View file

@ -94,7 +94,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase {
unset($_attr['name'], $_attr['assign'], $_attr['script']);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
$_paramsArray[] = "'$_key' => $_value";
}
$_params = 'array(' . implode(", ", $_paramsArray) . ')';

View file

@ -32,7 +32,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
$_attr = $this->_get_attributes($args);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -33,7 +33,7 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
$_attr = $this->_get_attributes($args);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -29,10 +29,10 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$_attr = $this->_get_attributes($args);
$output = $_attr['value'];
// loop over list of modifiers
foreach ($_attr['modifierlist'] as $single_modifier) {
foreach ((array)$_attr['modifierlist'] as $single_modifier) {
preg_match_all('/(((\'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\'|[^:"]*"[^"\\\\]*(?:\\\\.[^"\\\\]*)*")[^:]*)+|::?|[^:]+)/', $single_modifier, $mod_array);
$modifier = $mod_array[0][0];
for ($i = 0, $count = count($mod_array[0]);$i < $count;$i++) {
for ($i = 0, $count = count((array)$mod_array[0]);$i < $count;$i++) {
if ($mod_array[0][$i] == ':') {
$mod_array[0][$i] = ',';
}
@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// check for plugin modifiercompiler
} else if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
$plugin = 'smarty_modifiercompiler_' . $modifier;
foreach($mod_array[0] as $key => $value) {
foreach ((array)$mod_array[0] as $key => $value) {
if ($value == ',') {
unset ($mod_array[0][$key]);
}

View file

@ -33,7 +33,7 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
$_attr = $this->_get_attributes($args);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -37,7 +37,7 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
// convert attributes into parameter array string
if ($this->compiler->smarty->registered_objects[$tag][2]) {
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -32,7 +32,7 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
$_attr = $this->_get_attributes($args);
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -35,7 +35,7 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
$this->compiler->tag_nocache = !$compiler->smarty->registered_plugins['function'][$tag][1];
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
foreach ((array)$_attr as $_key => $_value) {
if (is_int($_key)) {
$_paramsArray[] = "$_key=>$_value";
} else {

View file

@ -100,7 +100,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
}
if (isset($_index[1])) {
array_shift($_index);
foreach ($_index as $_ind) {
foreach ((array)$_index as $_ind) {
$compiled_ref = $compiled_ref . "[$_ind]";
}
}

View file

@ -39,7 +39,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase {
$output .= "unset(\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]);\n";
$section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]";
foreach ($_attr as $attr_name => $attr_value) {
foreach ((array)$_attr as $attr_name => $attr_value) {
switch ($attr_name) {
case 'loop':
$output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int)\$_loop); unset(\$_loop);\n";

View file

@ -37,14 +37,14 @@ abstract class Smarty_Internal_CompileBase
{
// check if all required attributes present
foreach ($this->required_attributes as $attr) {
if (!array_key_exists($attr, $args)) {
if (!array_key_exists($attr, (array)$args)) {
$this->compiler->trigger_template_error("missing \"" . $attr . "\" attribute");
}
}
// check for unallowed attributes
if ($this->optional_attributes != array('_any')) {
$tmp_array = array_merge($this->required_attributes, $this->optional_attributes);
foreach ($args as $key => $dummy) {
foreach ((array)$args as $key => $dummy) {
if (!in_array($key, $tmp_array) && $key !== 0) {
$this->compiler->trigger_template_error("unexpected \"" . $key . "\" attribute");
}

View file

@ -246,7 +246,7 @@ class Smarty_Internal_Config {
$_config_vars = array();
include($this->getCompiledFilepath ());
// copy global config vars
foreach ($_config_vars['vars'] as $variable => $value) {
foreach ((array)$_config_vars['vars'] as $variable => $value) {
if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {
$scope->config_vars[$variable] = $value;
} else {
@ -254,7 +254,7 @@ class Smarty_Internal_Config {
}
}
// scan sections
foreach ($_config_vars['sections'] as $this_section => $dummy) {
foreach ((array)$_config_vars['sections'] as $this_section => $dummy) {
if ($sections == null || in_array($this_section, (array)$sections)) {
foreach ($_config_vars['sections'][$this_section]['vars'] as $variable => $value) {
if ($this->smarty->config_overwrite || !isset($scope->config_vars[$variable])) {

View file

@ -91,7 +91,7 @@ class Smarty_Internal_Configfilelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state START');
@ -198,7 +198,7 @@ class Smarty_Internal_Configfilelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state VALUE');
@ -319,7 +319,7 @@ class Smarty_Internal_Configfilelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state NAKED_STRING_VALUE');
@ -388,7 +388,7 @@ class Smarty_Internal_Configfilelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state COMMENT');
@ -466,7 +466,7 @@ class Smarty_Internal_Configfilelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state SECTION');

View file

@ -127,7 +127,7 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
$ss = preg_split('/(\\\\.)/', $escaped_string, -1, PREG_SPLIT_DELIM_CAPTURE);
$str = "";
foreach ($ss as $s) {
foreach ((array)$ss as $s) {
if (strlen($s) === 2 && $s[0] === '\\') {
if (isset(self::$escapes_single[$s[1]])) {
$s = self::$escapes_single[$s[1]];
@ -166,7 +166,7 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
if (!isset($this->compiler->config_data['vars'])) {
$this->compiler->config_data['vars'] = Array();
}
foreach ($vars as $var) {
foreach ((array)$vars as $var) {
$this->set_var($var, $this->compiler->config_data);
}
}
@ -175,7 +175,7 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser
if (!isset($this->compiler->config_data['sections'][$section_name]['vars'])) {
$this->compiler->config_data['sections'][$section_name]['vars'] = Array();
}
foreach ($vars as $var) {
foreach ((array)$vars as $var) {
$this->set_var($var, $this->compiler->config_data['sections'][$section_name]);
}
}

View file

@ -28,7 +28,7 @@ class Smarty_Internal_Data {
public function assign($tpl_var, $value = null, $nocache = false, $scope = SMARTY_LOCAL_SCOPE)
{
if (is_array($tpl_var)) {
foreach ($tpl_var as $_key => $_val) {
foreach ((array)$tpl_var as $_key => $_val) {
if ($_key != '') {
$this->tpl_vars[$_key] = new Smarty_variable($_val, $nocache, $scope);
}
@ -93,7 +93,7 @@ class Smarty_Internal_Data {
{
if (is_array($tpl_var)) {
// $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val) {
foreach ((array)$tpl_var as $_key => $_val) {
if ($_key != '') {
if (!isset($this->tpl_vars[$_key])) {
$tpl_var_inst = $this->getVariable($_key, null, true, false);
@ -110,7 +110,7 @@ class Smarty_Internal_Data {
settype($this->tpl_vars[$_key]->value, 'array');
}
if ($merge && is_array($_val)) {
foreach($_val as $_mkey => $_mval) {
foreach ((array)$_val as $_mkey => $_mval) {
$this->tpl_vars[$_key]->value[$_mkey] = $_mval;
}
} else {
@ -135,7 +135,7 @@ class Smarty_Internal_Data {
settype($this->tpl_vars[$tpl_var]->value, 'array');
}
if ($merge && is_array($value)) {
foreach($value as $_mkey => $_mval) {
foreach ((array)$value as $_mkey => $_mval) {
$this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
}
} else {
@ -162,7 +162,7 @@ class Smarty_Internal_Data {
settype($this->tpl_vars[$tpl_var]->value, 'array');
}
if ($merge && is_array($value)) {
foreach($value as $_key => $_val) {
foreach ((array)$value as $_key => $_val) {
$this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
}
} else {
@ -229,7 +229,7 @@ class Smarty_Internal_Data {
public function clearAssign($tpl_var)
{
if (is_array($tpl_var)) {
foreach ($tpl_var as $curr_var) {
foreach ((array)$tpl_var as $curr_var) {
unset($this->tpl_vars[$curr_var]);
}
} else {
@ -403,7 +403,7 @@ class Smarty_Data extends Smarty_Internal_Data {
$this->parent = $_parent;
} elseif (is_array($_parent)) {
// set up variable values
foreach ($_parent as $_key => $_val) {
foreach ((array)$_parent as $_key => $_val) {
$this->tpl_vars[$_key] = new Smarty_variable($_val);
}
} elseif ($_parent != null) {

View file

@ -206,10 +206,10 @@ class Smarty_Internal_Register {
*/
function resource($resource_type, $function_names)
{
if (count($function_names) == 4) {
if (count((array)$function_names) == 4) {
$this->smarty->_plugins['resource'][$resource_type] =
array($function_names, false);
} elseif (count($function_names) == 5) {
} elseif (count((array)$function_names) == 5) {
$this->smarty->_plugins['resource'][$resource_type] =
array(array(array(&$function_names[0], $function_names[1]),
array(&$function_names[0], $function_names[2]),

View file

@ -55,7 +55,7 @@ class Smarty_Internal_Resource_Extends {
{
$sha1String = '';
$_files = explode('|', $_template->resource_name);
foreach ($_files as $_file) {
foreach ((array)$_files as $_file) {
$_filepath = $_template->buildTemplateFilepath ($_file);
if ($_filepath !== false) {
if ($_template->security) {
@ -92,7 +92,7 @@ class Smarty_Internal_Resource_Extends {
$_files = array_reverse($this->allFilepaths);
$_first = reset($_files);
$_last = end($_files);
foreach ($_files as $_file => $_filepath) {
foreach ((array)$_files as $_file => $_filepath) {
if ($_filepath === false) {
throw new SmartyException("Unable to load template 'file : {$_file}'");
}
@ -108,7 +108,7 @@ class Smarty_Internal_Resource_Extends {
$this->smarty->trigger_error("unmatched {block} {/block} pairs in file '$_filepath'");
}
preg_match_all("!{$this->_ldl}block\s(.+?){$this->_rdl}|{$this->_ldl}/block(.*?){$this->_rdl}!", $_content, $_result, PREG_OFFSET_CAPTURE);
$_result_count = count($_result[0]);
$_result_count = count((array)$_result[0]);
$_start = 0;
while ($_start < $_result_count) {
$_end = 0;
@ -211,7 +211,7 @@ class Smarty_Internal_Resource_Extends {
if (substr($_compile_dir, -1) != DS) {
$_compile_dir .= DS;
}
return $_compile_dir . $_filepath . '.' . $_template->resource_type . '.' . basename($_files[count($_files)-1]) . $_cache . '.php';
return $_compile_dir . $_filepath . '.' . $_template->resource_type . '.' . basename($_files[count((array)$_files)-1]) . $_cache . '.php';
}
}

View file

@ -482,8 +482,8 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) {
$this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
foreach($this->required_plugins as $code => $tmp1) {
foreach($tmp1 as $name => $tmp) {
foreach($tmp as $type => $data) {
foreach ((array)$tmp1 as $name => $tmp) {
foreach ((array)$tmp as $type => $data) {
$this->parent->required_plugins[$code][$name][$type] = $data;
}
}
@ -504,7 +504,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
preg_match_all("!/\*%%SmartyNocache:{$this->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$this->properties['nocache_hash']}%%\*/!s", $this->rendered_content, $cache_parts);
$output = '';
// loop over items, stitch back together
foreach($cache_split as $curr_idx => $curr_split) {
foreach ((array)$cache_split as $curr_idx => $curr_split) {
// escape PHP tags in template content
$output .= preg_replace('/(<%|%>|<\?php|<\?|\?>)/', '<?php echo \'$1\'; ?>', $curr_split);
if (isset($cache_parts[0][$curr_idx])) {
@ -770,7 +770,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
if (!empty($this->required_plugins['compiled'])) {
$plugins_string = '<?php ';
foreach($this->required_plugins['compiled'] as $tmp) {
foreach($tmp as $data) {
foreach ((array)$tmp as $data) {
$plugins_string .= "if (!is_callable('{$data['function']}')) include '{$data['file']}';\n";
}
}
@ -780,7 +780,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
$this->has_nocache_code = true;
$plugins_string .= "<?php echo '/*%%SmartyNocache:{$this->properties['nocache_hash']}%%*/<?php ";
foreach($this->required_plugins['nocache'] as $tmp) {
foreach($tmp as $data) {
foreach ((array)$tmp as $data) {
$plugins_string .= "if (!is_callable(\'{$data['function']}\')) include \'{$data['file']}\';\n";
}
}

View file

@ -163,7 +163,7 @@ class Smarty_Internal_Templatelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TEXT');
@ -452,7 +452,7 @@ class Smarty_Internal_Templatelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state SMARTY');
@ -898,7 +898,7 @@ class Smarty_Internal_Templatelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state LITERAL');
@ -1022,7 +1022,7 @@ class Smarty_Internal_Templatelexer
if (preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches)) {
$yysubmatches = $yymatches;
$yymatches = array_filter($yymatches, 'strlen'); // remove empty sub-patterns
if (!count($yymatches)) {
if (!count((array)$yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
'an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state DOUBLEQUOTEDSTRING');

View file

@ -62,7 +62,7 @@ class Smarty_Internal_Utility {
foreach((array)$this->smarty->template_dir as $_dir) {
$_compileDirs = new RecursiveDirectoryIterator($_dir);
$_compile = new RecursiveIteratorIterator($_compileDirs);
foreach ($_compile as $_fileinfo) {
foreach ((array)$_compile as $_fileinfo) {
if (strpos($_fileinfo, '.svn') !== false) continue;
$_file = $_fileinfo->getFilename();
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
@ -120,7 +120,7 @@ class Smarty_Internal_Utility {
foreach((array)$this->smarty->config_dir as $_dir) {
$_compileDirs = new RecursiveDirectoryIterator($_dir);
$_compile = new RecursiveIteratorIterator($_compileDirs);
foreach ($_compile as $_fileinfo) {
foreach ((array)$_compile as $_fileinfo) {
if (strpos($_fileinfo, '.svn') !== false) continue;
$_file = $_fileinfo->getFilename();
if (!substr_compare($_file, $extention, - strlen($extention)) == 0) continue;
@ -184,7 +184,7 @@ class Smarty_Internal_Utility {
$_count = 0;
$_compileDirs = new RecursiveDirectoryIterator($_dir);
$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_compile as $_file) {
foreach ((array)$_compile as $_file) {
if (strpos($_file, '.svn') !== false) continue;
if ($_file->isDir()) {
if (!$_compile->isDot()) {

View file

@ -106,7 +106,7 @@ class Smarty_Internal_Wrapper {
default:
// convert foo_bar_baz to fooBarBaz style names
$name_parts = explode('_',$name);
foreach($name_parts as $idx=>$part) {
foreach ((array)$name_parts as $idx=>$part) {
if($idx==0)
$name_parts[$idx] = strtolower($part);
else