mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-11 17:33:56 +09:00
Updates to vendors etc
This commit is contained in:
100
vendor/symfony/string/AbstractUnicodeString.php
vendored
100
vendor/symfony/string/AbstractUnicodeString.php
vendored
@@ -124,7 +124,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
}
|
||||
|
||||
if (null === $transliterator) {
|
||||
throw new InvalidArgumentException(sprintf('Unknown transliteration rule "%s".', $rule));
|
||||
throw new InvalidArgumentException(\sprintf('Unknown transliteration rule "%s".', $rule));
|
||||
}
|
||||
|
||||
self::$transliterators['any-latin/bgn'] = $transliterator;
|
||||
@@ -135,15 +135,21 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
} elseif (!\function_exists('iconv')) {
|
||||
$s = preg_replace('/[^\x00-\x7F]/u', '?', $s);
|
||||
} else {
|
||||
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
|
||||
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
|
||||
$previousLocale = setlocale(\LC_CTYPE, 0);
|
||||
try {
|
||||
setlocale(\LC_CTYPE, 'C');
|
||||
$s = @preg_replace_callback('/[^\x00-\x7F]/u', static function ($c) {
|
||||
$c = (string) iconv('UTF-8', 'ASCII//TRANSLIT', $c[0]);
|
||||
|
||||
if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
|
||||
throw new \LogicException(sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
|
||||
}
|
||||
if ('' === $c && '' === iconv('UTF-8', 'ASCII//TRANSLIT', '²')) {
|
||||
throw new \LogicException(\sprintf('"%s" requires a translit-able iconv implementation, try installing "gnu-libiconv" if you\'re using Alpine Linux.', static::class));
|
||||
}
|
||||
|
||||
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
|
||||
}, $s);
|
||||
return 1 < \strlen($c) ? ltrim($c, '\'`"^~') : ('' !== $c ? $c : '?');
|
||||
}, $s);
|
||||
} finally {
|
||||
setlocale(\LC_CTYPE, $previousLocale);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,7 +161,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
public function camel(): static
|
||||
{
|
||||
$str = clone $this;
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?![A-Z]{2,})/u', static function ($m) {
|
||||
$str->string = str_replace(' ', '', preg_replace_callback('/\b.(?!\p{Lu})/u', static function ($m) {
|
||||
static $i = 0;
|
||||
|
||||
return 1 === ++$i ? ('İ' === $m[0] ? 'i̇' : mb_strtolower($m[0], 'UTF-8')) : mb_convert_case($m[0], \MB_CASE_TITLE, 'UTF-8');
|
||||
@@ -190,7 +196,7 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
|
||||
if (!$compat || !\defined('Normalizer::NFKC_CF')) {
|
||||
$str->string = normalizer_normalize($str->string, $compat ? \Normalizer::NFKC : \Normalizer::NFC);
|
||||
$str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $this->string), 'UTF-8');
|
||||
$str->string = mb_strtolower(str_replace(self::FOLD_FROM, self::FOLD_TO, $str->string), 'UTF-8');
|
||||
} else {
|
||||
$str->string = normalizer_normalize($str->string, \Normalizer::NFKC_CF);
|
||||
}
|
||||
@@ -220,6 +226,21 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale In the format language_region (e.g. tr_TR)
|
||||
*/
|
||||
public function localeLower(string $locale): static
|
||||
{
|
||||
if (null !== $transliterator = $this->getLocaleTransliterator($locale, 'Lower')) {
|
||||
$str = clone $this;
|
||||
$str->string = $transliterator->transliterate($str->string);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
return $this->lower();
|
||||
}
|
||||
|
||||
public function match(string $regexp, int $flags = 0, int $offset = 0): array
|
||||
{
|
||||
$match = ((\PREG_PATTERN_ORDER | \PREG_SET_ORDER) & $flags) ? 'preg_match_all' : 'preg_match';
|
||||
@@ -363,6 +384,21 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale In the format language_region (e.g. tr_TR)
|
||||
*/
|
||||
public function localeTitle(string $locale): static
|
||||
{
|
||||
if (null !== $transliterator = $this->getLocaleTransliterator($locale, 'Title')) {
|
||||
$str = clone $this;
|
||||
$str->string = $transliterator->transliterate($str->string);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
return $this->title();
|
||||
}
|
||||
|
||||
public function trim(string $chars = " \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}"): static
|
||||
{
|
||||
if (" \t\n\r\0\x0B\x0C\u{A0}\u{FEFF}" !== $chars && !preg_match('//u', $chars)) {
|
||||
@@ -450,6 +486,21 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $locale In the format language_region (e.g. tr_TR)
|
||||
*/
|
||||
public function localeUpper(string $locale): static
|
||||
{
|
||||
if (null !== $transliterator = $this->getLocaleTransliterator($locale, 'Upper')) {
|
||||
$str = clone $this;
|
||||
$str->string = $transliterator->transliterate($str->string);
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
return $this->upper();
|
||||
}
|
||||
|
||||
public function width(bool $ignoreAnsiDecoration = true): int
|
||||
{
|
||||
$width = 0;
|
||||
@@ -587,4 +638,33 @@ abstract class AbstractUnicodeString extends AbstractString
|
||||
|
||||
return $width;
|
||||
}
|
||||
|
||||
private function getLocaleTransliterator(string $locale, string $id): ?\Transliterator
|
||||
{
|
||||
$rule = $locale.'-'.$id;
|
||||
if (\array_key_exists($rule, self::$transliterators)) {
|
||||
return self::$transliterators[$rule];
|
||||
}
|
||||
|
||||
if (null !== $transliterator = self::$transliterators[$rule] = \Transliterator::create($rule)) {
|
||||
return $transliterator;
|
||||
}
|
||||
|
||||
// Try to find a parent locale (nl_BE -> nl)
|
||||
if (false === $i = strpos($locale, '_')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$parentRule = substr_replace($locale, '-'.$id, $i);
|
||||
|
||||
// Parent locale was already cached, return and store as current locale
|
||||
if (\array_key_exists($parentRule, self::$transliterators)) {
|
||||
return self::$transliterators[$rule] = self::$transliterators[$parentRule];
|
||||
}
|
||||
|
||||
// Create transliterator based on parent locale and cache the result on both initial and parent locale values
|
||||
$transliterator = \Transliterator::create($parentRule);
|
||||
|
||||
return self::$transliterators[$rule] = self::$transliterators[$parentRule] = $transliterator;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user