Skip to content

Commit

Permalink
Update and apply CS rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Jan 6, 2021
1 parent a40894e commit 8592bf6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
30 changes: 15 additions & 15 deletions Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
*/
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(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;
}
if (!isset($s[strspn($s, self::$ASCII)])) {
Expand Down Expand Up @@ -154,7 +154,7 @@ private static function recompose($s)
|| $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];
Expand Down Expand Up @@ -206,7 +206,7 @@ private static function decompose($s, $c)
$compatMap = self::$KD;
}

$c = array();
$c = [];
$i = 0;
$len = \strlen($s);

Expand All @@ -217,7 +217,7 @@ private static function decompose($s, $c)
if ($c) {
ksort($c);
$result .= implode('', $c);
$c = array();
$c = [];
}

$j = 1 + strspn($s, $ASCII, $i + 1);
Expand All @@ -233,7 +233,7 @@ private static function decompose($s, $c)
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);
Expand Down Expand Up @@ -285,7 +285,7 @@ private static function decompose($s, $c)
if ($c) {
ksort($c);
$result .= implode('', $c);
$c = array();
$c = [];
}

$result .= $uchr;
Expand Down
18 changes: 9 additions & 9 deletions Resources/stubs/Normalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 1;
public const FORM_D = 2;
public const FORM_KD = 3;
public const FORM_C = 4;
public const FORM_KC = 5;
public const NFD = 2;
public const NFKD = 3;
public const NFC = 4;
public const NFKC = 5;
}
2 changes: 1 addition & 1 deletion bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

use Symfony\Polyfill\Intl\Normalizer as p;

if (PHP_VERSION_ID >= 80000) {
if (\PHP_VERSION_ID >= 80000) {
return require __DIR__.'/bootstrap80.php';
}

Expand Down

0 comments on commit 8592bf6

Please sign in to comment.