Addressed setlocale issue caught by phpstan

setlocale could be called with no second param if the language given to
the modified function was empty.
This commit is contained in:
Dan Brown 2022-09-05 13:33:05 +01:00
parent ee1e936660
commit 2d7552aa09
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -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);
}
}
}