Commaaa2
This commit is contained in:
46
vendor/symfony/string/AbstractString.php
vendored
46
vendor/symfony/string/AbstractString.php
vendored
@@ -74,7 +74,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
foreach ($values as $k => $v) {
|
||||
if (\is_string($k) && '' !== $k && $k !== $j = (string) new static($k)) {
|
||||
$keys = $keys ?? array_keys($values);
|
||||
$keys ??= array_keys($values);
|
||||
$keys[$i] = $j;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return '' === $this->string;
|
||||
}
|
||||
|
||||
abstract public function join(array $strings, string $lastGlue = null): static;
|
||||
abstract public function join(array $strings, ?string $lastGlue = null): static;
|
||||
|
||||
public function jsonSerialize(): string
|
||||
{
|
||||
@@ -429,16 +429,16 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
abstract public function reverse(): static;
|
||||
|
||||
abstract public function slice(int $start = 0, int $length = null): static;
|
||||
abstract public function slice(int $start = 0, ?int $length = null): static;
|
||||
|
||||
abstract public function snake(): static;
|
||||
|
||||
abstract public function splice(string $replacement, int $start = 0, int $length = null): static;
|
||||
abstract public function splice(string $replacement, int $start = 0, ?int $length = null): static;
|
||||
|
||||
/**
|
||||
* @return static[]
|
||||
*/
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
|
||||
{
|
||||
if (null === $flags) {
|
||||
throw new \TypeError('Split behavior when $flags is null must be implemented by child classes.');
|
||||
@@ -448,19 +448,11 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
$delimiter .= 'i';
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
|
||||
|
||||
try {
|
||||
if (false === $chunks = preg_split($delimiter, $this->string, $limit, $flags)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Splitting failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException('Splitting failed with unknown error code.');
|
||||
throw new RuntimeException('Splitting failed with error: '.preg_last_error_msg());
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
@@ -503,7 +495,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
abstract public function title(bool $allWords = false): static;
|
||||
|
||||
public function toByteString(string $toEncoding = null): ByteString
|
||||
public function toByteString(?string $toEncoding = null): ByteString
|
||||
{
|
||||
$b = new ByteString();
|
||||
|
||||
@@ -515,20 +507,14 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $b;
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
|
||||
try {
|
||||
try {
|
||||
$b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
|
||||
} catch (InvalidArgumentException $e) {
|
||||
if (!\function_exists('iconv')) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$b->string = iconv('UTF-8', $toEncoding, $this->string);
|
||||
$b->string = mb_convert_encoding($this->string, $toEncoding, 'UTF-8');
|
||||
} catch (\ValueError $e) {
|
||||
if (!\function_exists('iconv')) {
|
||||
throw new InvalidArgumentException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
|
||||
$b->string = iconv('UTF-8', $toEncoding, $this->string);
|
||||
}
|
||||
|
||||
return $b;
|
||||
@@ -558,7 +544,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
*/
|
||||
public function trimPrefix($prefix): static
|
||||
{
|
||||
if (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
if (\is_array($prefix) || $prefix instanceof \Traversable) { // don't use is_iterable(), it's slow
|
||||
foreach ($prefix as $s) {
|
||||
$t = $this->trimPrefix($s);
|
||||
|
||||
@@ -592,7 +578,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
*/
|
||||
public function trimSuffix($suffix): static
|
||||
{
|
||||
if (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
if (\is_array($suffix) || $suffix instanceof \Traversable) { // don't use is_iterable(), it's slow
|
||||
foreach ($suffix as $s) {
|
||||
$t = $this->trimSuffix($s);
|
||||
|
||||
|
||||
56
vendor/symfony/string/AbstractUnicodeString.php
vendored
56
vendor/symfony/string/AbstractUnicodeString.php
vendored
@@ -37,20 +37,16 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
private const ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
|
||||
|
||||
// the subset of folded case mappings that is not in lower case mappings
|
||||
private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'İ', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
|
||||
private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'i̇', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
|
||||
|
||||
// the subset of upper case mappings that map one code point to many code points
|
||||
private const UPPER_FROM = ['ß', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'և', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ', 'ʼn', 'ΐ', 'ΰ', 'ǰ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾶ', 'ῆ', 'ῒ', 'ΐ', 'ῖ', 'ῗ', 'ῢ', 'ΰ', 'ῤ', 'ῦ', 'ῧ', 'ῶ'];
|
||||
private const UPPER_TO = ['SS', 'FF', 'FI', 'FL', 'FFI', 'FFL', 'ST', 'ST', 'ԵՒ', 'ՄՆ', 'ՄԵ', 'ՄԻ', 'ՎՆ', 'ՄԽ', 'ʼN', 'Ϊ́', 'Ϋ́', 'J̌', 'H̱', 'T̈', 'W̊', 'Y̊', 'Aʾ', 'Υ̓', 'Υ̓̀', 'Υ̓́', 'Υ̓͂', 'Α͂', 'Η͂', 'Ϊ̀', 'Ϊ́', 'Ι͂', 'Ϊ͂', 'Ϋ̀', 'Ϋ́', 'Ρ̓', 'Υ͂', 'Ϋ͂', 'Ω͂'];
|
||||
private const FOLD_FROM = ['İ', 'µ', 'ſ', "\xCD\x85", 'ς', 'ϐ', 'ϑ', 'ϕ', 'ϖ', 'ϰ', 'ϱ', 'ϵ', 'ẛ', "\xE1\xBE\xBE", 'ß', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'և', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'ẚ', 'ẞ', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ᾈ', 'ᾉ', 'ᾊ', 'ᾋ', 'ᾌ', 'ᾍ', 'ᾎ', 'ᾏ', 'ᾐ', 'ᾑ', 'ᾒ', 'ᾓ', 'ᾔ', 'ᾕ', 'ᾖ', 'ᾗ', 'ᾘ', 'ᾙ', 'ᾚ', 'ᾛ', 'ᾜ', 'ᾝ', 'ᾞ', 'ᾟ', 'ᾠ', 'ᾡ', 'ᾢ', 'ᾣ', 'ᾤ', 'ᾥ', 'ᾦ', 'ᾧ', 'ᾨ', 'ᾩ', 'ᾪ', 'ᾫ', 'ᾬ', 'ᾭ', 'ᾮ', 'ᾯ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'ᾼ', 'ῂ', 'ῃ', 'ῄ', 'ῆ', 'ῇ', 'ῌ', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ῲ', 'ῳ', 'ῴ', 'ῶ', 'ῷ', 'ῼ', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'ſt', 'st', 'ﬓ', 'ﬔ', 'ﬕ', 'ﬖ', 'ﬗ'];
|
||||
private const FOLD_TO = ['i̇', 'μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', 'ṡ', 'ι', 'ss', 'ʼn', 'ǰ', 'ΐ', 'ΰ', 'եւ', 'ẖ', 'ẗ', 'ẘ', 'ẙ', 'aʾ', 'ss', 'ὐ', 'ὒ', 'ὔ', 'ὖ', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἀι', 'ἁι', 'ἂι', 'ἃι', 'ἄι', 'ἅι', 'ἆι', 'ἇι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ἠι', 'ἡι', 'ἢι', 'ἣι', 'ἤι', 'ἥι', 'ἦι', 'ἧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὠι', 'ὡι', 'ὢι', 'ὣι', 'ὤι', 'ὥι', 'ὦι', 'ὧι', 'ὰι', 'αι', 'άι', 'ᾶ', 'ᾶι', 'αι', 'ὴι', 'ηι', 'ήι', 'ῆ', 'ῆι', 'ηι', 'ῒ', 'ῖ', 'ῗ', 'ῢ', 'ῤ', 'ῦ', 'ῧ', 'ὼι', 'ωι', 'ώι', 'ῶ', 'ῶι', 'ωι', 'ff', 'fi', 'fl', 'ffi', 'ffl', 'st', 'st', 'մն', 'մե', 'մի', 'վն', 'մխ'];
|
||||
|
||||
// the subset of https://github.com/unicode-org/cldr/blob/master/common/transforms/Latin-ASCII.xml that is not in NFKD
|
||||
private const TRANSLIT_FROM = ['Æ', 'Ð', 'Ø', 'Þ', 'ß', 'æ', 'ð', 'ø', 'þ', 'Đ', 'đ', 'Ħ', 'ħ', 'ı', 'ĸ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'ʼn', 'Ŋ', 'ŋ', 'Œ', 'œ', 'Ŧ', 'ŧ', 'ƀ', 'Ɓ', 'Ƃ', 'ƃ', 'Ƈ', 'ƈ', 'Ɖ', 'Ɗ', 'Ƌ', 'ƌ', 'Ɛ', 'Ƒ', 'ƒ', 'Ɠ', 'ƕ', 'Ɩ', 'Ɨ', 'Ƙ', 'ƙ', 'ƚ', 'Ɲ', 'ƞ', 'Ƣ', 'ƣ', 'Ƥ', 'ƥ', 'ƫ', 'Ƭ', 'ƭ', 'Ʈ', 'Ʋ', 'Ƴ', 'ƴ', 'Ƶ', 'ƶ', 'DŽ', 'Dž', 'dž', 'Ǥ', 'ǥ', 'ȡ', 'Ȥ', 'ȥ', 'ȴ', 'ȵ', 'ȶ', 'ȷ', 'ȸ', 'ȹ', 'Ⱥ', 'Ȼ', 'ȼ', 'Ƚ', 'Ⱦ', 'ȿ', 'ɀ', 'Ƀ', 'Ʉ', 'Ɇ', 'ɇ', 'Ɉ', 'ɉ', 'Ɍ', 'ɍ', 'Ɏ', 'ɏ', 'ɓ', 'ɕ', 'ɖ', 'ɗ', 'ɛ', 'ɟ', 'ɠ', 'ɡ', 'ɢ', 'ɦ', 'ɧ', 'ɨ', 'ɪ', 'ɫ', 'ɬ', 'ɭ', 'ɱ', 'ɲ', 'ɳ', 'ɴ', 'ɶ', 'ɼ', 'ɽ', 'ɾ', 'ʀ', 'ʂ', 'ʈ', 'ʉ', 'ʋ', 'ʏ', 'ʐ', 'ʑ', 'ʙ', 'ʛ', 'ʜ', 'ʝ', 'ʟ', 'ʠ', 'ʣ', 'ʥ', 'ʦ', 'ʪ', 'ʫ', 'ᴀ', 'ᴁ', 'ᴃ', 'ᴄ', 'ᴅ', 'ᴆ', 'ᴇ', 'ᴊ', 'ᴋ', 'ᴌ', 'ᴍ', 'ᴏ', 'ᴘ', 'ᴛ', 'ᴜ', 'ᴠ', 'ᴡ', 'ᴢ', 'ᵫ', 'ᵬ', 'ᵭ', 'ᵮ', 'ᵯ', 'ᵰ', 'ᵱ', 'ᵲ', 'ᵳ', 'ᵴ', 'ᵵ', 'ᵶ', 'ᵺ', 'ᵻ', 'ᵽ', 'ᵾ', 'ᶀ', 'ᶁ', 'ᶂ', 'ᶃ', 'ᶄ', 'ᶅ', 'ᶆ', 'ᶇ', 'ᶈ', 'ᶉ', 'ᶊ', 'ᶌ', 'ᶍ', 'ᶎ', 'ᶏ', 'ᶑ', 'ᶒ', 'ᶓ', 'ᶖ', 'ᶙ', 'ẚ', 'ẜ', 'ẝ', 'ẞ', 'Ỻ', 'ỻ', 'Ỽ', 'ỽ', 'Ỿ', 'ỿ', '©', '®', '₠', '₢', '₣', '₤', '₧', '₺', '₹', 'ℌ', '℞', '㎧', '㎮', '㏆', '㏗', '㏞', '㏟', '¼', '½', '¾', '⅓', '⅔', '⅕', '⅖', '⅗', '⅘', '⅙', '⅚', '⅛', '⅜', '⅝', '⅞', '⅟', '〇', '‘', '’', '‚', '‛', '“', '”', '„', '‟', '′', '″', '〝', '〞', '«', '»', '‹', '›', '‐', '‑', '‒', '–', '—', '―', '︱', '︲', '﹘', '‖', '⁄', '⁅', '⁆', '⁎', '、', '。', '〈', '〉', '《', '》', '〔', '〕', '〘', '〙', '〚', '〛', '︑', '︒', '︹', '︺', '︽', '︾', '︿', '﹀', '﹑', '﹝', '﹞', '⦅', '⦆', '。', '、', '×', '÷', '−', '∕', '∖', '∣', '∥', '≪', '≫', '⦅', '⦆'];
|
||||
private const TRANSLIT_TO = ['AE', 'D', 'O', 'TH', 'ss', 'ae', 'd', 'o', 'th', 'D', 'd', 'H', 'h', 'i', 'q', 'L', 'l', 'L', 'l', '\'n', 'N', 'n', 'OE', 'oe', 'T', 't', 'b', 'B', 'B', 'b', 'C', 'c', 'D', 'D', 'D', 'd', 'E', 'F', 'f', 'G', 'hv', 'I', 'I', 'K', 'k', 'l', 'N', 'n', 'OI', 'oi', 'P', 'p', 't', 'T', 't', 'T', 'V', 'Y', 'y', 'Z', 'z', 'DZ', 'Dz', 'dz', 'G', 'g', 'd', 'Z', 'z', 'l', 'n', 't', 'j', 'db', 'qp', 'A', 'C', 'c', 'L', 'T', 's', 'z', 'B', 'U', 'E', 'e', 'J', 'j', 'R', 'r', 'Y', 'y', 'b', 'c', 'd', 'd', 'e', 'j', 'g', 'g', 'G', 'h', 'h', 'i', 'I', 'l', 'l', 'l', 'm', 'n', 'n', 'N', 'OE', 'r', 'r', 'r', 'R', 's', 't', 'u', 'v', 'Y', 'z', 'z', 'B', 'G', 'H', 'j', 'L', 'q', 'dz', 'dz', 'ts', 'ls', 'lz', 'A', 'AE', 'B', 'C', 'D', 'D', 'E', 'J', 'K', 'L', 'M', 'O', 'P', 'T', 'U', 'V', 'W', 'Z', 'ue', 'b', 'd', 'f', 'm', 'n', 'p', 'r', 'r', 's', 't', 'z', 'th', 'I', 'p', 'U', 'b', 'd', 'f', 'g', 'k', 'l', 'm', 'n', 'p', 'r', 's', 'v', 'x', 'z', 'a', 'd', 'e', 'e', 'i', 'u', 'a', 's', 's', 'SS', 'LL', 'll', 'V', 'v', 'Y', 'y', '(C)', '(R)', 'CE', 'Cr', 'Fr.', 'L.', 'Pts', 'TL', 'Rs', 'x', 'Rx', 'm/s', 'rad/s', 'C/kg', 'pH', 'V/m', 'A/m', ' 1/4', ' 1/2', ' 3/4', ' 1/3', ' 2/3', ' 1/5', ' 2/5', ' 3/5', ' 4/5', ' 1/6', ' 5/6', ' 1/8', ' 3/8', ' 5/8', ' 7/8', ' 1/', '0', '\'', '\'', ',', '\'', '"', '"', ',,', '"', '\'', '"', '"', '"', '<<', '>>', '<', '>', '-', '-', '-', '-', '-', '-', '-', '-', '-', '||', '/', '[', ']', '*', ',', '.', '<', '>', '<<', '>>', '[', ']', '[', ']', '[', ']', ',', '.', '[', ']', '<<', '>>', '<', '>', ',', '[', ']', '((', '))', '.', ',', '*', '/', '-', '/', '\\', '|', '||', '<<', '>>', '((', '))'];
|
||||
|
||||
private static $transliterators = [];
|
||||
private static $tableZero;
|
||||
private static $tableWide;
|
||||
private static array $transliterators = [];
|
||||
private static array $tableZero;
|
||||
private static array $tableWide;
|
||||
|
||||
public static function fromCodePoints(int ...$codes): static
|
||||
{
|
||||
@@ -121,10 +117,10 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$s = preg_replace("/([AUO])\u{0308}(?=\p{Ll})/u", '$1e', $s);
|
||||
$s = str_replace(["a\u{0308}", "o\u{0308}", "u\u{0308}", "A\u{0308}", "O\u{0308}", "U\u{0308}"], ['ae', 'oe', 'ue', 'AE', 'OE', 'UE'], $s);
|
||||
} elseif (\function_exists('transliterator_transliterate')) {
|
||||
if (null === $transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule)) {
|
||||
if (null === $transliterator = self::$transliterators[$rule] ??= \Transliterator::create($rule)) {
|
||||
if ('any-latin/bgn' === $rule) {
|
||||
$rule = 'any-latin';
|
||||
$transliterator = self::$transliterators[$rule] ?? self::$transliterators[$rule] = \Transliterator::create($rule);
|
||||
$transliterator = self::$transliterators[$rule] ??= \Transliterator::create($rule);
|
||||
}
|
||||
|
||||
if (null === $transliterator) {
|
||||
@@ -159,7 +155,9 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
public function camel(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) use (&$i) {
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function ($m) {
|
||||
static $i = 0;
|
||||
|
||||
return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
|
||||
}, preg_replace('/[^\pL0-9]++/u', ' ', $this->string)));
|
||||
|
||||
@@ -192,7 +190,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
|
||||
if (!$compat || !\defined('Normalizer::NFKC_CF')) {
|
||||
$str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC);
|
||||
$str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $this->string), 'UTF-8');
|
||||
$str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $str->string), 'UTF-8');
|
||||
} else {
|
||||
$str->string = normalizer_normalize($str->string, \Normalizer::NFKC_CF);
|
||||
}
|
||||
@@ -200,7 +198,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function join(array $strings, string $lastGlue = null): static
|
||||
public function join(array $strings, ?string $lastGlue = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -230,19 +228,11 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$regexp .= 'i';
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
|
||||
|
||||
try {
|
||||
if (false === $match($regexp.'u', $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException('Matching failed with unknown error code.');
|
||||
throw new RuntimeException('Matching failed with error: '.preg_last_error_msg());
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
@@ -322,14 +312,14 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$replace = 'preg_replace';
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
|
||||
|
||||
try {
|
||||
if (null === $string = $replace($fromRegexp.'u', $to, $this->string)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -368,9 +358,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
|
||||
$limit = $allWords ? -1 : 1;
|
||||
|
||||
$str->string = preg_replace_callback('/\b./u', static function (array $m): string {
|
||||
return mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
|
||||
}, $str->string, $limit);
|
||||
$str->string = preg_replace_callback('/\b./u', static fn (array $m): string => mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8'), $str->string, $limit);
|
||||
|
||||
return $str;
|
||||
}
|
||||
@@ -467,7 +455,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$width = 0;
|
||||
$s = str_replace(["\x00", "\x05", "\x07"], '', $this->string);
|
||||
|
||||
if (false !== strpos($s, "\r")) {
|
||||
if (str_contains($s, "\r")) {
|
||||
$s = str_replace(["\r\n", "\r"], "\n", $s);
|
||||
}
|
||||
|
||||
@@ -558,9 +546,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (null === self::$tableZero) {
|
||||
self::$tableZero = require __DIR__.'/Resources/data/wcswidth_table_zero.php';
|
||||
}
|
||||
self::$tableZero ??= require __DIR__.'/Resources/data/wcswidth_table_zero.php';
|
||||
|
||||
if ($codePoint >= self::$tableZero[0][0] && $codePoint <= self::$tableZero[$ubound = \count(self::$tableZero) - 1][1]) {
|
||||
$lbound = 0;
|
||||
@@ -577,9 +563,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
}
|
||||
}
|
||||
|
||||
if (null === self::$tableWide) {
|
||||
self::$tableWide = require __DIR__.'/Resources/data/wcswidth_table_wide.php';
|
||||
}
|
||||
self::$tableWide ??= require __DIR__.'/Resources/data/wcswidth_table_wide.php';
|
||||
|
||||
if ($codePoint >= self::$tableWide[0][0] && $codePoint <= self::$tableWide[$ubound = \count(self::$tableWide) - 1][1]) {
|
||||
$lbound = 0;
|
||||
|
||||
36
vendor/symfony/string/ByteString.php
vendored
36
vendor/symfony/string/ByteString.php
vendored
@@ -42,13 +42,13 @@ class ByteString extends AbstractString
|
||||
* Copyright (c) 2004-2020, Facebook, Inc. (https://www.facebook.com/)
|
||||
*/
|
||||
|
||||
public static function fromRandom(int $length = 16, string $alphabet = null): self
|
||||
public static function fromRandom(int $length = 16, ?string $alphabet = null): self
|
||||
{
|
||||
if ($length <= 0) {
|
||||
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
|
||||
}
|
||||
|
||||
$alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
|
||||
$alphabet ??= self::ALPHABET_ALPHANUMERIC;
|
||||
$alphabetSize = \strlen($alphabet);
|
||||
$bits = (int) ceil(log($alphabetSize, 2.0));
|
||||
if ($bits <= 0 || $bits > 56) {
|
||||
@@ -205,7 +205,7 @@ class ByteString extends AbstractString
|
||||
return '' === $this->string || preg_match('//u', $this->string);
|
||||
}
|
||||
|
||||
public function join(array $strings, string $lastGlue = null): static
|
||||
public function join(array $strings, ?string $lastGlue = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -236,19 +236,11 @@ class ByteString extends AbstractString
|
||||
$regexp .= 'i';
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
|
||||
|
||||
try {
|
||||
if (false === $match($regexp, $this->string, $matches, $flags | \PREG_UNMATCHED_AS_NULL, $offset)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
|
||||
throw new RuntimeException('Matching failed with unknown error code.');
|
||||
throw new RuntimeException('Matching failed with error: '.preg_last_error_msg());
|
||||
}
|
||||
} finally {
|
||||
restore_error_handler();
|
||||
@@ -308,14 +300,14 @@ class ByteString extends AbstractString
|
||||
|
||||
$replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
|
||||
|
||||
try {
|
||||
if (null === $string = $replace($fromRegexp, $to, $this->string)) {
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -340,7 +332,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function slice(int $start = 0, int $length = null): static
|
||||
public function slice(int $start = 0, ?int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
|
||||
@@ -356,7 +348,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): static
|
||||
public function splice(string $replacement, int $start = 0, ?int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
|
||||
@@ -364,9 +356,9 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
|
||||
{
|
||||
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
|
||||
if (1 > $limit ??= \PHP_INT_MAX) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
@@ -410,12 +402,12 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function toUnicodeString(string $fromEncoding = null): UnicodeString
|
||||
public function toUnicodeString(?string $fromEncoding = null): UnicodeString
|
||||
{
|
||||
return new UnicodeString($this->toCodePointString($fromEncoding)->string);
|
||||
}
|
||||
|
||||
public function toCodePointString(string $fromEncoding = null): CodePointString
|
||||
public function toCodePointString(?string $fromEncoding = null): CodePointString
|
||||
{
|
||||
$u = new CodePointString();
|
||||
|
||||
@@ -425,7 +417,7 @@ class ByteString extends AbstractString
|
||||
return $u;
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
set_error_handler(static fn ($t, $m) => throw new InvalidArgumentException($m));
|
||||
|
||||
try {
|
||||
try {
|
||||
|
||||
5
vendor/symfony/string/CHANGELOG.md
vendored
5
vendor/symfony/string/CHANGELOG.md
vendored
@@ -1,6 +1,11 @@
|
||||
CHANGELOG
|
||||
=========
|
||||
|
||||
6.2
|
||||
---
|
||||
|
||||
* Add support for emoji in `AsciiSlugger`
|
||||
|
||||
5.4
|
||||
---
|
||||
|
||||
|
||||
8
vendor/symfony/string/CodePointString.php
vendored
8
vendor/symfony/string/CodePointString.php
vendored
@@ -186,7 +186,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function slice(int $start = 0, int $length = null): static
|
||||
public function slice(int $start = 0, ?int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = mb_substr($this->string, $start, $length, 'UTF-8');
|
||||
@@ -194,7 +194,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): static
|
||||
public function splice(string $replacement, int $start = 0, ?int $length = null): static
|
||||
{
|
||||
if (!preg_match('//u', $replacement)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -208,9 +208,9 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
|
||||
{
|
||||
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
|
||||
if (1 > $limit ??= \PHP_INT_MAX) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
|
||||
124
vendor/symfony/string/Inflector/EnglishInflector.php
vendored
124
vendor/symfony/string/Inflector/EnglishInflector.php
vendored
@@ -21,12 +21,36 @@ final class EnglishInflector implements InflectorInterface
|
||||
private const PLURAL_MAP = [
|
||||
// First entry: plural suffix, reversed
|
||||
// Second entry: length of plural suffix
|
||||
// Third entry: Whether the suffix may succeed a vocal
|
||||
// Third entry: Whether the suffix may succeed a vowel
|
||||
// Fourth entry: Whether the suffix may succeed a consonant
|
||||
// Fifth entry: singular suffix, normal
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
['a', 1, true, true, ['on', 'um']],
|
||||
// bacteria (bacterium)
|
||||
['airetcab', 8, true, true, 'bacterium'],
|
||||
|
||||
// corpora (corpus)
|
||||
['aroproc', 7, true, true, 'corpus'],
|
||||
|
||||
// criteria (criterion)
|
||||
['airetirc', 8, true, true, 'criterion'],
|
||||
|
||||
// curricula (curriculum)
|
||||
['alucirruc', 9, true, true, 'curriculum'],
|
||||
|
||||
// genera (genus)
|
||||
['areneg', 6, true, true, 'genus'],
|
||||
|
||||
// media (medium)
|
||||
['aidem', 5, true, true, 'medium'],
|
||||
|
||||
// memoranda (memorandum)
|
||||
['adnaromem', 9, true, true, 'memorandum'],
|
||||
|
||||
// phenomena (phenomenon)
|
||||
['anemonehp', 9, true, true, 'phenomenon'],
|
||||
|
||||
// strata (stratum)
|
||||
['atarts', 6, true, true, 'stratum'],
|
||||
|
||||
// nebulae (nebula)
|
||||
['ea', 2, true, true, 'a'],
|
||||
@@ -55,6 +79,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// indices (index), appendices (appendix), prices (price)
|
||||
['seci', 4, false, true, ['ex', 'ix', 'ice']],
|
||||
|
||||
// codes (code)
|
||||
['sedoc', 5, false, true, 'code'],
|
||||
|
||||
// selfies (selfie)
|
||||
['seifles', 7, true, true, 'selfie'],
|
||||
|
||||
@@ -64,6 +91,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// movies (movie)
|
||||
['seivom', 6, true, true, 'movie'],
|
||||
|
||||
// names (name)
|
||||
['seman', 5, true, false, 'name'],
|
||||
|
||||
// conspectuses (conspectus), prospectuses (prospectus)
|
||||
['sesutcep', 8, true, true, 'pectus'],
|
||||
|
||||
@@ -88,6 +118,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// accesses (access), addresses (address), kisses (kiss)
|
||||
['sess', 4, true, false, 'ss'],
|
||||
|
||||
// statuses (status)
|
||||
['sesutats', 8, true, true, 'status'],
|
||||
|
||||
// analyses (analysis), ellipses (ellipsis), fungi (fungus),
|
||||
// neuroses (neurosis), theses (thesis), emphases (emphasis),
|
||||
// oases (oasis), crises (crisis), houses (house), bases (base),
|
||||
@@ -132,6 +165,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// shoes (shoe)
|
||||
['se', 2, true, true, ['', 'e']],
|
||||
|
||||
// status (status)
|
||||
['sutats', 6, true, true, 'status'],
|
||||
|
||||
// tags (tag)
|
||||
['s', 1, true, true, ''],
|
||||
|
||||
@@ -150,10 +186,13 @@ final class EnglishInflector implements InflectorInterface
|
||||
private const SINGULAR_MAP = [
|
||||
// First entry: singular suffix, reversed
|
||||
// Second entry: length of singular suffix
|
||||
// Third entry: Whether the suffix may succeed a vocal
|
||||
// Third entry: Whether the suffix may succeed a vowel
|
||||
// Fourth entry: Whether the suffix may succeed a consonant
|
||||
// Fifth entry: plural suffix, normal
|
||||
|
||||
// axes (axis)
|
||||
['sixa', 4, false, false, 'axes'],
|
||||
|
||||
// criterion (criteria)
|
||||
['airetirc', 8, false, false, 'criterion'],
|
||||
|
||||
@@ -223,7 +262,10 @@ final class EnglishInflector implements InflectorInterface
|
||||
// teeth (tooth)
|
||||
['htoot', 5, true, true, 'teeth'],
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
// albums (album)
|
||||
['mubla', 5, true, true, 'albums'],
|
||||
|
||||
// bacteria (bacterium), curricula (curriculum), media (medium), memoranda (memorandum), phenomena (phenomenon), strata (stratum)
|
||||
['mu', 2, true, true, 'a'],
|
||||
|
||||
// men (man), women (woman)
|
||||
@@ -232,17 +274,11 @@ final class EnglishInflector implements InflectorInterface
|
||||
// people (person)
|
||||
['nosrep', 6, true, true, ['persons', 'people']],
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
['noi', 3, true, true, 'ions'],
|
||||
// criteria (criterion)
|
||||
['noiretirc', 9, true, true, 'criteria'],
|
||||
|
||||
// coupon (coupons)
|
||||
['nop', 3, true, true, 'pons'],
|
||||
|
||||
// seasons (season), treasons (treason), poisons (poison), lessons (lesson)
|
||||
['nos', 3, true, true, 'sons'],
|
||||
|
||||
// bacteria (bacterium), criteria (criterion), phenomena (phenomenon)
|
||||
['no', 2, true, true, 'a'],
|
||||
// phenomena (phenomenon)
|
||||
['nonemonehp', 10, true, true, 'phenomena'],
|
||||
|
||||
// echoes (echo)
|
||||
['ohce', 4, true, true, 'echoes'],
|
||||
@@ -253,6 +289,9 @@ final class EnglishInflector implements InflectorInterface
|
||||
// atlases (atlas)
|
||||
['salta', 5, true, true, 'atlases'],
|
||||
|
||||
// aliases (alias)
|
||||
['saila', 5, true, true, 'aliases'],
|
||||
|
||||
// irises (iris)
|
||||
['siri', 4, true, true, 'irises'],
|
||||
|
||||
@@ -273,6 +312,15 @@ final class EnglishInflector implements InflectorInterface
|
||||
// circuses (circus)
|
||||
['suc', 3, true, true, 'cuses'],
|
||||
|
||||
// hippocampi (hippocampus)
|
||||
['supmacoppih', 11, false, false, 'hippocampi'],
|
||||
|
||||
// campuses (campus)
|
||||
['sup', 3, true, true, 'puses'],
|
||||
|
||||
// status (status)
|
||||
['sutats', 6, true, true, ['status', 'statuses']],
|
||||
|
||||
// conspectuses (conspectus), prospectuses (prospectus)
|
||||
['sutcep', 6, true, true, 'pectuses'],
|
||||
|
||||
@@ -328,15 +376,30 @@ final class EnglishInflector implements InflectorInterface
|
||||
// deer
|
||||
'reed',
|
||||
|
||||
// equipment
|
||||
'tnempiuqe',
|
||||
|
||||
// feedback
|
||||
'kcabdeef',
|
||||
|
||||
// fish
|
||||
'hsif',
|
||||
|
||||
// health
|
||||
'htlaeh',
|
||||
|
||||
// history
|
||||
'yrotsih',
|
||||
|
||||
// info
|
||||
'ofni',
|
||||
|
||||
// information
|
||||
'noitamrofni',
|
||||
|
||||
// money
|
||||
'yenom',
|
||||
|
||||
// moose
|
||||
'esoom',
|
||||
|
||||
@@ -348,11 +411,17 @@ final class EnglishInflector implements InflectorInterface
|
||||
|
||||
// species
|
||||
'seiceps',
|
||||
|
||||
// traffic
|
||||
'ciffart',
|
||||
|
||||
// aircraft
|
||||
'tfarcria',
|
||||
|
||||
// hardware
|
||||
'erawdrah',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function singularize(string $plural): array
|
||||
{
|
||||
$pluralRev = strrev($plural);
|
||||
@@ -384,14 +453,14 @@ final class EnglishInflector implements InflectorInterface
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $pluralLength) {
|
||||
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
|
||||
$nextIsVowel = str_contains('aeiou', $lowerPluralRev[$j]);
|
||||
|
||||
if (!$map[2] && $nextIsVocal) {
|
||||
// suffix may not succeed a vocal but next char is one
|
||||
if (!$map[2] && $nextIsVowel) {
|
||||
// suffix may not succeed a vowel but next char is one
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$map[3] && !$nextIsVocal) {
|
||||
if (!$map[3] && !$nextIsVowel) {
|
||||
// suffix may not succeed a consonant but next char is one
|
||||
break;
|
||||
}
|
||||
@@ -429,9 +498,6 @@ final class EnglishInflector implements InflectorInterface
|
||||
return [$plural];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pluralize(string $singular): array
|
||||
{
|
||||
$singularRev = strrev($singular);
|
||||
@@ -464,14 +530,14 @@ final class EnglishInflector implements InflectorInterface
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $singularLength) {
|
||||
$nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]);
|
||||
$nextIsVowel = str_contains('aeiou', $lowerSingularRev[$j]);
|
||||
|
||||
if (!$map[2] && $nextIsVocal) {
|
||||
// suffix may not succeed a vocal but next char is one
|
||||
if (!$map[2] && $nextIsVowel) {
|
||||
// suffix may not succeed a vowel but next char is one
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$map[3] && !$nextIsVocal) {
|
||||
if (!$map[3] && !$nextIsVowel) {
|
||||
// suffix may not succeed a consonant but next char is one
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -110,9 +110,6 @@ final class FrenchInflector implements InflectorInterface
|
||||
*/
|
||||
private const UNINFLECTED = '/^(abcès|accès|abus|albatros|anchois|anglais|autobus|bois|brebis|carquois|cas|chas|colis|concours|corps|cours|cyprès|décès|devis|discours|dos|embarras|engrais|entrelacs|excès|fils|fois|gâchis|gars|glas|héros|intrus|jars|jus|kermès|lacis|legs|lilas|marais|mars|matelas|mépris|mets|mois|mors|obus|os|palais|paradis|parcours|pardessus|pays|plusieurs|poids|pois|pouls|printemps|processus|progrès|puits|pus|rabais|radis|recors|recours|refus|relais|remords|remous|rictus|rhinocéros|repas|rubis|sans|sas|secours|sens|souris|succès|talus|tapis|tas|taudis|temps|tiers|univers|velours|verglas|vernis|virus)$/i';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function singularize(string $plural): array
|
||||
{
|
||||
if ($this->isInflectedWord($plural)) {
|
||||
@@ -130,9 +127,6 @@ final class FrenchInflector implements InflectorInterface
|
||||
return [$plural];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function pluralize(string $singular): array
|
||||
{
|
||||
if ($this->isInflectedWord($singular)) {
|
||||
|
||||
2
vendor/symfony/string/LICENSE
vendored
2
vendor/symfony/string/LICENSE
vendored
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2019-2023 Fabien Potencier
|
||||
Copyright (c) 2019-present Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
14
vendor/symfony/string/LazyString.php
vendored
14
vendor/symfony/string/LazyString.php
vendored
@@ -30,14 +30,16 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
}
|
||||
|
||||
$lazyString = new static();
|
||||
$lazyString->value = static function () use (&$callback, &$arguments, &$value): string {
|
||||
$lazyString->value = static function () use (&$callback, &$arguments): string {
|
||||
static $value;
|
||||
|
||||
if (null !== $arguments) {
|
||||
if (!\is_callable($callback)) {
|
||||
$callback[0] = $callback[0]();
|
||||
$callback[1] = $callback[1] ?? '__invoke';
|
||||
$callback[1] ??= '__invoke';
|
||||
}
|
||||
$value = $callback(...$arguments);
|
||||
$callback = self::getPrettyName($callback);
|
||||
$callback = !\is_scalar($value) && !$value instanceof \Stringable ? self::getPrettyName($callback) : 'callable';
|
||||
$arguments = null;
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
public static function fromStringable(string|int|float|bool|\Stringable $value): static
|
||||
{
|
||||
if (\is_object($value)) {
|
||||
return static::fromCallable([$value, '__toString']);
|
||||
return static::fromCallable($value->__toString(...));
|
||||
}
|
||||
|
||||
$lazyString = new static();
|
||||
@@ -86,7 +88,7 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
try {
|
||||
return $this->value = ($this->value)();
|
||||
} catch (\Throwable $e) {
|
||||
if (\TypeError::class === \get_class($e) && __FILE__ === $e->getFile()) {
|
||||
if (\TypeError::class === $e::class && __FILE__ === $e->getFile()) {
|
||||
$type = explode(', ', $e->getMessage());
|
||||
$type = substr(array_pop($type), 0, -\strlen(' returned'));
|
||||
$r = new \ReflectionFunction($this->value);
|
||||
@@ -127,7 +129,7 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
} elseif ($callback instanceof \Closure) {
|
||||
$r = new \ReflectionFunction($callback);
|
||||
|
||||
if (false !== strpos($r->name, '{closure}') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
|
||||
if (str_contains($r->name, '{closure') || !$class = \PHP_VERSION_ID >= 80111 ? $r->getClosureCalledClass() : $r->getClosureScopeClass()) {
|
||||
return $r->name;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/*
|
||||
* This file has been auto-generated by the Symfony String Component for internal use.
|
||||
*
|
||||
* Unicode version: 15.0.0
|
||||
* Date: 2022-10-05T17:16:36+02:00
|
||||
* Unicode version: 15.1.0
|
||||
* Date: 2023-09-13T11:47:12+00:00
|
||||
*/
|
||||
|
||||
return [
|
||||
@@ -166,7 +166,7 @@ return [
|
||||
],
|
||||
[
|
||||
12272,
|
||||
12283,
|
||||
12287,
|
||||
],
|
||||
[
|
||||
12288,
|
||||
@@ -396,6 +396,10 @@ return [
|
||||
12736,
|
||||
12771,
|
||||
],
|
||||
[
|
||||
12783,
|
||||
12783,
|
||||
],
|
||||
[
|
||||
12784,
|
||||
12799,
|
||||
@@ -1110,6 +1114,14 @@ return [
|
||||
],
|
||||
[
|
||||
191457,
|
||||
191471,
|
||||
],
|
||||
[
|
||||
191472,
|
||||
192093,
|
||||
],
|
||||
[
|
||||
192094,
|
||||
194559,
|
||||
],
|
||||
[
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/*
|
||||
* This file has been auto-generated by the Symfony String Component for internal use.
|
||||
*
|
||||
* Unicode version: 15.0.0
|
||||
* Date: 2022-10-05T17:16:37+02:00
|
||||
* Unicode version: 15.1.0
|
||||
* Date: 2023-09-13T11:47:13+00:00
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
@@ -31,7 +31,7 @@ if (!\function_exists(s::class)) {
|
||||
*/
|
||||
function s(?string $string = ''): AbstractString
|
||||
{
|
||||
$string = $string ?? '';
|
||||
$string ??= '';
|
||||
|
||||
return preg_match('//u', $string) ? new UnicodeString($string) : new ByteString($string);
|
||||
}
|
||||
|
||||
58
vendor/symfony/string/Slugger/AsciiSlugger.php
vendored
58
vendor/symfony/string/Slugger/AsciiSlugger.php
vendored
@@ -11,6 +11,7 @@
|
||||
|
||||
namespace Symfony\Component\String\Slugger;
|
||||
|
||||
use Symfony\Component\Intl\Transliterator\EmojiTransliterator;
|
||||
use Symfony\Component\String\AbstractUnicodeString;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
use Symfony\Contracts\Translation\LocaleAwareInterface;
|
||||
@@ -58,6 +59,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
private \Closure|array $symbolsMap = [
|
||||
'en' => ['@' => 'at', '&' => 'and'],
|
||||
];
|
||||
private bool|string $emoji = false;
|
||||
|
||||
/**
|
||||
* Cache of transliterators per locale.
|
||||
@@ -66,50 +68,63 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
*/
|
||||
private array $transliterators = [];
|
||||
|
||||
public function __construct(string $defaultLocale = null, array|\Closure $symbolsMap = null)
|
||||
public function __construct(?string $defaultLocale = null, array|\Closure|null $symbolsMap = null)
|
||||
{
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
$this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return void
|
||||
*/
|
||||
public function setLocale(string $locale)
|
||||
{
|
||||
$this->defaultLocale = $locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLocale(): string
|
||||
{
|
||||
return $this->defaultLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @param bool|string $emoji true will use the same locale,
|
||||
* false will disable emoji,
|
||||
* and a string to use a specific locale
|
||||
*/
|
||||
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
|
||||
public function withEmoji(bool|string $emoji = true): static
|
||||
{
|
||||
$locale = $locale ?? $this->defaultLocale;
|
||||
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__));
|
||||
}
|
||||
|
||||
$new = clone $this;
|
||||
$new->emoji = $emoji;
|
||||
|
||||
return $new;
|
||||
}
|
||||
|
||||
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString
|
||||
{
|
||||
$locale ??= $this->defaultLocale;
|
||||
|
||||
$transliterator = [];
|
||||
if ($locale && ('de' === $locale || 0 === strpos($locale, 'de_'))) {
|
||||
if ($locale && ('de' === $locale || str_starts_with($locale, 'de_'))) {
|
||||
// Use the shortcut for German in UnicodeString::ascii() if possible (faster and no requirement on intl)
|
||||
$transliterator = ['de-ASCII'];
|
||||
} elseif (\function_exists('transliterator_transliterate') && $locale) {
|
||||
$transliterator = (array) $this->createTransliterator($locale);
|
||||
}
|
||||
|
||||
if ($emojiTransliterator = $this->createEmojiTransliterator($locale)) {
|
||||
$transliterator[] = $emojiTransliterator;
|
||||
}
|
||||
|
||||
if ($this->symbolsMap instanceof \Closure) {
|
||||
// If the symbols map is passed as a closure, there is no need to fallback to the parent locale
|
||||
// as the closure can just provide substitutions for all locales of interest.
|
||||
$symbolsMap = $this->symbolsMap;
|
||||
array_unshift($transliterator, static function ($s) use ($symbolsMap, $locale) {
|
||||
return $symbolsMap($s, $locale);
|
||||
});
|
||||
array_unshift($transliterator, static fn ($s) => $symbolsMap($s, $locale));
|
||||
}
|
||||
|
||||
$unicodeString = (new UnicodeString($string))->ascii($transliterator);
|
||||
@@ -161,6 +176,25 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
return $this->transliterators[$locale] = $this->transliterators[$parent] = $transliterator ?? null;
|
||||
}
|
||||
|
||||
private function createEmojiTransliterator(?string $locale): ?EmojiTransliterator
|
||||
{
|
||||
if (\is_string($this->emoji)) {
|
||||
$locale = $this->emoji;
|
||||
} elseif (!$this->emoji) {
|
||||
return null;
|
||||
}
|
||||
|
||||
while (null !== $locale) {
|
||||
try {
|
||||
return EmojiTransliterator::create("emoji-$locale");
|
||||
} catch (\IntlException) {
|
||||
$locale = self::getParentLocale($locale);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function getParentLocale(?string $locale): ?string
|
||||
{
|
||||
if (!$locale) {
|
||||
|
||||
@@ -23,5 +23,5 @@ interface SluggerInterface
|
||||
/**
|
||||
* Creates a slug for the given string and locale, using appropriate transliteration when needed.
|
||||
*/
|
||||
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString;
|
||||
public function slug(string $string, string $separator = '-', ?string $locale = null): AbstractUnicodeString;
|
||||
}
|
||||
|
||||
59
vendor/symfony/string/UnicodeString.php
vendored
59
vendor/symfony/string/UnicodeString.php
vendored
@@ -34,23 +34,32 @@ class UnicodeString extends AbstractUnicodeString
|
||||
{
|
||||
public function __construct(string $string = '')
|
||||
{
|
||||
$this->string = normalizer_is_normalized($string) ? $string : normalizer_normalize($string);
|
||||
if ('' === $string || normalizer_is_normalized($this->string = $string)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (false === $this->string) {
|
||||
if (false === $string = normalizer_normalize($string)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
}
|
||||
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix));
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
|
||||
if (false === $str->string) {
|
||||
if (normalizer_is_normalized($str->string)) {
|
||||
return $str;
|
||||
}
|
||||
|
||||
if (false === $string = normalizer_normalize($str->string)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
}
|
||||
|
||||
$str->string = $string;
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
@@ -139,7 +148,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
|
||||
try {
|
||||
$i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
|
||||
} catch (\ValueError $e) {
|
||||
} catch (\ValueError) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -176,7 +185,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function join(array $strings, string $lastGlue = null): static
|
||||
public function join(array $strings, ?string $lastGlue = null): static
|
||||
{
|
||||
$str = parent::join($strings, $lastGlue);
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
@@ -209,12 +218,17 @@ class UnicodeString extends AbstractUnicodeString
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
|
||||
if (false === $str->string) {
|
||||
if (normalizer_is_normalized($str->string)) {
|
||||
return $str;
|
||||
}
|
||||
|
||||
if (false === $string = normalizer_normalize($str->string)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
}
|
||||
|
||||
$str->string = $string;
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
@@ -235,11 +249,16 @@ class UnicodeString extends AbstractUnicodeString
|
||||
}
|
||||
|
||||
$str->string = $result.$tail;
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
|
||||
if (false === $str->string) {
|
||||
if (normalizer_is_normalized($str->string)) {
|
||||
return $str;
|
||||
}
|
||||
|
||||
if (false === $string = normalizer_normalize($str->string)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
}
|
||||
|
||||
$str->string = $string;
|
||||
}
|
||||
|
||||
return $str;
|
||||
@@ -253,7 +272,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function slice(int $start = 0, int $length = null): static
|
||||
public function slice(int $start = 0, ?int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -262,25 +281,30 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): static
|
||||
public function splice(string $replacement, int $start = 0, ?int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
$start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
|
||||
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? 2147483647)) : $length;
|
||||
$str->string = substr_replace($this->string, $replacement, $start, $length ?? 2147483647);
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
|
||||
if (false === $str->string) {
|
||||
if (normalizer_is_normalized($str->string)) {
|
||||
return $str;
|
||||
}
|
||||
|
||||
if (false === $string = normalizer_normalize($str->string)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
}
|
||||
|
||||
$str->string = $string;
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
public function split(string $delimiter, ?int $limit = null, ?int $flags = null): array
|
||||
{
|
||||
if (1 > $limit = $limit ?? 2147483647) {
|
||||
if (1 > $limit ??= 2147483647) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
@@ -338,6 +362,9 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $prefix === grapheme_extract($this->string, \strlen($prefix), \GRAPHEME_EXTR_MAXBYTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
if (!\is_string($this->string)) {
|
||||
|
||||
13
vendor/symfony/string/composer.json
vendored
13
vendor/symfony/string/composer.json
vendored
@@ -16,20 +16,21 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.0.2",
|
||||
"php": ">=8.1",
|
||||
"symfony/polyfill-ctype": "~1.8",
|
||||
"symfony/polyfill-intl-grapheme": "~1.0",
|
||||
"symfony/polyfill-intl-normalizer": "~1.0",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/error-handler": "^5.4|^6.0",
|
||||
"symfony/http-client": "^5.4|^6.0",
|
||||
"symfony/translation-contracts": "^2.0|^3.0",
|
||||
"symfony/var-exporter": "^5.4|^6.0"
|
||||
"symfony/error-handler": "^5.4|^6.0|^7.0",
|
||||
"symfony/intl": "^6.2|^7.0",
|
||||
"symfony/http-client": "^5.4|^6.0|^7.0",
|
||||
"symfony/translation-contracts": "^2.5|^3.0",
|
||||
"symfony/var-exporter": "^5.4|^6.0|^7.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/translation-contracts": "<2.0"
|
||||
"symfony/translation-contracts": "<2.5"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\String\\": "" },
|
||||
|
||||
Reference in New Issue
Block a user