From aa49154e5a9ee135c3f0286ddda8a01a5290b1ed Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Wed, 15 Nov 2023 17:53:47 +0100 Subject: Fix more type errors, stricter typing --- modules-available/statistics/pages/list.inc.php | 4 ++-- modules-available/statistics/pages/machine.inc.php | 8 ++++---- modules-available/statistics/pages/summary.inc.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'modules-available/statistics/pages') diff --git a/modules-available/statistics/pages/list.inc.php b/modules-available/statistics/pages/list.inc.php index b318cc68..facffdd0 100644 --- a/modules-available/statistics/pages/list.inc.php +++ b/modules-available/statistics/pages/list.inc.php @@ -89,9 +89,9 @@ class SubPage $row['subnet'] = "$octets[0].$octets[1].$octets[2]"; $row['lastoctet'] = $octets[3]; } - $row['ramclass'] = StatisticsStyling::ramColorClass($row['mbram']); + $row['ramclass'] = StatisticsStyling::ramColorClass((int)$row['mbram']); $row['kvmclass'] = StatisticsStyling::kvmColorClass($row['kvmstate']); - $row['hddclass'] = StatisticsStyling::hddColorClass($row['gbtmp']); + $row['hddclass'] = StatisticsStyling::hddColorClass((int)$row['gbtmp']); if (empty($row['hostname'])) { $row['hostname'] = $row['clientip']; } diff --git a/modules-available/statistics/pages/machine.inc.php b/modules-available/statistics/pages/machine.inc.php index 24bf7c1e..fe82797d 100644 --- a/modules-available/statistics/pages/machine.inc.php +++ b/modules-available/statistics/pages/machine.inc.php @@ -219,9 +219,9 @@ class SubPage $client['live_cpuidle'] = 100 - $client['live_cpuload']; } $client['live_cputemppercent'] = max(0, min(100, 110 - $client['live_cputemp'])); - $client['ramclass'] = StatisticsStyling::ramColorClass($client['mbram']); + $client['ramclass'] = StatisticsStyling::ramColorClass((int)$client['mbram']); $client['kvmclass'] = StatisticsStyling::kvmColorClass($client['kvmstate']); - $client['hddclass'] = StatisticsStyling::hddColorClass($client['gbtmp']); + $client['hddclass'] = StatisticsStyling::hddColorClass((int)$client['gbtmp']); // Format HDD data to strings foreach ($hdds['hdds'] as &$hdd) { $hdd['smart_status_failed'] = !($client['smart_status//passed'] ?? 1); @@ -405,8 +405,8 @@ class SubPage } if (count($spans['rows']) > 10) { $spans['hasrows2'] = true; - $spans['rows2'] = array_slice($spans['rows'], ceil(count($spans['rows']) / 2)); - $spans['rows'] = array_slice($spans['rows'], 0, ceil(count($spans['rows']) / 2)); + $spans['rows2'] = array_slice($spans['rows'], (int)ceil(count($spans['rows']) / 2)); + $spans['rows'] = array_slice($spans['rows'], 0, (int)ceil(count($spans['rows']) / 2)); } $spans['isclient'] = $client['isclient']; Render::addTemplate('machine-usage', $spans); diff --git a/modules-available/statistics/pages/summary.inc.php b/modules-available/statistics/pages/summary.inc.php index d0538b38..e9c25456 100644 --- a/modules-available/statistics/pages/summary.inc.php +++ b/modules-available/statistics/pages/summary.inc.php @@ -129,7 +129,7 @@ class SubPage ['data' => $points1, 'label' => 'Online', 'borderColor' => '#8f3'], ['data' => $points2, 'label' => 'In use', 'borderColor' => '#e76'], ]]); - $data['markings'] = json_encode($lectures, true); + $data['markings'] = json_encode($lectures); } if (Module::get('runmode') !== false) { $res = Database::queryFirst('SELECT Count(*) AS cnt FROM machine m INNER JOIN runmode r USING (machineuuid)' @@ -287,9 +287,9 @@ class SubPage $row['firstseen'] = Util::prettyTime($row['firstseen']); $row['gbram'] = round(round($row['mbram'] / 500) / 2, 1); // Trial and error until we got "expected" rounding.. $row['gbtmp'] = round($row['id44mb'] / 1024); - $row['ramclass'] = StatisticsStyling::ramColorClass($row['mbram']); + $row['ramclass'] = StatisticsStyling::ramColorClass((int)$row['mbram']); $row['kvmclass'] = StatisticsStyling::kvmColorClass($row['kvmstate']); - $row['hddclass'] = StatisticsStyling::hddColorClass($row['gbtmp']); + $row['hddclass'] = StatisticsStyling::hddColorClass((int)$row['gbtmp']); $row['kvmicon'] = $row['kvmstate'] === 'ENABLED' ? '✓' : '✗'; if (++$count > 5) { $row['collapse'] = 'collapse'; -- cgit v1.2.3-55-g7522