Completed
Push — master ( ec785e...ab9775 )
by Lars
17:39
created
src/voku/helper/UTF8.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1703,7 +1703,7 @@  discard block
 block discarded – undo
1703 1703
    * @param string $encodingLabel ISO-8859-1 || UTF-8
1704 1704
    * @param string $str
1705 1705
    *
1706
-   * @return false|string Will return false on error.
1706
+   * @return string Will return false on error.
1707 1707
    */
1708 1708
   public static function encode($encodingLabel, $str)
1709 1709
   {
@@ -4843,7 +4843,7 @@  discard block
 block discarded – undo
4843 4843
    * @param int    $start
4844 4844
    * @param int    $len
4845 4845
    *
4846
-   * @return int|null
4846
+   * @return integer
4847 4847
    */
4848 4848
   public static function strspn($s, $mask, $start = 0, $len = 2147483647)
4849 4849
   {
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
   public static function add_bom_to_string($str)
365 365
   {
366 366
     if (!self::is_bom(substr($str, 0, 3))) {
367
-      $str = self::bom() . $str;
367
+      $str = self::bom().$str;
368 368
     }
369 369
 
370 370
     return $str;
@@ -1684,7 +1684,7 @@  discard block
 block discarded – undo
1684 1684
     self::checkForSupport();
1685 1685
 
1686 1686
     return mb_convert_encoding(
1687
-        '&#x' . dechex($code) . ';',
1687
+        '&#x'.dechex($code).';',
1688 1688
         'UTF-8',
1689 1689
         'HTML-ENTITIES'
1690 1690
     );
@@ -1902,7 +1902,7 @@  discard block
 block discarded – undo
1902 1902
           if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) {
1903 1903
             // Prevent leading combining chars
1904 1904
             // for NFC-safe concatenations.
1905
-            $var = $leading_combining . $var;
1905
+            $var = $leading_combining.$var;
1906 1906
           }
1907 1907
         }
1908 1908
         break;
@@ -2169,7 +2169,7 @@  discard block
 block discarded – undo
2169 2169
    */
2170 2170
   protected static function getData($file)
2171 2171
   {
2172
-    $file = __DIR__ . '/data/' . $file . '.ser';
2172
+    $file = __DIR__.'/data/'.$file.'.ser';
2173 2173
     if (file_exists($file)) {
2174 2174
       return unserialize(file_get_contents($file));
2175 2175
     } else {
@@ -2634,9 +2634,9 @@  discard block
 block discarded – undo
2634 2634
     if (ctype_digit((string)$int)) {
2635 2635
       $hex = dechex((int)$int);
2636 2636
 
2637
-      $hex = (strlen($hex) < 4 ? substr('0000' . $hex, -4) : $hex);
2637
+      $hex = (strlen($hex) < 4 ? substr('0000'.$hex, -4) : $hex);
2638 2638
 
2639
-      return $pfix . $hex;
2639
+      return $pfix.$hex;
2640 2640
     }
2641 2641
 
2642 2642
     return '';
@@ -3173,7 +3173,7 @@  discard block
 block discarded – undo
3173 3173
    */
3174 3174
   public static function lcfirst($str)
3175 3175
   {
3176
-    return self::strtolower(self::substr($str, 0, 1)) . self::substr($str, 1);
3176
+    return self::strtolower(self::substr($str, 0, 1)).self::substr($str, 1);
3177 3177
   }
3178 3178
 
3179 3179
   /**
@@ -3561,7 +3561,7 @@  discard block
 block discarded – undo
3561 3561
 
3562 3562
     if (is_array($what)) {
3563 3563
       foreach ($what as $item) {
3564
-        $str = preg_replace('/(' . preg_quote($item, '/') . ')+/', $item, $str);
3564
+        $str = preg_replace('/('.preg_quote($item, '/').')+/', $item, $str);
3565 3565
       }
3566 3566
     }
3567 3567
 
@@ -3660,7 +3660,7 @@  discard block
 block discarded – undo
3660 3660
   {
3661 3661
     static $rxClassCache = array();
3662 3662
 
3663
-    $cacheKey = $s . $class;
3663
+    $cacheKey = $s.$class;
3664 3664
 
3665 3665
     if (isset($rxClassCache[$cacheKey])) {
3666 3666
       return $rxClassCache[$cacheKey];
@@ -3670,7 +3670,7 @@  discard block
 block discarded – undo
3670 3670
 
3671 3671
     foreach (self::str_split($s) as $s) {
3672 3672
       if ('-' === $s) {
3673
-        $class[0] = '-' . $class[0];
3673
+        $class[0] = '-'.$class[0];
3674 3674
       } elseif (!isset($s[2])) {
3675 3675
         $class[0] .= preg_quote($s, '/');
3676 3676
       } elseif (1 === self::strlen($s)) {
@@ -3680,12 +3680,12 @@  discard block
 block discarded – undo
3680 3680
       }
3681 3681
     }
3682 3682
 
3683
-    $class[0] = '[' . $class[0] . ']';
3683
+    $class[0] = '['.$class[0].']';
3684 3684
 
3685 3685
     if (1 === count($class)) {
3686 3686
       $return = $class[0];
3687 3687
     } else {
3688
-      $return = '(?:' . implode('|', $class) . ')';
3688
+      $return = '(?:'.implode('|', $class).')';
3689 3689
     }
3690 3690
 
3691 3691
     $rxClassCache[$cacheKey] = $return;
@@ -3699,7 +3699,7 @@  discard block
 block discarded – undo
3699 3699
   public static function showSupport()
3700 3700
   {
3701 3701
     foreach (self::$support as $utf8Support) {
3702
-      echo $utf8Support . "\n<br>";
3702
+      echo $utf8Support."\n<br>";
3703 3703
     }
3704 3704
   }
3705 3705
 
@@ -3716,7 +3716,7 @@  discard block
 block discarded – undo
3716 3716
       return '';
3717 3717
     }
3718 3718
 
3719
-    return '&#' . self::ord($chr) . ';';
3719
+    return '&#'.self::ord($chr).';';
3720 3720
   }
3721 3721
 
3722 3722
   /**
@@ -3765,19 +3765,19 @@  discard block
 block discarded – undo
3765 3765
           $ret[] = $str[$i];
3766 3766
         } elseif ((($str[$i] & "\xE0") === "\xC0") && isset($str[$i + 1])) {
3767 3767
           if (($str[$i + 1] & "\xC0") === "\x80") {
3768
-            $ret[] = $str[$i] . $str[$i + 1];
3768
+            $ret[] = $str[$i].$str[$i + 1];
3769 3769
 
3770 3770
             $i++;
3771 3771
           }
3772 3772
         } elseif ((($str[$i] & "\xF0") === "\xE0") && isset($str[$i + 2])) {
3773 3773
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80")) {
3774
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2];
3774
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2];
3775 3775
 
3776 3776
             $i += 2;
3777 3777
           }
3778 3778
         } elseif ((($str[$i] & "\xF8") === "\xF0") && isset($str[$i + 3])) {
3779 3779
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80") && (($str[$i + 3] & "\xC0") === "\x80")) {
3780
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2] . $str[$i + 3];
3780
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2].$str[$i + 3];
3781 3781
 
3782 3782
             $i += 3;
3783 3783
           }
@@ -3897,7 +3897,7 @@  discard block
 block discarded – undo
3897 3897
       if ('' === $s .= '') {
3898 3898
         $s = '/^(?<=.)$/';
3899 3899
       } else {
3900
-        $s = '/' . preg_quote($s, '/') . '/ui';
3900
+        $s = '/'.preg_quote($s, '/').'/ui';
3901 3901
       }
3902 3902
     }
3903 3903
 
@@ -3929,7 +3929,7 @@  discard block
 block discarded – undo
3929 3929
     }
3930 3930
 
3931 3931
     if (self::substr($str, $length - 1, 1) === ' ') {
3932
-      return self::substr($str, 0, $length - 1) . $strAddOn;
3932
+      return self::substr($str, 0, $length - 1).$strAddOn;
3933 3933
     }
3934 3934
 
3935 3935
     $str = self::substr($str, 0, $length);
@@ -3938,9 +3938,9 @@  discard block
 block discarded – undo
3938 3938
     $new_str = implode(' ', $array);
3939 3939
 
3940 3940
     if ($new_str == '') {
3941
-      $str = self::substr($str, 0, $length - 1) . $strAddOn;
3941
+      $str = self::substr($str, 0, $length - 1).$strAddOn;
3942 3942
     } else {
3943
-      $str = $new_str . $strAddOn;
3943
+      $str = $new_str.$strAddOn;
3944 3944
     }
3945 3945
 
3946 3946
     return $str;
@@ -3986,7 +3986,7 @@  discard block
 block discarded – undo
3986 3986
           $pre = '';
3987 3987
       }
3988 3988
 
3989
-      return $pre . $input . $post;
3989
+      return $pre.$input.$post;
3990 3990
     }
3991 3991
 
3992 3992
     return $input;
@@ -4121,7 +4121,7 @@  discard block
 block discarded – undo
4121 4121
         $a[] = grapheme_extract($str, 1, GRAPHEME_EXTR_COUNT, $p, $p);
4122 4122
       }
4123 4123
     } else {
4124
-      preg_match_all('/' . Grapheme::GRAPHEME_CLUSTER_RX . '/u', $str, $a);
4124
+      preg_match_all('/'.Grapheme::GRAPHEME_CLUSTER_RX.'/u', $str, $a);
4125 4125
       $a = $a[0];
4126 4126
     }
4127 4127
 
@@ -4262,7 +4262,7 @@  discard block
 block discarded – undo
4262 4262
 
4263 4263
       $bank = $ord >> 8;
4264 4264
       if (!array_key_exists($bank, (array)$UTF8_TO_ASCII)) {
4265
-        $bankfile = __DIR__ . '/data/' . sprintf('x%02x', $bank) . '.php';
4265
+        $bankfile = __DIR__.'/data/'.sprintf('x%02x', $bank).'.php';
4266 4266
         if (file_exists($bankfile)) {
4267 4267
           /** @noinspection PhpIncludeInspection */
4268 4268
           include $bankfile;
@@ -4342,7 +4342,7 @@  discard block
 block discarded – undo
4342 4342
    */
4343 4343
   public static function strcmp($str1, $str2)
4344 4344
   {
4345
-    return $str1 . '' === $str2 . '' ? 0 : strcmp(
4345
+    return $str1.'' === $str2.'' ? 0 : strcmp(
4346 4346
         Normalizer::normalize($str1, Normalizer::NFD),
4347 4347
         Normalizer::normalize($str2, Normalizer::NFD)
4348 4348
     );
@@ -4371,7 +4371,7 @@  discard block
 block discarded – undo
4371 4371
     }
4372 4372
 
4373 4373
     /* @var $len array */
4374
-    if (preg_match('/^(.*?)' . self::rxClass($charlist) . '/us', $str, $len)) {
4374
+    if (preg_match('/^(.*?)'.self::rxClass($charlist).'/us', $str, $len)) {
4375 4375
       return self::strlen($len[1]);
4376 4376
     } else {
4377 4377
       return self::strlen($str);
@@ -4568,7 +4568,7 @@  discard block
 block discarded – undo
4568 4568
    */
4569 4569
   public static function strnatcmp($str1, $str2)
4570 4570
   {
4571
-    return $str1 . '' === $str2 . '' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
4571
+    return $str1.'' === $str2.'' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
4572 4572
   }
4573 4573
 
4574 4574
   /**
@@ -4611,7 +4611,7 @@  discard block
 block discarded – undo
4611 4611
    */
4612 4612
   public static function strpbrk($s, $charList)
4613 4613
   {
4614
-    if (preg_match('/' . self::rxClass($charList) . '/us', $s, $m)) {
4614
+    if (preg_match('/'.self::rxClass($charList).'/us', $s, $m)) {
4615 4615
       return substr($s, strpos($s, $m[0]));
4616 4616
     } else {
4617 4617
       return false;
@@ -4880,7 +4880,7 @@  discard block
 block discarded – undo
4880 4880
       $s = self::substr($s, $start, $len);
4881 4881
     }
4882 4882
 
4883
-    return preg_match('/^' . self::rxClass($mask) . '+/u', $s, $s) ? self::strlen($s[0]) : 0;
4883
+    return preg_match('/^'.self::rxClass($mask).'+/u', $s, $s) ? self::strlen($s[0]) : 0;
4884 4884
   }
4885 4885
 
4886 4886
   /**
@@ -5287,7 +5287,7 @@  discard block
 block discarded – undo
5287 5287
 
5288 5288
     $strSwappedCase = preg_replace_callback(
5289 5289
         '/[\S]/u',
5290
-        function ($match) use ($encoding) {
5290
+        function($match) use ($encoding) {
5291 5291
           $marchToUpper = UTF8::strtoupper($match[0], $encoding);
5292 5292
 
5293 5293
           if ($match[0] == $marchToUpper) {
@@ -5496,40 +5496,40 @@  discard block
 block discarded – undo
5496 5496
         if ($c1 >= "\xc0" & $c1 <= "\xdf") { // looks like 2 bytes UTF8
5497 5497
 
5498 5498
           if ($c2 >= "\x80" && $c2 <= "\xbf") { // yeah, almost sure it's UTF8 already
5499
-            $buf .= $c1 . $c2;
5499
+            $buf .= $c1.$c2;
5500 5500
             $i++;
5501 5501
           } else { // not valid UTF8 - convert it
5502 5502
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
5503 5503
             $cc2 = ($c1 & "\x3f") | "\x80";
5504
-            $buf .= $cc1 . $cc2;
5504
+            $buf .= $cc1.$cc2;
5505 5505
           }
5506 5506
 
5507 5507
         } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
5508 5508
 
5509 5509
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
5510
-            $buf .= $c1 . $c2 . $c3;
5510
+            $buf .= $c1.$c2.$c3;
5511 5511
             $i += 2;
5512 5512
           } else { // not valid UTF8 - convert it
5513 5513
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
5514 5514
             $cc2 = ($c1 & "\x3f") | "\x80";
5515
-            $buf .= $cc1 . $cc2;
5515
+            $buf .= $cc1.$cc2;
5516 5516
           }
5517 5517
 
5518 5518
         } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
5519 5519
 
5520 5520
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
5521
-            $buf .= $c1 . $c2 . $c3 . $c4;
5521
+            $buf .= $c1.$c2.$c3.$c4;
5522 5522
             $i += 3;
5523 5523
           } else { // not valid UTF8 - convert it
5524 5524
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
5525 5525
             $cc2 = ($c1 & "\x3f") | "\x80";
5526
-            $buf .= $cc1 . $cc2;
5526
+            $buf .= $cc1.$cc2;
5527 5527
           }
5528 5528
 
5529 5529
         } else { // doesn't look like UTF8, but should be converted
5530 5530
           $cc1 = (chr(ord($c1) / 64) | "\xc0");
5531 5531
           $cc2 = (($c1 & "\x3f") | "\x80");
5532
-          $buf .= $cc1 . $cc2;
5532
+          $buf .= $cc1.$cc2;
5533 5533
         }
5534 5534
 
5535 5535
       } elseif (($c1 & "\xc0") == "\x80") { // needs conversion
@@ -5540,7 +5540,7 @@  discard block
 block discarded – undo
5540 5540
         } else {
5541 5541
           $cc1 = (chr($ordC1 / 64) | "\xc0");
5542 5542
           $cc2 = (($c1 & "\x3f") | "\x80");
5543
-          $buf .= $cc1 . $cc2;
5543
+          $buf .= $cc1.$cc2;
5544 5544
         }
5545 5545
 
5546 5546
       } else { // it doesn't need conversion
@@ -5553,7 +5553,7 @@  discard block
 block discarded – undo
5553 5553
     // decode unicode escape sequences
5554 5554
     $buf = preg_replace_callback(
5555 5555
         '/\\\\u([0-9a-f]{4})/i',
5556
-        function ($match) {
5556
+        function($match) {
5557 5557
           return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
5558 5558
         },
5559 5559
         $buf
@@ -5562,7 +5562,7 @@  discard block
 block discarded – undo
5562 5562
     // decode UTF-8 codepoints
5563 5563
     $buf = preg_replace_callback(
5564 5564
         '/&#\d{2,4};/',
5565
-        function ($match) {
5565
+        function($match) {
5566 5566
           return mb_convert_encoding($match[0], 'UTF-8', 'HTML-ENTITIES');
5567 5567
         },
5568 5568
         $buf
@@ -5633,7 +5633,7 @@  discard block
 block discarded – undo
5633 5633
    */
5634 5634
   public static function ucfirst($str)
5635 5635
   {
5636
-    return self::strtoupper(self::substr($str, 0, 1)) . self::substr($str, 1);
5636
+    return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
5637 5637
   }
5638 5638
 
5639 5639
   /**
@@ -6076,7 +6076,7 @@  discard block
 block discarded – undo
6076 6076
 
6077 6077
     $words = (int)$words;
6078 6078
 
6079
-    preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $str, $matches);
6079
+    preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $str, $matches);
6080 6080
 
6081 6081
     if (
6082 6082
         !isset($matches[0])
@@ -6086,7 +6086,7 @@  discard block
 block discarded – undo
6086 6086
       return $str;
6087 6087
     }
6088 6088
 
6089
-    return self::rtrim($matches[0]) . $strAddOn;
6089
+    return self::rtrim($matches[0]).$strAddOn;
6090 6090
   }
6091 6091
 
6092 6092
   /**
@@ -6153,7 +6153,7 @@  discard block
 block discarded – undo
6153 6153
       $str .= $break;
6154 6154
     }
6155 6155
 
6156
-    return $str . implode('', $chars);
6156
+    return $str.implode('', $chars);
6157 6157
   }
6158 6158
 
6159 6159
   /**
Please login to merge, or discard this patch.
src/voku/helper/Bootup.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     if (!preg_match('//u', urldecode($uri))) {
92 92
       $uri = preg_replace_callback(
93 93
           '/[\x80-\xFF]+/',
94
-          function ($m) {
94
+          function($m) {
95 95
             return urlencode($m[0]);
96 96
           },
97 97
           $uri
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
       $uri = preg_replace_callback(
101 101
           '/(?:%[89A-F][0-9A-F])+/i',
102
-          function ($m) {
102
+          function($m) {
103 103
             return urlencode(UTF8::encode('UTF-8', urldecode($m[0])));
104 104
           },
105 105
           $uri
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
         // Use ob_start() to buffer content and avoid problem of headers already sent...
110 110
         if (headers_sent() === false) {
111 111
           $severProtocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1');
112
-          header($severProtocol . ' 301 Moved Permanently');
113
-          header('Location: ' . $uri);
112
+          header($severProtocol.' 301 Moved Permanently');
113
+          header('Location: '.$uri);
114 114
           exit();
115 115
         }
116 116
       }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
       if ($s[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $s)) {
198 198
         // Prevent leading combining chars
199 199
         // for NFC-safe concatenations.
200
-        $s = $leading_combining . $s;
200
+        $s = $leading_combining.$s;
201 201
       }
202 202
     }
203 203
 
Please login to merge, or discard this patch.