From 128b6b06dfb64a516392418f148fead7b4579569 Mon Sep 17 00:00:00 2001 From: ralf Date: Sun, 24 Apr 2022 20:52:49 +0200 Subject: [PATCH] fix PHP 8.x TypeError: string & int --- api/src/Etemplate/Widget/Select.php | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/api/src/Etemplate/Widget/Select.php b/api/src/Etemplate/Widget/Select.php index a958e05bfc..44b8364e6f 100644 --- a/api/src/Etemplate/Widget/Select.php +++ b/api/src/Etemplate/Widget/Select.php @@ -570,7 +570,7 @@ class Select extends Etemplate\Widget $decr = $type > 0 ? $type : 10; for ($i=0; $i <= 100; $i += $decr) { - $options[intval($i)] = intval($i).'%'; + $options[(int)$i] = (int)$i.'%'; } $options[100] = '100%'; if (!$rows || !empty($value)) @@ -669,8 +669,14 @@ class Select extends Etemplate\Widget if ($type <= 0) $type = 3; if ($type2 <= 0) $type2 = 2; if ($type > 100 && $type2 > 100 && $type > $type) { $y = $type; $type=$type2; $type2=$y; } - $y = date('Y')-$type; - if ($value && $value-$type < $y || $type > 100) $y = $type > 100 ? $type : $value-$type; + if ($value && $value-$type < $y || $type > 100) + { + $y = $type > 100 ? $type : $value-$type; + } + else + { + $y = (int)date('Y')-$type; + } $to = date('Y')+$type2; if ($value && $value+$type2 > $to || $type2 > 100) $to = $type2 > 100 ? $type2 : $value+$type2; for ($n = 0; $y <= $to && $n < 200; ++$n) @@ -682,7 +688,7 @@ class Select extends Etemplate\Widget case 'select-month': $options = self::$monthnames; - $value = intval($value); + $value = (int)$value; break; case 'select-dow': // options: rows[,0=summaries befor days, 1=summaries after days, 2=no summaries[,extraStyleMultiselect]] @@ -731,7 +737,7 @@ class Select extends Etemplate\Widget } if (!is_array($value)) { - $value_in = $value; + $value_in = (int)$value; $value = array(); foreach (array_keys($options) as $val) { @@ -757,14 +763,14 @@ class Select extends Etemplate\Widget // fall-through case 'select-number': // options: rows,min,max,decrement,suffix - $type = $type === '' ? 1 : intval($type); // min - $type2 = $type2 === '' ? 10 : intval($type2); // max + $type = $type === '' ? 1 : (int)$type; // min + $type2 = $type2 === '' ? 10 : (int)$type2; // max $format = '%d'; if (!empty($type3) && $type3[0] == '0') // leading zero { $format = '%0'.strlen($type3).'d'; } - $type3 = !$type3 ? 1 : intval($type3); // decrement + $type3 = !$type3 ? 1 : (int)$type3; // decrement if (($type <= $type2) != ($type3 > 0)) { $type3 = -$type3; // void infinite loop @@ -980,4 +986,4 @@ class Select extends Etemplate\Widget $response->data($options); } } -Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Select', array('selectbox', 'listbox', 'select', 'menupopup')); +Etemplate\Widget::registerWidget(__NAMESPACE__.'\\Select', array('selectbox', 'listbox', 'select', 'menupopup')); \ No newline at end of file