This commit is contained in:
2025-05-12 14:25:25 +02:00
parent ab2db755ef
commit 9e378ca2b7
2719 changed files with 46505 additions and 60181 deletions

View File

@@ -11,7 +11,7 @@
namespace Symfony\Component\String\Slugger;
use Symfony\Component\Intl\Transliterator\EmojiTransliterator;
use Symfony\Component\Emoji\EmojiTransliterator;
use Symfony\Component\String\AbstractUnicodeString;
use Symfony\Component\String\UnicodeString;
use Symfony\Contracts\Translation\LocaleAwareInterface;
@@ -55,7 +55,6 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
'zh' => 'Han-Latin',
];
private ?string $defaultLocale;
private \Closure|array $symbolsMap = [
'en' => ['@' => 'at', '&' => 'and'],
];
@@ -68,9 +67,10 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
*/
private array $transliterators = [];
public function __construct(string $defaultLocale = null, array|\Closure $symbolsMap = null)
{
$this->defaultLocale = $defaultLocale;
public function __construct(
private ?string $defaultLocale = null,
array|\Closure|null $symbolsMap = null,
) {
$this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
}
@@ -92,7 +92,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
public function withEmoji(bool|string $emoji = true): static
{
if (false !== $emoji && !class_exists(EmojiTransliterator::class)) {
throw new \LogicException(sprintf('You cannot use the "%s()" method as the "symfony/intl" package is not installed. Try running "composer require symfony/intl".', __METHOD__));
throw new \LogicException(\sprintf('You cannot use the "%s()" method as the "symfony/emoji" package is not installed. Try running "composer require symfony/emoji".', __METHOD__));
}
$new = clone $this;
@@ -101,7 +101,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
return $new;
}
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
{
$locale ??= $this->defaultLocale;