From cf1eaeedf3026948cf2210af1c747bdc3522d6ff Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 10 Jun 2022 13:39:00 +0300 Subject: * add UserHelper methods to manipulate user database (add, modify, delete) * expose said methods via CLI (update.php) * fix several invocations of deprecated functions * set stricter type hints on several method arguments --- classes/debug.php | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'classes/debug.php') diff --git a/classes/debug.php b/classes/debug.php index fbdf260e0..4777e8c74 100644 --- a/classes/debug.php +++ b/classes/debug.php @@ -68,9 +68,9 @@ class Debug { } /** - * @param int $level Debug::LOG_* + * @param Debug::LOG_* $level */ - public static function set_loglevel(int $level): void { + public static function set_loglevel($level): void { self::$loglevel = $level; } @@ -82,7 +82,21 @@ class Debug { } /** - * @param int $level Debug::LOG_* + * @param int $level integer loglevel value + * @return Debug::LOG_* if valid, warn and return LOG_DISABLED otherwise + */ + public static function map_loglevel(int $level) : int { + if (in_array($level, self::ALL_LOG_LEVELS)) { + /** @phpstan-ignore-next-line */ + return $level; + } else { + user_error("Passed invalid debug log level: $level", E_USER_WARNING); + return self::LOG_DISABLED; + } + } + + /** + * @param Debug::LOG_* $level log level */ public static function log(string $message, int $level = Debug::LOG_NORMAL): bool { -- cgit v1.2.3