Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17415c6

Browse files
committed
bug #51190 [Clock] load function only if not loaded before (xabbuh)
This PR was merged into the 6.3 branch. Discussion ---------- [Clock] load function only if not loaded before | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #51180 | License | MIT | Doc PR | We do the same for functions defined in the String, Translation and VarDumper components. Commits ------- 6b88ea7 load function only if not loaded before
2 parents e804806 + 6b88ea7 commit 17415c6

File tree

1 file changed

+11
-9
lines changed
  • src/Symfony/Component/Clock/Resources

1 file changed

+11
-9
lines changed

src/Symfony/Component/Clock/Resources/now.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
namespace Symfony\Component\Clock;
1313

14-
/**
15-
* Returns the current time as a DateTimeImmutable.
16-
*
17-
* Note that you should prefer injecting a ClockInterface or using
18-
* ClockAwareTrait when possible instead of using this function.
19-
*/
20-
function now(): \DateTimeImmutable
21-
{
22-
return Clock::get()->now();
14+
if (!\function_exists(now::class)) {
15+
/**
16+
* Returns the current time as a DateTimeImmutable.
17+
*
18+
* Note that you should prefer injecting a ClockInterface or using
19+
* ClockAwareTrait when possible instead of using this function.
20+
*/
21+
function now(): \DateTimeImmutable
22+
{
23+
return Clock::get()->now();
24+
}
2325
}

0 commit comments

Comments
 (0)