Updates to vendors etc

This commit is contained in:
Chris Hunt
2025-07-11 15:57:48 +01:00
parent d972cbcd0a
commit 8fb6438254
8043 changed files with 248005 additions and 189479 deletions

View File

@@ -263,7 +263,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
public function endsWith(string|iterable $suffix): bool
{
if (\is_string($suffix)) {
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
}
foreach ($suffix as $s) {
@@ -312,7 +312,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
public function equalsTo(string|iterable $string): bool
{
if (\is_string($string)) {
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
}
foreach ($string as $s) {
@@ -340,7 +340,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
public function indexOf(string|iterable $needle, int $offset = 0): ?int
{
if (\is_string($needle)) {
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
}
$i = \PHP_INT_MAX;
@@ -362,7 +362,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
public function indexOfLast(string|iterable $needle, int $offset = 0): ?int
{
if (\is_string($needle)) {
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
}
$i = null;
@@ -414,7 +414,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
public function repeat(int $multiplier): static
{
if (0 > $multiplier) {
throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
throw new InvalidArgumentException(\sprintf('Multiplier must be positive, %d given.', $multiplier));
}
$str = clone $this;
@@ -433,6 +433,16 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
abstract public function snake(): static;
public function kebab(): static
{
return $this->snake()->replace('_', '-');
}
public function pascal(): static
{
return $this->camel()->title();
}
abstract public function splice(string $replacement, int $start = 0, ?int $length = null): static;
/**
@@ -481,7 +491,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
public function startsWith(string|iterable $prefix): bool
{
if (\is_string($prefix)) {
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
throw new \TypeError(\sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
}
foreach ($prefix as $prefix) {
@@ -605,7 +615,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
return $str;
}
public function truncate(int $length, string $ellipsis = '', bool $cut = true): static
public function truncate(int $length, string $ellipsis = '', bool|TruncateMode $cut = TruncateMode::Char): static
{
$stringLength = $this->length();
@@ -619,16 +629,27 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
$ellipsisLength = 0;
}
if (!$cut) {
$desiredLength = $length;
if (TruncateMode::WordAfter === $cut || !$cut) {
if (null === $length = $this->indexOf([' ', "\r", "\n", "\t"], ($length ?: 1) - 1)) {
return clone $this;
}
$length += $ellipsisLength;
} elseif (TruncateMode::WordBefore === $cut && null !== $this->indexOf([' ', "\r", "\n", "\t"], ($length ?: 1) - 1)) {
$length += $ellipsisLength;
}
$str = $this->slice(0, $length - $ellipsisLength);
if (TruncateMode::WordBefore === $cut) {
if (0 === $ellipsisLength && $desiredLength === $this->indexOf([' ', "\r", "\n", "\t"], $length)) {
return $str;
}
$str = $str->beforeLast([' ', "\r", "\n", "\t"]);
}
return $ellipsisLength ? $str->trimEnd()->append($ellipsis) : $str;
}

View File

@@ -124,7 +124,7 @@ abstract class AbstractUnicodeString extends AbstractString
}
if (null === $transliterator) {
throw new InvalidArgumentException(sprintf('Unknown transliteration rule "%s".', $rule));
throw new InvalidArgumentException(\sprintf('Unknown transliteration rule "%s".', $rule));
}
self::$transliterators['any-latin/bgn'] = $transliterator;
@@ -135,15 +135,21 @@ abstract class AbstractUnicodeString extends AbstractString
} elseif (!\function_exists('iconv')) {
$s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
} else {
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
$previousLocale = setlocale(\LC_CTYPE, 0);
try {
setlocale(\LC_CTYPE, 'C');
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
}
if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
throw new \LogicException(\sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
}
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
}, $s);
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
}, $s);
} finally {
setlocale(\LC_CTYPE, $previousLocale);
}
}
}
@@ -155,7 +161,7 @@ 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) {
$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');
@@ -190,7 +196,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);
}
@@ -220,6 +226,21 @@ abstract class AbstractUnicodeString extends AbstractString
return $str;
}
/**
* @param string $locale In the format language_region (e.g. tr_TR)
*/
public function localeLower(string $locale): static
{
if (null !== $transliterator = $this->getLocaleTransliterator($locale, 'Lower')) {
$str = clone $this;
$str->string = $transliterator->transliterate($str->string);
return $str;
}
return $this->lower();
}
public function match(string $regexp, int $flags = 0, int $offset = 0): array
{
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
@@ -363,6 +384,21 @@ abstract class AbstractUnicodeString extends AbstractString
return $str;
}
/**
* @param string $locale In the format language_region (e.g. tr_TR)
*/
public function localeTitle(string $locale): static
{
if (null !== $transliterator = $this->getLocaleTransliterator($locale, 'Title')) {
$str = clone $this;
$str->string = $transliterator->transliterate($str->string);
return $str;
}
return $this->title();
}
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
{
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
@@ -450,6 +486,21 @@ abstract class AbstractUnicodeString extends AbstractString
return $str;
}
/**
* @param string $locale In the format language_region (e.g. tr_TR)
*/
public function localeUpper(string $locale): static
{
if (null !== $transliterator = $this->getLocaleTransliterator($locale, 'Upper')) {
$str = clone $this;
$str->string = $transliterator->transliterate($str->string);
return $str;
}
return $this->upper();
}
public function width(bool $ignoreAnsiDecoration = true): int
{
$width = 0;
@@ -587,4 +638,33 @@ abstract class AbstractUnicodeString extends AbstractString
return $width;
}
private function getLocaleTransliterator(string $locale, string $id): ?\Transliterator
{
$rule = $locale.'-'.$id;
if (\array_key_exists($rule, self::$transliterators)) {
return self::$transliterators[$rule];
}
if (null !== $transliterator = self::$transliterators[$rule] = \Transliterator::create($rule)) {
return $transliterator;
}
// Try to find a parent locale (nl_BE -> nl)
if (false === $i = strpos($locale, '_')) {
return null;
}
$parentRule = substr_replace($locale, '-'.$id, $i);
// Parent locale was already cached, return and store as current locale
if (\array_key_exists($parentRule, self::$transliterators)) {
return self::$transliterators[$rule] = self::$transliterators[$parentRule];
}
// Create transliterator based on parent locale and cache the result on both initial and parent locale values
$transliterator = \Transliterator::create($parentRule);
return self::$transliterators[$rule] = self::$transliterators[$parentRule] = $transliterator;
}
}

View File

@@ -11,6 +11,7 @@
namespace Symfony\Component\String;
use Random\Randomizer;
use Symfony\Component\String\Exception\ExceptionInterface;
use Symfony\Component\String\Exception\InvalidArgumentException;
use Symfony\Component\String\Exception\RuntimeException;
@@ -45,7 +46,7 @@ class ByteString extends AbstractString
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));
throw new InvalidArgumentException(\sprintf('A strictly positive length is expected, "%d" given.', $length));
}
$alphabet ??= self::ALPHABET_ALPHANUMERIC;
@@ -55,6 +56,10 @@ class ByteString extends AbstractString
throw new InvalidArgumentException('The length of the alphabet must in the [2^1, 2^56] range.');
}
if (\PHP_VERSION_ID >= 80300) {
return new static((new Randomizer())->getBytesFromString($alphabet, $length));
}
$ret = '';
while ($length > 0) {
$urandomLength = (int) ceil(2 * $length * $bits / 8.0);
@@ -335,7 +340,7 @@ class ByteString extends AbstractString
public function slice(int $start = 0, ?int $length = null): static
{
$str = clone $this;
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
$str->string = substr($this->string, $start, $length ?? \PHP_INT_MAX);
return $str;
}
@@ -436,7 +441,7 @@ class ByteString extends AbstractString
}
if (!$validEncoding) {
throw new InvalidArgumentException(sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
throw new InvalidArgumentException(\sprintf('Invalid "%s" string.', $fromEncoding ?? 'Windows-1252'));
}
$u->string = mb_convert_encoding($this->string, 'UTF-8', $fromEncoding ?? 'Windows-1252');

View File

@@ -1,6 +1,22 @@
CHANGELOG
=========
7.3
---
* Add the `AbstractString::pascal()` method
7.2
---
* Add `TruncateMode` enum to handle more truncate methods
* Add the `AbstractString::kebab()` method
7.1
---
* Add `localeLower()`, `localeUpper()`, `localeTitle()` methods to `AbstractUnicodeString`
6.2
---

View File

@@ -25,8 +25,35 @@ final class EnglishInflector implements InflectorInterface
// 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'],
// quora (quorum)
['arouq', 5, true, true, 'quorum'],
// 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'],
@@ -97,6 +124,9 @@ final class EnglishInflector implements InflectorInterface
// statuses (status)
['sesutats', 8, true, true, 'status'],
// article (articles), ancle (ancles)
['sel', 3, true, true, 'le'],
// analyses (analysis), ellipses (ellipsis), fungi (fungus),
// neuroses (neurosis), theses (thesis), emphases (emphasis),
// oases (oasis), crises (crisis), houses (house), bases (base),
@@ -141,7 +171,7 @@ final class EnglishInflector implements InflectorInterface
// shoes (shoe)
['se', 2, true, true, ['', 'e']],
// status (status)
// status (status)
['sutats', 6, true, true, 'status'],
// tags (tag)
@@ -238,7 +268,13 @@ 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'],
// quorums (quorum)
['murouq', 6, true, true, ['quora', 'quorums']],
// bacteria (bacterium), curricula (curriculum), media (medium), memoranda (memorandum), phenomena (phenomenon), strata (stratum)
['mu', 2, true, true, 'a'],
// men (man), women (woman)
@@ -247,20 +283,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'],
// icons (icon)
['noc', 3, true, true, 'cons'],
// 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'],
@@ -271,6 +298,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'],
@@ -291,12 +321,21 @@ 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'],
// nexuses (nexus)
['suxen', 5, false, false, 'nexuses'],
// fungi (fungus), alumni (alumnus), syllabi (syllabus), radii (radius)
['su', 2, true, true, 'i'],
@@ -318,14 +357,14 @@ final class EnglishInflector implements InflectorInterface
// indices (index)
['xedni', 5, false, true, ['indicies', 'indexes']],
// fax (faxes, faxxes)
['xaf', 3, true, true, ['faxes', 'faxxes']],
// boxes (box)
['xo', 2, false, true, 'oxes'],
// indexes (index), matrixes (matrix)
['x', 1, true, false, ['cies', 'xes']],
// appendices (appendix)
['xi', 2, false, true, 'ices'],
// indexes (index), matrixes (matrix), appendices (appendix)
['x', 1, true, false, ['ces', 'xes']],
// babies (baby)
['y', 1, false, true, 'ies'],
@@ -390,6 +429,9 @@ final class EnglishInflector implements InflectorInterface
// aircraft
'tfarcria',
// hardware
'erawdrah',
];
public function singularize(string $plural): array

View File

@@ -0,0 +1,126 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\String\Inflector;
final class SpanishInflector implements InflectorInterface
{
/**
* A list of all rules for pluralise.
*
* @see https://www.spanishdict.com/guide/spanish-plural-noun-forms
* @see https://www.rae.es/gram%C3%A1tica/morfolog%C3%ADa/la-formaci%C3%B3n-del-plural-plurales-en-s-y-plurales-en-es-reglas-generales
*/
// First entry: regex
// Second entry: replacement
private const PLURALIZE_REGEXP = [
// Specials sí, no
['/(sí|no)$/i', '\1es'],
// Words ending with vowel must use -s (RAE 3.2a, 3.2c)
['/(a|e|i|o|u|á|é|í|ó|ú)$/i', '\1s'],
// Word ending in s or x and the previous letter is accented (RAE 3.2n)
['/ás$/i', 'ases'],
['/és$/i', 'eses'],
['/ís$/i', 'ises'],
['/ós$/i', 'oses'],
['/ús$/i', 'uses'],
// Words ending in -ión must changed to -iones
['/ión$/i', '\1iones'],
// Words ending in some consonants must use -es (RAE 3.2k)
['/(l|r|n|d|j|s|x|ch|y)$/i', '\1es'],
// Word ending in z, must changed to ces
['/(z)$/i', 'ces'],
];
/**
* A list of all rules for singularize.
*/
private const SINGULARIZE_REGEXP = [
// Specials sí, no
['/(sí|no)es$/i', '\1'],
// Words ending in -ión must changed to -iones
['/iones$/i', '\1ión'],
// Word ending in z, must changed to ces
['/ces$/i', 'z'],
// Word ending in s or x and the previous letter is accented (RAE 3.2n)
['/(\w)ases$/i', '\1ás'],
['/eses$/i', 'és'],
['/ises$/i', 'ís'],
['/(\w{2,})oses$/i', '\1ós'],
['/(\w)uses$/i', '\1ús'],
// Words ending in some consonants and -es, must be the consonants
['/(l|r|n|d|j|s|x|ch|y)e?s$/i', '\1'],
// Words ended with vowel and s, must be vowel
['/(a|e|i|o|u|á|é|ó|í|ú)s$/i', '\1'],
];
private const UNINFLECTED_RULES = [
// Words ending with pies (RAE 3.2n)
'/.*(piés)$/i',
];
private const UNINFLECTED = '/^(lunes|martes|miércoles|jueves|viernes|análisis|torax|yo|pies)$/i';
public function singularize(string $plural): array
{
if ($this->isInflectedWord($plural)) {
return [$plural];
}
foreach (self::SINGULARIZE_REGEXP as $rule) {
[$regexp, $replace] = $rule;
if (1 === preg_match($regexp, $plural)) {
return [preg_replace($regexp, $replace, $plural)];
}
}
return [$plural];
}
public function pluralize(string $singular): array
{
if ($this->isInflectedWord($singular)) {
return [$singular];
}
foreach (self::PLURALIZE_REGEXP as $rule) {
[$regexp, $replace] = $rule;
if (1 === preg_match($regexp, $singular)) {
return [preg_replace($regexp, $replace, $singular)];
}
}
return [$singular.'s'];
}
private function isInflectedWord(string $word): bool
{
foreach (self::UNINFLECTED_RULES as $rule) {
if (1 === preg_match($rule, $word)) {
return true;
}
}
return 1 === preg_match(self::UNINFLECTED, $word);
}
}

View File

@@ -26,7 +26,7 @@ class LazyString implements \Stringable, \JsonSerializable
public static function fromCallable(callable|array $callback, mixed ...$arguments): static
{
if (\is_array($callback) && !\is_callable($callback) && !(($callback[0] ?? null) instanceof \Closure || 2 < \count($callback))) {
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']'));
throw new \TypeError(\sprintf('Argument 1 passed to "%s()" must be a callable or a [Closure, method] lazy-callable, "%s" given.', __METHOD__, '['.implode(', ', array_map('get_debug_type', $callback)).']'));
}
$lazyString = new static();
@@ -94,7 +94,7 @@ class LazyString implements \Stringable, \JsonSerializable
$r = new \ReflectionFunction($this->value);
$callback = $r->getStaticVariables()['callback'];
$e = new \TypeError(sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
$e = new \TypeError(\sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
}
throw $e;
@@ -129,7 +129,7 @@ class LazyString implements \Stringable, \JsonSerializable
} elseif ($callback instanceof \Closure) {
$r = new \ReflectionFunction($callback);
if (str_contains($r->name, '{closure}') || !$class = $r->getClosureCalledClass()) {
if ($r->isAnonymous() || !$class = $r->getClosureCalledClass()) {
return $r->name;
}

View File

@@ -1,10 +1,17 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 15.1.0
* Date: 2023-09-13T11:47:12+00:00
* Unicode version: 16.0.0
* Date: 2024-09-11T08:21:22+00:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
@@ -44,6 +51,10 @@ return [
9748,
9749,
],
[
9776,
9783,
],
[
9800,
9811,
@@ -52,6 +63,10 @@ return [
9855,
9855,
],
[
9866,
9871,
],
[
9875,
9875,
@@ -394,7 +409,7 @@ return [
],
[
12736,
12771,
12773,
],
[
12783,
@@ -452,6 +467,10 @@ return [
13312,
19903,
],
[
19904,
19967,
],
[
19968,
40959,
@@ -836,6 +855,10 @@ return [
101120,
101589,
],
[
101631,
101631,
],
[
101632,
101640,
@@ -880,6 +903,14 @@ return [
110960,
111355,
],
[
119552,
119638,
],
[
119648,
119670,
],
[
126980,
126980,
@@ -1054,23 +1085,19 @@ return [
],
[
129664,
129672,
129673,
],
[
129680,
129725,
],
[
129727,
129733,
129679,
129734,
],
[
129742,
129755,
129756,
],
[
129760,
129768,
129759,
129769,
],
[
129776,

View File

@@ -1,10 +1,17 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* This file has been auto-generated by the Symfony String Component for internal use.
*
* Unicode version: 15.1.0
* Date: 2023-09-13T11:47:13+00:00
* Unicode version: 16.0.0
* Date: 2024-09-11T08:21:22+00:00
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
return [
@@ -109,7 +116,7 @@ return [
2139,
],
[
2200,
2199,
2207,
],
[
@@ -916,12 +923,16 @@ return [
68900,
68903,
],
[
68969,
68973,
],
[
69291,
69292,
],
[
69373,
69372,
69375,
],
[
@@ -1044,6 +1055,26 @@ return [
70512,
70516,
],
[
70587,
70592,
],
[
70606,
70606,
],
[
70608,
70608,
],
[
70610,
70610,
],
[
70625,
70626,
],
[
70712,
70719,
@@ -1122,6 +1153,10 @@ return [
],
[
71453,
71453,
],
[
71455,
71455,
],
[
@@ -1276,6 +1311,10 @@ return [
73538,
73538,
],
[
73562,
73562,
],
[
78912,
78912,
@@ -1284,6 +1323,14 @@ return [
78919,
78933,
],
[
90398,
90409,
],
[
90413,
90415,
],
[
92912,
92916,
@@ -1400,6 +1447,10 @@ return [
124140,
124143,
],
[
124398,
124399,
],
[
125136,
125142,

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|null $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;

42
vendor/symfony/string/TruncateMode.php vendored Normal file
View File

@@ -0,0 +1,42 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\String;
enum TruncateMode
{
/**
* Will cut exactly at given length.
*
* Length: 14
* Source: Lorem ipsum dolor sit amet
* Output: Lorem ipsum do
*/
case Char;
/**
* Returns the string up to the last complete word containing the specified length.
*
* Length: 14
* Source: Lorem ipsum dolor sit amet
* Output: Lorem ipsum
*/
case WordBefore;
/**
* Returns the string up to the complete word after or at the given length.
*
* Length: 14
* Source: Lorem ipsum dolor sit amet
* Output: Lorem ipsum dolor
*/
case WordAfter;
}

View File

@@ -286,7 +286,7 @@ class UnicodeString extends AbstractUnicodeString
$str = clone $this;
$start = $start ? \strlen(grapheme_substr($this->string, 0, $start)) : 0;
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length ?? 2147483647)) : $length;
$length = $length ? \strlen(grapheme_substr($this->string, $start, $length)) : $length;
$str->string = substr_replace($this->string, $replacement, $start, $length ?? 2147483647);
if (normalizer_is_normalized($str->string)) {

View File

@@ -24,8 +24,9 @@
},
"require-dev": {
"symfony/error-handler": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
"symfony/emoji": "^7.1",
"symfony/http-client": "^6.4|^7.0",
"symfony/intl": "^6.4|^7.0",
"symfony/translation-contracts": "^2.5|^3.0",
"symfony/var-exporter": "^6.4|^7.0"
},