Completed
Push — master ( a1d5e4...f39b34 )
by Lars
22:27 queued 10:23
created
src/voku/helper/UTF8.php 1 patch
Spacing   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -818,7 +818,7 @@  discard block
 block discarded – undo
818 818
   public static function add_bom_to_string($str)
819 819
   {
820 820
     if (!self::is_bom(substr($str, 0, 3))) {
821
-      $str = self::bom() . $str;
821
+      $str = self::bom().$str;
822 822
     }
823 823
 
824 824
     return $str;
@@ -2142,7 +2142,7 @@  discard block
 block discarded – undo
2142 2142
     self::checkForSupport();
2143 2143
 
2144 2144
     return \mb_convert_encoding(
2145
-        '&#x' . dechex($code) . ';',
2145
+        '&#x'.dechex($code).';',
2146 2146
         'UTF-8',
2147 2147
         'HTML-ENTITIES'
2148 2148
     );
@@ -2420,7 +2420,7 @@  discard block
 block discarded – undo
2420 2420
           if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) {
2421 2421
             // Prevent leading combining chars
2422 2422
             // for NFC-safe concatenations.
2423
-            $var = $leading_combining . $var;
2423
+            $var = $leading_combining.$var;
2424 2424
           }
2425 2425
         }
2426 2426
         break;
@@ -2706,7 +2706,7 @@  discard block
 block discarded – undo
2706 2706
    */
2707 2707
   protected static function getData($file)
2708 2708
   {
2709
-    $file = __DIR__ . '/data/' . $file . '.php';
2709
+    $file = __DIR__.'/data/'.$file.'.php';
2710 2710
     if (file_exists($file)) {
2711 2711
       /** @noinspection PhpIncludeInspection */
2712 2712
       return require $file;
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
 
2811 2811
     return implode(
2812 2812
         array_map(
2813
-            function ($data) use ($keepAsciiChars) { return self::single_chr_html_encode($data, $keepAsciiChars); },
2813
+            function($data) use ($keepAsciiChars) { return self::single_chr_html_encode($data, $keepAsciiChars); },
2814 2814
             self::split($str)
2815 2815
         )
2816 2816
     );
@@ -3165,9 +3165,9 @@  discard block
 block discarded – undo
3165 3165
     if (ctype_digit((string)$int)) {
3166 3166
       $hex = dechex((int)$int);
3167 3167
 
3168
-      $hex = (strlen($hex) < 4 ? substr('0000' . $hex, -4) : $hex);
3168
+      $hex = (strlen($hex) < 4 ? substr('0000'.$hex, -4) : $hex);
3169 3169
 
3170
-      return $pfix . $hex;
3170
+      return $pfix.$hex;
3171 3171
     }
3172 3172
 
3173 3173
     return '';
@@ -3739,7 +3739,7 @@  discard block
 block discarded – undo
3739 3739
    */
3740 3740
   public static function lcfirst($str)
3741 3741
   {
3742
-    return self::strtolower(self::substr($str, 0, 1)) . self::substr($str, 1);
3742
+    return self::strtolower(self::substr($str, 0, 1)).self::substr($str, 1);
3743 3743
   }
3744 3744
 
3745 3745
   /**
@@ -4155,7 +4155,7 @@  discard block
 block discarded – undo
4155 4155
 
4156 4156
     if (is_array($what)) {
4157 4157
       foreach ($what as $item) {
4158
-        $str = preg_replace('/(' . preg_quote($item, '/') . ')+/', $item, $str);
4158
+        $str = preg_replace('/('.preg_quote($item, '/').')+/', $item, $str);
4159 4159
       }
4160 4160
     }
4161 4161
 
@@ -4254,7 +4254,7 @@  discard block
 block discarded – undo
4254 4254
   {
4255 4255
     static $rxClassCache = array();
4256 4256
 
4257
-    $cacheKey = $s . $class;
4257
+    $cacheKey = $s.$class;
4258 4258
 
4259 4259
     if (isset($rxClassCache[$cacheKey])) {
4260 4260
       return $rxClassCache[$cacheKey];
@@ -4265,7 +4265,7 @@  discard block
 block discarded – undo
4265 4265
     /** @noinspection SuspiciousLoopInspection */
4266 4266
     foreach (self::str_split($s) as $s) {
4267 4267
       if ('-' === $s) {
4268
-        $class[0] = '-' . $class[0];
4268
+        $class[0] = '-'.$class[0];
4269 4269
       } elseif (!isset($s[2])) {
4270 4270
         $class[0] .= preg_quote($s, '/');
4271 4271
       } elseif (1 === self::strlen($s)) {
@@ -4275,12 +4275,12 @@  discard block
 block discarded – undo
4275 4275
       }
4276 4276
     }
4277 4277
 
4278
-    $class[0] = '[' . $class[0] . ']';
4278
+    $class[0] = '['.$class[0].']';
4279 4279
 
4280 4280
     if (1 === count($class)) {
4281 4281
       $return = $class[0];
4282 4282
     } else {
4283
-      $return = '(?:' . implode('|', $class) . ')';
4283
+      $return = '(?:'.implode('|', $class).')';
4284 4284
     }
4285 4285
 
4286 4286
     $rxClassCache[$cacheKey] = $return;
@@ -4294,7 +4294,7 @@  discard block
 block discarded – undo
4294 4294
   public static function showSupport()
4295 4295
   {
4296 4296
     foreach (self::$support as $utf8Support) {
4297
-      echo $utf8Support . "\n<br>";
4297
+      echo $utf8Support."\n<br>";
4298 4298
     }
4299 4299
   }
4300 4300
 
@@ -4318,7 +4318,7 @@  discard block
 block discarded – undo
4318 4318
       }
4319 4319
     }
