1
0
mirror of https://github.com/freescout-helpdesk/freescout.git synced 2025-02-01 12:31:38 +01:00

Make sure Str::replaceFirst() always returns a string

This commit is contained in:
FreeScout 2023-01-18 23:38:21 -08:00
parent 3f6a9c4981
commit 8c28e9a2e9

View File

@ -325,16 +325,16 @@ class Str
public static function replaceFirst($search, $replace, $subject) public static function replaceFirst($search, $replace, $subject)
{ {
if ($search == '') { if ($search == '') {
return $subject; return $subject ?? '';
} }
$position = strpos($subject, $search); $position = strpos($subject, $search);
if ($position !== false) { if ($position !== false) {
return substr_replace($subject, $replace ?? '', $position, strlen($search)); return substr_replace($subject, $replace ?? '', $position, strlen($search)) ?? '';
} }
return $subject; return $subject ?? '';
} }
/** /**