diff options
Diffstat (limited to 'vendor/symfony/polyfill-intl-normalizer')
5 files changed, 57 insertions, 32 deletions
diff --git a/vendor/symfony/polyfill-intl-normalizer/Normalizer.php b/vendor/symfony/polyfill-intl-normalizer/Normalizer.php index a60fae6209..4443c2322a 100644 --- a/vendor/symfony/polyfill-intl-normalizer/Normalizer.php +++ b/vendor/symfony/polyfill-intl-normalizer/Normalizer.php @@ -23,28 +23,27 @@ namespace Symfony\Polyfill\Intl\Normalizer; */ class Normalizer { - const FORM_D = \Normalizer::FORM_D; - const FORM_KD = \Normalizer::FORM_KD; - const FORM_C = \Normalizer::FORM_C; - const FORM_KC = \Normalizer::FORM_KC; - const NFD = \Normalizer::NFD; - const NFKD = \Normalizer::NFKD; - const NFC = \Normalizer::NFC; - const NFKC = \Normalizer::NFKC; + public const FORM_D = \Normalizer::FORM_D; + public const FORM_KD = \Normalizer::FORM_KD; + public const FORM_C = \Normalizer::FORM_C; + public const FORM_KC = \Normalizer::FORM_KC; + public const NFD = \Normalizer::NFD; + public const NFKD = \Normalizer::NFKD; + public const NFC = \Normalizer::NFC; + public const NFKC = \Normalizer::NFKC; private static $C; private static $D; private static $KD; private static $cC; - private static $ulenMask = array("\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4); + private static $ulenMask = ["\xC0" => 2, "\xD0" => 2, "\xE0" => 3, "\xF0" => 4]; private static $ASCII = "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x00\x01\x02\x03\x04\x05\x06\x07\x08\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F"; - public static function isNormalized($s, $form = self::NFC) + public static function isNormalized(string $s, int $form = self::FORM_C) { - if (!\in_array($form, array(self::NFD, self::NFKD, self::NFC, self::NFKC))) { + if (!\in_array($form, [self::NFD, self::NFKD, self::NFC, self::NFKC])) { return false; } - $s = (string) $s; if (!isset($s[strspn($s, self::$ASCII)])) { return true; } @@ -55,9 +54,8 @@ class Normalizer return self::normalize($s, $form) === $s; } - public static function normalize($s, $form = self::NFC) + public static function normalize(string $s, int $form = self::FORM_C) { - $s = (string) $s; if (!preg_match('//u', $s)) { return false; } @@ -72,7 +70,11 @@ class Normalizer return $s; } - return false; + if (80000 > \PHP_VERSION_ID) { + return false; + } + + throw new \ValueError('normalizer_normalize(): Argument #2 ($form) must be a a valid normalization form'); } if ('' === $s) { @@ -152,7 +154,7 @@ class Normalizer || $lastUcls) { // Table lookup and combining chars composition - $ucls = isset($combClass[$uchr]) ? $combClass[$uchr] : 0; + $ucls = $combClass[$uchr] ?? 0; if (isset($compMap[$lastUchr.$uchr]) && (!$lastUcls || $lastUcls < $ucls)) { $lastUchr = $compMap[$lastUchr.$uchr]; @@ -204,7 +206,7 @@ class Normalizer $compatMap = self::$KD; } - $c = array(); + $c = []; $i = 0; $len = \strlen($s); @@ -215,7 +217,7 @@ class Normalizer if ($c) { ksort($c); $result .= implode('', $c); - $c = array(); + $c = []; } $j = 1 + strspn($s, $ASCII, $i + 1); @@ -231,7 +233,7 @@ class Normalizer if ($uchr < "\xEA\xB0\x80" || "\xED\x9E\xA3" < $uchr) { // Table lookup - if ($uchr !== $j = isset($compatMap[$uchr]) ? $compatMap[$uchr] : (isset($decompMap[$uchr]) ? $decompMap[$uchr] : $uchr)) { + if ($uchr !== $j = $compatMap[$uchr] ?? ($decompMap[$uchr] ?? $uchr)) { $uchr = $j; $j = \strlen($uchr); @@ -283,7 +285,7 @@ class Normalizer if ($c) { ksort($c); $result .= implode('', $c); - $c = array(); + $c = []; } $result .= $uchr; diff --git a/vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php b/vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php index ca18eff36f..0fdfc890a2 100644 --- a/vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php +++ b/vendor/symfony/polyfill-intl-normalizer/Resources/stubs/Normalizer.php @@ -5,13 +5,13 @@ class Normalizer extends Symfony\Polyfill\Intl\Normalizer\Normalizer /** * @deprecated since ICU 56 and removed in PHP 8 */ - const NONE = 1; - const FORM_D = 2; - const FORM_KD = 3; - const FORM_C = 4; - const FORM_KC = 5; - const NFD = 2; - const NFKD = 3; - const NFC = 4; - const NFKC = 5; + public const NONE = 2; + public const FORM_D = 4; + public const FORM_KD = 8; + public const FORM_C = 16; + public const FORM_KC = 32; + public const NFD = 4; + public const NFKD = 8; + public const NFC = 16; + public const NFKC = 32; } diff --git a/vendor/symfony/polyfill-intl-normalizer/bootstrap.php b/vendor/symfony/polyfill-intl-normalizer/bootstrap.php index bac4318c96..3608e5c05d 100644 --- a/vendor/symfony/polyfill-intl-normalizer/bootstrap.php +++ b/vendor/symfony/polyfill-intl-normalizer/bootstrap.php @@ -11,9 +11,13 @@ use Symfony\Polyfill\Intl\Normalizer as p; +if (\PHP_VERSION_ID >= 80000) { + return require __DIR__.'/bootstrap80.php'; +} + if (!function_exists('normalizer_is_normalized')) { - function normalizer_is_normalized($input, $form = p\Normalizer::NFC) { return p\Normalizer::isNormalized($input, $form); } + function normalizer_is_normalized($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::isNormalized($string, $form); } } if (!function_exists('normalizer_normalize')) { - function normalizer_normalize($input, $form = p\Normalizer::NFC) { return p\Normalizer::normalize($input, $form); } + function normalizer_normalize($string, $form = p\Normalizer::FORM_C) { return p\Normalizer::normalize($string, $form); } } diff --git a/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php b/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php new file mode 100644 index 0000000000..c9a29d7a9a --- /dev/null +++ b/vendor/symfony/polyfill-intl-normalizer/bootstrap80.php @@ -0,0 +1,19 @@ +<?php + +/* + * This file is part of the Symfony package. + * + * (c) Fabien Potencier <fabien@symfony.com> + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +use Symfony\Polyfill\Intl\Normalizer as p; + +if (!function_exists('normalizer_is_normalized')) { + function normalizer_is_normalized(string $string, int $form = p\Normalizer::FORM_C): bool { return p\Normalizer::isNormalized($string, $form); } +} +if (!function_exists('normalizer_normalize')) { + function normalizer_normalize(string $string, int $form = p\Normalizer::FORM_C): string|false { return p\Normalizer::normalize($string, $form); } +} diff --git a/vendor/symfony/polyfill-intl-normalizer/composer.json b/vendor/symfony/polyfill-intl-normalizer/composer.json index 873abd3eae..8f4cfb4dc0 100644 --- a/vendor/symfony/polyfill-intl-normalizer/composer.json +++ b/vendor/symfony/polyfill-intl-normalizer/composer.json @@ -29,7 +29,7 @@ "minimum-stability": "dev", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", |
