summaryrefslogtreecommitdiff
path: root/vendor/symfony/polyfill-mbstring
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/polyfill-mbstring')
-rw-r--r--vendor/symfony/polyfill-mbstring/LICENSE2
-rw-r--r--vendor/symfony/polyfill-mbstring/Mbstring.php87
-rw-r--r--vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php119
-rw-r--r--vendor/symfony/polyfill-mbstring/bootstrap.php4
-rw-r--r--vendor/symfony/polyfill-mbstring/bootstrap80.php4
-rw-r--r--vendor/symfony/polyfill-mbstring/composer.json2
6 files changed, 209 insertions, 9 deletions
diff --git a/vendor/symfony/polyfill-mbstring/LICENSE b/vendor/symfony/polyfill-mbstring/LICENSE
index 4cd8bdd..6e3afce 100644
--- a/vendor/symfony/polyfill-mbstring/LICENSE
+++ b/vendor/symfony/polyfill-mbstring/LICENSE
@@ -1,4 +1,4 @@
-Copyright (c) 2015-2019 Fabien Potencier
+Copyright (c) 2015-present Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/vendor/symfony/polyfill-mbstring/Mbstring.php b/vendor/symfony/polyfill-mbstring/Mbstring.php
index bce5c4a..2e0b969 100644
--- a/vendor/symfony/polyfill-mbstring/Mbstring.php
+++ b/vendor/symfony/polyfill-mbstring/Mbstring.php
@@ -69,7 +69,7 @@ final class Mbstring
{
public const MB_CASE_FOLD = \PHP_INT_MAX;
- private const CASE_FOLD = [
+ private const SIMPLE_CASE_FOLD = [
['µ', 'ſ', "\xCD\x85", 'ς', "\xCF\x90", "\xCF\x91", "\xCF\x95", "\xCF\x96", "\xCF\xB0", "\xCF\xB1", "\xCF\xB5", "\xE1\xBA\x9B", "\xE1\xBE\xBE"],
['μ', 's', 'ι', 'σ', 'β', 'θ', 'φ', 'π', 'κ', 'ρ', 'ε', "\xE1\xB9\xA1", 'ι'],
];
@@ -301,7 +301,11 @@ final class Mbstring
$map = $upper;
} else {
if (self::MB_CASE_FOLD === $mode) {
- $s = str_replace(self::CASE_FOLD[0], self::CASE_FOLD[1], $s);
+ static $caseFolding = null;
+ if (null === $caseFolding) {
+ $caseFolding = self::getData('caseFolding');
+ }
+ $s = strtr($s, $caseFolding);
}
static $lower = null;
@@ -406,6 +410,12 @@ final class Mbstring
public static function mb_check_encoding($var = null, $encoding = null)
{
+ if (PHP_VERSION_ID < 70200 && \is_array($var)) {
+ trigger_error('mb_check_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
+
+ return null;
+ }
+
if (null === $encoding) {
if (null === $var) {
return false;
@@ -413,7 +423,21 @@ final class Mbstring
$encoding = self::$internalEncoding;
}
- return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var);
+ if (!\is_array($var)) {
+ return self::mb_detect_encoding($var, [$encoding]) || false !== @iconv($encoding, $encoding, $var);
+ }
+
+ foreach ($var as $key => $value) {
+ if (!self::mb_check_encoding($key, $encoding)) {
+ return false;
+ }
+ if (!self::mb_check_encoding($value, $encoding)) {
+ return false;
+ }
+ }
+
+ return true;
+
}
public static function mb_detect_encoding($str, $encodingList = null, $strict = false)
@@ -638,8 +662,10 @@ final class Mbstring
public static function mb_stripos($haystack, $needle, $offset = 0, $encoding = null)
{
- $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
- $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
+ [$haystack, $needle] = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], [
+ self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding),
+ self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding),
+ ]);
return self::mb_strpos($haystack, $needle, $offset, $encoding);
}
@@ -674,8 +700,11 @@ final class Mbstring
public static function mb_strripos($haystack, $needle, $offset = 0, $encoding = null)
{
- $haystack = self::mb_convert_case($haystack, self::MB_CASE_FOLD, $encoding);
- $needle = self::mb_convert_case($needle, self::MB_CASE_FOLD, $encoding);
+ $haystack = self::mb_convert_case($haystack, \MB_CASE_LOWER, $encoding);
+ $needle = self::mb_convert_case($needle, \MB_CASE_LOWER, $encoding);
+
+ $haystack = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $haystack);
+ $needle = str_replace(self::SIMPLE_CASE_FOLD[0], self::SIMPLE_CASE_FOLD[1], $needle);
return self::mb_strrpos($haystack, $needle, $offset, $encoding);
}
@@ -798,6 +827,50 @@ final class Mbstring
return $code;
}
+ public static function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = \STR_PAD_RIGHT, string $encoding = null): string
+ {
+ if (!\in_array($pad_type, [\STR_PAD_RIGHT, \STR_PAD_LEFT, \STR_PAD_BOTH], true)) {
+ throw new \ValueError('mb_str_pad(): Argument #4 ($pad_type) must be STR_PAD_LEFT, STR_PAD_RIGHT, or STR_PAD_BOTH');
+ }
+
+ if (null === $encoding) {
+ $encoding = self::mb_internal_encoding();
+ }
+
+ try {
+ $validEncoding = @self::mb_check_encoding('', $encoding);
+ } catch (\ValueError $e) {
+ throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
+ }
+
+ // BC for PHP 7.3 and lower
+ if (!$validEncoding) {
+ throw new \ValueError(sprintf('mb_str_pad(): Argument #5 ($encoding) must be a valid encoding, "%s" given', $encoding));
+ }
+
+ if (self::mb_strlen($pad_string, $encoding) <= 0) {
+ throw new \ValueError('mb_str_pad(): Argument #3 ($pad_string) must be a non-empty string');
+ }
+
+ $paddingRequired = $length - self::mb_strlen($string, $encoding);
+
+ if ($paddingRequired < 1) {
+ return $string;
+ }
+
+ switch ($pad_type) {
+ case \STR_PAD_LEFT:
+ return self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding).$string;
+ case \STR_PAD_RIGHT:
+ return $string.self::mb_substr(str_repeat($pad_string, $paddingRequired), 0, $paddingRequired, $encoding);
+ default:
+ $leftPaddingLength = floor($paddingRequired / 2);
+ $rightPaddingLength = $paddingRequired - $leftPaddingLength;
+
+ return self::mb_substr(str_repeat($pad_string, $leftPaddingLength), 0, $leftPaddingLength, $encoding).$string.self::mb_substr(str_repeat($pad_string, $rightPaddingLength), 0, $rightPaddingLength, $encoding);
+ }
+ }
+
private static function getSubpart($pos, $part, $haystack, $encoding)
{
if (false === $pos) {
diff --git a/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php
new file mode 100644
index 0000000..512bba0
--- /dev/null
+++ b/vendor/symfony/polyfill-mbstring/Resources/unidata/caseFolding.php
@@ -0,0 +1,119 @@
+<?php
+
+return [
+ 'İ' => 'i̇',
+ 'µ' => 'μ',
+ 'ſ' => 's',
+ 'ͅ' => 'ι',
+ 'ς' => 'σ',
+ 'ϐ' => 'β',
+ 'ϑ' => 'θ',
+ 'ϕ' => 'φ',
+ 'ϖ' => 'π',
+ 'ϰ' => 'κ',
+ 'ϱ' => 'ρ',
+ 'ϵ' => 'ε',
+ 'ẛ' => 'ṡ',
+ 'ι' => 'ι',
+ 'ß' => 'ss',
+ 'ʼn' => 'ʼn',
+ 'ǰ' => 'ǰ',
+ 'ΐ' => 'ΐ',
+ 'ΰ' => 'ΰ',
+ 'և' => 'եւ',
+ 'ẖ' => 'ẖ',
+ 'ẗ' => 'ẗ',
+ 'ẘ' => 'ẘ',
+ 'ẙ' => 'ẙ',
+ 'ẚ' => 'aʾ',
+ 'ẞ' => 'ss',
+ 'ὐ' => 'ὐ',
+ 'ὒ' => 'ὒ',
+ 'ὔ' => 'ὔ',
+ 'ὖ' => 'ὖ',
+ 'ᾀ' => 'ἀι',
+ 'ᾁ' => 'ἁι',
+ 'ᾂ' => 'ἂι',
+ 'ᾃ' => 'ἃι',
+ 'ᾄ' => 'ἄι',
+ 'ᾅ' => 'ἅι',
+ 'ᾆ' => 'ἆι',
+ 'ᾇ' => 'ἇι',
+ 'ᾈ' => 'ἀι',
+ 'ᾉ' => 'ἁι',
+ 'ᾊ' => 'ἂι',
+ 'ᾋ' => 'ἃι',
+ 'ᾌ' => 'ἄι',
+ 'ᾍ' => 'ἅι',
+ 'ᾎ' => 'ἆι',
+ 'ᾏ' => 'ἇι',
+ 'ᾐ' => 'ἠι',
+ 'ᾑ' => 'ἡι',
+ 'ᾒ' => 'ἢι',
+ 'ᾓ' => 'ἣι',
+ 'ᾔ' => 'ἤι',
+ 'ᾕ' => 'ἥι',
+ 'ᾖ' => 'ἦι',
+ 'ᾗ' => 'ἧι',
+ 'ᾘ' => 'ἠι',
+ 'ᾙ' => 'ἡι',
+ 'ᾚ' => 'ἢι',
+ 'ᾛ' => 'ἣι',
+ 'ᾜ' => 'ἤι',
+ 'ᾝ' => 'ἥι',
+ 'ᾞ' => 'ἦι',
+ 'ᾟ' => 'ἧι',
+ 'ᾠ' => 'ὠι',
+ 'ᾡ' => 'ὡι',
+ 'ᾢ' => 'ὢι',
+ 'ᾣ' => 'ὣι',
+ 'ᾤ' => 'ὤι',
+ 'ᾥ' => 'ὥι',
+ 'ᾦ' => 'ὦι',
+ 'ᾧ' => 'ὧι',
+ 'ᾨ' => 'ὠι',
+ 'ᾩ' => 'ὡι',
+ 'ᾪ' => 'ὢι',
+ 'ᾫ' => 'ὣι',
+ 'ᾬ' => 'ὤι',
+ 'ᾭ' => 'ὥι',
+ 'ᾮ' => 'ὦι',
+ 'ᾯ' => 'ὧι',
+ 'ᾲ' => 'ὰι',
+ 'ᾳ' => 'αι',
+ 'ᾴ' => 'άι',
+ 'ᾶ' => 'ᾶ',
+ 'ᾷ' => 'ᾶι',
+ 'ᾼ' => 'αι',
+ 'ῂ' => 'ὴι',
+ 'ῃ' => 'ηι',
+ 'ῄ' => 'ήι',
+ 'ῆ' => 'ῆ',
+ 'ῇ' => 'ῆι',
+ 'ῌ' => 'ηι',
+ 'ῒ' => 'ῒ',
+ 'ῖ' => 'ῖ',
+ 'ῗ' => 'ῗ',
+ 'ῢ' => 'ῢ',
+ 'ῤ' => 'ῤ',
+ 'ῦ' => 'ῦ',
+ 'ῧ' => 'ῧ',
+ 'ῲ' => 'ὼι',
+ 'ῳ' => 'ωι',
+ 'ῴ' => 'ώι',
+ 'ῶ' => 'ῶ',
+ 'ῷ' => 'ῶι',
+ 'ῼ' => 'ωι',
+ 'ff' => 'ff',
+ 'fi' => 'fi',
+ 'fl' => 'fl',
+ 'ffi' => 'ffi',
+ 'ffl' => 'ffl',
+ 'ſt' => 'st',
+ 'st' => 'st',
+ 'ﬓ' => 'մն',
+ 'ﬔ' => 'մե',
+ 'ﬕ' => 'մի',
+ 'ﬖ' => 'վն',
+ 'ﬗ' => 'մխ',
+];
diff --git a/vendor/symfony/polyfill-mbstring/bootstrap.php b/vendor/symfony/polyfill-mbstring/bootstrap.php
index 1fedd1f..ecf1a03 100644
--- a/vendor/symfony/polyfill-mbstring/bootstrap.php
+++ b/vendor/symfony/polyfill-mbstring/bootstrap.php
@@ -132,6 +132,10 @@ if (!function_exists('mb_str_split')) {
function mb_str_split($string, $length = 1, $encoding = null) { return p\Mbstring::mb_str_split($string, $length, $encoding); }
}
+if (!function_exists('mb_str_pad')) {
+ function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
+}
+
if (extension_loaded('mbstring')) {
return;
}
diff --git a/vendor/symfony/polyfill-mbstring/bootstrap80.php b/vendor/symfony/polyfill-mbstring/bootstrap80.php
index 82f5ac4..2f9fb5b 100644
--- a/vendor/symfony/polyfill-mbstring/bootstrap80.php
+++ b/vendor/symfony/polyfill-mbstring/bootstrap80.php
@@ -128,6 +128,10 @@ if (!function_exists('mb_str_split')) {
function mb_str_split(?string $string, ?int $length = 1, ?string $encoding = null): array { return p\Mbstring::mb_str_split((string) $string, (int) $length, $encoding); }
}
+if (!function_exists('mb_str_pad')) {
+ function mb_str_pad(string $string, int $length, string $pad_string = ' ', int $pad_type = STR_PAD_RIGHT, ?string $encoding = null): string { return p\Mbstring::mb_str_pad($string, $length, $pad_string, $pad_type, $encoding); }
+}
+
if (extension_loaded('mbstring')) {
return;
}
diff --git a/vendor/symfony/polyfill-mbstring/composer.json b/vendor/symfony/polyfill-mbstring/composer.json
index 4489553..943e502 100644
--- a/vendor/symfony/polyfill-mbstring/composer.json
+++ b/vendor/symfony/polyfill-mbstring/composer.json
@@ -31,7 +31,7 @@
"minimum-stability": "dev",
"extra": {
"branch-alias": {
- "dev-main": "1.27-dev"
+ "dev-main": "1.28-dev"
},
"thanks": {
"name": "symfony/polyfill",