php8 warnings cleanup

This commit is contained in:
fbsanchez 2022-01-11 12:08:41 +01:00
parent b731a05bb3
commit 7ebd6a5f74
7 changed files with 47 additions and 34 deletions

View File

@ -36,7 +36,7 @@ if (isset($config['id_user']) === false) {
<script type="text/javascript" language="javascript">
$(document).ready(function(){
var menuType_value = "<?php echo $_SESSION['menu_type']; ?>";
var menuType_value = "<?php echo ($_SESSION['menu_type'] ?? ''); ?>";
if (menuType_value === '' || menuType_value === 'classic') {
$('ul.submenu').css('left', '214px');

View File

@ -659,15 +659,17 @@ class ConsoleSupervisor
$_cache_targets = [];
}
if ($_cache_targets[$key] !== null) {
if (isset($_cache_targets[$key]) === true
&& $_cache_targets[$key] !== null
) {
$targets = $_cache_targets[$key];
} else {
$targets = get_notification_source_targets(
$source_id,
$data['type']
);
$this->targetGroups = $targets['groups'];
$this->targetUsers = $targets['users'];
$this->targetGroups = ($targets['groups'] ?? null);
$this->targetUsers = ($targets['users'] ?? null);
$_cache_targets[$key] = $targets;
}

View File

@ -473,12 +473,13 @@ class HTML
bool $direct=false
) {
global $config;
$text_color = '';
if ($config['style'] === 'pandora_black') {
$text_color = 'style="color: white"';
}
$output = '';
if ($input['hidden'] == 1) {
if (($input['hidden'] ?? null) == 1) {
$class = ' hidden';
} else {
$class = '';
@ -488,9 +489,9 @@ class HTML
$class = $input['class'].$class;
}
if (is_array($input['block_content']) === true) {
$direct = (bool) $input['direct'];
$toggle = (bool) $input['toggle'];
if (is_array(($input['block_content'] ?? null)) === true) {
$direct = (bool) ($input['direct'] ?? false);
$toggle = (bool) ($input['toggle'] ?? false);
if (isset($input['label']) === true) {
$output .= '<span '.$text_color.'>'.$input['label'].'</span>';
@ -499,13 +500,13 @@ class HTML
// Print independent block of inputs.
$output .= '<li id="li-'.$input['block_id'].'" class="'.$class.'">';
if ($input['wrapper']) {
if (isset($input['wrapper']) === true) {
$output .= '<'.$input['wrapper'].' id="'.$input['block_id'].'" class="'.$class.'">';
}
if (!$direct) {
// Avoid encapsulation if input is direct => 1.
$output .= '<ul class="wizard '.$input['block_class'].'">';
$output .= '<ul class="wizard '.($input['block_class'] ?? '').'">';
}
$html = '';
@ -544,7 +545,7 @@ class HTML
$output .= '</ul>';
}
if ($input['wrapper']) {
if (isset($input['wrapper']) === true) {
$output .= '</'.$input['wrapper'].'>';
}
@ -560,7 +561,7 @@ class HTML
}
if (!$direct) {
$output .= '<li id="'.$input['id'].'" class="'.$class.'">';
$output .= '<li id="'.($input['id'] ?? '').'" class="'.$class.'">';
}
if (isset($input['label']) === true) {
@ -569,7 +570,7 @@ class HTML
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
$output .= ($input['extra'] ?? '');
if (!$direct) {
$output .= '</li>';
}
@ -581,7 +582,7 @@ class HTML
} else {
$output .= self::printInput($input['arguments']);
// Allow dynamic content.
$output .= $input['extra'];
$output .= ($input['extra'] ?? '');
}
}
@ -773,13 +774,13 @@ class HTML
bool $return=false,
bool $print_white_box=false
) {
$form = $data['form'];
$inputs = $data['inputs'];
$rawInputs = $data['rawInputs'];
$js = $data['js'];
$rawjs = $data['js_block'];
$cb_function = $data['cb_function'];
$cb_args = $data['cb_args'];
$form = ($data['form'] ?? null);
$inputs = ($data['inputs'] ?? []);
$rawInputs = ($data['rawInputs'] ?? null);
$js = ($data['js'] ?? null);
$rawjs = ($data['js_block'] ?? null);
$cb_function = ($data['cb_function'] ?? null);
$cb_args = ($data['cb_args'] ?? null);
$output_head = '';
if (empty($data['pre-content']) === false) {
@ -848,7 +849,9 @@ class HTML
$output .= '<ul class="wizard">';
foreach ($inputs as $input) {
if ($input['arguments']['type'] != 'submit') {
if (is_array(($input['arguments'] ?? null)) === true
&& $input['arguments']['type'] != 'submit'
) {
$output .= self::printBlock($input, true);
} else {
$output_submit .= self::printBlock($input, true);

View File

@ -3339,8 +3339,8 @@ function get_um_url()
*/
function config_return_in_bytes($val)
{
$val = (int) trim($val);
$last = strtolower($val[(strlen($val) - 1)]);
$val = (int) trim($val);
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0.
case 'g':

View File

@ -2816,7 +2816,7 @@ function html_print_input_number(array $settings):string
$output .= $attribute.'="'.$attr_value.'" ';
}
$output .= $function.'/>';
$output .= '/>';
}
}
@ -4472,8 +4472,8 @@ function html_print_switch($attributes=[])
$html_expand = '';
// Check the load values on status.
$html_expand .= (bool) ($attributes['value']) ? ' checked' : '';
$html_expand .= (bool) ($attributes['disabled']) ? ' disabled' : '';
$html_expand .= (bool) ($attributes['value'] ?? false) ? ' checked' : '';
$html_expand .= (bool) ($attributes['disabled'] ?? false) ? ' disabled' : '';
// Only load the valid attributes.
$valid_attrs = [
@ -4495,9 +4495,9 @@ function html_print_switch($attributes=[])
$attributes['style'] = '';
}
$disabled_class = (bool) ($attributes['disabled']) ? ' p-slider-disabled' : '';
$disabled_class = (bool) ($attributes['disabled'] ?? false) ? ' p-slider-disabled' : '';
return "<label class='p-switch ".$attributes['container-class']."' style='".$attributes['style']."'>
return "<label class='p-switch ".($attributes['container-class'] ?? '')."' style='".($attributes['style'] ?? '')."'>
<input type='checkbox' ".$html_expand.">
<span class='p-slider".$disabled_class."'></span>
</label>";
@ -4573,7 +4573,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$output = '';
if ($data['label'] && $input_only === false) {
if (($data['label'] ?? false) && $input_only === false) {
$output = '<'.$wrapper.' id="'.$wrapper.'-'.$data['name'].'" ';
$output .= ' class="'.$data['input_class'].'">';
$output .= '<label '.$style.' class="'.$data['label_class'].'">';
@ -5165,7 +5165,7 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$output .= '</'.$data['wrapper'].'>';
}
if ($data['label'] && $input_only === false) {
if (($data['label'] ?? false) && $input_only === false) {
$output .= '</'.$wrapper.'>';
if (!$data['return']) {
echo '</'.$wrapper.'>';

View File

@ -395,7 +395,15 @@ function menu_print_menu(&$menu)
}
// Choose valid section (sec).
if (enterprise_hook('enterprise_acl', [$config['id_user'], $mainsec, $main['sec2']]) == false) {
if ((bool) enterprise_hook(
'enterprise_acl',
[
$config['id_user'],
$mainsec,
($main['sec2'] ?? null),
]
) === false
) {
if ($count_sub_access > 0) {
// If any susection have access but main section not, we change main link to first subsection found
$main['sec2'] = $first_sub_sec2;

View File

@ -1010,7 +1010,7 @@ if (isset($_GET['bye'])) {
clear_pandora_error_for_header();
if ((bool) $config['node_deactivated'] === true) {
if ((bool) ($config['node_deactivated'] ?? false) === true) {
// Prevent access node if not merged.
include 'general/node_deactivated.php';
@ -1021,7 +1021,7 @@ if ((bool) $config['node_deactivated'] === true) {
exit('</html>');
}
if ((bool) $config['maintenance_mode'] === true
if ((bool) ($config['maintenance_mode'] ?? false) === true
&& (bool) users_is_admin() === false
) {
// Show maintenance web-page. For non-admin users only.
@ -1082,7 +1082,7 @@ if (get_parameter('login', 0) !== 0) {
}
if ((bool) $config['maintenance_mode'] === true
if ((bool) ($config['maintenance_mode'] ?? false) === true
&& (bool) users_is_admin() === false
) {
// Show maintenance web-page. For non-admin users only.