mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-09 00:13:58 +09:00
reinstall dependencies on php 7.4
This commit is contained in:
215
vendor/symfony/string/AbstractString.php
vendored
215
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 ??= array_keys($values);
|
||||
$keys = $keys ?? array_keys($values);
|
||||
$keys[$i] = $j;
|
||||
}
|
||||
|
||||
@@ -92,17 +92,15 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function after(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
public function after($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = \PHP_INT_MAX;
|
||||
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
foreach ((array) $needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOf($n, $offset);
|
||||
|
||||
@@ -125,17 +123,15 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function afterLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
public function afterLast($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = null;
|
||||
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
foreach ((array) $needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOfLast($n, $offset);
|
||||
|
||||
@@ -156,21 +152,22 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $this->slice($i);
|
||||
}
|
||||
|
||||
abstract public function append(string ...$suffix): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function append(string ...$suffix): self;
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function before(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
public function before($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = \PHP_INT_MAX;
|
||||
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
foreach ((array) $needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOf($n, $offset);
|
||||
|
||||
@@ -193,17 +190,15 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function beforeLast(string|iterable $needle, bool $includeNeedle = false, int $offset = 0): static
|
||||
public function beforeLast($needle, bool $includeNeedle = false, int $offset = 0): self
|
||||
{
|
||||
$str = clone $this;
|
||||
$i = null;
|
||||
|
||||
if (\is_string($needle)) {
|
||||
$needle = [$needle];
|
||||
}
|
||||
|
||||
foreach ($needle as $n) {
|
||||
foreach ((array) $needle as $n) {
|
||||
$n = (string) $n;
|
||||
$j = $this->indexOfLast($n, $offset);
|
||||
|
||||
@@ -234,14 +229,20 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return '' === $str->string ? [] : array_values(unpack('C*', $str->string));
|
||||
}
|
||||
|
||||
abstract public function camel(): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function camel(): self;
|
||||
|
||||
/**
|
||||
* @return static[]
|
||||
*/
|
||||
abstract public function chunk(int $length = 1): array;
|
||||
|
||||
public function collapseWhitespace(): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function collapseWhitespace(): self
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = trim(preg_replace("/(?:[ \n\r\t\x0C]{2,}+|[\n\r\t\x0C])/", ' ', $str->string), " \n\r\t\x0C");
|
||||
@@ -252,7 +253,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*/
|
||||
public function containsAny(string|iterable $needle): bool
|
||||
public function containsAny($needle): bool
|
||||
{
|
||||
return null !== $this->indexOf($needle);
|
||||
}
|
||||
@@ -260,9 +261,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $suffix
|
||||
*/
|
||||
public function endsWith(string|iterable $suffix): bool
|
||||
public function endsWith($suffix): bool
|
||||
{
|
||||
if (\is_string($suffix)) {
|
||||
if (!\is_array($suffix) && !$suffix instanceof \Traversable) {
|
||||
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
|
||||
}
|
||||
|
||||
@@ -275,7 +276,10 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return false;
|
||||
}
|
||||
|
||||
public function ensureEnd(string $suffix): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function ensureEnd(string $suffix): self
|
||||
{
|
||||
if (!$this->endsWith($suffix)) {
|
||||
return $this->append($suffix);
|
||||
@@ -287,7 +291,10 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $this->replaceMatches($regex.($this->ignoreCase ? 'i' : ''), '$1');
|
||||
}
|
||||
|
||||
public function ensureStart(string $prefix): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function ensureStart(string $prefix): self
|
||||
{
|
||||
$prefix = new static($prefix);
|
||||
|
||||
@@ -309,9 +316,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $string
|
||||
*/
|
||||
public function equalsTo(string|iterable $string): bool
|
||||
public function equalsTo($string): bool
|
||||
{
|
||||
if (\is_string($string)) {
|
||||
if (!\is_array($string) && !$string instanceof \Traversable) {
|
||||
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
|
||||
}
|
||||
|
||||
@@ -324,9 +331,15 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract public function folded(): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function folded(): self;
|
||||
|
||||
public function ignoreCase(): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function ignoreCase(): self
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->ignoreCase = true;
|
||||
@@ -337,9 +350,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*/
|
||||
public function indexOf(string|iterable $needle, int $offset = 0): ?int
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
{
|
||||
if (\is_string($needle)) {
|
||||
if (!\is_array($needle) && !$needle instanceof \Traversable) {
|
||||
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
|
||||
}
|
||||
|
||||
@@ -359,9 +372,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $needle
|
||||
*/
|
||||
public function indexOfLast(string|iterable $needle, int $offset = 0): ?int
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
{
|
||||
if (\is_string($needle)) {
|
||||
if (!\is_array($needle) && !$needle instanceof \Traversable) {
|
||||
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
|
||||
}
|
||||
|
||||
@@ -383,7 +396,10 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return '' === $this->string;
|
||||
}
|
||||
|
||||
abstract public function join(array $strings, string $lastGlue = null): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function join(array $strings, string $lastGlue = null): self;
|
||||
|
||||
public function jsonSerialize(): string
|
||||
{
|
||||
@@ -392,7 +408,10 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
|
||||
abstract public function length(): int;
|
||||
|
||||
abstract public function lower(): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function lower(): self;
|
||||
|
||||
/**
|
||||
* Matches the string using a regular expression.
|
||||
@@ -403,15 +422,30 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
*/
|
||||
abstract public function match(string $regexp, int $flags = 0, int $offset = 0): array;
|
||||
|
||||
abstract public function padBoth(int $length, string $padStr = ' '): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function padBoth(int $length, string $padStr = ' '): self;
|
||||
|
||||
abstract public function padEnd(int $length, string $padStr = ' '): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function padEnd(int $length, string $padStr = ' '): self;
|
||||
|
||||
abstract public function padStart(int $length, string $padStr = ' '): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function padStart(int $length, string $padStr = ' '): self;
|
||||
|
||||
abstract public function prepend(string ...$prefix): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function prepend(string ...$prefix): self;
|
||||
|
||||
public function repeat(int $multiplier): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function repeat(int $multiplier): self
|
||||
{
|
||||
if (0 > $multiplier) {
|
||||
throw new InvalidArgumentException(sprintf('Multiplier must be positive, %d given.', $multiplier));
|
||||
@@ -423,17 +457,37 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $str;
|
||||
}
|
||||
|
||||
abstract public function replace(string $from, string $to): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function replace(string $from, string $to): self;
|
||||
|
||||
abstract public function replaceMatches(string $fromRegexp, string|callable $to): static;
|
||||
/**
|
||||
* @param string|callable $to
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
abstract public function replaceMatches(string $fromRegexp, $to): self;
|
||||
|
||||
abstract public function reverse(): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function reverse(): self;
|
||||
|
||||
abstract public function slice(int $start = 0, int $length = null): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function slice(int $start = 0, int $length = null): self;
|
||||
|
||||
abstract public function snake(): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function snake(): self;
|
||||
|
||||
abstract public function splice(string $replacement, int $start = 0, int $length = null): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function splice(string $replacement, int $start = 0, int $length = null): self;
|
||||
|
||||
/**
|
||||
* @return static[]
|
||||
@@ -455,7 +509,7 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Splitting failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -486,9 +540,9 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* @param string|string[] $prefix
|
||||
*/
|
||||
public function startsWith(string|iterable $prefix): bool
|
||||
public function startsWith($prefix): bool
|
||||
{
|
||||
if (\is_string($prefix)) {
|
||||
if (!\is_array($prefix) && !$prefix instanceof \Traversable) {
|
||||
throw new \TypeError(sprintf('Method "%s()" must be overridden by class "%s" to deal with non-iterable values.', __FUNCTION__, static::class));
|
||||
}
|
||||
|
||||
@@ -501,7 +555,10 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return false;
|
||||
}
|
||||
|
||||
abstract public function title(bool $allWords = false): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function title(bool $allWords = false): self;
|
||||
|
||||
public function toByteString(string $toEncoding = null): ByteString
|
||||
{
|
||||
@@ -549,16 +606,24 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return new UnicodeString($this->string);
|
||||
}
|
||||
|
||||
abstract public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function trim(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;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
|
||||
|
||||
/**
|
||||
* @param string|string[] $prefix
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function trimPrefix($prefix): static
|
||||
public function trimPrefix($prefix): self
|
||||
{
|
||||
if (\is_array($prefix) || $prefix instanceof \Traversable) { // don't use is_iterable(), it's slow
|
||||
if (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
foreach ($prefix as $s) {
|
||||
$t = $this->trimPrefix($s);
|
||||
|
||||
@@ -585,14 +650,19 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $str;
|
||||
}
|
||||
|
||||
abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): self;
|
||||
|
||||
/**
|
||||
* @param string|string[] $suffix
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function trimSuffix($suffix): static
|
||||
public function trimSuffix($suffix): self
|
||||
{
|
||||
if (\is_array($suffix) || $suffix instanceof \Traversable) { // don't use is_iterable(), it's slow
|
||||
if (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
foreach ($suffix as $s) {
|
||||
$t = $this->trimSuffix($s);
|
||||
|
||||
@@ -619,7 +689,10 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function truncate(int $length, string $ellipsis = '', bool $cut = true): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function truncate(int $length, string $ellipsis = '', bool $cut = true): self
|
||||
{
|
||||
$stringLength = $this->length();
|
||||
|
||||
@@ -646,14 +719,20 @@ abstract class AbstractString implements \Stringable, \JsonSerializable
|
||||
return $ellipsisLength ? $str->trimEnd()->append($ellipsis) : $str;
|
||||
}
|
||||
|
||||
abstract public function upper(): static;
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
abstract public function upper(): self;
|
||||
|
||||
/**
|
||||
* Returns the printable length on a terminal.
|
||||
*/
|
||||
abstract public function width(bool $ignoreAnsiDecoration = true): int;
|
||||
|
||||
public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function wordwrap(int $width = 75, string $break = "\n", bool $cut = false): self
|
||||
{
|
||||
$lines = '' !== $break ? $this->split($break) : [clone $this];
|
||||
$chars = [];
|
||||
|
||||
65
vendor/symfony/string/AbstractUnicodeString.php
vendored
65
vendor/symfony/string/AbstractUnicodeString.php
vendored
@@ -52,7 +52,10 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
private static $tableZero;
|
||||
private static $tableWide;
|
||||
|
||||
public static function fromCodePoints(int ...$codes): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public static function fromCodePoints(int ...$codes): self
|
||||
{
|
||||
$string = '';
|
||||
|
||||
@@ -156,7 +159,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function camel(): static
|
||||
public function camel(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) use (&$i) {
|
||||
@@ -186,11 +189,11 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $codePoints;
|
||||
}
|
||||
|
||||
public function folded(bool $compat = true): static
|
||||
public function folded(bool $compat = true): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
if (!$compat || !\defined('Normalizer::NFKC_CF')) {
|
||||
if (!$compat || \PHP_VERSION_ID < 70300 || !\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 {
|
||||
@@ -200,7 +203,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): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -214,7 +217,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function lower(): static
|
||||
public function lower(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = mb_strtolower(str_replace('İ', 'i̇', $str->string), 'UTF-8');
|
||||
@@ -237,7 +240,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -251,7 +254,10 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $matches;
|
||||
}
|
||||
|
||||
public function normalize(int $form = self::NFC): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function normalize(int $form = self::NFC): self
|
||||
{
|
||||
if (!\in_array($form, [self::NFC, self::NFD, self::NFKC, self::NFKD])) {
|
||||
throw new InvalidArgumentException('Unsupported normalization form.');
|
||||
@@ -263,7 +269,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function padBoth(int $length, string $padStr = ' '): static
|
||||
public function padBoth(int $length, string $padStr = ' '): parent
|
||||
{
|
||||
if ('' === $padStr || !preg_match('//u', $padStr)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -275,7 +281,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $this->pad($length, $pad, \STR_PAD_BOTH);
|
||||
}
|
||||
|
||||
public function padEnd(int $length, string $padStr = ' '): static
|
||||
public function padEnd(int $length, string $padStr = ' '): parent
|
||||
{
|
||||
if ('' === $padStr || !preg_match('//u', $padStr)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -287,7 +293,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $this->pad($length, $pad, \STR_PAD_RIGHT);
|
||||
}
|
||||
|
||||
public function padStart(int $length, string $padStr = ' '): static
|
||||
public function padStart(int $length, string $padStr = ' '): parent
|
||||
{
|
||||
if ('' === $padStr || !preg_match('//u', $padStr)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -299,13 +305,17 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $this->pad($length, $pad, \STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
public function replaceMatches(string $fromRegexp, string|callable $to): static
|
||||
public function replaceMatches(string $fromRegexp, $to): parent
|
||||
{
|
||||
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);
|
||||
@@ -329,7 +339,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -346,7 +356,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function reverse(): static
|
||||
public function reverse(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = implode('', array_reverse(preg_split('/(\X)/u', $str->string, -1, \PREG_SPLIT_DELIM_CAPTURE | \PREG_SPLIT_NO_EMPTY)));
|
||||
@@ -354,7 +364,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function snake(): static
|
||||
public function snake(): parent
|
||||
{
|
||||
$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');
|
||||
@@ -362,7 +372,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function title(bool $allWords = false): static
|
||||
public function title(bool $allWords = false): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -375,7 +385,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
|
||||
{
|
||||
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 chars.');
|
||||
@@ -388,7 +398,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
|
||||
{
|
||||
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 chars.');
|
||||
@@ -401,7 +411,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimPrefix($prefix): static
|
||||
public function trimPrefix($prefix): parent
|
||||
{
|
||||
if (!$this->ignoreCase) {
|
||||
return parent::trimPrefix($prefix);
|
||||
@@ -421,7 +431,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): parent
|
||||
{
|
||||
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 chars.');
|
||||
@@ -434,7 +444,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimSuffix($suffix): static
|
||||
public function trimSuffix($suffix): parent
|
||||
{
|
||||
if (!$this->ignoreCase) {
|
||||
return parent::trimSuffix($suffix);
|
||||
@@ -454,11 +464,15 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function upper(): static
|
||||
public function upper(): parent
|
||||
{
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -467,7 +481,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
$width = 0;
|
||||
$s = str_replace(["\x00", "\x05", "\x07"], '', $this->string);
|
||||
|
||||
if (str_contains($s, "\r")) {
|
||||
if (false !== strpos($s, "\r")) {
|
||||
$s = str_replace(["\r\n", "\r"], "\n", $s);
|
||||
}
|
||||
|
||||
@@ -494,7 +508,10 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $width;
|
||||
}
|
||||
|
||||
private function pad(int $len, self $pad, int $type): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
private function pad(int $len, self $pad, int $type): parent
|
||||
{
|
||||
$sLen = $this->length();
|
||||
|
||||
|
||||
94
vendor/symfony/string/ByteString.php
vendored
94
vendor/symfony/string/ByteString.php
vendored
@@ -48,7 +48,7 @@ class ByteString extends AbstractString
|
||||
throw new InvalidArgumentException(sprintf('A strictly positive length is expected, "%d" given.', $length));
|
||||
}
|
||||
|
||||
$alphabet ??= self::ALPHABET_ALPHANUMERIC;
|
||||
$alphabet = $alphabet ?? self::ALPHABET_ALPHANUMERIC;
|
||||
$alphabetSize = \strlen($alphabet);
|
||||
$bits = (int) ceil(log($alphabetSize, 2.0));
|
||||
if ($bits <= 0 || $bits > 56) {
|
||||
@@ -92,7 +92,7 @@ class ByteString extends AbstractString
|
||||
return '' === $str ? [] : [\ord($str)];
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): static
|
||||
public function append(string ...$suffix): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
|
||||
@@ -100,7 +100,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function camel(): static
|
||||
public function camel(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -132,23 +132,27 @@ class ByteString extends AbstractString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function endsWith(string|iterable|AbstractString $suffix): bool
|
||||
public function endsWith($suffix): bool
|
||||
{
|
||||
if ($suffix instanceof AbstractString) {
|
||||
if ($suffix instanceof parent) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (!\is_string($suffix)) {
|
||||
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
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|iterable|AbstractString $string): bool
|
||||
public function equalsTo($string): bool
|
||||
{
|
||||
if ($string instanceof AbstractString) {
|
||||
if ($string instanceof parent) {
|
||||
$string = $string->string;
|
||||
} elseif (!\is_string($string)) {
|
||||
} elseif (\is_array($string) || $string instanceof \Traversable) {
|
||||
return parent::equalsTo($string);
|
||||
} else {
|
||||
$string = (string) $string;
|
||||
}
|
||||
|
||||
if ('' !== $string && $this->ignoreCase) {
|
||||
@@ -158,7 +162,7 @@ class ByteString extends AbstractString
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
public function folded(): static
|
||||
public function folded(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtolower($str->string);
|
||||
@@ -166,12 +170,14 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
if ($needle instanceof parent) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -183,12 +189,14 @@ class ByteString extends AbstractString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
if ($needle instanceof parent) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -205,7 +213,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): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -220,7 +228,7 @@ class ByteString extends AbstractString
|
||||
return \strlen($this->string);
|
||||
}
|
||||
|
||||
public function lower(): static
|
||||
public function lower(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtolower($str->string);
|
||||
@@ -243,7 +251,7 @@ class ByteString extends AbstractString
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -257,7 +265,7 @@ class ByteString extends AbstractString
|
||||
return $matches;
|
||||
}
|
||||
|
||||
public function padBoth(int $length, string $padStr = ' '): static
|
||||
public function padBoth(int $length, string $padStr = ' '): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_BOTH);
|
||||
@@ -265,7 +273,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function padEnd(int $length, string $padStr = ' '): static
|
||||
public function padEnd(int $length, string $padStr = ' '): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_RIGHT);
|
||||
@@ -273,7 +281,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function padStart(int $length, string $padStr = ' '): static
|
||||
public function padStart(int $length, string $padStr = ' '): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_pad($this->string, $length, $padStr, \STR_PAD_LEFT);
|
||||
@@ -281,7 +289,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function prepend(string ...$prefix): static
|
||||
public function prepend(string ...$prefix): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$str->string;
|
||||
@@ -289,7 +297,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replace(string $from, string $to): static
|
||||
public function replace(string $from, string $to): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -300,13 +308,21 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replaceMatches(string $fromRegexp, string|callable $to): static
|
||||
public function replaceMatches(string $fromRegexp, $to): parent
|
||||
{
|
||||
if ($this->ignoreCase) {
|
||||
$fromRegexp .= 'i';
|
||||
}
|
||||
|
||||
$replace = \is_array($to) || $to instanceof \Closure ? 'preg_replace_callback' : 'preg_replace';
|
||||
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';
|
||||
}
|
||||
|
||||
set_error_handler(static function ($t, $m) { throw new InvalidArgumentException($m); });
|
||||
|
||||
@@ -315,7 +331,7 @@ class ByteString extends AbstractString
|
||||
$lastError = preg_last_error();
|
||||
|
||||
foreach (get_defined_constants(true)['pcre'] as $k => $v) {
|
||||
if ($lastError === $v && str_ends_with($k, '_ERROR')) {
|
||||
if ($lastError === $v && '_ERROR' === substr($k, -6)) {
|
||||
throw new RuntimeException('Matching failed with '.$k.'.');
|
||||
}
|
||||
}
|
||||
@@ -332,7 +348,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function reverse(): static
|
||||
public function reverse(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strrev($str->string);
|
||||
@@ -340,7 +356,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): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
|
||||
@@ -348,7 +364,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function snake(): static
|
||||
public function snake(): parent
|
||||
{
|
||||
$str = $this->camel();
|
||||
$str->string = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $str->string));
|
||||
@@ -356,7 +372,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): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
|
||||
@@ -366,7 +382,7 @@ class ByteString extends AbstractString
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
{
|
||||
if (1 > $limit ??= \PHP_INT_MAX) {
|
||||
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
@@ -391,9 +407,9 @@ class ByteString extends AbstractString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function startsWith(string|iterable|AbstractString $prefix): bool
|
||||
public function startsWith($prefix): bool
|
||||
{
|
||||
if ($prefix instanceof AbstractString) {
|
||||
if ($prefix instanceof parent) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (!\is_string($prefix)) {
|
||||
return parent::startsWith($prefix);
|
||||
@@ -402,7 +418,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): static
|
||||
public function title(bool $allWords = false): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = $allWords ? ucwords($str->string) : ucfirst($str->string);
|
||||
@@ -452,7 +468,7 @@ class ByteString extends AbstractString
|
||||
return $u;
|
||||
}
|
||||
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C"): static
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C"): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = trim($str->string, $chars);
|
||||
@@ -460,7 +476,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): static
|
||||
public function trimEnd(string $chars = " \t\n\r\0\x0B\x0C"): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = rtrim($str->string, $chars);
|
||||
@@ -468,7 +484,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): static
|
||||
public function trimStart(string $chars = " \t\n\r\0\x0B\x0C"): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = ltrim($str->string, $chars);
|
||||
@@ -476,7 +492,7 @@ class ByteString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function upper(): static
|
||||
public function upper(): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = strtoupper($str->string);
|
||||
|
||||
42
vendor/symfony/string/CodePointString.php
vendored
42
vendor/symfony/string/CodePointString.php
vendored
@@ -33,7 +33,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
$this->string = $string;
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): static
|
||||
public function append(string ...$suffix): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string .= 1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix);
|
||||
@@ -80,12 +80,14 @@ class CodePointString extends AbstractUnicodeString
|
||||
return '' === $str->string ? [] : [mb_ord($str->string, 'UTF-8')];
|
||||
}
|
||||
|
||||
public function endsWith(string|iterable|AbstractString $suffix): bool
|
||||
public function endsWith($suffix): bool
|
||||
{
|
||||
if ($suffix instanceof AbstractString) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (!\is_string($suffix)) {
|
||||
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
return parent::endsWith($suffix);
|
||||
} else {
|
||||
$suffix = (string) $suffix;
|
||||
}
|
||||
|
||||
if ('' === $suffix || !preg_match('//u', $suffix)) {
|
||||
@@ -99,12 +101,14 @@ class CodePointString extends AbstractUnicodeString
|
||||
return \strlen($this->string) >= \strlen($suffix) && 0 === substr_compare($this->string, $suffix, -\strlen($suffix));
|
||||
}
|
||||
|
||||
public function equalsTo(string|iterable|AbstractString $string): bool
|
||||
public function equalsTo($string): bool
|
||||
{
|
||||
if ($string instanceof AbstractString) {
|
||||
$string = $string->string;
|
||||
} elseif (!\is_string($string)) {
|
||||
} elseif (\is_array($string) || $string instanceof \Traversable) {
|
||||
return parent::equalsTo($string);
|
||||
} else {
|
||||
$string = (string) $string;
|
||||
}
|
||||
|
||||
if ('' !== $string && $this->ignoreCase) {
|
||||
@@ -114,12 +118,14 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -131,12 +137,14 @@ class CodePointString extends AbstractUnicodeString
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
if ('' === $needle) {
|
||||
@@ -153,7 +161,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return mb_strlen($this->string, 'UTF-8');
|
||||
}
|
||||
|
||||
public function prepend(string ...$prefix): static
|
||||
public function prepend(string ...$prefix): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
|
||||
@@ -165,7 +173,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replace(string $from, string $to): static
|
||||
public function replace(string $from, string $to): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -186,7 +194,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): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = mb_substr($this->string, $start, $length, 'UTF-8');
|
||||
@@ -194,7 +202,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): AbstractString
|
||||
{
|
||||
if (!preg_match('//u', $replacement)) {
|
||||
throw new InvalidArgumentException('Invalid UTF-8 string.');
|
||||
@@ -210,7 +218,7 @@ class CodePointString extends AbstractUnicodeString
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
{
|
||||
if (1 > $limit ??= \PHP_INT_MAX) {
|
||||
if (1 > $limit = $limit ?? \PHP_INT_MAX) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
@@ -239,12 +247,14 @@ class CodePointString extends AbstractUnicodeString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function startsWith(string|iterable|AbstractString $prefix): bool
|
||||
public function startsWith($prefix): bool
|
||||
{
|
||||
if ($prefix instanceof AbstractString) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (!\is_string($prefix)) {
|
||||
} elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
return parent::startsWith($prefix);
|
||||
} else {
|
||||
$prefix = (string) $prefix;
|
||||
}
|
||||
|
||||
if ('' === $prefix || !preg_match('//u', $prefix)) {
|
||||
|
||||
@@ -384,7 +384,7 @@ final class EnglishInflector implements InflectorInterface
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $pluralLength) {
|
||||
$nextIsVocal = str_contains('aeiou', $lowerPluralRev[$j]);
|
||||
$nextIsVocal = false !== strpos('aeiou', $lowerPluralRev[$j]);
|
||||
|
||||
if (!$map[2] && $nextIsVocal) {
|
||||
// suffix may not succeed a vocal but next char is one
|
||||
@@ -464,7 +464,7 @@ final class EnglishInflector implements InflectorInterface
|
||||
if ($j === $suffixLength) {
|
||||
// Is there any character preceding the suffix in the plural string?
|
||||
if ($j < $singularLength) {
|
||||
$nextIsVocal = str_contains('aeiou', $lowerSingularRev[$j]);
|
||||
$nextIsVocal = false !== strpos('aeiou', $lowerSingularRev[$j]);
|
||||
|
||||
if (!$map[2] && $nextIsVocal) {
|
||||
// suffix may not succeed a vocal but next char is one
|
||||
|
||||
41
vendor/symfony/string/LazyString.php
vendored
41
vendor/symfony/string/LazyString.php
vendored
@@ -18,15 +18,17 @@ namespace Symfony\Component\String;
|
||||
*/
|
||||
class LazyString implements \Stringable, \JsonSerializable
|
||||
{
|
||||
private \Closure|string $value;
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param callable|array $callback A callable or a [Closure, method] lazy-callable
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromCallable(callable|array $callback, mixed ...$arguments): static
|
||||
public static function fromCallable($callback, ...$arguments): self
|
||||
{
|
||||
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)).']'));
|
||||
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)));
|
||||
}
|
||||
|
||||
$lazyString = new static();
|
||||
@@ -47,8 +49,17 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
return $lazyString;
|
||||
}
|
||||
|
||||
public static function fromStringable(string|int|float|bool|\Stringable $value): static
|
||||
/**
|
||||
* @param string|int|float|bool|\Stringable $value
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function fromStringable($value): self
|
||||
{
|
||||
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']);
|
||||
}
|
||||
@@ -62,22 +73,27 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
/**
|
||||
* Tells whether the provided value can be cast to string.
|
||||
*/
|
||||
final public static function isStringable(mixed $value): bool
|
||||
final public static function isStringable($value): bool
|
||||
{
|
||||
return \is_string($value) || $value instanceof \Stringable || \is_scalar($value);
|
||||
return \is_string($value) || $value instanceof self || (\is_object($value) ? method_exists($value, '__toString') : \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(\Stringable|string|int|float|bool $value): string
|
||||
final public static function resolve($value): string
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
if (\is_string($this->value)) {
|
||||
return $this->value;
|
||||
@@ -95,6 +111,11 @@ 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;
|
||||
}
|
||||
}
|
||||
@@ -127,7 +148,7 @@ class LazyString implements \Stringable, \JsonSerializable
|
||||
} elseif ($callback instanceof \Closure) {
|
||||
$r = new \ReflectionFunction($callback);
|
||||
|
||||
if (str_contains($r->name, '{closure}') || !$class = $r->getClosureScopeClass()) {
|
||||
if (false !== strpos($r->name, '{closure}') || !$class = $r->getClosureScopeClass()) {
|
||||
return $r->name;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
23
vendor/symfony/string/Slugger/AsciiSlugger.php
vendored
23
vendor/symfony/string/Slugger/AsciiSlugger.php
vendored
@@ -54,8 +54,8 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
'zh' => 'Han-Latin',
|
||||
];
|
||||
|
||||
private ?string $defaultLocale;
|
||||
private \Closure|array $symbolsMap = [
|
||||
private $defaultLocale;
|
||||
private $symbolsMap = [
|
||||
'en' => ['@' => 'at', '&' => 'and'],
|
||||
];
|
||||
|
||||
@@ -64,10 +64,17 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
*
|
||||
* @var \Transliterator[]
|
||||
*/
|
||||
private array $transliterators = [];
|
||||
private $transliterators = [];
|
||||
|
||||
public function __construct(string $defaultLocale = null, array|\Closure $symbolsMap = null)
|
||||
/**
|
||||
* @param array|\Closure|null $symbolsMap
|
||||
*/
|
||||
public function __construct(string $defaultLocale = null, $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;
|
||||
}
|
||||
@@ -75,7 +82,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setLocale(string $locale)
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->defaultLocale = $locale;
|
||||
}
|
||||
@@ -83,7 +90,7 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getLocale(): string
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->defaultLocale;
|
||||
}
|
||||
@@ -93,10 +100,10 @@ class AsciiSlugger implements SluggerInterface, LocaleAwareInterface
|
||||
*/
|
||||
public function slug(string $string, string $separator = '-', string $locale = null): AbstractUnicodeString
|
||||
{
|
||||
$locale ??= $this->defaultLocale;
|
||||
$locale = $locale ?? $this->defaultLocale;
|
||||
|
||||
$transliterator = [];
|
||||
if ($locale && ('de' === $locale || str_starts_with($locale, 'de_'))) {
|
||||
if ($locale && ('de' === $locale || 0 === strpos($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) {
|
||||
|
||||
59
vendor/symfony/string/UnicodeString.php
vendored
59
vendor/symfony/string/UnicodeString.php
vendored
@@ -41,7 +41,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
}
|
||||
}
|
||||
|
||||
public function append(string ...$suffix): static
|
||||
public function append(string ...$suffix): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = $this->string.(1 >= \count($suffix) ? ($suffix[0] ?? '') : implode('', $suffix));
|
||||
@@ -82,12 +82,14 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function endsWith(string|iterable|AbstractString $suffix): bool
|
||||
public function endsWith($suffix): bool
|
||||
{
|
||||
if ($suffix instanceof AbstractString) {
|
||||
$suffix = $suffix->string;
|
||||
} elseif (!\is_string($suffix)) {
|
||||
} elseif (\is_array($suffix) || $suffix instanceof \Traversable) {
|
||||
return parent::endsWith($suffix);
|
||||
} else {
|
||||
$suffix = (string) $suffix;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -104,12 +106,14 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $suffix === grapheme_extract($this->string, \strlen($suffix), \GRAPHEME_EXTR_MAXBYTES, \strlen($this->string) - \strlen($suffix));
|
||||
}
|
||||
|
||||
public function equalsTo(string|iterable|AbstractString $string): bool
|
||||
public function equalsTo($string): bool
|
||||
{
|
||||
if ($string instanceof AbstractString) {
|
||||
$string = $string->string;
|
||||
} elseif (!\is_string($string)) {
|
||||
} elseif (\is_array($string) || $string instanceof \Traversable) {
|
||||
return parent::equalsTo($string);
|
||||
} else {
|
||||
$string = (string) $string;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -122,12 +126,14 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $string === $this->string;
|
||||
}
|
||||
|
||||
public function indexOf(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
public function indexOf($needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
return parent::indexOf($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -139,19 +145,21 @@ class UnicodeString extends AbstractUnicodeString
|
||||
|
||||
try {
|
||||
$i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
|
||||
} catch (\ValueError) {
|
||||
} catch (\ValueError $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return false === $i ? null : $i;
|
||||
}
|
||||
|
||||
public function indexOfLast(string|iterable|AbstractString $needle, int $offset = 0): ?int
|
||||
public function indexOfLast($needle, int $offset = 0): ?int
|
||||
{
|
||||
if ($needle instanceof AbstractString) {
|
||||
$needle = $needle->string;
|
||||
} elseif (!\is_string($needle)) {
|
||||
} elseif (\is_array($needle) || $needle instanceof \Traversable) {
|
||||
return parent::indexOfLast($needle, $offset);
|
||||
} else {
|
||||
$needle = (string) $needle;
|
||||
}
|
||||
|
||||
$form = null === $this->ignoreCase ? \Normalizer::NFD : \Normalizer::NFC;
|
||||
@@ -176,7 +184,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): AbstractString
|
||||
{
|
||||
$str = parent::join($strings, $lastGlue);
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
@@ -189,7 +197,10 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return grapheme_strlen($this->string);
|
||||
}
|
||||
|
||||
public function normalize(int $form = self::NFC): static
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function normalize(int $form = self::NFC): parent
|
||||
{
|
||||
$str = clone $this;
|
||||
|
||||
@@ -205,7 +216,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function prepend(string ...$prefix): static
|
||||
public function prepend(string ...$prefix): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = (1 >= \count($prefix) ? ($prefix[0] ?? '') : implode('', $prefix)).$this->string;
|
||||
@@ -218,7 +229,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replace(string $from, string $to): static
|
||||
public function replace(string $from, string $to): AbstractString
|
||||
{
|
||||
$str = clone $this;
|
||||
normalizer_is_normalized($from) ?: $from = normalizer_normalize($from);
|
||||
@@ -245,7 +256,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $str;
|
||||
}
|
||||
|
||||
public function replaceMatches(string $fromRegexp, string|callable $to): static
|
||||
public function replaceMatches(string $fromRegexp, $to): AbstractString
|
||||
{
|
||||
$str = parent::replaceMatches($fromRegexp, $to);
|
||||
normalizer_is_normalized($str->string) ?: $str->string = normalizer_normalize($str->string);
|
||||
@@ -253,19 +264,25 @@ 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): AbstractString
|
||||
{
|
||||
$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): static
|
||||
public function splice(string $replacement, int $start = 0, int $length = null): AbstractString
|
||||
{
|
||||
$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);
|
||||
@@ -280,7 +297,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
{
|
||||
if (1 > $limit ??= 2147483647) {
|
||||
if (1 > $limit = $limit ?? 2147483647) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
@@ -316,12 +333,14 @@ class UnicodeString extends AbstractUnicodeString
|
||||
return $chunks;
|
||||
}
|
||||
|
||||
public function startsWith(string|iterable|AbstractString $prefix): bool
|
||||
public function startsWith($prefix): bool
|
||||
{
|
||||
if ($prefix instanceof AbstractString) {
|
||||
$prefix = $prefix->string;
|
||||
} elseif (!\is_string($prefix)) {
|
||||
} elseif (\is_array($prefix) || $prefix instanceof \Traversable) {
|
||||
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,20 +16,21 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"php": ">=7.2.5",
|
||||
"symfony/polyfill-ctype": "~1.8",
|
||||
"symfony/polyfill-intl-grapheme": "~1.0",
|
||||
"symfony/polyfill-intl-normalizer": "~1.0",
|
||||
"symfony/polyfill-mbstring": "~1.0"
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/polyfill-php80": "~1.15"
|
||||
},
|
||||
"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": "^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"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/translation-contracts": "<2.0"
|
||||
"symfony/translation-contracts": ">=3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": { "Symfony\\Component\\String\\": "" },
|
||||
|
||||
Reference in New Issue
Block a user