functions.php 861 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\String;
  11. if (!\function_exists(u::class)) {
  12. function u(?string $string = ''): UnicodeString
  13. {
  14. return new UnicodeString($string ?? '');
  15. }
  16. }
  17. if (!\function_exists(b::class)) {
  18. function b(?string $string = ''): ByteString
  19. {
  20. return new ByteString($string ?? '');
  21. }
  22. }
  23. if (!\function_exists(s::class)) {
  24. /**
  25. * @return UnicodeString|ByteString
  26. */
  27. function s(?string $string = ''): AbstractString
  28. {
  29. $string = $string ?? '';
  30. return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
  31. }
  32. }