fix:更新已知bug,优化代码
This commit is contained in:
209
vendor/symfony/string/AbstractString.php
vendored
209
vendor/symfony/string/AbstractString.php
vendored
@@ -92,15 +92,17 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function after($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = \PHP_INT_MAX;
|
||||
|
||||
foreach ((array) $needle as $n) {
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOf($n, $offset);
|
||||
|
||||
@@ -123,15 +125,17 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function afterLast($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = null;
|
||||
|
||||
foreach ((array) $needle as $n) {
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOfLast($n, $offset);
|
||||
|
||||
@@ -152,22 +156,21 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $this->slice($i);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function append(string ...$suffix): self;
|
||||
abstract public function append(string ...$suffix): static;
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function before($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = \PHP_INT_MAX;
|
||||
|
||||
foreach ((array) $needle as $n) {
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOf($n, $offset);
|
||||
|
||||
@@ -190,15 +193,17 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function beforeLast($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = null;
|
||||
|
||||
foreach ((array) $needle as $n) {
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOfLast($n, $offset);
|
||||
|
||||
@@ -229,23 +234,17 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return '' === $str->string ? [] : array_values(unpack('C*', $str->string));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function camel(): self;
|
||||
abstract public function camel(): static;
|
||||
|
||||
/**
|
||||
* @return static[]
|
||||
*/
|
||||
abstract public function chunk(int $length = 1): array;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function collapseWhitespace(): self
|
||||
public function collapseWhitespace(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = trim(preg_replace('/(?:\s{2,}+|[^\S ])/', ' ', $str->string));
|
||||
$str->string = trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $str->string), " \n\r\t\x0C");
|
||||
|
||||
return $str;
|
||||
}
|
||||
@@ -253,7 +252,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*/
|
||||
public function containsAny($needle): bool
|
||||
public function containsAny(string|iterable $needle): bool
|
||||
{
|
||||
return null !== $this->indexOf($needle);
|
||||
}
|
||||
@@ -261,9 +260,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $suffix
|
||||
*/
|
||||
public function endsWith($suffix): bool
|
||||
public function endsWith(string|iterable $suffix): bool
|
||||
{
|
||||
if (!\is_array($suffix) && !$suffix instanceof \Traversable) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -276,10 +275,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function ensureEnd(string $suffix): self
|
||||
public function ensureEnd(string $suffix): static
|
||||
{
|
||||
if (!$this->endsWith($suffix)) {
|
||||
return $this->append($suffix);
|
||||
@@ -291,10 +287,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function ensureStart(string $prefix): self
|
||||
public function ensureStart(string $prefix): static
|
||||
{
|
||||
$prefix = new static($prefix);
|
||||
|
||||
@@ -316,9 +309,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $string
|
||||
*/
|
||||
public function equalsTo($string): bool
|
||||
public function equalsTo(string|iterable $string): bool
|
||||
{
|
||||
if (!\is_array($string) && !$string instanceof \Traversable) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -331,15 +324,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function folded(): self;
|
||||
abstract public function folded(): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function ignoreCase(): self
|
||||
public function ignoreCase(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->ignoreCase = true;
|
||||
@@ -350,9 +337,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*/
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
public function indexOf(string|iterable $needle, int $offset = 0): ?int
|
||||
{
|
||||
if (!\is_array($needle) && !$needle instanceof \Traversable) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -372,9 +359,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*/
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
public function indexOfLast(string|iterable $needle, int $offset = 0): ?int
|
||||
{
|
||||
if (!\is_array($needle) && !$needle instanceof \Traversable) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -396,10 +383,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return '' === $this->string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function join(array $strings, string $lastGlue = null): self;
|
||||
abstract public function join(array $strings, string $lastGlue = null): static;
|
||||
|
||||
public function jsonSerialize(): string
|
||||
{
|
||||
@@ -408,10 +392,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
abstract public function length(): int;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function lower(): self;
|
||||
abstract public function lower(): static;
|
||||
|
||||
/**
|
||||
* Matches the string using a regular expression.
|
||||
@@ -422,30 +403,15 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
*/
|
||||
abstract public function match(string $regexp, int $flags = 0, int $offset = 0): array;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function padBoth(int $length, string $padStr = ' '): self;
|
||||
abstract public function padBoth(int $length, string $padStr = ' '): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function padEnd(int $length, string $padStr = ' '): self;
|
||||
abstract public function padEnd(int $length, string $padStr = ' '): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function padStart(int $length, string $padStr = ' '): self;
|
||||
abstract public function padStart(int $length, string $padStr = ' '): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function prepend(string ...$prefix): self;
|
||||
abstract public function prepend(string ...$prefix): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function repeat(int $multiplier): self
|
||||
public function repeat(int $multiplier): static
|
||||
{
|
||||
if (0 > $multiplier) {
|
||||
throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
|
||||
@@ -457,37 +423,17 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function replace(string $from, string $to): self;
|
||||
abstract public function replace(string $from, string $to): static;
|
||||
|
||||
/**
|
||||
* @param string|callable $to
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
abstract public function replaceMatches(string $fromRegexp, $to): self;
|
||||
abstract public function replaceMatches(string $fromRegexp, string|callable $to): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function reverse(): self;
|
||||
abstract public function reverse(): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function slice(int $start = 0, int $length = null): self;
|
||||
abstract public function slice(int $start = 0, int $length = null): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function snake(): self;
|
||||
abstract public function snake(): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
|
||||
abstract public function splice(string $replacement, int $start = 0, int $length = null): static;
|
||||
|
||||
/**
|
||||
* @return static[]
|
||||
@@ -540,9 +486,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $prefix
|
||||
*/
|
||||
public function startsWith($prefix): bool
|
||||
public function startsWith(string|iterable $prefix): bool
|
||||
{
|
||||
if (!\is_array($prefix) && !$prefix instanceof \Traversable) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -555,10 +501,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function title(bool $allWords = false): self;
|
||||
abstract public function title(bool $allWords = false): static;
|
||||
|
||||
public function toByteString(string $toEncoding = null): ByteString
|
||||
{
|
||||
@@ -606,22 +549,14 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return new UnicodeString($this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
|
||||
abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
|
||||
abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
|
||||
|
||||
/**
|
||||
* @param string|string[] $prefix
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function trimPrefix($prefix): self
|
||||
public function trimPrefix($prefix): static
|
||||
{
|
||||
if (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
foreach ($prefix as $s) {
|
||||
@@ -650,17 +585,12 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
|
||||
abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
|
||||
|
||||
/**
|
||||
* @param string|string[] $suffix
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function trimSuffix($suffix): self
|
||||
public function trimSuffix($suffix): static
|
||||
{
|
||||
if (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
foreach ($suffix as $s) {
|
||||
@@ -689,10 +619,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function truncate(int $length, string $ellipsis = '', bool $cut = true): self
|
||||
public function truncate(int $length, string $ellipsis = '', bool $cut = true): static
|
||||
{
|
||||
$stringLength = $this->length();
|
||||
|
||||
@@ -719,20 +646,14 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $ellipsisLength ? $str->trimEnd()->append($ellipsis) : $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function upper(): self;
|
||||
abstract public function upper(): static;
|
||||
|
||||
/**
|
||||
* Returns the printable length on a terminal.
|
||||
*/
|
||||
abstract public function width(bool $ignoreAnsiDecoration = true): int;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self
|
||||
public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): static
|
||||
{
|
||||
$lines = '' !== $break ? $this->split($break) : [clone $this];
|
||||
$chars = [];
|
||||
|
||||
63
vendor/symfony/string/AbstractUnicodeString.php
vendored
63
vendor/symfony/string/AbstractUnicodeString.php
vendored
@@ -52,10 +52,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
private static $tableZero;
|
||||
private static $tableWide;
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function fromCodePoints(int ...$codes): self
|
||||
public static function fromCodePoints(int ...$codes): static
|
||||
{
|
||||
$string = '';
|
||||
|
||||
@@ -159,10 +156,10 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function camel(): parent
|
||||
public function camel(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b./u', static function ($m) use (&$i) {
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) use (&$i) {
|
||||
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)));
|
||||
|
||||
@@ -189,11 +186,11 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $codePoints;
|
||||
}
|
||||
|
||||
public function folded(bool $compat = true): parent
|
||||
public function folded(bool $compat = true): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
if (!$compat || \PHP_VERSION_ID < 70300 || !\defined('Normalizer::NFKC_CF')) {
|
||||
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');
|
||||
} else {
|
||||
@@ -203,7 +200,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function join(array $strings, string $lastGlue = null): parent
|
||||
public function join(array $strings, string $lastGlue = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -217,7 +214,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function lower(): parent
|
||||
public function lower(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = mb_strtolower(str_replace('İ', 'i̇', $str->string), 'UTF-8');
|
||||
@@ -254,10 +251,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function normalize(int $form = self::NFC): self
|
||||
public function normalize(int $form = self::NFC): static
|
||||
{
|
||||
if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) {
|
||||
throw new InvalidArgumentException('Unsupported normalization form.');
|
||||
@@ -269,7 +263,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function padBoth(int $length, string $padStr = ' '): parent
|
||||
public function padBoth(int $length, string $padStr = ' '): static
|
||||
{
|
||||
if ('' === $padStr || !preg_match('//u', $padStr)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -281,7 +275,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $this->pad($length, $pad, \STR_PAD_BOTH);
|
||||
}
|
||||
|
||||
public function padEnd(int $length, string $padStr = ' '): parent
|
||||
public function padEnd(int $length, string $padStr = ' '): static
|
||||
{
|
||||
if ('' === $padStr || !preg_match('//u', $padStr)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -293,7 +287,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $this->pad($length, $pad, \STR_PAD_RIGHT);
|
||||
}
|
||||
|
||||
public function padStart(int $length, string $padStr = ' '): parent
|
||||
public function padStart(int $length, string $padStr = ' '): static
|
||||
{
|
||||
if ('' === $padStr || !preg_match('//u', $padStr)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -305,17 +299,13 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $this->pad($length, $pad, \STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function replaceMatches(string $fromRegexp, $to): parent
|
||||
public function replaceMatches(string $fromRegexp, string|callable $to): static
|
||||
{
|
||||
if ($this->ignoreCase) {
|
||||
$fromRegexp .= 'i';
|
||||
}
|
||||
|
||||
if (\is_array($to) || $to instanceof \Closure) {
|
||||
if (!\is_callable($to)) {
|
||||
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
|
||||
}
|
||||
|
||||
$replace = 'preg_replace_callback';
|
||||
$to = static function (array $m) use ($to): string {
|
||||
$to = $to($m);
|
||||
@@ -356,7 +346,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function reverse(): parent
|
||||
public function reverse(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
|
||||
@@ -364,15 +354,15 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function snake(): parent
|
||||
public function snake(): static
|
||||
{
|
||||
$str = $this->camel()->title();
|
||||
$str = $this->camel();
|
||||
$str->string = mb_strtolower(preg_replace(['/(\p{Lu}+)(\p{Lu}\p{Ll})/u', '/([\p{Ll}0-9])(\p{Lu})/u'], '\1_\2', $str->string), 'UTF-8');
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function title(bool $allWords = false): parent
|
||||
public function title(bool $allWords = false): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -385,7 +375,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
|
||||
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)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 chars.');
|
||||
@@ -398,7 +388,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
|
||||
public function trimEnd(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)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 chars.');
|
||||
@@ -411,7 +401,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimPrefix($prefix): parent
|
||||
public function trimPrefix($prefix): static
|
||||
{
|
||||
if (!$this->ignoreCase) {
|
||||
return parent::trimPrefix($prefix);
|
||||
@@ -431,7 +421,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
|
||||
public function trimStart(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)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 chars.');
|
||||
@@ -444,7 +434,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimSuffix($suffix): parent
|
||||
public function trimSuffix($suffix): static
|
||||
{
|
||||
if (!$this->ignoreCase) {
|
||||
return parent::trimSuffix($suffix);
|
||||
@@ -464,15 +454,11 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function upper(): parent
|
||||
public function upper(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = mb_strtoupper($str->string, 'UTF-8');
|
||||
|
||||
if (\PHP_VERSION_ID < 70300) {
|
||||
$str->string = str_replace(self::UPPER_FROM, self::UPPER_TO, $str->string);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
@@ -508,10 +494,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
private function pad(int $len, self $pad, int $type): parent
|
||||
private function pad(int $len, self $pad, int $type): static
|
||||
{
|
||||
$sLen = $this->length();
|
||||
|
||||
|
||||
93
vendor/symfony/string/ByteString.php
vendored
93
vendor/symfony/string/ByteString.php
vendored
@@ -92,7 +92,7 @@ class ByteString extends AbstractString
|
||||
return '' === $str ? [] : [\ord($str)];
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): parent
|
||||
public function append(string ...$suffix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
|
||||
@@ -100,10 +100,13 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function camel(): parent
|
||||
public function camel(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = lcfirst(str_replace(' ', '', ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
|
||||
|
||||
$parts = explode(' ', trim(ucwords(preg_replace('/[^a-zA-Z0-9\x7f-\xff]++/', ' ', $this->string))));
|
||||
$parts[0] = 1 !== \strlen($parts[0]) && ctype_upper($parts[0]) ? $parts[0] : lcfirst($parts[0]);
|
||||
$str->string = implode('', $parts);
|
||||
|
||||
return $str;
|
||||
}
|
||||
@@ -129,27 +132,23 @@ class ByteString extends AbstractString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function endsWith($suffix): bool
|
||||
public function endsWith(string|iterable|AbstractString $suffix): bool
|
||||
{
|
||||
if ($suffix instanceof parent) {
|
||||
if ($suffix instanceof AbstractString) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
} elseif (!\is_string($suffix)) {
|
||||
return parent::endsWith($suffix);
|
||||
} else {
|
||||
$suffix = (string) $suffix;
|
||||
}
|
||||
|
||||
return '' !== $suffix && \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix), null, $this->ignoreCase);
|
||||
}
|
||||
|
||||
public function equalsTo($string): bool
|
||||
public function equalsTo(string|iterable|AbstractString $string): bool
|
||||
{
|
||||
if ($string instanceof parent) {
|
||||
if ($string instanceof AbstractString) {
|
||||
$string = $string->string;
|
||||
} elseif (\is_array($string) || $string instanceof \Traversable) {
|
||||
} elseif (!\is_string($string)) {
|
||||
return parent::equalsTo($string);
|
||||
} else {
|
||||
$string = (string) $string;
|
||||
}
|
||||
|
||||
if ('' !== $string && $this->ignoreCase) {
|
||||
@@ -159,7 +158,7 @@ class ByteString extends AbstractString
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
public function folded(): parent
|
||||
public function folded(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtolower($str->string);
|
||||
@@ -167,14 +166,12 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof parent) {
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -186,14 +183,12 @@ class ByteString extends AbstractString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof parent) {
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -210,7 +205,7 @@ class ByteString extends AbstractString
|
||||
return '' === $this->string || preg_match('//u', $this->string);
|
||||
}
|
||||
|
||||
public function join(array $strings, string $lastGlue = null): parent
|
||||
public function join(array $strings, string $lastGlue = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -225,7 +220,7 @@ class ByteString extends AbstractString
|
||||
return \strlen($this->string);
|
||||
}
|
||||
|
||||
public function lower(): parent
|
||||
public function lower(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtolower($str->string);
|
||||
@@ -262,7 +257,7 @@ class ByteString extends AbstractString
|
||||
return $matches;
|
||||
}
|
||||
|
||||
public function padBoth(int $length, string $padStr = ' '): parent
|
||||
public function padBoth(int $length, string $padStr = ' '): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
|
||||
@@ -270,7 +265,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function padEnd(int $length, string $padStr = ' '): parent
|
||||
public function padEnd(int $length, string $padStr = ' '): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
|
||||
@@ -278,7 +273,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function padStart(int $length, string $padStr = ' '): parent
|
||||
public function padStart(int $length, string $padStr = ' '): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
|
||||
@@ -286,7 +281,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function prepend(string ...$prefix): parent
|
||||
public function prepend(string ...$prefix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
|
||||
@@ -294,7 +289,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replace(string $from, string $to): parent
|
||||
public function replace(string $from, string $to): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -305,21 +300,13 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replaceMatches(string $fromRegexp, $to): parent
|
||||
public function replaceMatches(string $fromRegexp, string|callable $to): static
|
||||
{
|
||||
if ($this->ignoreCase) {
|
||||
$fromRegexp .= 'i';
|
||||
}
|
||||
|
||||
if (\is_array($to)) {
|
||||
if (!\is_callable($to)) {
|
||||
throw new \TypeError(sprintf('Argument 2 passed to "%s::replaceMatches()" must be callable, array given.', static::class));
|
||||
}
|
||||
|
||||
$replace = 'preg_replace_callback';
|
||||
} else {
|
||||
$replace = $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
|
||||
}
|
||||
$replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
|
||||
@@ -345,7 +332,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function reverse(): parent
|
||||
public function reverse(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strrev($str->string);
|
||||
@@ -353,7 +340,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function slice(int $start = 0, int $length = null): parent
|
||||
public function slice(int $start = 0, int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
|
||||
@@ -361,15 +348,15 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function snake(): parent
|
||||
public function snake(): static
|
||||
{
|
||||
$str = $this->camel()->title();
|
||||
$str = $this->camel();
|
||||
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): parent
|
||||
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);
|
||||
@@ -404,9 +391,9 @@ class ByteString extends AbstractString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function startsWith($prefix): bool
|
||||
public function startsWith(string|iterable|AbstractString $prefix): bool
|
||||
{
|
||||
if ($prefix instanceof parent) {
|
||||
if ($prefix instanceof AbstractString) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (!\is_string($prefix)) {
|
||||
return parent::startsWith($prefix);
|
||||
@@ -415,7 +402,7 @@ class ByteString extends AbstractString
|
||||
return '' !== $prefix && 0 === ($this->ignoreCase ? strncasecmp($this->string, $prefix, \strlen($prefix)) : strncmp($this->string, $prefix, \strlen($prefix)));
|
||||
}
|
||||
|
||||
public function title(bool $allWords = false): parent
|
||||
public function title(bool $allWords = false): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
|
||||
@@ -465,7 +452,7 @@ class ByteString extends AbstractString
|
||||
return $u;
|
||||
}
|
||||
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C"): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = trim($str->string, $chars);
|
||||
@@ -473,7 +460,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = rtrim($str->string, $chars);
|
||||
@@ -481,7 +468,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = ltrim($str->string, $chars);
|
||||
@@ -489,7 +476,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function upper(): parent
|
||||
public function upper(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtoupper($str->string);
|
||||
|
||||
40
vendor/symfony/string/CodePointString.php
vendored
40
vendor/symfony/string/CodePointString.php
vendored
@@ -33,7 +33,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): AbstractString
|
||||
public function append(string ...$suffix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
|
||||
@@ -80,14 +80,12 @@ class CodePointString extends AbstractUnicodeString
|
||||
return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
|
||||
}
|
||||
|
||||
public function endsWith($suffix): bool
|
||||
public function endsWith(string|iterable|AbstractString $suffix): bool
|
||||
{
|
||||
if ($suffix instanceof AbstractString) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
} elseif (!\is_string($suffix)) {
|
||||
return parent::endsWith($suffix);
|
||||
} else {
|
||||
$suffix = (string) $suffix;
|
||||
}
|
||||
|
||||
if ('' === $suffix || !preg_match('//u', $suffix)) {
|
||||
@@ -101,14 +99,12 @@ class CodePointString extends AbstractUnicodeString
|
||||
return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix));
|
||||
}
|
||||
|
||||
public function equalsTo($string): bool
|
||||
public function equalsTo(string|iterable|AbstractString $string): bool
|
||||
{
|
||||
if ($string instanceof AbstractString) {
|
||||
$string = $string->string;
|
||||
} elseif (\is_array($string) || $string instanceof \Traversable) {
|
||||
} elseif (!\is_string($string)) {
|
||||
return parent::equalsTo($string);
|
||||
} else {
|
||||
$string = (string) $string;
|
||||
}
|
||||
|
||||
if ('' !== $string && $this->ignoreCase) {
|
||||
@@ -118,14 +114,12 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -137,14 +131,12 @@ class CodePointString extends AbstractUnicodeString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -161,7 +153,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return mb_strlen($this->string, 'UTF-8');
|
||||
}
|
||||
|
||||
public function prepend(string ...$prefix): AbstractString
|
||||
public function prepend(string ...$prefix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
|
||||
@@ -173,7 +165,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replace(string $from, string $to): AbstractString
|
||||
public function replace(string $from, string $to): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -194,7 +186,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function slice(int $start = 0, int $length = null): AbstractString
|
||||
public function slice(int $start = 0, int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = mb_substr($this->string, $start, $length, 'UTF-8');
|
||||
@@ -202,7 +194,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): static
|
||||
{
|
||||
if (!preg_match('//u', $replacement)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -247,14 +239,12 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function startsWith($prefix): bool
|
||||
public function startsWith(string|iterable|AbstractString $prefix): bool
|
||||
{
|
||||
if ($prefix instanceof AbstractString) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
} elseif (!\is_string($prefix)) {
|
||||
return parent::startsWith($prefix);
|
||||
} else {
|
||||
$prefix = (string) $prefix;
|
||||
}
|
||||
|
||||
if ('' === $prefix || !preg_match('//u', $prefix)) {
|
||||
|
||||
39
vendor/symfony/string/LazyString.php
vendored
39
vendor/symfony/string/LazyString.php
vendored
@@ -18,17 +18,15 @@ namespace Symfony\Component\String;
|
||||
*/
|
||||
class LazyString implements \Stringable, \JsonSerializable
|
||||
{
|
||||
private $value;
|
||||
private \Closure|string $value;
|
||||
|
||||
/**
|
||||
* @param callable|array $callback A callable or a [Closure, method] lazy-callable
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromCallable($callback, ...$arguments): self
|
||||
public static function fromCallable(callable|array $callback, mixed ...$arguments): static
|
||||
{
|
||||
if (!\is_callable($callback) && !(\is_array($callback) && isset($callback[0]) && $callback[0] 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__, get_debug_type($callback)));
|
||||
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)).']'));
|
||||
}
|
||||
|
||||
$lazyString = new static();
|
||||
@@ -49,17 +47,8 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
return $lazyString;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|int|float|bool|\Stringable $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromStringable($value): self
|
||||
public static function fromStringable(string|int|float|bool|\Stringable $value): static
|
||||
{
|
||||
if (!self::isStringable($value)) {
|
||||
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a scalar or a stringable object, "%s" given.', __METHOD__, get_debug_type($value)));
|
||||
}
|
||||
|
||||
if (\is_object($value)) {
|
||||
return static::fromCallable([$value, '__toString']);
|
||||
}
|
||||
@@ -73,27 +62,22 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* Tells whether the provided value can be cast to string.
|
||||
*/
|
||||
final public static function isStringable($value): bool
|
||||
final public static function isStringable(mixed $value): bool
|
||||
{
|
||||
return \is_string($value) || $value instanceof self || (\is_object($value) ? method_exists($value, '__toString') : \is_scalar($value));
|
||||
return \is_string($value) || $value instanceof \Stringable || \is_scalar($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts scalars and stringable objects to strings.
|
||||
*
|
||||
* @param object|string|int|float|bool $value
|
||||
*
|
||||
* @throws \TypeError When the provided value is not stringable
|
||||
*/
|
||||
final public static function resolve($value): string
|
||||
final public static function resolve(\Stringable|string|int|float|bool $value): string
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
if (\is_string($this->value)) {
|
||||
return $this->value;
|
||||
@@ -111,11 +95,6 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
$e = new \TypeError(sprintf('Return value of %s() passed to %s::fromCallable() must be of the type string, %s returned.', $callback, static::class, $type));
|
||||
}
|
||||
|
||||
if (\PHP_VERSION_ID < 70400) {
|
||||
// leverage the ErrorHandler component with graceful fallback when it's not available
|
||||
return trigger_error($e, \E_USER_ERROR);
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/*
|
||||
* This file has been auto-generated by the Symfony String Component for internal use.
|
||||
*
|
||||
* Unicode version: 14.0.0
|
||||
* Date: 2021-09-17T09:20:30+02:00
|
||||
* Unicode version: 15.0.0
|
||||
* Date: 2022-10-05T17:16:36+02:00
|
||||
*/
|
||||
|
||||
return [
|
||||
@@ -856,10 +856,18 @@ return [
|
||||
110848,
|
||||
110882,
|
||||
],
|
||||
[
|
||||
110898,
|
||||
110898,
|
||||
],
|
||||
[
|
||||
110928,
|
||||
110930,
|
||||
],
|
||||
[
|
||||
110933,
|
||||
110933,
|
||||
],
|
||||
[
|
||||
110948,
|
||||
110951,
|
||||
@@ -1005,7 +1013,7 @@ return [
|
||||
128727,
|
||||
],
|
||||
[
|
||||
128733,
|
||||
128732,
|
||||
128735,
|
||||
],
|
||||
[
|
||||
@@ -1038,39 +1046,31 @@ return [
|
||||
],
|
||||
[
|
||||
129648,
|
||||
129652,
|
||||
],
|
||||
[
|
||||
129656,
|
||||
129660,
|
||||
],
|
||||
[
|
||||
129664,
|
||||
129670,
|
||||
129672,
|
||||
],
|
||||
[
|
||||
129680,
|
||||
129708,
|
||||
129725,
|
||||
],
|
||||
[
|
||||
129712,
|
||||
129722,
|
||||
],
|
||||
[
|
||||
129728,
|
||||
129727,
|
||||
129733,
|
||||
],
|
||||
[
|
||||
129744,
|
||||
129753,
|
||||
129742,
|
||||
129755,
|
||||
],
|
||||
[
|
||||
129760,
|
||||
129767,
|
||||
129768,
|
||||
],
|
||||
[
|
||||
129776,
|
||||
129782,
|
||||
129784,
|
||||
],
|
||||
[
|
||||
131072,
|
||||
@@ -1082,10 +1082,10 @@ return [
|
||||
],
|
||||
[
|
||||
173824,
|
||||
177976,
|
||||
177977,
|
||||
],
|
||||
[
|
||||
177977,
|
||||
177978,
|
||||
177983,
|
||||
],
|
||||
[
|
||||
@@ -1130,6 +1130,14 @@ return [
|
||||
],
|
||||
[
|
||||
201547,
|
||||
201551,
|
||||
],
|
||||
[
|
||||
201552,
|
||||
205743,
|
||||
],
|
||||
[
|
||||
205744,
|
||||
262141,
|
||||
],
|
||||
];
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
/*
|
||||
* This file has been auto-generated by the Symfony String Component for internal use.
|
||||
*
|
||||
* Unicode version: 14.0.0
|
||||
* Date: 2021-09-17T09:20:30+02:00
|
||||
* Unicode version: 15.0.0
|
||||
* Date: 2022-10-05T17:16:37+02:00
|
||||
*/
|
||||
|
||||
return [
|
||||
@@ -382,7 +382,7 @@ return [
|
||||
],
|
||||
[
|
||||
3784,
|
||||
3789,
|
||||
3790,
|
||||
],
|
||||
[
|
||||
3864,
|
||||
@@ -920,6 +920,10 @@ return [
|
||||
69291,
|
||||
69292,
|
||||
],
|
||||
[
|
||||
69373,
|
||||
69375,
|
||||
],
|
||||
[
|
||||
69446,
|
||||
69456,
|
||||
@@ -1008,6 +1012,10 @@ return [
|
||||
70206,
|
||||
70206,
|
||||
],
|
||||
[
|
||||
70209,
|
||||
70209,
|
||||
],
|
||||
[
|
||||
70367,
|
||||
70367,
|
||||
@@ -1252,6 +1260,30 @@ return [
|
||||
73459,
|
||||
73460,
|
||||
],
|
||||
[
|
||||
73472,
|
||||
73473,
|
||||
],
|
||||
[
|
||||
73526,
|
||||
73530,
|
||||
],
|
||||
[
|
||||
73536,
|
||||
73536,
|
||||
],
|
||||
[
|
||||
73538,
|
||||
73538,
|
||||
],
|
||||
[
|
||||
78912,
|
||||
78912,
|
||||
],
|
||||
[
|
||||
78919,
|
||||
78933,
|
||||
],
|
||||
[
|
||||
92912,
|
||||
92916,
|
||||
@@ -1348,6 +1380,10 @@ return [
|
||||
122918,
|
||||
122922,
|
||||
],
|
||||
[
|
||||
123023,
|
||||
123023,
|
||||
],
|
||||
[
|
||||
123184,
|
||||
123190,
|
||||
@@ -1360,6 +1396,10 @@ return [
|
||||
123628,
|
||||
123631,
|
||||
],
|
||||
[
|
||||
124140,
|
||||
124143,
|
||||
],
|
||||
[
|
||||
125136,
|
||||
125142,
|
||||
|
||||
19
vendor/symfony/string/Slugger/AsciiSlugger.php
vendored
19
vendor/symfony/string/Slugger/AsciiSlugger.php
vendored
@@ -54,8 +54,8 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
'zh' => 'Han-Latin',
|
||||
];
|
||||
|
||||
private $defaultLocale;
|
||||
private $symbolsMap = [
|
||||
private ?string $defaultLocale;
|
||||
private \Closure|array $symbolsMap = [
|
||||
'en' => ['@' => 'at', '&' => 'and'],
|
||||
];
|
||||
|
||||
@@ -64,17 +64,10 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
*
|
||||
* @var \Transliterator[]
|
||||
*/
|
||||
private $transliterators = [];
|
||||
private array $transliterators = [];
|
||||
|
||||
/**
|
||||
* @param array|\Closure|null $symbolsMap
|
||||
*/
|
||||
public function __construct(string $defaultLocale = null, $symbolsMap = null)
|
||||
public function __construct(string $defaultLocale = null, array|\Closure $symbolsMap = null)
|
||||
{
|
||||
if (null !== $symbolsMap && !\is_array($symbolsMap) && !$symbolsMap instanceof \Closure) {
|
||||
throw new \TypeError(sprintf('Argument 2 passed to "%s()" must be array, Closure or null, "%s" given.', __METHOD__, \gettype($symbolsMap)));
|
||||
}
|
||||
|
||||
$this->defaultLocale = $defaultLocale;
|
||||
$this->symbolsMap = $symbolsMap ?? $this->symbolsMap;
|
||||
}
|
||||
@@ -82,7 +75,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
public function setLocale(string $locale)
|
||||
{
|
||||
$this->defaultLocale = $locale;
|
||||
}
|
||||
@@ -90,7 +83,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLocale()
|
||||
public function getLocale(): string
|
||||
{
|
||||
return $this->defaultLocale;
|
||||
}
|
||||
|
||||
55
vendor/symfony/string/UnicodeString.php
vendored
55
vendor/symfony/string/UnicodeString.php
vendored
@@ -41,7 +41,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
}
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): AbstractString
|
||||
public function append(string ...$suffix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix));
|
||||
@@ -82,14 +82,12 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function endsWith($suffix): bool
|
||||
public function endsWith(string|iterable|AbstractString $suffix): bool
|
||||
{
|
||||
if ($suffix instanceof AbstractString) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
} elseif (!\is_string($suffix)) {
|
||||
return parent::endsWith($suffix);
|
||||
} else {
|
||||
$suffix = (string) $suffix;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -106,14 +104,12 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
|
||||
}
|
||||
|
||||
public function equalsTo($string): bool
|
||||
public function equalsTo(string|iterable|AbstractString $string): bool
|
||||
{
|
||||
if ($string instanceof AbstractString) {
|
||||
$string = $string->string;
|
||||
} elseif (\is_array($string) || $string instanceof \Traversable) {
|
||||
} elseif (!\is_string($string)) {
|
||||
return parent::equalsTo($string);
|
||||
} else {
|
||||
$string = (string) $string;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -126,14 +122,12 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -152,14 +146,12 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
} elseif (!\is_string($needle)) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -184,7 +176,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function join(array $strings, string $lastGlue = null): AbstractString
|
||||
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);
|
||||
@@ -197,10 +189,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return grapheme_strlen($this->string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function normalize(int $form = self::NFC): parent
|
||||
public function normalize(int $form = self::NFC): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -216,7 +205,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function prepend(string ...$prefix): AbstractString
|
||||
public function prepend(string ...$prefix): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
|
||||
@@ -229,7 +218,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replace(string $from, string $to): AbstractString
|
||||
public function replace(string $from, string $to): static
|
||||
{
|
||||
$str = clone $this;
|
||||
normalizer_is_normalized($from) ?: $from = normalizer_normalize($from);
|
||||
@@ -256,7 +245,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replaceMatches(string $fromRegexp, $to): AbstractString
|
||||
public function replaceMatches(string $fromRegexp, string|callable $to): static
|
||||
{
|
||||
$str = parent::replaceMatches($fromRegexp, $to);
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
@@ -264,25 +253,19 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function slice(int $start = 0, int $length = null): AbstractString
|
||||
public function slice(int $start = 0, int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
|
||||
$start = 0;
|
||||
}
|
||||
$str->string = (string) grapheme_substr($this->string, $start, $length ?? 2147483647);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): static
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
if (\PHP_VERSION_ID < 80000 && 0 > $start && grapheme_strlen($this->string) < -$start) {
|
||||
$start = 0;
|
||||
}
|
||||
$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);
|
||||
@@ -333,14 +316,12 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function startsWith($prefix): bool
|
||||
public function startsWith(string|iterable|AbstractString $prefix): bool
|
||||
{
|
||||
if ($prefix instanceof AbstractString) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
} elseif (!\is_string($prefix)) {
|
||||
return parent::startsWith($prefix);
|
||||
} else {
|
||||
$prefix = (string) $prefix;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
|
||||
15
vendor/symfony/string/composer.json
vendored
15
vendor/symfony/string/composer.json
vendored
@@ -16,21 +16,20 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"php": ">=8.0.2",
|
||||
"symfony/polyfill-ctype": "~1.8",
|
||||
"symfony/polyfill-intl-grapheme": "~1.0",
|
||||
"symfony/polyfill-intl-normalizer": "~1.0",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/polyfill-php80": "~1.15"
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/error-handler": "^4.4|^5.0|^6.0",
|
||||
"symfony/http-client": "^4.4|^5.0|^6.0",
|
||||
"symfony/translation-contracts": "^1.1|^2",
|
||||
"symfony/var-exporter": "^4.4|^5.0|^6.0"
|
||||
"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"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/translation-contracts": ">=3.0"
|
||||
"symfony/translation-contracts": "<2.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\String\\": "" },
|
||||
|
||||
Reference in New Issue
Block a user