From abcd0e8ba205aac8bd9006e99d783afc999af0af Mon Sep 17 00:00:00 2001 From: wn_ Date: Sat, 23 Nov 2024 17:43:24 +0000 Subject: Use native union types in most places. --- classes/Prefs.php | 39 +++++++++------------------------------ 1 file changed, 9 insertions(+), 30 deletions(-) (limited to 'classes/Prefs.php') diff --git a/classes/Prefs.php b/classes/Prefs.php index 8d84d5ec2..f7e6e39c0 100644 --- a/classes/Prefs.php +++ b/classes/Prefs.php @@ -164,10 +164,7 @@ class Prefs { return isset(self::_DEFAULTS[$pref_name]); } - /** - * @return bool|int|null|string - */ - static function get_default(string $pref_name) { + static function get_default(string $pref_name): bool|int|null|string { if (self::is_valid($pref_name)) return self::_DEFAULTS[$pref_name][0]; else @@ -193,14 +190,14 @@ class Prefs { /** * @return array> */ - static function get_all(int $owner_uid, ?int $profile_id = null) { + static function get_all(int $owner_uid, ?int $profile_id = null): array { return self::get_instance()->_get_all($owner_uid, $profile_id); } /** * @return array> */ - private function _get_all(int $owner_uid, ?int $profile_id = null) { + private function _get_all(int $owner_uid, ?int $profile_id = null): array { $rv = []; $ref = new ReflectionClass(get_class($this)); @@ -247,17 +244,11 @@ class Prefs { } } - /** - * @return bool|int|null|string - */ - static function get(string $pref_name, int $owner_uid, ?int $profile_id = null) { + static function get(string $pref_name, int $owner_uid, ?int $profile_id = null): bool|int|null|string { return self::get_instance()->_get($pref_name, $owner_uid, $profile_id); } - /** - * @return bool|int|null|string - */ - private function _get(string $pref_name, int $owner_uid, ?int $profile_id) { + private function _get(string $pref_name, int $owner_uid, ?int $profile_id): bool|int|null|string { if (isset(self::_DEFAULTS[$pref_name])) { if (!$profile_id || in_array($pref_name, self::_PROFILE_BLACKLIST)) $profile_id = null; @@ -298,34 +289,22 @@ class Prefs { return isset($this->cache[$cache_key]); } - /** - * @return bool|int|null|string - */ - private function _get_cache(string $pref_name, int $owner_uid, ?int $profile_id) { + private function _get_cache(string $pref_name, int $owner_uid, ?int $profile_id): bool|int|null|string { $cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name); return $this->cache[$cache_key] ?? null; } - /** - * @param bool|int|string $value - */ - private function _set_cache(string $pref_name, $value, int $owner_uid, ?int $profile_id): void { + private function _set_cache(string $pref_name, bool|int|string $value, int $owner_uid, ?int $profile_id): void { $cache_key = sprintf("%d/%d/%s", $owner_uid, $profile_id, $pref_name); $this->cache[$cache_key] = $value; } - /** - * @param bool|int|string $value - */ - static function set(string $pref_name, $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool { + static function set(string $pref_name, bool|int|string $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool { return self::get_instance()->_set($pref_name, $value, $owner_uid, $profile_id); } - /** - * @param bool|int|string $value - */ - private function _set(string $pref_name, $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool { + private function _set(string $pref_name, bool|int|string $value, int $owner_uid, ?int $profile_id, bool $strip_tags = true): bool { if (!$profile_id) $profile_id = null; if ($profile_id && in_array($pref_name, self::_PROFILE_BLACKLIST)) -- cgit v1.2.3-54-g00ecf