@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=0); |
|
3 | +declare(strict_types = 0); |
|
4 | 4 | |
5 | 5 | namespace voku\helper; |
6 | 6 |
@@ -963,16 +963,16 @@ |
||
963 | 963 | $str = UTF8NonStrict::chr($code_point); |
964 | 964 | } elseif (0x800 > $code_point) { |
965 | 965 | $str = UTF8NonStrict::chr(0xC0 | $code_point >> 6) . |
966 | - UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
|
966 | + UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
|
967 | 967 | } elseif (0x10000 > $code_point) { |
968 | 968 | $str = UTF8NonStrict::chr(0xE0 | $code_point >> 12) . |
969 | - UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F) . |
|
970 | - UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
|
969 | + UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F) . |
|
970 | + UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
|
971 | 971 | } else { |
972 | 972 | $str = UTF8NonStrict::chr(0xF0 | $code_point >> 18) . |
973 | - UTF8NonStrict::chr(0x80 | $code_point >> 12 & 0x3F) . |
|
974 | - UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F) . |
|
975 | - UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
|
973 | + UTF8NonStrict::chr(0x80 | $code_point >> 12 & 0x3F) . |
|
974 | + UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F) . |
|
975 | + UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | if ($encoding !== 'UTF-8') { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace voku\helper; |
6 | 6 | |
@@ -853,7 +853,7 @@ discard block |
||
853 | 853 | public static function add_bom_to_string($str) |
854 | 854 | { |
855 | 855 | if (self::string_has_bom($str) === false) { |
856 | - $str = self::bom() . $str; |
|
856 | + $str = self::bom().$str; |
|
857 | 857 | } |
858 | 858 | |
859 | 859 | return $str; |
@@ -954,7 +954,7 @@ discard block |
||
954 | 954 | |
955 | 955 | // use static cache, only if there is no support for "\IntlChar" |
956 | 956 | static $CHAR_CACHE = array(); |
957 | - $cacheKey = $code_point . $encoding; |
|
957 | + $cacheKey = $code_point.$encoding; |
|
958 | 958 | if (isset($CHAR_CACHE[$cacheKey]) === true) { |
959 | 959 | return $CHAR_CACHE[$cacheKey]; |
960 | 960 | } |
@@ -962,16 +962,16 @@ discard block |
||
962 | 962 | if (0x80 > $code_point %= 0x200000) { |
963 | 963 | $str = UTF8NonStrict::chr($code_point); |
964 | 964 | } elseif (0x800 > $code_point) { |
965 | - $str = UTF8NonStrict::chr(0xC0 | $code_point >> 6) . |
|
965 | + $str = UTF8NonStrict::chr(0xC0 | $code_point >> 6). |
|
966 | 966 | UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
967 | 967 | } elseif (0x10000 > $code_point) { |
968 | - $str = UTF8NonStrict::chr(0xE0 | $code_point >> 12) . |
|
969 | - UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F) . |
|
968 | + $str = UTF8NonStrict::chr(0xE0 | $code_point >> 12). |
|
969 | + UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F). |
|
970 | 970 | UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
971 | 971 | } else { |
972 | - $str = UTF8NonStrict::chr(0xF0 | $code_point >> 18) . |
|
973 | - UTF8NonStrict::chr(0x80 | $code_point >> 12 & 0x3F) . |
|
974 | - UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F) . |
|
972 | + $str = UTF8NonStrict::chr(0xF0 | $code_point >> 18). |
|
973 | + UTF8NonStrict::chr(0x80 | $code_point >> 12 & 0x3F). |
|
974 | + UTF8NonStrict::chr(0x80 | $code_point >> 6 & 0x3F). |
|
975 | 975 | UTF8NonStrict::chr(0x80 | $code_point & 0x3F); |
976 | 976 | } |
977 | 977 | |
@@ -1258,7 +1258,7 @@ discard block |
||
1258 | 1258 | $flags = ENT_QUOTES; |
1259 | 1259 | } |
1260 | 1260 | |
1261 | - return self::html_entity_decode('&#' . $int . ';', $flags); |
|
1261 | + return self::html_entity_decode('&#'.$int.';', $flags); |
|
1262 | 1262 | } |
1263 | 1263 | |
1264 | 1264 | /** |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | && |
1336 | 1336 | self::$SUPPORT['mbstring'] === false |
1337 | 1337 | ) { |
1338 | - trigger_error('UTF8::encode() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
1338 | + trigger_error('UTF8::encode() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | 1341 | $strEncoded = \mb_convert_encoding( |
@@ -1544,7 +1544,7 @@ discard block |
||
1544 | 1544 | ) { |
1545 | 1545 | // Prevent leading combining chars |
1546 | 1546 | // for NFC-safe concatenations. |
1547 | - $var = $leading_combining . $var; |
|
1547 | + $var = $leading_combining.$var; |
|
1548 | 1548 | } |
1549 | 1549 | } |
1550 | 1550 | |
@@ -1965,7 +1965,7 @@ discard block |
||
1965 | 1965 | */ |
1966 | 1966 | private static function getData($file) |
1967 | 1967 | { |
1968 | - $file = __DIR__ . '/data/' . $file . '.php'; |
|
1968 | + $file = __DIR__.'/data/'.$file.'.php'; |
|
1969 | 1969 | if (file_exists($file)) { |
1970 | 1970 | /** @noinspection PhpIncludeInspection */ |
1971 | 1971 | return require $file; |
@@ -2084,7 +2084,7 @@ discard block |
||
2084 | 2084 | return implode( |
2085 | 2085 | '', |
2086 | 2086 | array_map( |
2087 | - function ($data) use ($keepAsciiChars, $encoding) { |
|
2087 | + function($data) use ($keepAsciiChars, $encoding) { |
|
2088 | 2088 | return UTF8::single_chr_html_encode($data, $keepAsciiChars, $encoding); |
2089 | 2089 | }, |
2090 | 2090 | self::split($str) |
@@ -2203,7 +2203,7 @@ discard block |
||
2203 | 2203 | |
2204 | 2204 | $str = preg_replace_callback( |
2205 | 2205 | "/&#\d{2,6};/", |
2206 | - function ($matches) use ($encoding) { |
|
2206 | + function($matches) use ($encoding) { |
|
2207 | 2207 | $returnTmp = \mb_convert_encoding($matches[0], $encoding, 'HTML-ENTITIES'); |
2208 | 2208 | |
2209 | 2209 | if ($returnTmp !== '"' && $returnTmp !== "'") { |
@@ -2527,9 +2527,9 @@ discard block |
||
2527 | 2527 | if ((int)$int === $int) { |
2528 | 2528 | $hex = dechex($int); |
2529 | 2529 | |
2530 | - $hex = (strlen($hex) < 4 ? substr('0000' . $hex, -4) : $hex); |
|
2530 | + $hex = (strlen($hex) < 4 ? substr('0000'.$hex, -4) : $hex); |
|
2531 | 2531 | |
2532 | - return $pfix . $hex; |
|
2532 | + return $pfix.$hex; |
|
2533 | 2533 | } |
2534 | 2534 | |
2535 | 2535 | return ''; |
@@ -3250,7 +3250,7 @@ discard block |
||
3250 | 3250 | */ |
3251 | 3251 | public static function lcfirst($str) |
3252 | 3252 | { |
3253 | - return self::strtolower(self::substr($str, 0, 1)) . self::substr($str, 1); |
|
3253 | + return self::strtolower(self::substr($str, 0, 1)).self::substr($str, 1); |
|
3254 | 3254 | } |
3255 | 3255 | |
3256 | 3256 | /** |
@@ -3274,7 +3274,7 @@ discard block |
||
3274 | 3274 | return preg_replace('/^[\pZ\pC]+/u', '', $str); |
3275 | 3275 | } |
3276 | 3276 | |
3277 | - return preg_replace('/^' . self::rxClass($chars) . '+/u', '', $str); |
|
3277 | + return preg_replace('/^'.self::rxClass($chars).'+/u', '', $str); |
|
3278 | 3278 | } |
3279 | 3279 | |
3280 | 3280 | /** |
@@ -3788,7 +3788,7 @@ discard block |
||
3788 | 3788 | if (is_array($what) === true) { |
3789 | 3789 | /** @noinspection ForeachSourceInspection */ |
3790 | 3790 | foreach ($what as $item) { |
3791 | - $str = preg_replace('/(' . preg_quote($item, '/') . ')+/', $item, $str); |
|
3791 | + $str = preg_replace('/('.preg_quote($item, '/').')+/', $item, $str); |
|
3792 | 3792 | } |
3793 | 3793 | } |
3794 | 3794 | |
@@ -3901,7 +3901,7 @@ discard block |
||
3901 | 3901 | return preg_replace('/[\pZ\pC]+$/u', '', $str); |
3902 | 3902 | } |
3903 | 3903 | |
3904 | - return preg_replace('/' . self::rxClass($chars) . '+$/u', '', $str); |
|
3904 | + return preg_replace('/'.self::rxClass($chars).'+$/u', '', $str); |
|
3905 | 3905 | } |
3906 | 3906 | |
3907 | 3907 | /** |
@@ -3916,7 +3916,7 @@ discard block |
||
3916 | 3916 | { |
3917 | 3917 | static $RX_CLASSS_CACHE = array(); |
3918 | 3918 | |
3919 | - $cacheKey = $s . $class; |
|
3919 | + $cacheKey = $s.$class; |
|
3920 | 3920 | |
3921 | 3921 | if (isset($RX_CLASSS_CACHE[$cacheKey])) { |
3922 | 3922 | return $RX_CLASSS_CACHE[$cacheKey]; |
@@ -3928,7 +3928,7 @@ discard block |
||
3928 | 3928 | /** @noinspection SuspiciousLoopInspection */ |
3929 | 3929 | foreach (self::str_split($s) as $s) { |
3930 | 3930 | if ('-' === $s) { |
3931 | - $class[0] = '-' . $class[0]; |
|
3931 | + $class[0] = '-'.$class[0]; |
|
3932 | 3932 | } elseif (!isset($s[2])) { |
3933 | 3933 | $class[0] .= preg_quote($s, '/'); |
3934 | 3934 | } elseif (1 === self::strlen($s)) { |
@@ -3939,13 +3939,13 @@ discard block |
||
3939 | 3939 | } |
3940 | 3940 | |
3941 | 3941 | if ($class[0]) { |
3942 | - $class[0] = '[' . $class[0] . ']'; |
|
3942 | + $class[0] = '['.$class[0].']'; |
|
3943 | 3943 | } |
3944 | 3944 | |
3945 | 3945 | if (1 === count($class)) { |
3946 | 3946 | $return = $class[0]; |
3947 | 3947 | } else { |
3948 | - $return = '(?:' . implode('|', $class) . ')'; |
|
3948 | + $return = '(?:'.implode('|', $class).')'; |
|
3949 | 3949 | } |
3950 | 3950 | |
3951 | 3951 | $RX_CLASSS_CACHE[$cacheKey] = $return; |
@@ -3963,7 +3963,7 @@ discard block |
||
3963 | 3963 | } |
3964 | 3964 | |
3965 | 3965 | foreach (self::$SUPPORT as $utf8Support) { |
3966 | - echo $utf8Support . "\n<br>"; |
|
3966 | + echo $utf8Support."\n<br>"; |
|
3967 | 3967 | } |
3968 | 3968 | } |
3969 | 3969 | |
@@ -3997,7 +3997,7 @@ discard block |
||
3997 | 3997 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
3998 | 3998 | } |
3999 | 3999 | |
4000 | - return '&#' . self::ord($char, $encoding) . ';'; |
|
4000 | + return '&#'.self::ord($char, $encoding).';'; |
|
4001 | 4001 | } |
4002 | 4002 | |
4003 | 4003 | /** |
@@ -4056,7 +4056,7 @@ discard block |
||
4056 | 4056 | ) { |
4057 | 4057 | |
4058 | 4058 | if (($str[$i + 1] & "\xC0") === "\x80") { |
4059 | - $ret[] = $str[$i] . $str[$i + 1]; |
|
4059 | + $ret[] = $str[$i].$str[$i + 1]; |
|
4060 | 4060 | |
4061 | 4061 | $i++; |
4062 | 4062 | } |
@@ -4072,7 +4072,7 @@ discard block |
||
4072 | 4072 | && |
4073 | 4073 | ($str[$i + 2] & "\xC0") === "\x80" |
4074 | 4074 | ) { |
4075 | - $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2]; |
|
4075 | + $ret[] = $str[$i].$str[$i + 1].$str[$i + 2]; |
|
4076 | 4076 | |
4077 | 4077 | $i += 2; |
4078 | 4078 | } |
@@ -4090,7 +4090,7 @@ discard block |
||
4090 | 4090 | && |
4091 | 4091 | ($str[$i + 3] & "\xC0") === "\x80" |
4092 | 4092 | ) { |
4093 | - $ret[] = $str[$i] . $str[$i + 1] . $str[$i + 2] . $str[$i + 3]; |
|
4093 | + $ret[] = $str[$i].$str[$i + 1].$str[$i + 2].$str[$i + 3]; |
|
4094 | 4094 | |
4095 | 4095 | $i += 3; |
4096 | 4096 | } |
@@ -4103,7 +4103,7 @@ discard block |
||
4103 | 4103 | $ret = array_chunk($ret, $length); |
4104 | 4104 | |
4105 | 4105 | return array_map( |
4106 | - function ($item) { |
|
4106 | + function($item) { |
|
4107 | 4107 | return implode('', $item); |
4108 | 4108 | }, $ret |
4109 | 4109 | ); |
@@ -4202,7 +4202,7 @@ discard block |
||
4202 | 4202 | foreach (self::$ICONV_ENCODING as $encodingTmp) { |
4203 | 4203 | # INFO: //IGNORE and //TRANSLIT still throw notice |
4204 | 4204 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
4205 | - if (md5(@\iconv($encodingTmp, $encodingTmp . '//IGNORE', $str)) === $md5) { |
|
4205 | + if (md5(@\iconv($encodingTmp, $encodingTmp.'//IGNORE', $str)) === $md5) { |
|
4206 | 4206 | return $encodingTmp; |
4207 | 4207 | } |
4208 | 4208 | } |
@@ -4292,7 +4292,7 @@ discard block |
||
4292 | 4292 | if ('' === $s .= '') { |
4293 | 4293 | $s = '/^(?<=.)$/'; |
4294 | 4294 | } else { |
4295 | - $s = '/' . preg_quote($s, '/') . '/ui'; |
|
4295 | + $s = '/'.preg_quote($s, '/').'/ui'; |
|
4296 | 4296 | } |
4297 | 4297 | } |
4298 | 4298 | |
@@ -4350,7 +4350,7 @@ discard block |
||
4350 | 4350 | } |
4351 | 4351 | |
4352 | 4352 | if (self::substr($str, $length - 1, 1) === ' ') { |
4353 | - return self::substr($str, 0, $length - 1) . $strAddOn; |
|
4353 | + return self::substr($str, 0, $length - 1).$strAddOn; |
|
4354 | 4354 | } |
4355 | 4355 | |
4356 | 4356 | $str = self::substr($str, 0, $length); |
@@ -4359,9 +4359,9 @@ discard block |
||
4359 | 4359 | $new_str = implode(' ', $array); |
4360 | 4360 | |
4361 | 4361 | if ($new_str === '') { |
4362 | - $str = self::substr($str, 0, $length - 1) . $strAddOn; |
|
4362 | + $str = self::substr($str, 0, $length - 1).$strAddOn; |
|
4363 | 4363 | } else { |
4364 | - $str = $new_str . $strAddOn; |
|
4364 | + $str = $new_str.$strAddOn; |
|
4365 | 4365 | } |
4366 | 4366 | |
4367 | 4367 | return $str; |
@@ -4416,7 +4416,7 @@ discard block |
||
4416 | 4416 | $pre = ''; |
4417 | 4417 | } |
4418 | 4418 | |
4419 | - return $pre . $str . $post; |
|
4419 | + return $pre.$str.$post; |
|
4420 | 4420 | } |
4421 | 4421 | |
4422 | 4422 | return $str; |
@@ -4566,7 +4566,7 @@ discard block |
||
4566 | 4566 | } |
4567 | 4567 | |
4568 | 4568 | /** @noinspection PhpInternalEntityUsedInspection */ |
4569 | - preg_match_all('/' . Grapheme::GRAPHEME_CLUSTER_RX . '/u', $str, $a); |
|
4569 | + preg_match_all('/'.Grapheme::GRAPHEME_CLUSTER_RX.'/u', $str, $a); |
|
4570 | 4570 | $a = $a[0]; |
4571 | 4571 | |
4572 | 4572 | if ($len === 1) { |
@@ -4761,7 +4761,7 @@ discard block |
||
4761 | 4761 | public static function strcmp($str1, $str2) |
4762 | 4762 | { |
4763 | 4763 | /** @noinspection PhpUndefinedClassInspection */ |
4764 | - return $str1 . '' === $str2 . '' ? 0 : strcmp( |
|
4764 | + return $str1.'' === $str2.'' ? 0 : strcmp( |
|
4765 | 4765 | \Normalizer::normalize($str1, \Normalizer::NFD), |
4766 | 4766 | \Normalizer::normalize($str2, \Normalizer::NFD) |
4767 | 4767 | ); |
@@ -4792,7 +4792,7 @@ discard block |
||
4792 | 4792 | return null; |
4793 | 4793 | } |
4794 | 4794 | |
4795 | - if (preg_match('/^(.*?)' . self::rxClass($charList) . '/us', $str, $length)) { |
|
4795 | + if (preg_match('/^(.*?)'.self::rxClass($charList).'/us', $str, $length)) { |
|
4796 | 4796 | /** @noinspection OffsetOperationsInspection */ |
4797 | 4797 | return self::strlen($length[1]); |
4798 | 4798 | } |
@@ -5007,7 +5007,7 @@ discard block |
||
5007 | 5007 | && |
5008 | 5008 | self::$SUPPORT['mbstring'] === false |
5009 | 5009 | ) { |
5010 | - trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5010 | + trigger_error('UTF8::stristr() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5011 | 5011 | } |
5012 | 5012 | |
5013 | 5013 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -5018,7 +5018,7 @@ discard block |
||
5018 | 5018 | return \grapheme_stristr($haystack, $needle, $before_needle); |
5019 | 5019 | } |
5020 | 5020 | |
5021 | - preg_match('/^(.*?)' . preg_quote($needle, '/') . '/usi', $haystack, $match); |
|
5021 | + preg_match('/^(.*?)'.preg_quote($needle, '/').'/usi', $haystack, $match); |
|
5022 | 5022 | |
5023 | 5023 | if (!isset($match[1])) { |
5024 | 5024 | return false; |
@@ -5082,7 +5082,7 @@ discard block |
||
5082 | 5082 | && |
5083 | 5083 | self::$SUPPORT['iconv'] === false |
5084 | 5084 | ) { |
5085 | - trigger_error('UTF8::strlen() without mbstring / iconv cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5085 | + trigger_error('UTF8::strlen() without mbstring / iconv cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5086 | 5086 | } |
5087 | 5087 | |
5088 | 5088 | if ( |
@@ -5161,7 +5161,7 @@ discard block |
||
5161 | 5161 | */ |
5162 | 5162 | public static function strnatcmp($str1, $str2) |
5163 | 5163 | { |
5164 | - return $str1 . '' === $str2 . '' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2)); |
|
5164 | + return $str1.'' === $str2.'' ? 0 : strnatcmp(self::strtonatfold($str1), self::strtonatfold($str2)); |
|
5165 | 5165 | } |
5166 | 5166 | |
5167 | 5167 | /** |
@@ -5222,7 +5222,7 @@ discard block |
||
5222 | 5222 | return false; |
5223 | 5223 | } |
5224 | 5224 | |
5225 | - if (preg_match('/' . self::rxClass($char_list) . '/us', $haystack, $m)) { |
|
5225 | + if (preg_match('/'.self::rxClass($char_list).'/us', $haystack, $m)) { |
|
5226 | 5226 | return substr($haystack, strpos($haystack, $m[0])); |
5227 | 5227 | } else { |
5228 | 5228 | return false; |
@@ -5291,7 +5291,7 @@ discard block |
||
5291 | 5291 | && |
5292 | 5292 | self::$SUPPORT['mbstring'] === false |
5293 | 5293 | ) { |
5294 | - trigger_error('UTF8::strpos() without mbstring / iconv cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5294 | + trigger_error('UTF8::strpos() without mbstring / iconv cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5295 | 5295 | } |
5296 | 5296 | |
5297 | 5297 | if ( |
@@ -5507,7 +5507,7 @@ discard block |
||
5507 | 5507 | && |
5508 | 5508 | self::$SUPPORT['mbstring'] === false |
5509 | 5509 | ) { |
5510 | - trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5510 | + trigger_error('UTF8::strripos() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5511 | 5511 | } |
5512 | 5512 | |
5513 | 5513 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -5587,7 +5587,7 @@ discard block |
||
5587 | 5587 | && |
5588 | 5588 | self::$SUPPORT['mbstring'] === false |
5589 | 5589 | ) { |
5590 | - trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5590 | + trigger_error('UTF8::strrpos() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5591 | 5591 | } |
5592 | 5592 | |
5593 | 5593 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -5647,7 +5647,7 @@ discard block |
||
5647 | 5647 | return 0; |
5648 | 5648 | } |
5649 | 5649 | |
5650 | - return preg_match('/^' . self::rxClass($mask) . '+/u', $str, $str) ? self::strlen($str[0]) : 0; |
|
5650 | + return preg_match('/^'.self::rxClass($mask).'+/u', $str, $str) ? self::strlen($str[0]) : 0; |
|
5651 | 5651 | } |
5652 | 5652 | |
5653 | 5653 | /** |
@@ -5693,7 +5693,7 @@ discard block |
||
5693 | 5693 | && |
5694 | 5694 | self::$SUPPORT['mbstring'] === false |
5695 | 5695 | ) { |
5696 | - trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5696 | + trigger_error('UTF8::strstr() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5697 | 5697 | } |
5698 | 5698 | |
5699 | 5699 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -5710,7 +5710,7 @@ discard block |
||
5710 | 5710 | } |
5711 | 5711 | } |
5712 | 5712 | |
5713 | - preg_match('/^(.*?)' . preg_quote($needle, '/') . '/us', $haystack, $match); |
|
5713 | + preg_match('/^(.*?)'.preg_quote($needle, '/').'/us', $haystack, $match); |
|
5714 | 5714 | |
5715 | 5715 | if (!isset($match[1])) { |
5716 | 5716 | return false; |
@@ -5974,7 +5974,7 @@ discard block |
||
5974 | 5974 | && |
5975 | 5975 | self::$SUPPORT['mbstring'] === false |
5976 | 5976 | ) { |
5977 | - trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
5977 | + trigger_error('UTF8::substr() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
5978 | 5978 | } |
5979 | 5979 | |
5980 | 5980 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -6087,14 +6087,14 @@ discard block |
||
6087 | 6087 | && |
6088 | 6088 | self::$SUPPORT['mbstring'] === false |
6089 | 6089 | ) { |
6090 | - trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', E_USER_WARNING); |
|
6090 | + trigger_error('UTF8::substr_count() without mbstring cannot handle "'.$encoding.'" encoding', E_USER_WARNING); |
|
6091 | 6091 | } |
6092 | 6092 | |
6093 | 6093 | if (self::$SUPPORT['mbstring'] === true) { |
6094 | 6094 | return \mb_substr_count($haystack, $needle, $encoding); |
6095 | 6095 | } |
6096 | 6096 | |
6097 | - preg_match_all('/' . preg_quote($needle, '/') . '/us', $haystack, $matches, PREG_SET_ORDER); |
|
6097 | + preg_match_all('/'.preg_quote($needle, '/').'/us', $haystack, $matches, PREG_SET_ORDER); |
|
6098 | 6098 | |
6099 | 6099 | return count($matches); |
6100 | 6100 | } |
@@ -6341,7 +6341,7 @@ discard block |
||
6341 | 6341 | |
6342 | 6342 | $strSwappedCase = preg_replace_callback( |
6343 | 6343 | '/[\S]/u', |
6344 | - function ($match) use ($encoding) { |
|
6344 | + function($match) use ($encoding) { |
|
6345 | 6345 | $marchToUpper = UTF8::strtoupper($match[0], $encoding); |
6346 | 6346 | |
6347 | 6347 | if ($match[0] === $marchToUpper) { |
@@ -6671,13 +6671,13 @@ discard block |
||
6671 | 6671 | $c2 = $i + 1 >= $max ? "\x00" : $str[$i + 1]; |
6672 | 6672 | |
6673 | 6673 | if ($c2 >= "\x80" && $c2 <= "\xBF") { // yeah, almost sure it's UTF8 already |
6674 | - $buf .= $c1 . $c2; |
|
6674 | + $buf .= $c1.$c2; |
|
6675 | 6675 | $i++; |
6676 | 6676 | } else { // not valid UTF8 - convert it |
6677 | 6677 | $cc1tmp = ord($c1) / 64; |
6678 | 6678 | $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0"; |
6679 | 6679 | $cc2 = ($c1 & "\x3F") | "\x80"; |
6680 | - $buf .= $cc1 . $cc2; |
|
6680 | + $buf .= $cc1.$cc2; |
|
6681 | 6681 | } |
6682 | 6682 | |
6683 | 6683 | } elseif ($c1 >= "\xE0" && $c1 <= "\xEF") { // looks like 3 bytes UTF8 |
@@ -6686,13 +6686,13 @@ discard block |
||
6686 | 6686 | $c3 = $i + 2 >= $max ? "\x00" : $str[$i + 2]; |
6687 | 6687 | |
6688 | 6688 | if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF") { // yeah, almost sure it's UTF8 already |
6689 | - $buf .= $c1 . $c2 . $c3; |
|
6689 | + $buf .= $c1.$c2.$c3; |
|
6690 | 6690 | $i += 2; |
6691 | 6691 | } else { // not valid UTF8 - convert it |
6692 | 6692 | $cc1tmp = ord($c1) / 64; |
6693 | 6693 | $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0"; |
6694 | 6694 | $cc2 = ($c1 & "\x3F") | "\x80"; |
6695 | - $buf .= $cc1 . $cc2; |
|
6695 | + $buf .= $cc1.$cc2; |
|
6696 | 6696 | } |
6697 | 6697 | |
6698 | 6698 | } elseif ($c1 >= "\xF0" && $c1 <= "\xF7") { // looks like 4 bytes UTF8 |
@@ -6702,20 +6702,20 @@ discard block |
||
6702 | 6702 | $c4 = $i + 3 >= $max ? "\x00" : $str[$i + 3]; |
6703 | 6703 | |
6704 | 6704 | if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF" && $c4 >= "\x80" && $c4 <= "\xBF") { // yeah, almost sure it's UTF8 already |
6705 | - $buf .= $c1 . $c2 . $c3 . $c4; |
|
6705 | + $buf .= $c1.$c2.$c3.$c4; |
|
6706 | 6706 | $i += 3; |
6707 | 6707 | } else { // not valid UTF8 - convert it |
6708 | 6708 | $cc1tmp = ord($c1) / 64; |
6709 | 6709 | $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0"; |
6710 | 6710 | $cc2 = ($c1 & "\x3F") | "\x80"; |
6711 | - $buf .= $cc1 . $cc2; |
|
6711 | + $buf .= $cc1.$cc2; |
|
6712 | 6712 | } |
6713 | 6713 | |
6714 | 6714 | } else { // doesn't look like UTF8, but should be converted |
6715 | 6715 | $cc1tmp = ord($c1) / 64; |
6716 | 6716 | $cc1 = UTF8NonStrict::chr($cc1tmp) | "\xC0"; |
6717 | 6717 | $cc2 = ($c1 & "\x3F") | "\x80"; |
6718 | - $buf .= $cc1 . $cc2; |
|
6718 | + $buf .= $cc1.$cc2; |
|
6719 | 6719 | } |
6720 | 6720 | |
6721 | 6721 | } elseif (($c1 & "\xC0") === "\x80") { // needs conversion |
@@ -6726,7 +6726,7 @@ discard block |
||
6726 | 6726 | } else { |
6727 | 6727 | $cc1 = UTF8NonStrict::chr($ordC1 / 64) | "\xC0"; |
6728 | 6728 | $cc2 = ($c1 & "\x3F") | "\x80"; |
6729 | - $buf .= $cc1 . $cc2; |
|
6729 | + $buf .= $cc1.$cc2; |
|
6730 | 6730 | } |
6731 | 6731 | |
6732 | 6732 | } else { // it doesn't need conversion |
@@ -6737,7 +6737,7 @@ discard block |
||
6737 | 6737 | // decode unicode escape sequences |
6738 | 6738 | $buf = preg_replace_callback( |
6739 | 6739 | '/\\\\u([0-9a-f]{4})/i', |
6740 | - function ($match) { |
|
6740 | + function($match) { |
|
6741 | 6741 | return \mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE'); |
6742 | 6742 | }, |
6743 | 6743 | $buf |
@@ -6791,7 +6791,7 @@ discard block |
||
6791 | 6791 | */ |
6792 | 6792 | public static function ucfirst($str, $encoding = 'UTF-8', $cleanUtf8 = false) |
6793 | 6793 | { |
6794 | - return self::strtoupper(self::substr($str, 0, 1, $encoding, $cleanUtf8), $encoding, $cleanUtf8) . self::substr($str, 1, null, $encoding, $cleanUtf8); |
|
6794 | + return self::strtoupper(self::substr($str, 0, 1, $encoding, $cleanUtf8), $encoding, $cleanUtf8).self::substr($str, 1, null, $encoding, $cleanUtf8); |
|
6795 | 6795 | } |
6796 | 6796 | |
6797 | 6797 | /** |
@@ -7266,7 +7266,7 @@ discard block |
||
7266 | 7266 | return ''; |
7267 | 7267 | } |
7268 | 7268 | |
7269 | - preg_match('/^\s*+(?:\S++\s*+){1,' . $words . '}/u', $str, $matches); |
|
7269 | + preg_match('/^\s*+(?:\S++\s*+){1,'.$words.'}/u', $str, $matches); |
|
7270 | 7270 | |
7271 | 7271 | if ( |
7272 | 7272 | !isset($matches[0]) |
@@ -7276,7 +7276,7 @@ discard block |
||
7276 | 7276 | return $str; |
7277 | 7277 | } |
7278 | 7278 | |
7279 | - return self::rtrim($matches[0]) . $strAddOn; |
|
7279 | + return self::rtrim($matches[0]).$strAddOn; |
|
7280 | 7280 | } |
7281 | 7281 | |
7282 | 7282 | /** |
@@ -7344,7 +7344,7 @@ discard block |
||
7344 | 7344 | $strReturn .= $break; |
7345 | 7345 | } |
7346 | 7346 | |
7347 | - return $strReturn . implode('', $chars); |
|
7347 | + return $strReturn.implode('', $chars); |
|
7348 | 7348 | } |
7349 | 7349 | |
7350 | 7350 | /** |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -declare(strict_types=1); |
|
3 | +declare(strict_types = 1); |
|
4 | 4 | |
5 | 5 | namespace voku\helper; |
6 | 6 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | $uri = preg_replace_callback( |
98 | 98 | '/[\x80-\xFF]+/', |
99 | - function ($m) { |
|
99 | + function($m) { |
|
100 | 100 | return urlencode($m[0]); |
101 | 101 | }, |
102 | 102 | $uri |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | |
105 | 105 | $uri = preg_replace_callback( |
106 | 106 | '/(?:%[89A-F][0-9A-F])+/i', |
107 | - function ($m) { |
|
107 | + function($m) { |
|
108 | 108 | return urlencode(UTF8::encode('UTF-8', urldecode($m[0]))); |
109 | 109 | }, |
110 | 110 | $uri |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | ) { |
120 | 120 | // Use ob_start() to buffer content and avoid problem of headers already sent... |
121 | 121 | $severProtocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'); |
122 | - header($severProtocol . ' 301 Moved Permanently'); |
|
123 | - header('Location: ' . $uri); |
|
122 | + header($severProtocol.' 301 Moved Permanently'); |
|
123 | + header('Location: '.$uri); |
|
124 | 124 | exit(); |
125 | 125 | } |
126 | 126 |