Update to Kirby 4.7.0
This commit is contained in:
parent
02a9ab387c
commit
ba25a9a198
509 changed files with 26604 additions and 14872 deletions
|
@ -50,6 +50,9 @@ namespace Symfony\Polyfill\Mbstring;
|
|||
* - mb_substr_count - Count the number of substring occurrences
|
||||
* - mb_ucfirst - Make a string's first character uppercase
|
||||
* - mb_lcfirst - Make a string's first character lowercase
|
||||
* - mb_trim - Strip whitespace (or other characters) from the beginning and end of a string
|
||||
* - mb_ltrim - Strip whitespace (or other characters) from the beginning of a string
|
||||
* - mb_rtrim - Strip whitespace (or other characters) from the end of a string
|
||||
*
|
||||
* Not implemented:
|
||||
* - mb_convert_kana - Convert "kana" one from another ("zen-kaku", "han-kaku" and more)
|
||||
|
@ -83,12 +86,6 @@ final class Mbstring
|
|||
public static function mb_convert_encoding($s, $toEncoding, $fromEncoding = null)
|
||||
{
|
||||
if (\is_array($s)) {
|
||||
if (PHP_VERSION_ID < 70200) {
|
||||
trigger_error('mb_convert_encoding() expects parameter 1 to be string, array given', \E_USER_WARNING);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$r = [];
|
||||
foreach ($s as $str) {
|
||||
$r[] = self::mb_convert_encoding($str, $toEncoding, $fromEncoding);
|
||||
|
@ -427,12 +424,6 @@ 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;
|
||||
|
@ -980,17 +971,75 @@ final class Mbstring
|
|||
return $encoding;
|
||||
}
|
||||
|
||||
public static function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string
|
||||
{
|
||||
return self::mb_internal_trim('{^[%s]+|[%1$s]+$}Du', $string, $characters, $encoding, __FUNCTION__);
|
||||
}
|
||||
|
||||
public static function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string
|
||||
{
|
||||
return self::mb_internal_trim('{^[%s]+}Du', $string, $characters, $encoding, __FUNCTION__);
|
||||
}
|
||||
|
||||
public static function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string
|
||||
{
|
||||
return self::mb_internal_trim('{[%s]+$}D', $string, $characters, $encoding, __FUNCTION__);
|
||||
}
|
||||
|
||||
private static function mb_internal_trim(string $regex, string $string, ?string $characters, ?string $encoding, string $function): string
|
||||
{
|
||||
if (null === $encoding) {
|
||||
$encoding = self::mb_internal_encoding();
|
||||
} else {
|
||||
self::assertEncoding($encoding, $function.'(): Argument #3 ($encoding) must be a valid encoding, "%s" given');
|
||||
}
|
||||
|
||||
if ('' === $characters) {
|
||||
return null === $encoding ? $string : self::mb_convert_encoding($string, $encoding);
|
||||
}
|
||||
|
||||
if ('UTF-8' === $encoding) {
|
||||
$encoding = null;
|
||||
if (!preg_match('//u', $string)) {
|
||||
$string = @iconv('UTF-8', 'UTF-8//IGNORE', $string);
|
||||
}
|
||||
if (null !== $characters && !preg_match('//u', $characters)) {
|
||||
$characters = @iconv('UTF-8', 'UTF-8//IGNORE', $characters);
|
||||
}
|
||||
} else {
|
||||
$string = iconv($encoding, 'UTF-8//IGNORE', $string);
|
||||
|
||||
if (null !== $characters) {
|
||||
$characters = iconv($encoding, 'UTF-8//IGNORE', $characters);
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $characters) {
|
||||
$characters = "\\0 \f\n\r\t\v\u{00A0}\u{1680}\u{2000}\u{2001}\u{2002}\u{2003}\u{2004}\u{2005}\u{2006}\u{2007}\u{2008}\u{2009}\u{200A}\u{2028}\u{2029}\u{202F}\u{205F}\u{3000}\u{0085}\u{180E}";
|
||||
} else {
|
||||
$characters = preg_quote($characters);
|
||||
}
|
||||
|
||||
$string = preg_replace(sprintf($regex, $characters), '', $string);
|
||||
|
||||
if (null === $encoding) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
return iconv('UTF-8', $encoding.'//IGNORE', $string);
|
||||
}
|
||||
|
||||
private static function assertEncoding(string $encoding, string $errorFormat): void
|
||||
{
|
||||
try {
|
||||
$validEncoding = @self::mb_check_encoding('', $encoding);
|
||||
} catch (\ValueError $e) {
|
||||
throw new \ValueError(\sprintf($errorFormat, $encoding));
|
||||
throw new \ValueError(sprintf($errorFormat, $encoding));
|
||||
}
|
||||
|
||||
// BC for PHP 7.3 and lower
|
||||
if (!$validEncoding) {
|
||||
throw new \ValueError(\sprintf($errorFormat, $encoding));
|
||||
throw new \ValueError(sprintf($errorFormat, $encoding));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -144,6 +144,19 @@ if (!function_exists('mb_lcfirst')) {
|
|||
function mb_lcfirst(string $string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_trim')) {
|
||||
function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_ltrim')) {
|
||||
function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_rtrim')) {
|
||||
function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); }
|
||||
}
|
||||
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ if (!function_exists('mb_strstr')) {
|
|||
function mb_strstr(?string $haystack, ?string $needle, ?bool $before_needle = false, ?string $encoding = null): string|false { return p\Mbstring::mb_strstr((string) $haystack, (string) $needle, (bool) $before_needle, $encoding); }
|
||||
}
|
||||
if (!function_exists('mb_get_info')) {
|
||||
function mb_get_info(?string $type = 'all'): array|string|int|false { return p\Mbstring::mb_get_info((string) $type); }
|
||||
function mb_get_info(?string $type = 'all'): array|string|int|false|null { return p\Mbstring::mb_get_info((string) $type); }
|
||||
}
|
||||
if (!function_exists('mb_http_output')) {
|
||||
function mb_http_output(?string $encoding = null): string|bool { return p\Mbstring::mb_http_output($encoding); }
|
||||
|
@ -140,6 +140,18 @@ if (!function_exists('mb_lcfirst')) {
|
|||
function mb_lcfirst($string, ?string $encoding = null): string { return p\Mbstring::mb_lcfirst($string, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_trim')) {
|
||||
function mb_trim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_trim($string, $characters, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_ltrim')) {
|
||||
function mb_ltrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_ltrim($string, $characters, $encoding); }
|
||||
}
|
||||
|
||||
if (!function_exists('mb_rtrim')) {
|
||||
function mb_rtrim(string $string, ?string $characters = null, ?string $encoding = null): string { return p\Mbstring::mb_rtrim($string, $characters, $encoding); }
|
||||
}
|
||||
|
||||
if (extension_loaded('mbstring')) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
"php": ">=7.2"
|
||||
},
|
||||
"provide": {
|
||||
"ext-mbstring": "*"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue