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/baseconfig/inc/configholder.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/baseconfig/inc/configholder.inc.php')
-rw-r--r-- | modules-available/baseconfig/inc/configholder.inc.php | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/modules-available/baseconfig/inc/configholder.inc.php b/modules-available/baseconfig/inc/configholder.inc.php index 224f2aab..75b43460 100644 --- a/modules-available/baseconfig/inc/configholder.inc.php +++ b/modules-available/baseconfig/inc/configholder.inc.php @@ -19,7 +19,7 @@ class ConfigHolder * @param false|string|array $value false to unset, string value, or array with keys value and displayvalue * @param int $prio priority of this value, in case the same key gets set multiple times */ - public static function add($key, $value, $prio = 0) + public static function add(string $key, $value, int $prio = 0): void { if (!isset(self::$config[$key])) { self::$config[$key] = []; @@ -43,22 +43,19 @@ class ConfigHolder } } - public static function get($key) + public static function get(string $key): ?string { if (!isset(self::$config[$key])) - return false; + return null; return self::$config[$key][0]['value']; } - /** - * @param callable $func - */ - public static function addPostHook($func) + public static function addPostHook(callable $func): void { self::$postHooks[] = array('context' => &self::$context, 'function' => $func); } - public static function applyPostHooks() + public static function applyPostHooks(): void { foreach (self::$postHooks as $hook) { $newContext = $hook['context']; @@ -69,7 +66,7 @@ class ConfigHolder self::$postHooks = []; } - public static function getRecursiveConfig($prettyPrint = true) + public static function getRecursiveConfig(bool $prettyPrint = true): array { $ret = []; foreach (self::$config as $key => $list) { @@ -97,7 +94,7 @@ class ConfigHolder return $ret; } - public static function outputConfig() + public static function outputConfig(): void { foreach (self::$config as $key => $list) { echo str_pad('# ' . $key . ' ', 35, '#', STR_PAD_BOTH), "\n"; @@ -129,7 +126,7 @@ class ConfigHolder * @param string $string input * @return string escaped sh string */ - private static function escape($string) + private static function escape(string $string): string { return str_replace(["'", "\n", "\r"], ["'\"'\"'", ' ', ' '], $string); } |