[String] Check if function exists before declaring it
This commit is contained in:
parent
b15bfc45d6
commit
cc00e0eb78
@ -11,16 +11,21 @@
|
||||
|
||||
namespace Symfony\Component\String;
|
||||
|
||||
if (!\function_exists(u::class)) {
|
||||
function u(?string $string = ''): UnicodeString
|
||||
{
|
||||
return new UnicodeString($string ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
if (!\function_exists(b::class)) {
|
||||
function b(?string $string = ''): ByteString
|
||||
{
|
||||
return new ByteString($string ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
if (!\function_exists(s::class)) {
|
||||
/**
|
||||
* @return UnicodeString|ByteString
|
||||
*/
|
||||
@ -30,3 +35,4 @@ function s(?string $string = ''): AbstractString
|
||||
|
||||
return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\Translation;
|
||||
|
||||
if (!\function_exists(t::class)) {
|
||||
/**
|
||||
* @author Nate Wiebe <nate@northern.co>
|
||||
*/
|
||||
@ -18,3 +19,4 @@ function t(string $message, array $parameters = [], string $domain = null): Tran
|
||||
{
|
||||
return new TranslatableMessage($message, $parameters, $domain);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user