Completed
Pull Request — master (#29)
by Lars
11:28
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
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
   public static function add_bom_to_string($str)
820 820
   {
821 821
     if (!self::is_bom(substr($str, 0, 3))) {
822
-      $str = self::bom() . $str;
822
+      $str = self::bom().$str;
823 823
     }
824 824
 
825 825
     return $str;
@@ -2135,7 +2135,7 @@  discard block
 block discarded – undo
2135 2135
     self::checkForSupport();
2136 2136
 
2137 2137
     return mb_convert_encoding(
2138
-        '&#x' . dechex($code) . ';',
2138
+        '&#x'.dechex($code).';',
2139 2139
         'UTF-8',
2140 2140
         'HTML-ENTITIES'
2141 2141
     );
@@ -2353,7 +2353,7 @@  discard block
 block discarded – undo
2353 2353
           if ($var[0] >= "\x80" && isset($n[0], $leading_combining[0]) && preg_match('/^\p{Mn}/u', $var)) {
2354 2354
             // Prevent leading combining chars
2355 2355
             // for NFC-safe concatenations.
2356
-            $var = $leading_combining . $var;
2356
+            $var = $leading_combining.$var;
2357 2357
           }
2358 2358
         }
2359 2359
         break;
@@ -2620,7 +2620,7 @@  discard block
 block discarded – undo
2620 2620
    */
2621 2621
   protected static function getData($file)
2622 2622
   {
2623
-    $file = __DIR__ . '/data/' . $file . '.php';
2623
+    $file = __DIR__.'/data/'.$file.'.php';
2624 2624
     if (file_exists($file)) {
2625 2625
       /** @noinspection PhpIncludeInspection */
2626 2626
       return require $file;
@@ -3086,9 +3086,9 @@  discard block
 block discarded – undo
3086 3086
     if (ctype_digit((string)$int)) {
3087 3087
       $hex = dechex((int)$int);
3088 3088
 
3089
-      $hex = (strlen($hex) < 4 ? substr('0000' . $hex, -4) : $hex);
3089
+      $hex = (strlen($hex) < 4 ? substr('0000'.$hex, -4) : $hex);
3090 3090
 
3091
-      return $pfix . $hex;
3091
+      return $pfix.$hex;
3092 3092
     }
3093 3093
 
3094 3094
     return '';
@@ -3625,7 +3625,7 @@  discard block
 block discarded – undo
3625 3625
    */
3626 3626
   public static function lcfirst($str)
3627 3627
   {
3628
-    return self::strtolower(self::substr($str, 0, 1)) . self::substr($str, 1);
3628
+    return self::strtolower(self::substr($str, 0, 1)).self::substr($str, 1);
3629 3629
   }
3630 3630
 
3631 3631
   /**
@@ -4009,7 +4009,7 @@  discard block
 block discarded – undo
4009 4009
 
4010 4010
     if (is_array($what)) {
4011 4011
       foreach ($what as $item) {
4012
-        $str = preg_replace('/(' . preg_quote($item, '/') . ')+/', $item, $str);
4012
+        $str = preg_replace('/('.preg_quote($item, '/').')+/', $item, $str);
4013 4013
       }
4014 4014
     }
4015 4015
 
@@ -4108,7 +4108,7 @@  discard block
 block discarded – undo
4108 4108
   {
4109 4109
     static $rxClassCache = array();
4110 4110
 
4111
-    $cacheKey = $s . $class;
4111
+    $cacheKey = $s.$class;
4112 4112
 
4113 4113
     if (isset($rxClassCache[$cacheKey])) {
4114 4114
       return $rxClassCache[$cacheKey];
@@ -4118,7 +4118,7 @@  discard block
 block discarded – undo
4118 4118
 
4119 4119
     foreach (self::str_split($s) as $s) {
4120 4120
       if ('-' === $s) {
4121
-        $class[0] = '-' . $class[0];
4121
+        $class[0] = '-'.$class[0];
4122 4122
       } elseif (!isset($s[2])) {
4123 4123
         $class[0] .= preg_quote($s, '/');
4124 4124
       } elseif (1 === self::strlen($s)) {
@@ -4128,12 +4128,12 @@  discard block
 block discarded – undo
4128 4128
       }
4129 4129
     }
4130 4130
 
4131
-    $class[0] = '[' . $class[0] . ']';
4131
+    $class[0] = '['.$class[0].']';
4132 4132
 
4133 4133
     if (1 === count($class)) {
4134 4134
       $return = $class[0];
4135 4135
     } else {
4136
-      $return = '(?:' . implode('|', $class) . ')';
4136
+      $return = '(?:'.implode('|', $class).')';
4137 4137
     }
4138 4138
 
4139 4139
     $rxClassCache[$cacheKey] = $return;
@@ -4147,7 +4147,7 @@  discard block
 block discarded – undo
4147 4147
   public static function showSupport()
4148 4148
   {
4149 4149
     foreach (self::$support as $utf8Support) {
4150
-      echo $utf8Support . "\n<br>";
4150
+      echo $utf8Support."\n<br>";
4151 4151
     }
4152 4152
   }
4153 4153
 
@@ -4164,7 +4164,7 @@  discard block
 block discarded – undo
4164 4164
       return '';
4165 4165
     }
4166 4166
 
4167
-    return '&#' . self::ord($chr) . ';';
4167
+    return '&#'.self::ord($chr).';';
4168 4168
   }
4169 4169
 
4170 4170
   /**
@@ -4213,19 +4213,19 @@  discard block
 block discarded – undo
4213 4213
           $ret[] = $str[$i];
4214 4214
         } elseif ((($str[$i] & "\xE0") === "\xC0") && isset($str[$i + 1])) {
4215 4215
           if (($str[$i + 1] & "\xC0") === "\x80") {
4216
-            $ret[] = $str[$i] . $str[$i + 1];
4216
+            $ret[] = $str[$i].$str[$i + 1];
4217 4217
 
4218 4218
             $i++;
4219 4219
           }
4220 4220
         } elseif ((($str[$i] & "\xF0") === "\xE0") && isset($str[$i + 2])) {
4221 4221
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80")) {
4222
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2];
4222
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2];
4223 4223
 
4224 4224
             $i += 2;
4225 4225
           }
4226 4226
         } elseif ((($str[$i] & "\xF8") === "\xF0") && isset($str[$i + 3])) {
4227 4227
           if ((($str[$i + 1] & "\xC0") === "\x80") && (($str[$i + 2] & "\xC0") === "\x80") && (($str[$i + 3] & "\xC0") === "\x80")) {
4228
-            $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2] . $str[$i + 3];
4228
+            $ret[] = $str[$i].$str[$i + 1].$str[$i + 2].$str[$i + 3];
4229 4229
 
4230 4230
             $i += 3;
4231 4231
           }
@@ -4339,7 +4339,7 @@  discard block
 block discarded – undo
4339 4339
       if ('' === $s .= '') {
4340 4340
         $s = '/^(?<=.)$/';
4341 4341
       } else {
4342
-        $s = '/' . preg_quote($s, '/') . '/ui';
4342
+        $s = '/'.preg_quote($s, '/').'/ui';
4343 4343
       }
4344 4344
     }
4345 4345
 
@@ -4371,7 +4371,7 @@  discard block
 block discarded – undo
4371 4371
     }
4372 4372
 
4373 4373
     if (self::substr($str, $length - 1, 1) === ' ') {
4374
-      return self::substr($str, 0, $length - 1) . $strAddOn;
4374
+      return self::substr($str, 0, $length - 1).$strAddOn;
4375 4375
     }
4376 4376
 
4377 4377
     $str = self::substr($str, 0, $length);
@@ -4380,9 +4380,9 @@  discard block
 block discarded – undo
4380 4380
     $new_str = implode(' ', $array);
4381 4381
 
4382 4382
     if ($new_str == '') {
4383
-      $str = self::substr($str, 0, $length - 1) . $strAddOn;
4383
+      $str = self::substr($str, 0, $length - 1).$strAddOn;
4384 4384
     } else {
4385
-      $str = $new_str . $strAddOn;
4385
+      $str = $new_str.$strAddOn;
4386 4386
     }
4387 4387
 
4388 4388
     return $str;
@@ -4428,7 +4428,7 @@  discard block
 block discarded – undo
4428 4428
           $pre = '';
4429 4429
       }
4430 4430
 
4431
-      return $pre . $input . $post;
4431
+      return $pre.$input.$post;
4432 4432
     }
4433 4433
 
4434 4434
     return $input;
@@ -4563,7 +4563,7 @@  discard block
 block discarded – undo
4563 4563
         $a[] = grapheme_extract($str, 1, GRAPHEME_EXTR_COUNT, $p, $p);
4564 4564
       }
4565 4565
     } else {
4566
-      preg_match_all('/' . Grapheme::GRAPHEME_CLUSTER_RX . '/u', $str, $a);
4566
+      preg_match_all('/'.Grapheme::GRAPHEME_CLUSTER_RX.'/u', $str, $a);
4567 4567
       $a = $a[0];
4568 4568
     }
4569 4569
 
@@ -4704,7 +4704,7 @@  discard block
 block discarded – undo
4704 4704
 
4705 4705
       $bank = $ord >> 8;
4706 4706
       if (!array_key_exists($bank, (array)$UTF8_TO_ASCII)) {
4707
-        $bankfile = __DIR__ . '/data/' . sprintf('x%02x', $bank) . '.php';
4707
+        $bankfile = __DIR__.'/data/'.sprintf('x%02x', $bank).'.php';
4708 4708
         if (file_exists($bankfile)) {
4709 4709
           /** @noinspection PhpIncludeInspection */
4710 4710
           require $bankfile;
@@ -4784,7 +4784,7 @@  discard block
 block discarded – undo
4784 4784
    */
4785 4785
   public static function strcmp($str1, $str2)
4786 4786
   {
4787
-    return $str1 . '' === $str2 . '' ? 0 : strcmp(
4787
+    return $str1.'' === $str2.'' ? 0 : strcmp(
4788 4788
         Normalizer::normalize($str1, Normalizer::NFD),
4789 4789
         Normalizer::normalize($str2, Normalizer::NFD)
4790 4790
     );
@@ -4813,7 +4813,7 @@  discard block
 block discarded – undo
4813 4813
     }
4814 4814
 
4815 4815
     /* @var $len array */
4816
-    if (preg_match('/^(.*?)' . self::rxClass($charlist) . '/us', $str, $len)) {
4816
+    if (preg_match('/^(.*?)'.self::rxClass($charlist).'/us', $str, $len)) {
4817 4817
       return self::strlen($len[1]);
4818 4818
     } else {
4819 4819
       return self::strlen($str);
@@ -5010,7 +5010,7 @@  discard block
 block discarded – undo
5010 5010
    */
5011 5011
   public static function strnatcmp($str1, $str2)
5012 5012
   {
5013
-    return $str1 . '' === $str2 . '' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
5013
+    return $str1.'' === $str2.'' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2));
5014 5014
   }
5015 5015
 
5016 5016
   /**
@@ -5053,7 +5053,7 @@  discard block
 block discarded – undo
5053 5053
    */
5054 5054
   public static function strpbrk($s, $charList)
5055 5055
   {
5056
-    if (preg_match('/' . self::rxClass($charList) . '/us', $s, $m)) {
5056
+    if (preg_match('/'.self::rxClass($charList).'/us', $s, $m)) {
5057 5057
       return substr($s, strpos($s, $m[0]));
5058 5058
     } else {
5059 5059
       return false;
@@ -5322,7 +5322,7 @@  discard block
 block discarded – undo
5322 5322
       $s = self::substr($s, $start, $len);
5323 5323
     }
5324 5324
 
5325
-    return preg_match('/^' . self::rxClass($mask) . '+/u', $s, $s) ? self::strlen($s[0]) : 0;
5325
+    return preg_match('/^'.self::rxClass($mask).'+/u', $s, $s) ? self::strlen($s[0]) : 0;
5326 5326
   }
5327 5327
 
5328 5328
   /**
@@ -5729,7 +5729,7 @@  discard block
 block discarded – undo
5729 5729
 
5730 5730
     $strSwappedCase = preg_replace_callback(
5731 5731
         '/[\S]/u',
5732
-        function ($match) use ($encoding) {
5732
+        function($match) use ($encoding) {
5733 5733
           $marchToUpper = UTF8::strtoupper($match[0], $encoding);
5734 5734
 
5735 5735
           if ($match[0] == $marchToUpper) {
@@ -5938,40 +5938,40 @@  discard block
 block discarded – undo
5938 5938
         if ($c1 >= "\xc0" & $c1 <= "\xdf") { // looks like 2 bytes UTF8
5939 5939
 
5940 5940
           if ($c2 >= "\x80" && $c2 <= "\xbf") { // yeah, almost sure it's UTF8 already
5941
-            $buf .= $c1 . $c2;
5941
+            $buf .= $c1.$c2;
5942 5942
             $i++;
5943 5943
           } else { // not valid UTF8 - convert it
5944 5944
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
5945 5945
             $cc2 = ($c1 & "\x3f") | "\x80";
5946
-            $buf .= $cc1 . $cc2;
5946
+            $buf .= $cc1.$cc2;
5947 5947
           }
5948 5948
 
5949 5949
         } elseif ($c1 >= "\xe0" & $c1 <= "\xef") { // looks like 3 bytes UTF8
5950 5950
 
5951 5951
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf") { // yeah, almost sure it's UTF8 already
5952
-            $buf .= $c1 . $c2 . $c3;
5952
+            $buf .= $c1.$c2.$c3;
5953 5953
             $i += 2;
5954 5954
           } else { // not valid UTF8 - convert it
5955 5955
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
5956 5956
             $cc2 = ($c1 & "\x3f") | "\x80";
5957
-            $buf .= $cc1 . $cc2;
5957
+            $buf .= $cc1.$cc2;
5958 5958
           }
5959 5959
 
5960 5960
         } elseif ($c1 >= "\xf0" & $c1 <= "\xf7") { // looks like 4 bytes UTF8
5961 5961
 
5962 5962
           if ($c2 >= "\x80" && $c2 <= "\xbf" && $c3 >= "\x80" && $c3 <= "\xbf" && $c4 >= "\x80" && $c4 <= "\xbf") { // yeah, almost sure it's UTF8 already
5963
-            $buf .= $c1 . $c2 . $c3 . $c4;
5963
+            $buf .= $c1.$c2.$c3.$c4;
5964 5964
             $i += 3;
5965 5965
           } else { // not valid UTF8 - convert it
5966 5966
             $cc1 = (chr(ord($c1) / 64) | "\xc0");
5967 5967
             $cc2 = ($c1 & "\x3f") | "\x80";
5968
-            $buf .= $cc1 . $cc2;
5968
+            $buf .= $cc1.$cc2;
5969 5969
           }
5970 5970
 
5971 5971
         } else { // doesn't look like UTF8, but should be converted
5972 5972
           $cc1 = (chr(ord($c1) / 64) | "\xc0");
5973 5973
           $cc2 = (($c1 & "\x3f") | "\x80");
5974
-          $buf .= $cc1 . $cc2;
5974
+          $buf .= $cc1.$cc2;
5975 5975
         }
5976 5976
 
5977 5977
       } elseif (($c1 & "\xc0") == "\x80") { // needs conversion
@@ -5982,7 +5982,7 @@  discard block
 block discarded – undo
5982 5982
         } else {
5983 5983
           $cc1 = (chr($ordC1 / 64) | "\xc0");
5984 5984
           $cc2 = (($c1 & "\x3f") | "\x80");
5985
-          $buf .= $cc1 . $cc2;
5985
+          $buf .= $cc1.$cc2;
5986 5986
         }
5987 5987
 
5988 5988
       } else { // it doesn't need conversion
@@ -5995,7 +5995,7 @@  discard block
 block discarded – undo
5995 5995
     // decode unicode escape sequences
5996 5996
     $buf = preg_replace_callback(
5997 5997
         '/\\\\u([0-9a-f]{4})/i',
5998
-        function ($match) {
5998
+        function($match) {
5999 5999
           return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
6000 6000
         },
6001 6001
         $buf
@@ -6004,7 +6004,7 @@  discard block
 block discarded – undo
6004 6004
     // decode UTF-8 codepoints
6005 6005
     $buf = preg_replace_callback(
6006 6006
         '/&#\d{2,4};/',
6007
-        function ($match) {
6007
+        function($match) {
6008 6008
           return mb_convert_encoding($match[0], 'UTF-8', 'HTML-ENTITIES');
6009 6009
         },
6010 6010
         $buf
@@ -6075,7 +6075,7 @@  discard block
 block discarded – undo
6075 6075
    */
6076 6076
   public static function ucfirst($str)
6077 6077
   {
6078
-    return self::strtoupper(self::substr($str, 0, 1)) . self::substr($str, 1);
6078
+    return self::strtoupper(self::substr($str, 0, 1)).self::substr($str, 1);
6079 6079
   }
6080 6080
 
6081 6081
   /**
@@ -6518,7 +6518,7 @@  discard block
 block discarded – undo
6518 6518
 
6519 6519
     $words = (int)$words;
6520 6520
 
6521
-    preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $str, $matches);
6521
+    preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $str, $matches);
6522 6522
 
6523 6523
     if (
6524 6524
         !isset($matches[0])
@@ -6528,7 +6528,7 @@  discard block
 block discarded – undo
6528 6528
       return $str;
6529 6529
     }
6530 6530
 
6531
-    return self::rtrim($matches[0]) . $strAddOn;
6531
+    return self::rtrim($matches[0]).$strAddOn;
6532 6532
   }
6533 6533
 
6534 6534
   /**
@@ -6595,7 +6595,7 @@  discard block
 block discarded – undo
6595 6595
       $str .= $break;
6596 6596
     }
6597 6597
 
6598
-    return $str . implode('', $chars);
6598
+    return $str.implode('', $chars);
6599 6599
   }
6600 6600
 
6601 6601
   /**
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.
src/voku/helper/data/translit_extra.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -227,6 +227,6 @@
 block discarded – undo
227 227
     '⦆' => '))',
228 228
 );
229 229
 
230
-$result =& $data;
230
+$result = & $data;
231 231
 unset($data);
232 232
 return $result;
Please login to merge, or discard this patch.
src/voku/helper/data/caseFolding_full.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -217,6 +217,6 @@
 block discarded – undo
217 217
         ),
218 218
 );
219 219
 
220
-$result =& $data;
220
+$result = & $data;
221 221
 unset($data);
222 222
 return $result;
Please login to merge, or discard this patch.