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:
parent
3f6a9c4981
commit
8c28e9a2e9
@ -325,16 +325,16 @@ class Str
|
||||
public static function replaceFirst($search, $replace, $subject)
|
||||
{
|
||||
if ($search == '') {
|
||||
return $subject;
|
||||
return $subject ?? '';
|
||||
}
|
||||
|
||||
$position = strpos($subject, $search);
|
||||
|
||||
if ($position !== false) {
|
||||
return substr_replace($subject, $replace ?? '', $position, strlen($search));
|
||||
return substr_replace($subject, $replace ?? '', $position, strlen($search)) ?? '';
|
||||
}
|
||||
|
||||
return $subject;
|
||||
return $subject ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user