package and depencies
This commit is contained in:
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): 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;
|
||||
@@ -145,21 +139,19 @@ class UnicodeString extends AbstractUnicodeString
|
||||
|
||||
try {
|
||||
$i = $this->ignoreCase ? grapheme_stripos($this->string, $needle, $offset) : grapheme_strpos($this->string, $needle, $offset);
|
||||
} catch (\ValueError $e) {
|
||||
} catch (\ValueError) {
|
||||
return null;
|
||||
}
|
||||
|
||||
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);
|
||||
@@ -297,7 +280,7 @@ class UnicodeString extends AbstractUnicodeString
|
||||
|
||||
public function split(string $delimiter, int $limit = null, int $flags = null): array
|
||||
{
|
||||
if (1 > $limit = $limit ?? 2147483647) {
|
||||
if (1 > $limit ??= 2147483647) {
|
||||
throw new InvalidArgumentException('Split limit must be a positive integer.');
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
Reference in New Issue
Block a user