From 321f6fc84d382b52e2d0f340d6375976cc96e8d0 Mon Sep 17 00:00:00 2001 From: Simon Asika Date: Sun, 19 Nov 2023 17:48:32 +0800 Subject: [PATCH] Fix error settings --- src/Core/Service/ErrorService.php | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Core/Service/ErrorService.php b/src/Core/Service/ErrorService.php index fbe197f9..95fcd5a9 100644 --- a/src/Core/Service/ErrorService.php +++ b/src/Core/Service/ErrorService.php @@ -424,13 +424,26 @@ public static function normalizeMessage(string $message): string return trim(explode("\n", $message)[0]); } - public static function getReportLevel(): int + public static function getReportLevel(array|int|null $errors = null): int { - return E_ALL - & ~E_WARNING - & ~E_DEPRECATED - & ~E_USER_WARNING - & ~E_USER_DEPRECATED - & ~E_USER_NOTICE; + if ($errors === null) { + return E_ALL + & ~E_WARNING + & ~E_DEPRECATED + & ~E_NOTICE + & ~E_USER_WARNING + & ~E_USER_DEPRECATED + & ~E_USER_NOTICE; + } + + $level = 0; + + foreach ($errors as $error => $enabled) { + if ($enabled) { + $level |= $error; + } + } + + return $level; } }