Completed
Push — master ( f39b34...54357b )
by Lars
12:58 queued 01:58
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;
@@ -2824,7 +2824,7 @@  discard block
 block discarded – undo
2824 2824
 
2825 2825
     return implode(
2826 2826
         array_map(
2827
-            function ($data) use ($keepAsciiChars) {
2827
+            function($data) use ($keepAsciiChars) {
2828 2828
               return self::single_chr_html_encode($data, $keepAsciiChars);
2829 2829
             },
2830 2830
             self::split($str)
@@ -3181,9 +3181,9 @@  discard block
 block discarded – undo
3181 3181
     if (ctype_digit((string)$int)) {
3182 3182
       $hex = dechex((int)$int);
3183 3183
 
3184
-      $hex = (strlen($hex) < 4 ? substr('0000' . $hex, -4) : $hex);
3184
+      $hex = (strlen($hex) < 4 ? substr('0000'.$hex, -4) : $hex);
3185 3185
 
3186
-      return $pfix . $hex;
3186
+      return $pfix.$hex;
3187 3187
     }
3188 3188
 
3189 3189
     return '';
@@ -3755,7 +3755,7 @@  discard block
 block discarded – undo
3755 3755
    */
3756 3756
   public static function lcfirst($str)
3757 3757
   {
3758
-    return self::strtolower(self::substr($str, 0, 1)) . self::substr($str, 1);
3758
+    return self::strtolower(self::substr($str, 0, 1)).self::substr($str, 1);
3759 3759
   }
3760 3760
 
3761 3761
   /**
@@ -4171,7 +4171,7 @@  discard block
 block discarded – undo
4171 4171
 
4172 4172
     if (is_array($what)) {
4173 4173
       foreach ($what as $item) {
4174
-        $str = preg_replace('/(' . preg_quote($item, '/') . ')+/', $item, $str);
4174
+        $str = preg_replace('/('.preg_quote($item, '/').')+/', $item, $str);
4175 4175
       }
4176 4176
     }
4177 4177
 
@@ -4271,7 +4271,7 @@  discard block
 block discarded – undo
4271 4271
   {
4272 4272
     static $rxClassCache = array();
4273 4273
 
4274
-    $cacheKey = $s . $class;
4274
+    $cacheKey = $s.$class;
4275 4275
 
4276 4276
     if (isset($rxClassCache[$cacheKey])) {
4277 4277
       return $rxClassCache[$cacheKey];
@@ -4282,7 +4282,7 @@  discard block
 block discarded – undo
4282 4282
     /** @noinspection SuspiciousLoopInspection */
4283 4283
     foreach (self::str_split($s) as $s) {
4284 4284
       if ('-' === $s) {
4285
-        $class[0] = '-' . $class[0];
4285
+        $class[0] = '-'.$class[0];
4286 4286
       } elseif (!isset($s[2])) {
4287 4287
         $class[0] .= preg_quote($s, '/');
4288 4288
       } elseif (1 === self::strlen($s)) {
@@ -4292,12 +4292,12 @@  discard block
 block discarded – undo
4292 4292
       }
4293 4293
     }
4294 4294
 
4295
-    $class[0] = '[' . $class[0] . ']';
4295
+    $class[0] = '['.$class[0].']';
4296 4296
 
4297 4297
     if (1 === count($class)) {
4298 4298
       $return = $class[0];
4299 4299
     } else {
4300
-      $return = '(?:' . implode('|', $class) . ')';
4300
+      $return = '(?:'.implode('|', $class).')';
4301 4301
     }
4302 4302
 
4303 4303
     $rxClassCache[$cacheKey] = $return;
@@ -4311,7 +4311,7 @@  discard block
 block discarded – undo
4311 4311
   public static function showSupport()
4312 4312
   {
4313 4313
     foreach (self::$support as $utf8Support) {
4314
-      echo $utf8Support . "\n<br>";
4314
+      echo $utf8Support."\n<br>";
4315 4315
     }
4316 4316
   }
4317 4317
 
@@ -4335,7 +4335,7 @@  discard block
 block discarded – undo
4335 4335
       }
4336 4336
     }
4337 4337
 
4338
-    return '&#' . self::ord($chr) . ';';
4338
+    return '&#'.self::ord($chr).';';
4339 4339
   }
