Fix incorrect return type of utf8_trim() if input string contains invalid UTF-8 sequence

This commit is contained in:
Kijin Sung 2024-12-04 15:59:16 +09:00
parent 3a322cdfce
commit 0c815fc27b

View file

@ -692,7 +692,7 @@ function utf8_normalize_spaces($str, bool $multiline = false): string
*/
function utf8_trim($str): string
{
return preg_replace('/^[\s\pZ\pC]+|[\s\pZ\pC]+$/u', '', (string)$str);
return preg_replace('/^[\s\pZ\pC]+|[\s\pZ\pC]+$/u', '', (string)$str) ?? '';
}
/**