From 06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 14 Nov 2023 14:47:55 +0100 Subject: Add function param/return types, fix a lot more phpstorm complaints --- inc/property.inc.php | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) (limited to 'inc/property.inc.php') diff --git a/inc/property.inc.php b/inc/property.inc.php index dd72c187..5efcfe3a 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -41,7 +41,7 @@ class Property * @param string|null|false $value the value to store for $key * @param int $maxAgeMinutes how long to keep this entry around at least, in minutes. 0 for infinite */ - public static function set(string $key, $value, int $maxAgeMinutes = 0) + public static function set(string $key, $value, int $maxAgeMinutes = 0): void { if ($value === false || $value === null) { Database::exec("DELETE FROM property WHERE name = :key", ['key' => $key]); @@ -82,11 +82,9 @@ class Property } /** - * @param string $key - * @param int $subkey * @return ?string entry from property list */ - public static function getListEntry(string $key, int $subkey) + public static function getListEntry(string $key, int $subkey): ?string { $row = Database::queryFirst("SELECT dateline, `value` FROM property_list WHERE `name` = :key AND subkey = :subkey", ['key' => $key, 'subkey' => $subkey]); @@ -188,12 +186,12 @@ class Property * Legacy getters/setters */ - public static function getServerIp() + public static function getServerIp(): string { - return self::get('server-ip', 'none'); + return self::get('server-ip', 'invalid'); } - public static function setServerIp(string $value, $automatic = false): bool + public static function setServerIp(string $value, bool $automatic = false): bool { if ($value === self::getServerIp()) return false; @@ -203,16 +201,6 @@ class Property return true; } - public static function getBootMenu() - { - return json_decode(self::get('ipxe-menu'), true); - } - - public static function setBootMenu($value) - { - self::set('ipxe-menu', json_encode($value)); - } - public static function getVmStoreConfig() { return json_decode(self::get('vmstore-config'), true); @@ -247,14 +235,14 @@ class Property return self::get('last-warn-event-id', 0); } - public static function setNeedsSetup($value) + public static function setNeedsSetup(bool $value) { - self::set('needs-setup', $value); + self::set('needs-setup', (int)$value); } - public static function getNeedsSetup() + public static function getNeedsSetup(): bool { - return self::get('needs-setup'); + return self::get('needs-setup') != 0; } public static function setPasswordFieldType(string $value) -- cgit v1.2.3-55-g7522