diff options
author | Simon Rettberg | 2023-11-14 14:47:55 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-11-14 14:47:55 +0100 |
commit | 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch) | |
tree | 7e5493b102074672d8cfd8fe1a61e49f080edbe8 /modules-available/locationinfo/api.inc.php | |
parent | Update phpstorm config (diff) | |
download | slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.gz slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.xz slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.zip |
Add function param/return types, fix a lot more phpstorm complaints
Diffstat (limited to 'modules-available/locationinfo/api.inc.php')
-rw-r--r-- | modules-available/locationinfo/api.inc.php | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/modules-available/locationinfo/api.inc.php b/modules-available/locationinfo/api.inc.php index 14be7718..24919ba1 100644 --- a/modules-available/locationinfo/api.inc.php +++ b/modules-available/locationinfo/api.inc.php @@ -14,7 +14,7 @@ function HandleParameters() $get = Request::get('get', 0, 'string'); $uuid = Request::get('uuid', false, 'string'); - $output = false; + $output = null; if ($get === "timestamp") { $output = array('ts' => getLastChangeTs($uuid)); } elseif ($get === "machines") { @@ -24,7 +24,7 @@ function HandleParameters() $output = array_values($output); } elseif ($get === "config") { $type = InfoPanel::getConfig($uuid, $output); - if ($type === false) { + if ($type === null) { http_response_code(404); die('Panel not found'); } @@ -38,7 +38,7 @@ function HandleParameters() $locationIds = LocationInfo::getLocationsOr404($uuid); $output = LocationInfo::getCalendar($locationIds); } - if ($output !== false) { + if ($output !== null) { Header('Content-Type: application/json; charset=utf-8'); echo json_encode($output); } else { @@ -59,7 +59,7 @@ function HandleParameters() * @param string $paneluuid panels uuid * @return int UNIX_TIMESTAMP */ -function getLastChangeTs($paneluuid) +function getLastChangeTs(string $paneluuid): int { $panel = Database::queryFirst('SELECT lastchange, locationids FROM locationinfo_panel WHERE paneluuid = :paneluuid', compact('paneluuid')); @@ -84,7 +84,7 @@ function getLastChangeTs($paneluuid) * @param int[] $idList list of the location ids. * @return array aggregated PC states */ -function getPcStates($idList, $paneluuid) +function getPcStates(array $idList, string $paneluuid): array { $pcStates = array(); foreach ($idList as $id) { @@ -130,7 +130,7 @@ function getPcStates($idList, $paneluuid) * @param int[] $idList Array list of the locations. * @return array location tree data */ -function getLocationTree($idList) +function getLocationTree(array $idList): array { if (in_array(0, $idList)) { return array_values(Location::getTree()); @@ -140,7 +140,7 @@ function getLocationTree($idList) return findLocations($locations, $idList); } -function findLocations($locations, $idList) +function findLocations(array $locations, array $idList): array { $ret = array(); foreach ($locations as $location) { |