4320 4320
 
4321
-    return '&#' . self::ord($chr) . ';';
4321
+    return '&#'.self::ord($chr).';';
4322 4322
   }
4323 4323
 
4324 4324
   /**
@@ -4367,19 +4367,19 @@  discard block
 block discarded – undo
4367 4367
           $ret[] = $str[$i];
4368 4368
         } elseif ((($str[$i] & "\xE0") === "\xC0") && isset($str[$i + 1])) {
4369 4369
           if (($str[$i + 1] & "\xC0") === "\x80") {
4370
-            $ret[] = $str[$i] . $str[$i + 1];
4370
+            $ret[] = $str[$i].$str[$i + 1];
4371 4371
 
4372 4372
             $i++;
4373 4373
           }
4374 4374
         } elseif ((($str[$i] & "\xF0") === "\xE0") && isset($str[$i + 2])) {
4375 4375
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80")) {
4376
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2];
4376
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2];
4377 4377
 
4378 4378
             $i += 2;
4379 4379
           }
4380 4380
         } elseif ((($str[$i] & "\xF8") === "\xF0") && isset($str[$i + 3])) {
4381 4381
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80") && (($str[$i + 3] & "\xC0") === "\x80")) {
4382
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2] . $str[$i + 3];
4382
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2].$str[$i + 3];
4383 4383
 
4384 4384
             $i += 3;
4385 4385
           }
@@ -4513,7 +4513,7 @@  discard block
 block discarded – undo
4513 4513
       if ('' === $s .= '') {
4514 4514
         $s = '/^(?<=.)$/';
4515 4515
       } else {
4516
-        $s = '/' . preg_quote($s, '/') . '/ui';
4516
+        $s = '/'.preg_quote($s, '/').'/ui';
4517 4517
       }
4518 4518
     }
4519 4519
 
@@ -4547,7 +4547,7 @@  discard block
 block discarded – undo
4547 4547
     }
4548 4548
 
4549 4549
     if (self::substr($str, $length - 1, 1) === ' ') {
4550
-      return self::substr($str, 0, $length - 1) . $strAddOn;
4550
+      return self::substr($str, 0, $length - 1).$strAddOn;
4551 4551
     }
4552 4552
 
4553 4553
     $str = self::substr($str, 0, $length);
@@ -4556,9 +4556,9 @@  discard block
 block discarded – undo
4556 4556
     $new_str = implode(' ', $array);
4557 4557
 
4558 4558
     if ($new_str === '') {
4559
-      $str = self::substr($str, 0, $length - 1) . $strAddOn;
4559
+      $str = self::substr($str, 0, $length - 1).$strAddOn;
4560 4560
     } else {
4561
-      $str = $new_str . $strAddOn;
4561
+      $str = $new_str.$strAddOn;
4562 4562
     }
4563 4563
 
4564 4564
     return $str;
@@ -4604,7 +4604,7 @@  discard block
 block discarded – undo
4604 4604
           $pre = '';
4605 4605
       }
4606 4606
 
4607
-      return $pre . $input . $post;
4607
+      return $pre.$input.$post;
4608 4608
     }
4609 4609
 
4610 4610
     return $input;
@@ -4738,7 +4738,7 @@  discard block
 block discarded – undo
4738 4738
         $a[] = \grapheme_extract($str, 1, GRAPHEME_EXTR_COUNT, $p, $p);
4739 4739
       }
4740 4740
     } else {
4741
-      preg_match_all('/' . Grapheme::GRAPHEME_CLUSTER_RX . '/u', $str, $a);
4741
+      preg_match_all('/'.Grapheme::GRAPHEME_CLUSTER_RX.'/u', $str, $a);
4742 4742
       $a = $a[0];
4743 4743
     }
4744 4744
 
@@ -4879,7 +4879,7 @@  discard block
 block discarded – undo
4879 4879
 
4880 4880
       $bank = $ord >> 8;
4881 4881
       if (!array_key_exists($bank, (array)$UTF8_TO_ASCII)) {
4882
-        $bankfile = __DIR__ . '/data/' . sprintf('x%02x', $bank) . '.php';
4882
+        $bankfile = __DIR__.'/data/'.sprintf('x%02x', $bank).'.php';
4883 4883
         if (file_exists($bankfile)) {
4884 4884
           /** @noinspection PhpIncludeInspection */
