diff options
| author | wn_ <invalid@email.com> | 2024-11-23 17:43:24 +0000 |
|---|---|---|
| committer | wn_ <invalid@email.com> | 2024-11-23 17:43:24 +0000 |
| commit | abcd0e8ba205aac8bd9006e99d783afc999af0af (patch) | |
| tree | 8635fcd5b239f18db5ff831c7ef21a290a8ac6d8 /classes/Prefs.php | |
| parent | d4636716fb6e1879098823c2f037db5d8d3f24a0 (diff) | |
Use native union types in most places.
Diffstat (limited to 'classes/Prefs.php')
| -rw-r--r-- | classes/Prefs.php | 39 |
1 files changed, 9 insertions, 30 deletions
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<int, array<string, bool|int|null|string>> */ - 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<int, array<string, bool|int|null|string>> */ - 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)) |