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