From: Dan Brown Date: Mon, 5 Sep 2022 12:33:05 +0000 (+0100) Subject: Addressed setlocale issue caught by phpstan X-Git-Tag: v22.09~1^2~11 X-Git-Url: http://source.bookstackapp.com/bookstack/commitdiff_plain/2d7552aa09f41d019b40de31763ae104ca64f8a4 Addressed setlocale issue caught by phpstan setlocale could be called with no second param if the language given to the modified function was empty. --- diff --git a/app/Util/LanguageManager.php b/app/Util/LanguageManager.php index c33c73ad5..33ec0e3a9 100644 --- a/app/Util/LanguageManager.php +++ b/app/Util/LanguageManager.php @@ -113,7 +113,7 @@ class LanguageManager * Set the system date locale for localized date formatting. * Will try both the standard locale name and the UTF8 variant. */ - public function setPhpDateTimeLocale(string $language) + public function setPhpDateTimeLocale(string $language): void { $isoLang = $this->localeMap[$language]['iso'] ?? false; @@ -125,6 +125,8 @@ class LanguageManager $language, ]); - setlocale(LC_TIME, ...$locales); + if (!empty($locales)) { + setlocale(LC_TIME, ...$locales); + } } }