4885 4885
           require $bankfile;
@@ -4969,7 +4969,7 @@  discard block
 block discarded – undo
4969 4969
    */
4970 4970
   public static function strcmp($str1, $str2)
4971 4971
   {
4972
-    return $str1 . '' === $str2 . '' ? 0 : strcmp(
4972
+    return $str1.'' === $str2.'' ? 0 : strcmp(
4973 4973
         \Normalizer::normalize($str1, \Normalizer::NFD),
4974 4974
         \Normalizer::normalize($str2, \Normalizer::NFD)
4975 4975
     );
@@ -4997,7 +4997,7 @@  discard block
 block discarded – undo
4997 4997
       $str = (string)$str;
4998 4998
     }
4999 4999
 
5000
-    if (preg_match('/^(.*?)' . self::rxClass($charList) . '/us', $str, $length)) {
5000
+    if (preg_match('/^(.*?)'.self::rxClass($charList).'/us', $str, $length)) {
5001 5001
       /** @noinspection OffsetOperationsInspection */
5002 5002
       return self::strlen($length[1]);
5003 5003
     } else {
@@ -5213,7 +5213,7 @@  discard block
 block discarded – undo
5213 5213
    */
5214 5214
   public static function strnatcmp($str1, $str2)
5215 5215
   {
5216
-    return $str1 . '' === $str2 . '' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
5216
+    return $str1.'' === $str2.'' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
5217 5217
   }
5218 5218
 
5219 5219
   /**
@@ -5294,7 +5294,7 @@  discard block
 block discarded – undo
5294 5294
       return false;
5295 5295
     }
5296 5296
 
5297
-    if (preg_match('/' . self::rxClass($char_list) . '/us', $haystack, $m)) {
5297
+    if (preg_match('/'.self::rxClass($char_list).'/us', $haystack, $m)) {
5298 5298
       return substr($haystack, strpos($haystack, $m[0]));
5299 5299
     } else {
5300 5300
       return false;
@@ -5567,7 +5567,7 @@  discard block
 block discarded – undo
5567 5567
       $str = self::substr($str, $offset, $length);
5568 5568
     }
5569 5569
 
5570
-    return preg_match('/^' . self::rxClass($mask) . '+/u', $str, $str) ? self::strlen($str[0]) : 0;
5570
+    return preg_match('/^'.self::rxClass($mask).'+/u', $str, $str) ? self::strlen($str[0]) : 0;
5571 5571
   }
5572 5572
 
5573 5573
   /**
@@ -6004,7 +6004,7 @@  discard block
 block discarded – undo
6004 6004
 
6005 6005
     $strSwappedCase = preg_replace_callback(
6006 6006
         '/[\S]/u',
6007
-        function ($match) use ($encoding) {
6007
+        function($match) use ($encoding) {
6008 6008
           $marchToUpper = UTF8::strtoupper($match[0], $encoding);
6009 6009
 
6010 6010
           if ($match[0] === $marchToUpper) {
@@ -6213,40 +6213,40 @@  discard block
 block discarded – undo
6213 6213
         if ($c1 >= "\xc0" & $c1 <= "\xdf") { // looks like 2 bytes UTF8
6214 6214
 
6215 6215
           if ($c2 >= "\x80" && $c2 <= "\xbf") { // yeah, almost sure it's UTF8 already
6216
-            $buf .= $c1 . $c2;
6216
+            $buf .= $c1.$c2;
6217 6217
             $i++;
6218 6218
           } else { // not valid UTF8 - convert it
6219 6219
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
6220 6220
             $cc2 = ($c1 & "\x3f") | "\x80";
6221
-            $buf .= $cc1 . $cc2;
6221
+            $buf .= $cc1.$cc2;
6222 6222
           }
6223 6223
 
6224 6224
         } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6225 6225
 
6226 6226
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6227
-            $buf .= $c1 . $c2 . $c3;
6227
+            $buf .= $c1.$c2.$c3;
6228 6228
             $i += 2;
6229 6229
           } else { // not valid UTF8 - convert it
6230 6230
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
6231 6231
             $cc2 = ($c1 & "\x3f") | "\x80";
6232
-            $buf .= $cc1 . $cc2;
6232
+            $buf .= $cc1.$cc2;
6233 6233
           }
6234 6234
 
6235 6235
         } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6236 6236
 
6237 6237
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6238
-            $buf .= $c1 . $c2 . $c3 . $c4;
6238
+            $buf .= $c1.$c2.$c3.$c4;
6239 6239
             $i += 3;
6240 6240
           } else { // not valid UTF8 - convert it
6241 6241
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
6242 6242
             $cc2 = ($c1 & "\x3f") | "\x80";
6243
-            $buf .= $cc1 . $cc2;
6243
+            $buf .= $cc1.$cc2;
6244 6244
           }
6245 6245
 
6246 6246
         } else { // doesn't look like UTF8, but should be converted
6247 6247
           $cc1 = (chr(ord($c1) / 64) | "\xc0");
6248 6248
           $cc2 = (($c1 & "\x3f") | "\x80");
6249
-          $buf .= $cc1 . $cc2;
6249
+          $buf .= $cc1.$cc2;
6250 6250
         }
6251 6251
 
6252 6252
       } elseif (($c1 & "\xc0") === "\x80") { // needs conversion
@@ -6257,7 +6257,7 @@  discard block
 block discarded – undo
6257 6257
         } else {
6258 6258
           $cc1 = (chr($ordC1 / 64) | "\xc0");
6259 6259
           $cc2 = (($c1 & "\x3f") | "\x80");
6260
-          $buf .= $cc1 . $cc2;
6260
+          $buf .= $cc1.$cc2;
6261 6261
         }
6262 6262
 
6263 6263
       } else { // it doesn't need conversion
@@ -6270,7 +6270,7 @@  discard block
 block discarded – undo
6270 6270
     // decode unicode escape sequences
6271 6271
     $buf = preg_replace_callback(
6272 6272
         '/\\\\u([0-9a-f]{4})/i',
6273
-        function ($match) {
6273
+        function($match) {
6274 6274
           return \mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
6275 6275
         },
6276 6276
         $buf
@@ -6279,7 +6279,7 @@  discard block
 block discarded – undo
6279 6279
     // decode UTF-8 codepoints
6280 6280
     $buf = preg_replace_callback(
6281 6281
         '/&#\d{2,4};/',
6282
-        function ($match) {
6282
+        function($match) {
6283 6283
           return \mb_convert_encoding($match[0], 'UTF-8', 'HTML-ENTITIES');
6284 6284
         },
6285 6285
         $buf
@@ -6354,7 +6354,7 @@  discard block
 block discarded – undo
6354 6354
    */
6355 6355
   public static function ucfirst($str)
6356 6356
   {
6357
-    return self::strtoupper(self::substr($str, 0, 1)) . self::substr($str, 1);
6357
+    return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
6358 6358
   }
6359 6359
 
6360 6360
   /**
@@ -6803,7 +6803,7 @@  discard block
 block discarded – undo
6803 6803
       return '';
6804 6804
     }
6805 6805
 
6806
-    preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $str, $matches);
6806
+    preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $str, $matches);
6807 6807
 
6808 6808
     if (
6809 6809
         !isset($matches[0])
@@ -6813,7 +6813,7 @@  discard block
 block discarded – undo
6813 6813
       return $str;
6814 6814
     }
6815 6815
 
6816
-    return self::rtrim($matches[0]) . $strAddOn;
6816
+    return self::rtrim($matches[0]).$strAddOn;
6817 6817
   }
6818 6818
 
6819 6819
   /**
@@ -6895,7 +6895,7 @@  discard block
 block discarded – undo
6895 6895
       $strReturn .= $break;
6896 6896
     }
6897 6897
 
6898
-    return $strReturn . implode('', $chars);
6898
+    return $strReturn.implode('', $chars);
6899 6899
   }
6900 6900
 
6901 6901
   /**
Please login to merge, or discard this patch.