Update common.php

This commit is contained in:
Roman Kelesidis 2024-09-05 17:55:37 +07:00
commit 3911e72dba

View file

@ -239,12 +239,13 @@ function htmlCHR($txt, bool $double_encode = false, int $quote_style = ENT_QUOTE
} }
/** /**
* @param string $str * @param string|null $str
* @return string * @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));
} }
/** /**