updated composer
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user