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/statistics/inc/statistics.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/statistics/inc/statistics.inc.php')
-rw-r--r-- | modules-available/statistics/inc/statistics.inc.php | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/modules-available/statistics/inc/statistics.inc.php b/modules-available/statistics/inc/statistics.inc.php index d27c1a6a..2a9ca3c9 100644 --- a/modules-available/statistics/inc/statistics.inc.php +++ b/modules-available/statistics/inc/statistics.inc.php @@ -7,7 +7,7 @@ class Statistics private static $machineFields = false; - private static function initFields($returnData) + private static function initFields(int $returnData): string { if (self::$machineFields === false) { $r = new ReflectionClass('Machine'); @@ -25,17 +25,15 @@ class Statistics } /** - * @param string $machineuuid * @param int $returnData What kind of data to return Machine::NO_DATA, Machine::RAW_DATA, ... - * @return \Machine|false */ - public static function getMachine($machineuuid, $returnData) + public static function getMachine(string $machineuuid, int $returnData): ?Machine { $fields = self::initFields($returnData); $row = Database::queryFirst("SELECT $fields FROM machine WHERE machineuuid = :machineuuid", compact('machineuuid')); if ($row === false) - return false; + return null; $m = new Machine(); foreach ($row as $key => $val) { $m->{$key} = $val; @@ -44,12 +42,11 @@ class Statistics } /** - * @param string $ip * @param int $returnData What kind of data to return Machine::NO_DATA, Machine::RAW_DATA, ... * @param string $sort something like 'lastseen ASC' - not sanitized, don't pass user input! - * @return \Machine[] list of matches + * @return Machine[] list of matches */ - public static function getMachinesByIp($ip, $returnData, $sort = false) + public static function getMachinesByIp(string $ip, int $returnData, bool $sort = false): array { $fields = self::initFields($returnData); @@ -74,7 +71,7 @@ class Statistics const OFFLINE_LENGTH = '~offline-length'; const SUSPEND_LENGTH = '~suspend-length'; - public static function logMachineState($uuid, $ip, $type, $start, $length, $username = '') + public static function logMachineState(string $uuid, string $ip, string $type, int $start, int $length, string $username = ''): int { return Database::exec('INSERT INTO statistic (dateline, typeid, machineuuid, clientip, username, data)' . " VALUES (:start, :type, :uuid, :clientip, :username, :length)", array( |