From abc07b475da35ce5cae4a70ca28412e79c74624f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 12 May 2022 18:12:05 +0200 Subject: [inc/Property] Types, remove unused functions --- inc/property.inc.php | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/inc/property.inc.php b/inc/property.inc.php index e7f4cd25..96787f00 100644 --- a/inc/property.inc.php +++ b/inc/property.inc.php @@ -16,7 +16,7 @@ class Property * @param mixed $default value to return if $key does not exist in the property store * @return mixed the value attached to $key, or $default if $key does not exist */ - public static function get($key, $default = false) + public static function get(string $key, $default = false) { if (self::$cache === false) { $NOW = time(); @@ -40,7 +40,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($key, $value, $maxAgeMinutes = 0) + public static function set(string $key, $value, int $maxAgeMinutes = 0) { if ($value === false || $value === null) { Database::exec("DELETE FROM property WHERE name = :key", ['key' => $key]); @@ -66,7 +66,7 @@ class Property * @param string $key Key of list to get all items for * @return array All the items matching the key */ - public static function getList($key) + public static function getList(string $key): array { $res = Database::simpleQuery("SELECT dateline, value FROM property_list WHERE name = :key", compact('key')); $NOW = time(); @@ -86,7 +86,7 @@ class Property * @param string $value the value to add for $key * @param int $maxAgeMinutes how long to keep this entry around at least, in minutes. 0 for infinite */ - public static function addToList($key, $value, $maxAgeMinutes = 0) + public static function addToList(string $key, string $value, int $maxAgeMinutes = 0) { Database::exec("INSERT INTO property_list (name, value, dateline) VALUES (:key, :value, :dateline)", array( 'key' => $key, @@ -103,7 +103,7 @@ class Property * @param string $value item to remove * @return int number of items removed */ - public static function removeFromList($key, $value) + public static function removeFromList(string $key, string $value): int { return Database::exec("DELETE FROM property_list WHERE name = :key AND value = :value", array( 'key' => $key, @@ -117,7 +117,7 @@ class Property * @param string $key Key of list * @return int number of items removed */ - public static function clearList($key) + public static function clearList(string $key): int { return Database::exec("DELETE FROM property_list WHERE name = :key", compact('key')); } @@ -131,7 +131,7 @@ class Property return self::get('server-ip', 'none'); } - public static function setServerIp($value, $automatic = false) + public static function setServerIp(string $value, $automatic = false): bool { if ($value === self::getServerIp()) return false; @@ -175,21 +175,6 @@ class Property self::set('vmstore-config', json_encode($value)); } - public static function getDownloadTask($name) - { - return self::get('dl-' . $name); - } - - public static function setDownloadTask($name, $taskId) - { - self::set('dl-' . $name, $taskId, 5); - } - - public static function getCurrentSchemaVersion() - { - return self::get('webif-version'); - } - public static function setLastWarningId($id) { self::set('last-warn-event-id', $id); @@ -210,12 +195,12 @@ class Property return self::get('needs-setup'); } - public static function setPasswordFieldType($value) + public static function setPasswordFieldType(string $value) { self::set('password-type', $value); } - public static function getPasswordFieldType() + public static function getPasswordFieldType(): string { return self::get('password-type', 'password'); } -- cgit v1.2.3-55-g7522