Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cc00e0e

Browse filesBrowse files
Nyholmnicolas-grekas
authored andcommitted
[String] Check if function exists before declaring it
1 parent b15bfc4 commit cc00e0e
Copy full SHA for cc00e0e

File tree

2 files changed

+27
-19
lines changed
Filter options

2 files changed

+27
-19
lines changed

‎src/Symfony/Component/String/Resources/functions.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/String/Resources/functions.php
+19-13Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,28 @@
1111

1212
namespace Symfony\Component\String;
1313

14-
function u(?string $string = ''): UnicodeString
15-
{
16-
return new UnicodeString($string ?? '');
14+
if (!\function_exists(u::class)) {
15+
function u(?string $string = ''): UnicodeString
16+
{
17+
return new UnicodeString($string ?? '');
18+
}
1719
}
1820

19-
function b(?string $string = ''): ByteString
20-
{
21-
return new ByteString($string ?? '');
21+
if (!\function_exists(b::class)) {
22+
function b(?string $string = ''): ByteString
23+
{
24+
return new ByteString($string ?? '');
25+
}
2226
}
2327

24-
/**
25-
* @return UnicodeString|ByteString
26-
*/
27-
function s(?string $string = ''): AbstractString
28-
{
29-
$string = $string ?? '';
28+
if (!\function_exists(s::class)) {
29+
/**
30+
* @return UnicodeString|ByteString
31+
*/
32+
function s(?string $string = ''): AbstractString
33+
{
34+
$string = $string ?? '';
3035

31-
return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
36+
return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
37+
}
3238
}

‎src/Symfony/Component/Translation/Resources/functions.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/Resources/functions.php
+8-6Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111

1212
namespace Symfony\Component\Translation;
1313

14-
/**
15-
* @author Nate Wiebe <nate@northern.co>
16-
*/
17-
function t(string $message, array $parameters = [], string $domain = null): TranslatableMessage
18-
{
19-
return new TranslatableMessage($message, $parameters, $domain);
14+
if (!\function_exists(t::class)) {
15+
/**
16+
* @author Nate Wiebe <nate@northern.co>
17+
*/
18+
function t(string $message, array $parameters = [], string $domain = null): TranslatableMessage
19+
{
20+
return new TranslatableMessage($message, $parameters, $domain);
21+
}
2022
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.