23
23
*/
24
24
class Normalizer
25
25
{
26
- const FORM_D = \Normalizer::FORM_D ;
27
- const FORM_KD = \Normalizer::FORM_KD ;
28
- const FORM_C = \Normalizer::FORM_C ;
29
- const FORM_KC = \Normalizer::FORM_KC ;
30
- const NFD = \Normalizer::NFD ;
31
- const NFKD = \Normalizer::NFKD ;
32
- const NFC = \Normalizer::NFC ;
33
- const NFKC = \Normalizer::NFKC ;
26
+ public const FORM_D = \Normalizer::FORM_D ;
27
+ public const FORM_KD = \Normalizer::FORM_KD ;
28
+ public const FORM_C = \Normalizer::FORM_C ;
29
+ public const FORM_KC = \Normalizer::FORM_KC ;
30
+ public const NFD = \Normalizer::NFD ;
31
+ public const NFKD = \Normalizer::NFKD ;
32
+ public const NFC = \Normalizer::NFC ;
33
+ public const NFKC = \Normalizer::NFKC ;
34
34
35
35
private static $ C ;
36
36
private static $ D ;
37
37
private static $ KD ;
38
38
private static $ cC ;
39
- private static $ ulenMask = array ( "\xC0" => 2 , "\xD0" => 2 , "\xE0" => 3 , "\xF0" => 4 ) ;
39
+ private static $ ulenMask = [ "\xC0" => 2 , "\xD0" => 2 , "\xE0" => 3 , "\xF0" => 4 ] ;
40
40
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" ;
41
41
42
42
public static function isNormalized (string $ s , int $ form = self ::FORM_C )
43
43
{
44
- if (!\in_array ($ form , array ( self ::NFD , self ::NFKD , self ::NFC , self ::NFKC ) )) {
44
+ if (!\in_array ($ form , [ self ::NFD , self ::NFKD , self ::NFC , self ::NFKC ] )) {
45
45
return false ;
46
46
}
47
47
if (!isset ($ s [strspn ($ s , self ::$ ASCII )])) {
@@ -154,7 +154,7 @@ private static function recompose($s)
154
154
|| $ lastUcls ) {
155
155
// Table lookup and combining chars composition
156
156
157
- $ ucls = isset ( $ combClass [$ uchr ]) ? $ combClass [ $ uchr ] : 0 ;
157
+ $ ucls = $ combClass [$ uchr ] ?? 0 ;
158
158
159
159
if (isset ($ compMap [$ lastUchr .$ uchr ]) && (!$ lastUcls || $ lastUcls < $ ucls )) {
160
160
$ lastUchr = $ compMap [$ lastUchr .$ uchr ];
@@ -206,7 +206,7 @@ private static function decompose($s, $c)
206
206
$ compatMap = self ::$ KD ;
207
207
}
208
208
209
- $ c = array () ;
209
+ $ c = [] ;
210
210
$ i = 0 ;
211
211
$ len = \strlen ($ s );
212
212
@@ -217,7 +217,7 @@ private static function decompose($s, $c)
217
217
if ($ c ) {
218
218
ksort ($ c );
219
219
$ result .= implode ('' , $ c );
220
- $ c = array () ;
220
+ $ c = [] ;
221
221
}
222
222
223
223
$ j = 1 + strspn ($ s , $ ASCII , $ i + 1 );
@@ -233,7 +233,7 @@ private static function decompose($s, $c)
233
233
if ($ uchr < "\xEA\xB0\x80" || "\xED\x9E\xA3" < $ uchr ) {
234
234
// Table lookup
235
235
236
- if ($ uchr !== $ j = isset ( $ compatMap [$ uchr ]) ? $ compatMap [ $ uchr ] : ( isset ( $ decompMap [$ uchr ]) ? $ decompMap [ $ uchr ] : $ uchr )) {
236
+ if ($ uchr !== $ j = $ compatMap [$ uchr ] ?? ( $ decompMap [$ uchr ] ?? $ uchr )) {
237
237
$ uchr = $ j ;
238
238
239
239
$ j = \strlen ($ uchr );
@@ -285,7 +285,7 @@ private static function decompose($s, $c)
285
285
if ($ c ) {
286
286
ksort ($ c );
287
287
$ result .= implode ('' , $ c );
288
- $ c = array () ;
288
+ $ c = [] ;
289
289
}
290
290
291
291
$ result .= $ uchr ;
0 commit comments