4340 4340
 
4341 4341
   /**
@@ -4384,19 +4384,19 @@  discard block
 block discarded – undo
4384 4384
           $ret[] = $str[$i];
4385 4385
         } elseif ((($str[$i] & "\xE0") === "\xC0") && isset($str[$i + 1])) {
4386 4386
           if (($str[$i + 1] & "\xC0") === "\x80") {
4387
-            $ret[] = $str[$i] . $str[$i + 1];
4387
+            $ret[] = $str[$i].$str[$i + 1];
4388 4388
 
4389 4389
             $i++;
4390 4390
           }
4391 4391
         } elseif ((($str[$i] & "\xF0") === "\xE0") && isset($str[$i + 2])) {
4392 4392
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80")) {
4393
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2];
4393
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2];
4394 4394
 
4395 4395
             $i += 2;
4396 4396
           }
4397 4397
         } elseif ((($str[$i] & "\xF8") === "\xF0") && isset($str[$i + 3])) {
4398 4398
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80") && (($str[$i + 3] & "\xC0") === "\x80")) {
4399
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2] . $str[$i + 3];
4399
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2].$str[$i + 3];
4400 4400
 
4401 4401
             $i += 3;
4402 4402
           }
@@ -4530,7 +4530,7 @@  discard block
 block discarded – undo
4530 4530
       if ('' === $s .= '') {
4531 4531
         $s = '/^(?<=.)$/';
4532 4532
       } else {
4533
-        $s = '/' . preg_quote($s, '/') . '/ui';
4533
+        $s = '/'.preg_quote($s, '/').'/ui';
4534 4534
       }
4535 4535
     }
4536 4536
 
@@ -4564,7 +4564,7 @@  discard block
 block discarded – undo
4564 4564
     }
4565 4565
 
4566 4566
     if (self::substr($str, $length - 1, 1) === ' ') {
4567
-      return self::substr($str, 0, $length - 1) . $strAddOn;
4567
+      return self::substr($str, 0, $length - 1).$strAddOn;
4568 4568
     }
4569 4569
 
4570 4570
     $str = self::substr($str, 0, $length);
@@ -4573,9 +4573,9 @@  discard block
 block discarded – undo
4573 4573
     $new_str = implode(' ', $array);
4574 4574
 
4575 4575
     if ($new_str === '') {
4576
-      $str = self::substr($str, 0, $length - 1) . $strAddOn;
4576
+      $str = self::substr($str, 0, $length - 1).$strAddOn;
4577 4577
     } else {
4578
-      $str = $new_str . $strAddOn;
4578
+      $str = $new_str.$strAddOn;
4579 4579
     }
4580 4580
 
4581 4581
     return $str;
@@ -4621,7 +4621,7 @@  discard block
 block discarded – undo
4621 4621
           $pre = '';
4622 4622
       }
4623 4623
 
4624
-      return $pre . $input . $post;
4624
+      return $pre.$input.$post;
4625 4625
     }
4626 4626
 
4627 4627
     return $input;
@@ -4755,7 +4755,7 @@  discard block
 block discarded – undo
4755 4755
         $a[] = \grapheme_extract($str, 1, GRAPHEME_EXTR_COUNT, $p, $p);
4756 4756
       }
4757 4757
     } else {
4758
-      preg_match_all('/' . Grapheme::GRAPHEME_CLUSTER_RX . '/u', $str, $a);
4758
+      preg_match_all('/'.Grapheme::GRAPHEME_CLUSTER_RX.'/u', $str, $a);
4759 4759
       $a = $a[0];
4760 4760
     }
4761 4761
 
@@ -4896,7 +4896,7 @@  discard block
 block discarded – undo
4896 4896
 
4897 4897
       $bank = $ord >> 8;
4898 4898
       if (!array_key_exists($bank, (array)$UTF8_TO_ASCII)) {
4899
-        $bankfile = __DIR__ . '/data/' . sprintf('x%02x', $bank) . '.php';
4899
+        $bankfile = __DIR__.'/data/'.sprintf('x%02x', $bank).'.php';
4900 4900
         if (file_exists($bankfile)) {
4901 4901
           /** @noinspection PhpIncludeInspection */
