From 3911e72dba800ed099a00fc0619fcb06addc5d73 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Thu, 5 Sep 2024 17:55:37 +0700 Subject: [PATCH] Update common.php --- common.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common.php b/common.php index 47c39eb68..96de37e9d 100644 --- a/common.php +++ b/common.php @@ -239,12 +239,13 @@ function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTE } /** - * @param string $str - * @return string + * @param string|null $str + * @return string|null */ -function str_compact($str) +function str_compact(string|null $str): ?string { - return preg_replace('#\s+#u', ' ', trim($str ?? '')); + $str ??= ''; + return preg_replace('#\s+#u', ' ', trim($str)); } /**