4902 4902
           require $bankfile;
@@ -4986,7 +4986,7 @@  discard block
 block discarded – undo
4986 4986
    */
4987 4987
   public static function strcmp($str1, $str2)
4988 4988
   {
4989
-    return $str1 . '' === $str2 . '' ? 0 : strcmp(
4989
+    return $str1.'' === $str2.'' ? 0 : strcmp(
4990 4990
         \Normalizer::normalize($str1, \Normalizer::NFD),
4991 4991
         \Normalizer::normalize($str2, \Normalizer::NFD)
4992 4992
     );
@@ -5014,7 +5014,7 @@  discard block
 block discarded – undo
5014 5014
       $str = (string)$str;
5015 5015
     }
5016 5016
 
5017
-    if (preg_match('/^(.*?)' . self::rxClass($charList) . '/us', $str, $length)) {
5017
+    if (preg_match('/^(.*?)'.self::rxClass($charList).'/us', $str, $length)) {
5018 5018
       /** @noinspection OffsetOperationsInspection */
5019 5019
       return self::strlen($length[1]);
5020 5020
     } else {
@@ -5230,7 +5230,7 @@  discard block
 block discarded – undo
5230 5230
    */
5231 5231
   public static function strnatcmp($str1, $str2)
5232 5232
   {
5233
-    return $str1 . '' === $str2 . '' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
5233
+    return $str1.'' === $str2.'' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
5234 5234
   }
5235 5235
 
5236 5236
   /**
@@ -5311,7 +5311,7 @@  discard block
 block discarded – undo
5311 5311
       return false;
5312 5312
     }
5313 5313
 
5314
-    if (preg_match('/' . self::rxClass($char_list) . '/us', $haystack, $m)) {
5314
+    if (preg_match('/'.self::rxClass($char_list).'/us', $haystack, $m)) {
5315 5315
       return substr($haystack, strpos($haystack, $m[0]));
5316 5316
     } else {
5317 5317
       return false;
@@ -5584,7 +5584,7 @@  discard block
 block discarded – undo
5584 5584
       $str = self::substr($str, $offset, $length);
5585 5585
     }
5586 5586
 
5587
-    return preg_match('/^' . self::rxClass($mask) . '+/u', $str, $str) ? self::strlen($str[0]) : 0;
5587
+    return preg_match('/^'.self::rxClass($mask).'+/u', $str, $str) ? self::strlen($str[0]) : 0;
5588 5588
   }
5589 5589
 
5590 5590
   /**
@@ -6021,7 +6021,7 @@  discard block
 block discarded – undo
6021 6021
 
6022 6022
     $strSwappedCase = preg_replace_callback(
6023 6023
         '/[\S]/u',
6024
-        function ($match) use ($encoding) {
6024
+        function($match) use ($encoding) {
6025 6025
           $marchToUpper = UTF8::strtoupper($match[0], $encoding);
6026 6026
 
6027 6027
           if ($match[0] === $marchToUpper) {
@@ -6230,40 +6230,40 @@  discard block
 block discarded – undo
6230 6230
         if ($c1 >= "\xc0" & $c1 <= "\xdf") { // looks like 2 bytes UTF8
6231 6231
 
6232 6232
           if ($c2 >= "\x80" && $c2 <= "\xbf") { // yeah, almost sure it's UTF8 already
6233
-            $buf .= $c1 . $c2;
6233
+            $buf .= $c1.$c2;
6234 6234
             $i++;
6235 6235
           } else { // not valid UTF8 - convert it
6236 6236
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
6237 6237
             $cc2 = ($c1 & "\x3f") | "\x80";
6238
-            $buf .= $cc1 . $cc2;
6238
+            $buf .= $cc1.$cc2;
6239 6239
           }
6240 6240
 
6241 6241
         } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
6242 6242
 
6243 6243
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
6244
-            $buf .= $c1 . $c2 . $c3;
6244
+            $buf .= $c1.$c2.$c3;
6245 6245
             $i += 2;
6246 6246
           } else { // not valid UTF8 - convert it
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 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
6253 6253
 
6254 6254
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
6255
-            $buf .= $c1 . $c2 . $c3 . $c4;
6255
+            $buf .= $c1.$c2.$c3.$c4;
6256 6256
             $i += 3;
6257 6257
           } else { // not valid UTF8 - convert it
6258 6258
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
6259 6259
             $cc2 = ($c1 & "\x3f") | "\x80";
6260
-            $buf .= $cc1 . $cc2;
6260
+            $buf .= $cc1.$cc2;
6261 6261
           }
6262 6262
 
6263 6263
         } else { // doesn't look like UTF8, but should be converted
6264 6264
           $cc1 = (chr(ord($c1) / 64) | "\xc0");
6265 6265
           $cc2 = (($c1 & "\x3f") | "\x80");
6266
-          $buf .= $cc1 . $cc2;
6266
+          $buf .= $cc1.$cc2;
6267 6267
         }
6268 6268
 
6269 6269
       } elseif (($c1 & "\xc0") === "\x80") { // needs conversion
@@ -6274,7 +6274,7 @@  discard block
 block discarded – undo
6274 6274
         } else {
6275 6275
           $cc1 = (chr($ordC1 / 64) | "\xc0");
6276 6276
           $cc2 = (($c1 & "\x3f") | "\x80");
6277
-          $buf .= $cc1 . $cc2;
6277
+          $buf .= $cc1.$cc2;
6278 6278
         }
6279 6279
 
6280 6280
       } else { // it doesn't need conversion
@@ -6287,7 +6287,7 @@  discard block
 block discarded – undo
6287 6287
     // decode unicode escape sequences
6288 6288
     $buf = preg_replace_callback(
6289 6289
         '/\\\\u([0-9a-f]{4})/i',
6290
-        function ($match) {
6290
+        function($match) {
6291 6291
           return \mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
6292 6292
         },
6293 6293
         $buf
@@ -6296,7 +6296,7 @@  discard block
 block discarded – undo
6296 6296
     // decode UTF-8 codepoints
6297 6297
     $buf = preg_replace_callback(
6298 6298
         '/&#\d{2,4};/',
6299
-        function ($match) {
6299
+        function($match) {
6300 6300
           return \mb_convert_encoding($match[0], 'UTF-8', 'HTML-ENTITIES');
6301 6301
         },
6302 6302
         $buf
@@ -6371,7 +6371,7 @@  discard block
 block discarded – undo
6371 6371
    */
6372 6372
   public static function ucfirst($str)
6373 6373
   {
6374
-    return self::strtoupper(self::substr($str, 0, 1)) . self::substr($str, 1);
6374
+    return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
6375 6375
   }
6376 6376
 
6377 6377
   /**
@@ -6820,7 +6820,7 @@  discard block
 block discarded – undo
6820 6820
       return '';
6821 6821
     }
6822 6822
 
6823
-    preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $str, $matches);
6823
+    preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $str, $matches);
6824 6824
 
6825 6825
     if (
6826 6826
         !isset($matches[0])
@@ -6830,7 +6830,7 @@  discard block
 block discarded – undo
6830 6830
       return $str;
6831 6831
     }
6832 6832
 
6833
-    return self::rtrim($matches[0]) . $strAddOn;
6833
+    return self::rtrim($matches[0]).$strAddOn;
6834 6834
   }
6835 6835
 
6836 6836
   /**
@@ -6912,7 +6912,7 @@  discard block
 block discarded – undo
6912 6912
       $strReturn .= $break;
6913 6913
     }
6914 6914
 
6915
-    return $strReturn . implode('', $chars);
6915
+    return $strReturn.implode('', $chars);
6916 6916
   }
6917 6917
 
6918 6918
   /**
Please login to merge, or discard this patch.