@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | } |
264 | 264 | |
265 | 265 | if ($encoding === 'UTF-8') { |
266 | - return (string) \mb_substr($str, $pos, 1); |
|
266 | + return (string)\mb_substr($str, $pos, 1); |
|
267 | 267 | } |
268 | 268 | |
269 | - return (string) self::substr($str, $pos, 1, $encoding); |
|
269 | + return (string)self::substr($str, $pos, 1, $encoding); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | public static function add_bom_to_string(string $str): string |
287 | 287 | { |
288 | 288 | if (!self::string_has_bom($str)) { |
289 | - $str = self::bom() . $str; |
|
289 | + $str = self::bom().$str; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | return $str; |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | return ''; |
359 | 359 | } |
360 | 360 | |
361 | - $substr_index = $start_position + (int) \mb_strlen($start); |
|
361 | + $substr_index = $start_position + (int)\mb_strlen($start); |
|
362 | 362 | $end_position = \mb_strpos($str, $end, $substr_index); |
363 | 363 | if ( |
364 | 364 | $end_position === false |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | return ''; |
369 | 369 | } |
370 | 370 | |
371 | - return (string) \mb_substr($str, $substr_index, $end_position - $substr_index); |
|
371 | + return (string)\mb_substr($str, $substr_index, $end_position - $substr_index); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | return ''; |
379 | 379 | } |
380 | 380 | |
381 | - $substr_index = $start_position + (int) self::strlen($start, $encoding); |
|
381 | + $substr_index = $start_position + (int)self::strlen($start, $encoding); |
|
382 | 382 | $end_position = self::strpos($str, $end, $substr_index, $encoding); |
383 | 383 | if ( |
384 | 384 | $end_position === false |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | return ''; |
389 | 389 | } |
390 | 390 | |
391 | - return (string) self::substr( |
|
391 | + return (string)self::substr( |
|
392 | 392 | $str, |
393 | 393 | $substr_index, |
394 | 394 | $end_position - $substr_index, |
@@ -472,10 +472,10 @@ discard block |
||
472 | 472 | public static function char_at(string $str, int $index, string $encoding = 'UTF-8'): string |
473 | 473 | { |
474 | 474 | if ($encoding === 'UTF-8') { |
475 | - return (string) \mb_substr($str, $index, 1); |
|
475 | + return (string)\mb_substr($str, $index, 1); |
|
476 | 476 | } |
477 | 477 | |
478 | - return (string) self::substr($str, $index, 1, $encoding); |
|
478 | + return (string)self::substr($str, $index, 1, $encoding); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | /** |
@@ -590,14 +590,14 @@ discard block |
||
590 | 590 | /** |
591 | 591 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
592 | 592 | */ |
593 | - \trigger_error('UTF8::chr() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
593 | + \trigger_error('UTF8::chr() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | if (!\is_int($code_point) || $code_point <= 0) { |
597 | 597 | return null; |
598 | 598 | } |
599 | 599 | |
600 | - $cache_key = $code_point . '_' . $encoding; |
|
600 | + $cache_key = $code_point.'_'.$encoding; |
|
601 | 601 | if (isset($CHAR_CACHE[$cache_key])) { |
602 | 602 | return $CHAR_CACHE[$cache_key]; |
603 | 603 | } |
@@ -642,27 +642,27 @@ discard block |
||
642 | 642 | self::$CHR = self::getData('chr'); |
643 | 643 | } |
644 | 644 | |
645 | - $code_point = (int) $code_point; |
|
645 | + $code_point = (int)$code_point; |
|
646 | 646 | if ($code_point <= 0x7FF) { |
647 | 647 | /** |
648 | 648 | * @psalm-suppress PossiblyNullArrayAccess |
649 | 649 | */ |
650 | - $chr = self::$CHR[($code_point >> 6) + 0xC0] . |
|
650 | + $chr = self::$CHR[($code_point >> 6) + 0xC0]. |
|
651 | 651 | self::$CHR[($code_point & 0x3F) + 0x80]; |
652 | 652 | } elseif ($code_point <= 0xFFFF) { |
653 | 653 | /** |
654 | 654 | * @psalm-suppress PossiblyNullArrayAccess |
655 | 655 | */ |
656 | - $chr = self::$CHR[($code_point >> 12) + 0xE0] . |
|
657 | - self::$CHR[(($code_point >> 6) & 0x3F) + 0x80] . |
|
656 | + $chr = self::$CHR[($code_point >> 12) + 0xE0]. |
|
657 | + self::$CHR[(($code_point >> 6) & 0x3F) + 0x80]. |
|
658 | 658 | self::$CHR[($code_point & 0x3F) + 0x80]; |
659 | 659 | } else { |
660 | 660 | /** |
661 | 661 | * @psalm-suppress PossiblyNullArrayAccess |
662 | 662 | */ |
663 | - $chr = self::$CHR[($code_point >> 18) + 0xF0] . |
|
664 | - self::$CHR[(($code_point >> 12) & 0x3F) + 0x80] . |
|
665 | - self::$CHR[(($code_point >> 6) & 0x3F) + 0x80] . |
|
663 | + $chr = self::$CHR[($code_point >> 18) + 0xF0]. |
|
664 | + self::$CHR[(($code_point >> 12) & 0x3F) + 0x80]. |
|
665 | + self::$CHR[(($code_point >> 6) & 0x3F) + 0x80]. |
|
666 | 666 | self::$CHR[($code_point & 0x3F) + 0x80]; |
667 | 667 | } |
668 | 668 | |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | |
720 | 720 | if (self::$SUPPORT['mbstring_func_overload'] === true) { |
721 | 721 | return \array_map( |
722 | - static function (string $data): int { |
|
722 | + static function(string $data): int { |
|
723 | 723 | // "mb_" is available if overload is used, so use it ... |
724 | 724 | return \mb_strlen($data, 'CP850'); // 8-BIT |
725 | 725 | }, |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | $char = ''; |
807 | 807 | } |
808 | 808 | |
809 | - return self::int_to_hex(self::ord((string) $char), $prefix); |
|
809 | + return self::int_to_hex(self::ord((string)$char), $prefix); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | | ( [\x80-\xBF] ) # invalid byte in range 10000000 - 10111111 |
884 | 884 | | ( [\xC0-\xFF] ) # invalid byte in range 11000000 - 11111111 |
885 | 885 | /x'; |
886 | - $str = (string) \preg_replace($regex, '$1', $str); |
|
886 | + $str = (string)\preg_replace($regex, '$1', $str); |
|
887 | 887 | |
888 | 888 | if ($replace_diamond_question_mark) { |
889 | 889 | $str = self::replace_diamond_question_mark($str); |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | public static function cleanup($str): string |
923 | 923 | { |
924 | 924 | // init |
925 | - $str = (string) $str; |
|
925 | + $str = (string)$str; |
|
926 | 926 | |
927 | 927 | if ($str === '') { |
928 | 928 | return ''; |
@@ -1023,7 +1023,7 @@ discard block |
||
1023 | 1023 | public static function collapse_whitespace(string $str): string |
1024 | 1024 | { |
1025 | 1025 | if (self::$SUPPORT['mbstring'] === true) { |
1026 | - return \trim((string) \mb_ereg_replace('[[:space:]]+', ' ', $str)); |
|
1026 | + return \trim((string)\mb_ereg_replace('[[:space:]]+', ' ', $str)); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | return \trim(self::regex_replace($str, '[[:space:]]+', ' ')); |
@@ -1127,9 +1127,9 @@ discard block |
||
1127 | 1127 | // - 0-9 (U+0061 - U+007A) |
1128 | 1128 | // - ISO 10646 characters U+00A1 and higher |
1129 | 1129 | // We strip out any character not in the above list. |
1130 | - $str = (string) \preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $str); |
|
1130 | + $str = (string)\preg_replace('/[^\x{002D}\x{0030}-\x{0039}\x{0041}-\x{005A}\x{005F}\x{0061}-\x{007A}\x{00A1}-\x{FFFF}]/u', '', $str); |
|
1131 | 1131 | // Identifiers cannot start with a digit, two hyphens, or a hyphen followed by a digit. |
1132 | - $str = (string) \preg_replace(['/^[0-9]/', '/^(-[0-9])|^(--)/'], ['_', '__'], $str); |
|
1132 | + $str = (string)\preg_replace(['/^[0-9]/', '/^(-[0-9])|^(--)/'], ['_', '__'], $str); |
|
1133 | 1133 | |
1134 | 1134 | return \trim($str, '-'); |
1135 | 1135 | } |
@@ -1145,7 +1145,7 @@ discard block |
||
1145 | 1145 | */ |
1146 | 1146 | public static function css_stripe_media_queries(string $str): string |
1147 | 1147 | { |
1148 | - return (string) \preg_replace( |
|
1148 | + return (string)\preg_replace( |
|
1149 | 1149 | '#@media\\s+(?:only\\s)?(?:[\\s{(]|screen|all)\\s?[^{]+{.*}\\s*}\\s*#isumU', |
1150 | 1150 | '', |
1151 | 1151 | $str |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | { |
1187 | 1187 | // We cannot use html_entity_decode() here, as it will not return |
1188 | 1188 | // characters for many values < 160. |
1189 | - return mb_convert_encoding('&#' . $int . ';', 'UTF-8', 'HTML-ENTITIES'); |
|
1189 | + return mb_convert_encoding('&#'.$int.';', 'UTF-8', 'HTML-ENTITIES'); |
|
1190 | 1190 | } |
1191 | 1191 | |
1192 | 1192 | /** |
@@ -1236,7 +1236,7 @@ discard block |
||
1236 | 1236 | $flagOffset = 0x1F1E6; |
1237 | 1237 | $asciiOffset = 0x41; |
1238 | 1238 | |
1239 | - return (self::chr((self::ord($country_code_iso_3166_1[0]) - $asciiOffset + $flagOffset)) ?? '') . |
|
1239 | + return (self::chr((self::ord($country_code_iso_3166_1[0]) - $asciiOffset + $flagOffset)) ?? ''). |
|
1240 | 1240 | (self::chr((self::ord($country_code_iso_3166_1[1]) - $asciiOffset + $flagOffset)) ?? ''); |
1241 | 1241 | } |
1242 | 1242 | |
@@ -1270,16 +1270,16 @@ discard block |
||
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | if ($use_reversible_string_mappings) { |
1273 | - return (string) \str_replace( |
|
1274 | - (array) self::$EMOJI_KEYS_REVERSIBLE_CACHE, |
|
1275 | - (array) self::$EMOJI_VALUES_CACHE, |
|
1273 | + return (string)\str_replace( |
|
1274 | + (array)self::$EMOJI_KEYS_REVERSIBLE_CACHE, |
|
1275 | + (array)self::$EMOJI_VALUES_CACHE, |
|
1276 | 1276 | $str |
1277 | 1277 | ); |
1278 | 1278 | } |
1279 | 1279 | |
1280 | - return (string) \str_replace( |
|
1281 | - (array) self::$EMOJI_KEYS_CACHE, |
|
1282 | - (array) self::$EMOJI_VALUES_CACHE, |
|
1280 | + return (string)\str_replace( |
|
1281 | + (array)self::$EMOJI_KEYS_CACHE, |
|
1282 | + (array)self::$EMOJI_VALUES_CACHE, |
|
1283 | 1283 | $str |
1284 | 1284 | ); |
1285 | 1285 | } |
@@ -1314,16 +1314,16 @@ discard block |
||
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | if ($use_reversible_string_mappings) { |
1317 | - return (string) \str_replace( |
|
1318 | - (array) self::$EMOJI_VALUES_CACHE, |
|
1319 | - (array) self::$EMOJI_KEYS_REVERSIBLE_CACHE, |
|
1317 | + return (string)\str_replace( |
|
1318 | + (array)self::$EMOJI_VALUES_CACHE, |
|
1319 | + (array)self::$EMOJI_KEYS_REVERSIBLE_CACHE, |
|
1320 | 1320 | $str |
1321 | 1321 | ); |
1322 | 1322 | } |
1323 | 1323 | |
1324 | - return (string) \str_replace( |
|
1325 | - (array) self::$EMOJI_VALUES_CACHE, |
|
1326 | - (array) self::$EMOJI_KEYS_CACHE, |
|
1324 | + return (string)\str_replace( |
|
1325 | + (array)self::$EMOJI_VALUES_CACHE, |
|
1326 | + (array)self::$EMOJI_KEYS_CACHE, |
|
1327 | 1327 | $str |
1328 | 1328 | ); |
1329 | 1329 | } |
@@ -1389,7 +1389,7 @@ discard block |
||
1389 | 1389 | if ($to_encoding === 'JSON') { |
1390 | 1390 | $return = self::json_encode($str); |
1391 | 1391 | if ($return === false) { |
1392 | - throw new \InvalidArgumentException('The input string [' . $str . '] can not be used for json_encode().'); |
|
1392 | + throw new \InvalidArgumentException('The input string ['.$str.'] can not be used for json_encode().'); |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | return $return; |
@@ -1478,7 +1478,7 @@ discard block |
||
1478 | 1478 | /** |
1479 | 1479 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
1480 | 1480 | */ |
1481 | - \trigger_error('UTF8::encode() without mbstring cannot handle "' . $to_encoding . '" encoding', \E_USER_WARNING); |
|
1481 | + \trigger_error('UTF8::encode() without mbstring cannot handle "'.$to_encoding.'" encoding', \E_USER_WARNING); |
|
1482 | 1482 | } |
1483 | 1483 | |
1484 | 1484 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -1579,31 +1579,31 @@ discard block |
||
1579 | 1579 | $trim_chars = "\t\r\n -_()!~?=+/*\\,.:;\"'[]{}`&"; |
1580 | 1580 | |
1581 | 1581 | if ($length === null) { |
1582 | - $length = (int) \round((int) self::strlen($str, $encoding) / 2); |
|
1582 | + $length = (int)\round((int)self::strlen($str, $encoding) / 2); |
|
1583 | 1583 | } |
1584 | 1584 | |
1585 | 1585 | if ($search === '') { |
1586 | 1586 | if ($encoding === 'UTF-8') { |
1587 | 1587 | if ($length > 0) { |
1588 | - $string_length = (int) \mb_strlen($str); |
|
1588 | + $string_length = (int)\mb_strlen($str); |
|
1589 | 1589 | $end = ($length - 1) > $string_length ? $string_length : ($length - 1); |
1590 | 1590 | } else { |
1591 | 1591 | $end = 0; |
1592 | 1592 | } |
1593 | 1593 | |
1594 | - $pos = (int) \min( |
|
1594 | + $pos = (int)\min( |
|
1595 | 1595 | \mb_strpos($str, ' ', $end), |
1596 | 1596 | \mb_strpos($str, '.', $end) |
1597 | 1597 | ); |
1598 | 1598 | } else { |
1599 | 1599 | if ($length > 0) { |
1600 | - $string_length = (int) self::strlen($str, $encoding); |
|
1600 | + $string_length = (int)self::strlen($str, $encoding); |
|
1601 | 1601 | $end = ($length - 1) > $string_length ? $string_length : ($length - 1); |
1602 | 1602 | } else { |
1603 | 1603 | $end = 0; |
1604 | 1604 | } |
1605 | 1605 | |
1606 | - $pos = (int) \min( |
|
1606 | + $pos = (int)\min( |
|
1607 | 1607 | self::strpos($str, ' ', $end, $encoding), |
1608 | 1608 | self::strpos($str, '.', $end, $encoding) |
1609 | 1609 | ); |
@@ -1620,18 +1620,18 @@ discard block |
||
1620 | 1620 | return ''; |
1621 | 1621 | } |
1622 | 1622 | |
1623 | - return \rtrim($str_sub, $trim_chars) . $replacer_for_skipped_text; |
|
1623 | + return \rtrim($str_sub, $trim_chars).$replacer_for_skipped_text; |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | return $str; |
1627 | 1627 | } |
1628 | 1628 | |
1629 | 1629 | if ($encoding === 'UTF-8') { |
1630 | - $word_position = (int) \mb_stripos($str, $search); |
|
1631 | - $half_side = (int) ($word_position - $length / 2 + (int) \mb_strlen($search) / 2); |
|
1630 | + $word_position = (int)\mb_stripos($str, $search); |
|
1631 | + $half_side = (int)($word_position - $length / 2 + (int)\mb_strlen($search) / 2); |
|
1632 | 1632 | } else { |
1633 | - $word_position = (int) self::stripos($str, $search, 0, $encoding); |
|
1634 | - $half_side = (int) ($word_position - $length / 2 + (int) self::strlen($search, $encoding) / 2); |
|
1633 | + $word_position = (int)self::stripos($str, $search, 0, $encoding); |
|
1634 | + $half_side = (int)($word_position - $length / 2 + (int)self::strlen($search, $encoding) / 2); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | 1637 | $pos_start = 0; |
@@ -1643,12 +1643,12 @@ discard block |
||
1643 | 1643 | } |
1644 | 1644 | if ($half_text !== false) { |
1645 | 1645 | if ($encoding === 'UTF-8') { |
1646 | - $pos_start = (int) \max( |
|
1646 | + $pos_start = (int)\max( |
|
1647 | 1647 | \mb_strrpos($half_text, ' '), |
1648 | 1648 | \mb_strrpos($half_text, '.') |
1649 | 1649 | ); |
1650 | 1650 | } else { |
1651 | - $pos_start = (int) \max( |
|
1651 | + $pos_start = (int)\max( |
|
1652 | 1652 | self::strrpos($half_text, ' ', 0, $encoding), |
1653 | 1653 | self::strrpos($half_text, '.', 0, $encoding) |
1654 | 1654 | ); |
@@ -1658,19 +1658,19 @@ discard block |
||
1658 | 1658 | |
1659 | 1659 | if ($word_position && $half_side > 0) { |
1660 | 1660 | $offset = $pos_start + $length - 1; |
1661 | - $real_length = (int) self::strlen($str, $encoding); |
|
1661 | + $real_length = (int)self::strlen($str, $encoding); |
|
1662 | 1662 | |
1663 | 1663 | if ($offset > $real_length) { |
1664 | 1664 | $offset = $real_length; |
1665 | 1665 | } |
1666 | 1666 | |
1667 | 1667 | if ($encoding === 'UTF-8') { |
1668 | - $pos_end = (int) \min( |
|
1668 | + $pos_end = (int)\min( |
|
1669 | 1669 | \mb_strpos($str, ' ', $offset), |
1670 | 1670 | \mb_strpos($str, '.', $offset) |
1671 | 1671 | ) - $pos_start; |
1672 | 1672 | } else { |
1673 | - $pos_end = (int) \min( |
|
1673 | + $pos_end = (int)\min( |
|
1674 | 1674 | self::strpos($str, ' ', $offset, $encoding), |
1675 | 1675 | self::strpos($str, '.', $offset, $encoding) |
1676 | 1676 | ) - $pos_start; |
@@ -1678,12 +1678,12 @@ discard block |
||
1678 | 1678 | |
1679 | 1679 | if (!$pos_end || $pos_end <= 0) { |
1680 | 1680 | if ($encoding === 'UTF-8') { |
1681 | - $str_sub = \mb_substr($str, $pos_start, (int) \mb_strlen($str)); |
|
1681 | + $str_sub = \mb_substr($str, $pos_start, (int)\mb_strlen($str)); |
|
1682 | 1682 | } else { |
1683 | - $str_sub = self::substr($str, $pos_start, (int) self::strlen($str, $encoding), $encoding); |
|
1683 | + $str_sub = self::substr($str, $pos_start, (int)self::strlen($str, $encoding), $encoding); |
|
1684 | 1684 | } |
1685 | 1685 | if ($str_sub !== false) { |
1686 | - $extract = $replacer_for_skipped_text . \ltrim($str_sub, $trim_chars); |
|
1686 | + $extract = $replacer_for_skipped_text.\ltrim($str_sub, $trim_chars); |
|
1687 | 1687 | } else { |
1688 | 1688 | $extract = ''; |
1689 | 1689 | } |
@@ -1694,26 +1694,26 @@ discard block |
||
1694 | 1694 | $str_sub = self::substr($str, $pos_start, $pos_end, $encoding); |
1695 | 1695 | } |
1696 | 1696 | if ($str_sub !== false) { |
1697 | - $extract = $replacer_for_skipped_text . \trim($str_sub, $trim_chars) . $replacer_for_skipped_text; |
|
1697 | + $extract = $replacer_for_skipped_text.\trim($str_sub, $trim_chars).$replacer_for_skipped_text; |
|
1698 | 1698 | } else { |
1699 | 1699 | $extract = ''; |
1700 | 1700 | } |
1701 | 1701 | } |
1702 | 1702 | } else { |
1703 | 1703 | $offset = $length - 1; |
1704 | - $true_length = (int) self::strlen($str, $encoding); |
|
1704 | + $true_length = (int)self::strlen($str, $encoding); |
|
1705 | 1705 | |
1706 | 1706 | if ($offset > $true_length) { |
1707 | 1707 | $offset = $true_length; |
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | if ($encoding === 'UTF-8') { |
1711 | - $pos_end = (int) \min( |
|
1711 | + $pos_end = (int)\min( |
|
1712 | 1712 | \mb_strpos($str, ' ', $offset), |
1713 | 1713 | \mb_strpos($str, '.', $offset) |
1714 | 1714 | ); |
1715 | 1715 | } else { |
1716 | - $pos_end = (int) \min( |
|
1716 | + $pos_end = (int)\min( |
|
1717 | 1717 | self::strpos($str, ' ', $offset, $encoding), |
1718 | 1718 | self::strpos($str, '.', $offset, $encoding) |
1719 | 1719 | ); |
@@ -1726,7 +1726,7 @@ discard block |
||
1726 | 1726 | $str_sub = self::substr($str, 0, $pos_end, $encoding); |
1727 | 1727 | } |
1728 | 1728 | if ($str_sub !== false) { |
1729 | - $extract = \rtrim($str_sub, $trim_chars) . $replacer_for_skipped_text; |
|
1729 | + $extract = \rtrim($str_sub, $trim_chars).$replacer_for_skipped_text; |
|
1730 | 1730 | } else { |
1731 | 1731 | $extract = ''; |
1732 | 1732 | } |
@@ -1861,7 +1861,7 @@ discard block |
||
1861 | 1861 | { |
1862 | 1862 | $file_content = \file_get_contents($file_path); |
1863 | 1863 | if ($file_content === false) { |
1864 | - throw new \RuntimeException('file_get_contents() returned false for:' . $file_path); |
|
1864 | + throw new \RuntimeException('file_get_contents() returned false for:'.$file_path); |
|
1865 | 1865 | } |
1866 | 1866 | |
1867 | 1867 | return self::string_has_bom($file_content); |
@@ -1929,7 +1929,7 @@ discard block |
||
1929 | 1929 | ) { |
1930 | 1930 | // Prevent leading combining chars |
1931 | 1931 | // for NFC-safe concatenations. |
1932 | - $var = $leading_combining . $var; |
|
1932 | + $var = $leading_combining.$var; |
|
1933 | 1933 | } |
1934 | 1934 | } |
1935 | 1935 | |
@@ -2250,10 +2250,10 @@ discard block |
||
2250 | 2250 | } |
2251 | 2251 | |
2252 | 2252 | if ($encoding === 'UTF-8') { |
2253 | - return (string) \mb_substr($str, 0, $n); |
|
2253 | + return (string)\mb_substr($str, 0, $n); |
|
2254 | 2254 | } |
2255 | 2255 | |
2256 | - return (string) self::substr($str, 0, $n, $encoding); |
|
2256 | + return (string)self::substr($str, 0, $n, $encoding); |
|
2257 | 2257 | } |
2258 | 2258 | |
2259 | 2259 | /** |
@@ -2271,7 +2271,7 @@ discard block |
||
2271 | 2271 | */ |
2272 | 2272 | public static function fits_inside(string $str, int $box_size): bool |
2273 | 2273 | { |
2274 | - return (int) self::strlen($str) <= $box_size; |
|
2274 | + return (int)self::strlen($str) <= $box_size; |
|
2275 | 2275 | } |
2276 | 2276 | |
2277 | 2277 | /** |
@@ -2356,7 +2356,7 @@ discard block |
||
2356 | 2356 | return $str; |
2357 | 2357 | } |
2358 | 2358 | |
2359 | - $str = (string) $str; |
|
2359 | + $str = (string)$str; |
|
2360 | 2360 | $last = ''; |
2361 | 2361 | while ($last !== $str) { |
2362 | 2362 | $last = $str; |
@@ -2559,7 +2559,7 @@ discard block |
||
2559 | 2559 | if ($str_info === false) { |
2560 | 2560 | return $fallback; |
2561 | 2561 | } |
2562 | - $type_code = (int) ($str_info['chars1'] . $str_info['chars2']); |
|
2562 | + $type_code = (int)($str_info['chars1'].$str_info['chars2']); |
|
2563 | 2563 | |
2564 | 2564 | // DEBUG |
2565 | 2565 | //var_dump($type_code); |
@@ -2617,7 +2617,7 @@ discard block |
||
2617 | 2617 | // |
2618 | 2618 | |
2619 | 2619 | if ($encoding === 'UTF-8') { |
2620 | - $max_length = (int) \mb_strlen($possible_chars); |
|
2620 | + $max_length = (int)\mb_strlen($possible_chars); |
|
2621 | 2621 | if ($max_length === 0) { |
2622 | 2622 | return ''; |
2623 | 2623 | } |
@@ -2637,7 +2637,7 @@ discard block |
||
2637 | 2637 | } else { |
2638 | 2638 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
2639 | 2639 | |
2640 | - $max_length = (int) self::strlen($possible_chars, $encoding); |
|
2640 | + $max_length = (int)self::strlen($possible_chars, $encoding); |
|
2641 | 2641 | if ($max_length === 0) { |
2642 | 2642 | return ''; |
2643 | 2643 | } |
@@ -2673,16 +2673,16 @@ discard block |
||
2673 | 2673 | $rand_int = \mt_rand(0, \mt_getrandmax()); |
2674 | 2674 | } |
2675 | 2675 | |
2676 | - $unique_helper = $rand_int . |
|
2677 | - \session_id() . |
|
2678 | - ($_SERVER['REMOTE_ADDR'] ?? '') . |
|
2679 | - ($_SERVER['SERVER_ADDR'] ?? '') . |
|
2676 | + $unique_helper = $rand_int. |
|
2677 | + \session_id(). |
|
2678 | + ($_SERVER['REMOTE_ADDR'] ?? ''). |
|
2679 | + ($_SERVER['SERVER_ADDR'] ?? ''). |
|
2680 | 2680 | $extra_entropy; |
2681 | 2681 | |
2682 | 2682 | $unique_string = \uniqid($unique_helper, true); |
2683 | 2683 | |
2684 | 2684 | if ($use_md5) { |
2685 | - $unique_string = \md5($unique_string . $unique_helper); |
|
2685 | + $unique_string = \md5($unique_string.$unique_helper); |
|
2686 | 2686 | } |
2687 | 2687 | |
2688 | 2688 | return $unique_string; |
@@ -2761,7 +2761,7 @@ discard block |
||
2761 | 2761 | public static function hex_to_chr(string $hexdec) |
2762 | 2762 | { |
2763 | 2763 | /** @noinspection PhpUsageOfSilenceOperatorInspection - Invalid characters passed for attempted conversion, these have been ignored */ |
2764 | - return self::decimal_to_chr((int) @\hexdec($hexdec)); |
|
2764 | + return self::decimal_to_chr((int)@\hexdec($hexdec)); |
|
2765 | 2765 | } |
2766 | 2766 | |
2767 | 2767 | /** |
@@ -2781,7 +2781,7 @@ discard block |
||
2781 | 2781 | public static function hex_to_int($hexdec) |
2782 | 2782 | { |
2783 | 2783 | // init |
2784 | - $hexdec = (string) $hexdec; |
|
2784 | + $hexdec = (string)$hexdec; |
|
2785 | 2785 | |
2786 | 2786 | if ($hexdec === '') { |
2787 | 2787 | return false; |
@@ -2859,7 +2859,7 @@ discard block |
||
2859 | 2859 | return \implode( |
2860 | 2860 | '', |
2861 | 2861 | \array_map( |
2862 | - static function (string $chr) use ($keep_ascii_chars, $encoding): string { |
|
2862 | + static function(string $chr) use ($keep_ascii_chars, $encoding): string { |
|
2863 | 2863 | return self::single_chr_html_encode($chr, $keep_ascii_chars, $encoding); |
2864 | 2864 | }, |
2865 | 2865 | self::str_split($str) |
@@ -2973,7 +2973,7 @@ discard block |
||
2973 | 2973 | /** |
2974 | 2974 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
2975 | 2975 | */ |
2976 | - \trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
2976 | + \trigger_error('UTF8::html_entity_decode() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
2977 | 2977 | } |
2978 | 2978 | |
2979 | 2979 | do { |
@@ -2982,7 +2982,7 @@ discard block |
||
2982 | 2982 | if (\strpos($str, '&') !== false) { |
2983 | 2983 | if (\strpos($str, '&#') !== false) { |
2984 | 2984 | // decode also numeric & UTF16 two byte entities |
2985 | - $str = (string) \preg_replace( |
|
2985 | + $str = (string)\preg_replace( |
|
2986 | 2986 | '/(&#(?:x0*[0-9a-fA-F]{2,6}(?![0-9a-fA-F;])|(?:0*\d{2,6}(?![0-9;]))))/S', |
2987 | 2987 | '$1;', |
2988 | 2988 | $str |
@@ -3032,7 +3032,7 @@ discard block |
||
3032 | 3032 | */ |
3033 | 3033 | public static function html_stripe_empty_tags(string $str): string |
3034 | 3034 | { |
3035 | - return (string) \preg_replace( |
|
3035 | + return (string)\preg_replace( |
|
3036 | 3036 | '/<[^\\/>]*?>\\s*?<\\/[^>]*?>/u', |
3037 | 3037 | '', |
3038 | 3038 | $str |
@@ -3343,9 +3343,9 @@ discard block |
||
3343 | 3343 | { |
3344 | 3344 | $hex = \dechex($int); |
3345 | 3345 | |
3346 | - $hex = (\strlen($hex) < 4 ? \substr('0000' . $hex, -4) : $hex); |
|
3346 | + $hex = (\strlen($hex) < 4 ? \substr('0000'.$hex, -4) : $hex); |
|
3347 | 3347 | |
3348 | - return $prefix . $hex . ''; |
|
3348 | + return $prefix.$hex.''; |
|
3349 | 3349 | } |
3350 | 3350 | |
3351 | 3351 | /** |
@@ -3513,7 +3513,7 @@ discard block |
||
3513 | 3513 | */ |
3514 | 3514 | public static function is_binary($input, bool $strict = false): bool |
3515 | 3515 | { |
3516 | - $input = (string) $input; |
|
3516 | + $input = (string)$input; |
|
3517 | 3517 | if ($input === '') { |
3518 | 3518 | return false; |
3519 | 3519 | } |
@@ -3865,7 +3865,7 @@ discard block |
||
3865 | 3865 | public static function is_utf16($str, bool $check_if_string_is_binary = true) |
3866 | 3866 | { |
3867 | 3867 | // init |
3868 | - $str = (string) $str; |
|
3868 | + $str = (string)$str; |
|
3869 | 3869 | $str_chars = []; |
3870 | 3870 | |
3871 | 3871 | // fix for the "binary"-check |
@@ -3964,7 +3964,7 @@ discard block |
||
3964 | 3964 | public static function is_utf32($str, bool $check_if_string_is_binary = true) |
3965 | 3965 | { |
3966 | 3966 | // init |
3967 | - $str = (string) $str; |
|
3967 | + $str = (string)$str; |
|
3968 | 3968 | $str_chars = []; |
3969 | 3969 | |
3970 | 3970 | // fix for the "binary"-check |
@@ -4067,7 +4067,7 @@ discard block |
||
4067 | 4067 | return true; |
4068 | 4068 | } |
4069 | 4069 | |
4070 | - return self::is_utf8_string((string) $str, $strict); |
|
4070 | + return self::is_utf8_string((string)$str, $strict); |
|
4071 | 4071 | } |
4072 | 4072 | |
4073 | 4073 | /** |
@@ -4231,15 +4231,15 @@ discard block |
||
4231 | 4231 | $use_mb_functions = ($lang === null && !$try_to_keep_the_string_length); |
4232 | 4232 | |
4233 | 4233 | if ($encoding === 'UTF-8') { |
4234 | - $str_part_two = (string) \mb_substr($str, 1); |
|
4234 | + $str_part_two = (string)\mb_substr($str, 1); |
|
4235 | 4235 | |
4236 | 4236 | if ($use_mb_functions) { |
4237 | 4237 | $str_part_one = \mb_strtolower( |
4238 | - (string) \mb_substr($str, 0, 1) |
|
4238 | + (string)\mb_substr($str, 0, 1) |
|
4239 | 4239 | ); |
4240 | 4240 | } else { |
4241 | 4241 | $str_part_one = self::strtolower( |
4242 | - (string) \mb_substr($str, 0, 1), |
|
4242 | + (string)\mb_substr($str, 0, 1), |
|
4243 | 4243 | $encoding, |
4244 | 4244 | false, |
4245 | 4245 | $lang, |
@@ -4249,10 +4249,10 @@ discard block |
||
4249 | 4249 | } else { |
4250 | 4250 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
4251 | 4251 | |
4252 | - $str_part_two = (string) self::substr($str, 1, null, $encoding); |
|
4252 | + $str_part_two = (string)self::substr($str, 1, null, $encoding); |
|
4253 | 4253 | |
4254 | 4254 | $str_part_one = self::strtolower( |
4255 | - (string) self::substr($str, 0, 1, $encoding), |
|
4255 | + (string)self::substr($str, 0, 1, $encoding), |
|
4256 | 4256 | $encoding, |
4257 | 4257 | false, |
4258 | 4258 | $lang, |
@@ -4260,7 +4260,7 @@ discard block |
||
4260 | 4260 | ); |
4261 | 4261 | } |
4262 | 4262 | |
4263 | - return $str_part_one . $str_part_two; |
|
4263 | + return $str_part_one.$str_part_two; |
|
4264 | 4264 | } |
4265 | 4265 | |
4266 | 4266 | /** |
@@ -4371,7 +4371,7 @@ discard block |
||
4371 | 4371 | $pattern = '^[\\s]+'; |
4372 | 4372 | } |
4373 | 4373 | |
4374 | - return (string) \mb_ereg_replace($pattern, '', $str); |
|
4374 | + return (string)\mb_ereg_replace($pattern, '', $str); |
|
4375 | 4375 | } |
4376 | 4376 | |
4377 | 4377 | if ($chars !== null) { |
@@ -4408,7 +4408,7 @@ discard block |
||
4408 | 4408 | |
4409 | 4409 | $codepoint_max = \max($codepoints); |
4410 | 4410 | |
4411 | - return self::chr((int) $codepoint_max); |
|
4411 | + return self::chr((int)$codepoint_max); |
|
4412 | 4412 | } |
4413 | 4413 | |
4414 | 4414 | /** |
@@ -4428,7 +4428,7 @@ discard block |
||
4428 | 4428 | { |
4429 | 4429 | $bytes = self::chr_size_list($str); |
4430 | 4430 | if ($bytes !== []) { |
4431 | - return (int) \max($bytes); |
|
4431 | + return (int)\max($bytes); |
|
4432 | 4432 | } |
4433 | 4433 | |
4434 | 4434 | return 0; |
@@ -4474,7 +4474,7 @@ discard block |
||
4474 | 4474 | |
4475 | 4475 | $codepoint_min = \min($codepoints); |
4476 | 4476 | |
4477 | - return self::chr((int) $codepoint_min); |
|
4477 | + return self::chr((int)$codepoint_min); |
|
4478 | 4478 | } |
4479 | 4479 | |
4480 | 4480 | /** |
@@ -4504,7 +4504,7 @@ discard block |
||
4504 | 4504 | static $STATIC_NORMALIZE_ENCODING_CACHE = []; |
4505 | 4505 | |
4506 | 4506 | // init |
4507 | - $encoding = (string) $encoding; |
|
4507 | + $encoding = (string)$encoding; |
|
4508 | 4508 | |
4509 | 4509 | if (!$encoding) { |
4510 | 4510 | return $fallback; |
@@ -4566,7 +4566,7 @@ discard block |
||
4566 | 4566 | |
4567 | 4567 | $encoding_original = $encoding; |
4568 | 4568 | $encoding = \strtoupper($encoding); |
4569 | - $encoding_upper_helper = (string) \preg_replace('/[^a-zA-Z0-9]/u', '', $encoding); |
|
4569 | + $encoding_upper_helper = (string)\preg_replace('/[^a-zA-Z0-9]/u', '', $encoding); |
|
4570 | 4570 | |
4571 | 4571 | $equivalences = [ |
4572 | 4572 | 'ISO8859' => 'ISO-8859-1', |
@@ -4733,13 +4733,13 @@ discard block |
||
4733 | 4733 | static $CHAR_CACHE = []; |
4734 | 4734 | |
4735 | 4735 | // init |
4736 | - $chr = (string) $chr; |
|
4736 | + $chr = (string)$chr; |
|
4737 | 4737 | |
4738 | 4738 | if ($encoding !== 'UTF-8' && $encoding !== 'CP850') { |
4739 | 4739 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
4740 | 4740 | } |
4741 | 4741 | |
4742 | - $cache_key = $chr . '_' . $encoding; |
|
4742 | + $cache_key = $chr.'_'.$encoding; |
|
4743 | 4743 | if (isset($CHAR_CACHE[$cache_key])) { |
4744 | 4744 | return $CHAR_CACHE[$cache_key]; |
4745 | 4745 | } |
@@ -4772,7 +4772,7 @@ discard block |
||
4772 | 4772 | // fallback via vanilla php |
4773 | 4773 | // |
4774 | 4774 | |
4775 | - $chr = \unpack('C*', (string) \substr($chr, 0, 4)); |
|
4775 | + $chr = \unpack('C*', (string)\substr($chr, 0, 4)); |
|
4776 | 4776 | /** @noinspection PhpSillyAssignmentInspection - hack for phpstan */ |
4777 | 4777 | /** @var int[] $chr - "unpack": only false if the format string contains errors */ |
4778 | 4778 | $chr = $chr; |
@@ -4849,7 +4849,7 @@ discard block |
||
4849 | 4849 | public static function pcre_utf8_support(): bool |
4850 | 4850 | { |
4851 | 4851 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
4852 | - return (bool) @\preg_match('//u', ''); |
|
4852 | + return (bool)@\preg_match('//u', ''); |
|
4853 | 4853 | } |
4854 | 4854 | |
4855 | 4855 | /** |
@@ -4890,14 +4890,14 @@ discard block |
||
4890 | 4890 | * @psalm-suppress DocblockTypeContradiction |
4891 | 4891 | */ |
4892 | 4892 | if (!\is_numeric($step)) { |
4893 | - throw new \InvalidArgumentException('$step need to be a number, type given: ' . \gettype($step)); |
|
4893 | + throw new \InvalidArgumentException('$step need to be a number, type given: '.\gettype($step)); |
|
4894 | 4894 | } |
4895 | 4895 | |
4896 | 4896 | /** |
4897 | 4897 | * @psalm-suppress RedundantConditionGivenDocblockType - false-positive from psalm? |
4898 | 4898 | */ |
4899 | 4899 | if ($step <= 0) { |
4900 | - throw new \InvalidArgumentException('$step need to be a positive number, given: ' . $step); |
|
4900 | + throw new \InvalidArgumentException('$step need to be a positive number, given: '.$step); |
|
4901 | 4901 | } |
4902 | 4902 | } |
4903 | 4903 | |
@@ -4908,16 +4908,16 @@ discard block |
||
4908 | 4908 | $is_digit = false; |
4909 | 4909 | $is_xdigit = false; |
4910 | 4910 | |
4911 | - if ($use_ctype && \ctype_digit((string) $var1) && \ctype_digit((string) $var2)) { |
|
4911 | + if ($use_ctype && \ctype_digit((string)$var1) && \ctype_digit((string)$var2)) { |
|
4912 | 4912 | $is_digit = true; |
4913 | - $start = (int) $var1; |
|
4913 | + $start = (int)$var1; |
|
4914 | 4914 | } elseif ($use_ctype && \ctype_xdigit($var1) && \ctype_xdigit($var2)) { |
4915 | 4915 | $is_xdigit = true; |
4916 | - $start = (int) self::hex_to_int((string) $var1); |
|
4916 | + $start = (int)self::hex_to_int((string)$var1); |
|
4917 | 4917 | } elseif (!$use_ctype && \is_numeric($var1)) { |
4918 | - $start = (int) $var1; |
|
4918 | + $start = (int)$var1; |
|
4919 | 4919 | } else { |
4920 | - $start = self::ord((string) $var1); |
|
4920 | + $start = self::ord((string)$var1); |
|
4921 | 4921 | } |
4922 | 4922 | |
4923 | 4923 | if (!$start) { |
@@ -4925,13 +4925,13 @@ discard block |
||
4925 | 4925 | } |
4926 | 4926 | |
4927 | 4927 | if ($is_digit) { |
4928 | - $end = (int) $var2; |
|
4928 | + $end = (int)$var2; |
|
4929 | 4929 | } elseif ($is_xdigit) { |
4930 | - $end = (int) self::hex_to_int((string) $var2); |
|
4930 | + $end = (int)self::hex_to_int((string)$var2); |
|
4931 | 4931 | } elseif (!$use_ctype && \is_numeric($var2)) { |
4932 | - $end = (int) $var2; |
|
4932 | + $end = (int)$var2; |
|
4933 | 4933 | } else { |
4934 | - $end = self::ord((string) $var2); |
|
4934 | + $end = self::ord((string)$var2); |
|
4935 | 4935 | } |
4936 | 4936 | |
4937 | 4937 | if (!$end) { |
@@ -4940,7 +4940,7 @@ discard block |
||
4940 | 4940 | |
4941 | 4941 | $array = []; |
4942 | 4942 | foreach (\range($start, $end, $step) as $i) { |
4943 | - $array[] = (string) self::chr((int) $i, $encoding); |
|
4943 | + $array[] = (string)self::chr((int)$i, $encoding); |
|
4944 | 4944 | } |
4945 | 4945 | |
4946 | 4946 | return $array; |
@@ -5036,8 +5036,8 @@ discard block |
||
5036 | 5036 | $delimiter = '/'; |
5037 | 5037 | } |
5038 | 5038 | |
5039 | - return (string) \preg_replace( |
|
5040 | - $delimiter . $pattern . $delimiter . 'u' . $options, |
|
5039 | + return (string)\preg_replace( |
|
5040 | + $delimiter.$pattern.$delimiter.'u'.$options, |
|
5041 | 5041 | $replacement, |
5042 | 5042 | $str |
5043 | 5043 | ); |
@@ -5072,7 +5072,7 @@ discard block |
||
5072 | 5072 | |
5073 | 5073 | $str_length -= $bom_byte_length; |
5074 | 5074 | |
5075 | - $str = (string) $str_tmp; |
|
5075 | + $str = (string)$str_tmp; |
|
5076 | 5076 | } |
5077 | 5077 | } |
5078 | 5078 | |
@@ -5103,7 +5103,7 @@ discard block |
||
5103 | 5103 | */ |
5104 | 5104 | if (\is_array($what)) { |
5105 | 5105 | foreach ($what as $item) { |
5106 | - $str = (string) \preg_replace('/(' . \preg_quote($item, '/') . ')+/u', $item, $str); |
|
5106 | + $str = (string)\preg_replace('/('.\preg_quote($item, '/').')+/u', $item, $str); |
|
5107 | 5107 | } |
5108 | 5108 | } |
5109 | 5109 | |
@@ -5141,7 +5141,7 @@ discard block |
||
5141 | 5141 | */ |
5142 | 5142 | public static function remove_html_breaks(string $str, string $replacement = ''): string |
5143 | 5143 | { |
5144 | - return (string) \preg_replace("#/\r\n|\r|\n|<br.*/?>#isU", $replacement, $str); |
|
5144 | + return (string)\preg_replace("#/\r\n|\r|\n|<br.*/?>#isU", $replacement, $str); |
|
5145 | 5145 | } |
5146 | 5146 | |
5147 | 5147 | /** |
@@ -5205,17 +5205,17 @@ discard block |
||
5205 | 5205 | \strpos($str, $substring) === 0 |
5206 | 5206 | ) { |
5207 | 5207 | if ($encoding === 'UTF-8') { |
5208 | - return (string) \mb_substr( |
|
5208 | + return (string)\mb_substr( |
|
5209 | 5209 | $str, |
5210 | - (int) \mb_strlen($substring) |
|
5210 | + (int)\mb_strlen($substring) |
|
5211 | 5211 | ); |
5212 | 5212 | } |
5213 | 5213 | |
5214 | 5214 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
5215 | 5215 | |
5216 | - return (string) self::substr( |
|
5216 | + return (string)self::substr( |
|
5217 | 5217 | $str, |
5218 | - (int) self::strlen($substring, $encoding), |
|
5218 | + (int)self::strlen($substring, $encoding), |
|
5219 | 5219 | null, |
5220 | 5220 | $encoding |
5221 | 5221 | ); |
@@ -5243,19 +5243,19 @@ discard block |
||
5243 | 5243 | ): string { |
5244 | 5244 | if ($substring && \substr($str, -\strlen($substring)) === $substring) { |
5245 | 5245 | if ($encoding === 'UTF-8') { |
5246 | - return (string) \mb_substr( |
|
5246 | + return (string)\mb_substr( |
|
5247 | 5247 | $str, |
5248 | 5248 | 0, |
5249 | - (int) \mb_strlen($str) - (int) \mb_strlen($substring) |
|
5249 | + (int)\mb_strlen($str) - (int)\mb_strlen($substring) |
|
5250 | 5250 | ); |
5251 | 5251 | } |
5252 | 5252 | |
5253 | 5253 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
5254 | 5254 | |
5255 | - return (string) self::substr( |
|
5255 | + return (string)self::substr( |
|
5256 | 5256 | $str, |
5257 | 5257 | 0, |
5258 | - (int) self::strlen($str, $encoding) - (int) self::strlen($substring, $encoding), |
|
5258 | + (int)self::strlen($str, $encoding) - (int)self::strlen($substring, $encoding), |
|
5259 | 5259 | $encoding |
5260 | 5260 | ); |
5261 | 5261 | } |
@@ -5358,7 +5358,7 @@ discard block |
||
5358 | 5358 | /** @noinspection PhpUsageOfSilenceOperatorInspection - ignore "Unknown character" warnings, it's working anyway */ |
5359 | 5359 | @\mb_substitute_character($replacement_char_helper); |
5360 | 5360 | // the polyfill maybe return false, so cast to string |
5361 | - $str = (string) \mb_convert_encoding($str, 'UTF-8', 'UTF-8'); |
|
5361 | + $str = (string)\mb_convert_encoding($str, 'UTF-8', 'UTF-8'); |
|
5362 | 5362 | \mb_substitute_character($save); |
5363 | 5363 | } |
5364 | 5364 | |
@@ -5403,7 +5403,7 @@ discard block |
||
5403 | 5403 | $pattern = '[\\s]+$'; |
5404 | 5404 | } |
5405 | 5405 | |
5406 | - return (string) \mb_ereg_replace($pattern, '', $str); |
|
5406 | + return (string)\mb_ereg_replace($pattern, '', $str); |
|
5407 | 5407 | } |
5408 | 5408 | |
5409 | 5409 | if ($chars !== null) { |
@@ -5432,7 +5432,7 @@ discard block |
||
5432 | 5432 | |
5433 | 5433 | $html .= '<pre>'; |
5434 | 5434 | foreach (self::$SUPPORT as $key => &$value) { |
5435 | - $html .= $key . ' - ' . \print_r($value, true) . "\n<br>"; |
|
5435 | + $html .= $key.' - '.\print_r($value, true)."\n<br>"; |
|
5436 | 5436 | } |
5437 | 5437 | $html .= '</pre>'; |
5438 | 5438 | |
@@ -5474,7 +5474,7 @@ discard block |
||
5474 | 5474 | return $char; |
5475 | 5475 | } |
5476 | 5476 | |
5477 | - return '&#' . self::ord($char, $encoding) . ';'; |
|
5477 | + return '&#'.self::ord($char, $encoding).';'; |
|
5478 | 5478 | } |
5479 | 5479 | |
5480 | 5480 | /** |
@@ -5537,11 +5537,11 @@ discard block |
||
5537 | 5537 | $lang, |
5538 | 5538 | $try_to_keep_the_string_length |
5539 | 5539 | ); |
5540 | - $str = (string) \preg_replace('/^[-_]+/', '', $str); |
|
5540 | + $str = (string)\preg_replace('/^[-_]+/', '', $str); |
|
5541 | 5541 | |
5542 | 5542 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
5543 | 5543 | |
5544 | - $str = (string) \preg_replace_callback( |
|
5544 | + $str = (string)\preg_replace_callback( |
|
5545 | 5545 | '/[-_\\s]+(.)?/u', |
5546 | 5546 | /** |
5547 | 5547 | * @param array $match |
@@ -5550,7 +5550,7 @@ discard block |
||
5550 | 5550 | * |
5551 | 5551 | * @return string |
5552 | 5552 | */ |
5553 | - static function (array $match) use ($use_mb_functions, $encoding, $lang, $try_to_keep_the_string_length): string { |
|
5553 | + static function(array $match) use ($use_mb_functions, $encoding, $lang, $try_to_keep_the_string_length): string { |
|
5554 | 5554 | if (isset($match[1])) { |
5555 | 5555 | if ($use_mb_functions) { |
5556 | 5556 | if ($encoding === 'UTF-8') { |
@@ -5568,7 +5568,7 @@ discard block |
||
5568 | 5568 | $str |
5569 | 5569 | ); |
5570 | 5570 | |
5571 | - return (string) \preg_replace_callback( |
|
5571 | + return (string)\preg_replace_callback( |
|
5572 | 5572 | '/[\\p{N}]+(.)?/u', |
5573 | 5573 | /** |
5574 | 5574 | * @param array $match |
@@ -5577,7 +5577,7 @@ discard block |
||
5577 | 5577 | * |
5578 | 5578 | * @return string |
5579 | 5579 | */ |
5580 | - static function (array $match) use ($use_mb_functions, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length): string { |
|
5580 | + static function(array $match) use ($use_mb_functions, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length): string { |
|
5581 | 5581 | if ($use_mb_functions) { |
5582 | 5582 | if ($encoding === 'UTF-8') { |
5583 | 5583 | return \mb_strtoupper($match[0]); |
@@ -5772,7 +5772,7 @@ discard block |
||
5772 | 5772 | bool $try_to_keep_the_string_length = false |
5773 | 5773 | ): string { |
5774 | 5774 | if (self::$SUPPORT['mbstring'] === true) { |
5775 | - $str = (string) \mb_ereg_replace('\\B(\\p{Lu})', '-\1', \trim($str)); |
|
5775 | + $str = (string)\mb_ereg_replace('\\B(\\p{Lu})', '-\1', \trim($str)); |
|
5776 | 5776 | |
5777 | 5777 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
5778 | 5778 | if ($use_mb_functions && $encoding === 'UTF-8') { |
@@ -5781,10 +5781,10 @@ discard block |
||
5781 | 5781 | $str = self::strtolower($str, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length); |
5782 | 5782 | } |
5783 | 5783 | |
5784 | - return (string) \mb_ereg_replace('[\\-_\\s]+', $delimiter, $str); |
|
5784 | + return (string)\mb_ereg_replace('[\\-_\\s]+', $delimiter, $str); |
|
5785 | 5785 | } |
5786 | 5786 | |
5787 | - $str = (string) \preg_replace('/\\B(\\p{Lu})/u', '-\1', \trim($str)); |
|
5787 | + $str = (string)\preg_replace('/\\B(\\p{Lu})/u', '-\1', \trim($str)); |
|
5788 | 5788 | |
5789 | 5789 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
5790 | 5790 | if ($use_mb_functions && $encoding === 'UTF-8') { |
@@ -5793,7 +5793,7 @@ discard block |
||
5793 | 5793 | $str = self::strtolower($str, $encoding, $clean_utf8, $lang, $try_to_keep_the_string_length); |
5794 | 5794 | } |
5795 | 5795 | |
5796 | - return (string) \preg_replace('/[\\-_\\s]+/u', $delimiter, $str); |
|
5796 | + return (string)\preg_replace('/[\\-_\\s]+/u', $delimiter, $str); |
|
5797 | 5797 | } |
5798 | 5798 | |
5799 | 5799 | /** |
@@ -5817,7 +5817,7 @@ discard block |
||
5817 | 5817 | public static function str_detect_encoding($str) |
5818 | 5818 | { |
5819 | 5819 | // init |
5820 | - $str = (string) $str; |
|
5820 | + $str = (string)$str; |
|
5821 | 5821 | |
5822 | 5822 | // |
5823 | 5823 | // 1.) check binary strings (010001001...) like UTF-16 / UTF-32 / PDF / Images / ... |
@@ -5919,7 +5919,7 @@ discard block |
||
5919 | 5919 | foreach (self::$ENCODINGS as $encoding_tmp) { |
5920 | 5920 | // INFO: //IGNORE but still throw notice |
5921 | 5921 | /** @noinspection PhpUsageOfSilenceOperatorInspection */ |
5922 | - if ((string) @\iconv($encoding_tmp, $encoding_tmp . '//IGNORE', $str) === $str) { |
|
5922 | + if ((string)@\iconv($encoding_tmp, $encoding_tmp.'//IGNORE', $str) === $str) { |
|
5923 | 5923 | return $encoding_tmp; |
5924 | 5924 | } |
5925 | 5925 | } |
@@ -6009,7 +6009,7 @@ discard block |
||
6009 | 6009 | return $str; |
6010 | 6010 | } |
6011 | 6011 | |
6012 | - return $substring . $str; |
|
6012 | + return $substring.$str; |
|
6013 | 6013 | } |
6014 | 6014 | |
6015 | 6015 | /** |
@@ -6139,27 +6139,27 @@ discard block |
||
6139 | 6139 | string $encoding = 'UTF-8' |
6140 | 6140 | ): string { |
6141 | 6141 | if ($encoding === 'UTF-8') { |
6142 | - $len = (int) \mb_strlen($str); |
|
6142 | + $len = (int)\mb_strlen($str); |
|
6143 | 6143 | if ($index > $len) { |
6144 | 6144 | return $str; |
6145 | 6145 | } |
6146 | 6146 | |
6147 | 6147 | /** @noinspection UnnecessaryCastingInspection */ |
6148 | - return (string) \mb_substr($str, 0, $index) . |
|
6149 | - $substring . |
|
6150 | - (string) \mb_substr($str, $index, $len); |
|
6148 | + return (string)\mb_substr($str, 0, $index). |
|
6149 | + $substring. |
|
6150 | + (string)\mb_substr($str, $index, $len); |
|
6151 | 6151 | } |
6152 | 6152 | |
6153 | 6153 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
6154 | 6154 | |
6155 | - $len = (int) self::strlen($str, $encoding); |
|
6155 | + $len = (int)self::strlen($str, $encoding); |
|
6156 | 6156 | if ($index > $len) { |
6157 | 6157 | return $str; |
6158 | 6158 | } |
6159 | 6159 | |
6160 | - return ((string) self::substr($str, 0, $index, $encoding)) . |
|
6161 | - $substring . |
|
6162 | - ((string) self::substr($str, $index, $len, $encoding)); |
|
6160 | + return ((string)self::substr($str, 0, $index, $encoding)). |
|
6161 | + $substring. |
|
6162 | + ((string)self::substr($str, $index, $len, $encoding)); |
|
6163 | 6163 | } |
6164 | 6164 | |
6165 | 6165 | /** |
@@ -6199,15 +6199,15 @@ discard block |
||
6199 | 6199 | */ |
6200 | 6200 | public static function str_ireplace($search, $replacement, $subject, &$count = null) |
6201 | 6201 | { |
6202 | - $search = (array) $search; |
|
6202 | + $search = (array)$search; |
|
6203 | 6203 | |
6204 | 6204 | /** @noinspection AlterInForeachInspection */ |
6205 | 6205 | foreach ($search as &$s) { |
6206 | - $s = (string) $s; |
|
6206 | + $s = (string)$s; |
|
6207 | 6207 | if ($s === '') { |
6208 | 6208 | $s = '/^(?<=.)$/'; |
6209 | 6209 | } else { |
6210 | - $s = '/' . \preg_quote($s, '/') . '/ui'; |
|
6210 | + $s = '/'.\preg_quote($s, '/').'/ui'; |
|
6211 | 6211 | } |
6212 | 6212 | } |
6213 | 6213 | |
@@ -6255,12 +6255,12 @@ discard block |
||
6255 | 6255 | } |
6256 | 6256 | |
6257 | 6257 | if ($search === '') { |
6258 | - return $str . $replacement; |
|
6258 | + return $str.$replacement; |
|
6259 | 6259 | } |
6260 | 6260 | |
6261 | 6261 | $searchLength = \strlen($search); |
6262 | 6262 | if (\strncasecmp($str, $search, $searchLength) === 0) { |
6263 | - return $replacement . \substr($str, $searchLength); |
|
6263 | + return $replacement.\substr($str, $searchLength); |
|
6264 | 6264 | } |
6265 | 6265 | |
6266 | 6266 | return $str; |
@@ -6291,11 +6291,11 @@ discard block |
||
6291 | 6291 | } |
6292 | 6292 | |
6293 | 6293 | if ($search === '') { |
6294 | - return $str . $replacement; |
|
6294 | + return $str.$replacement; |
|
6295 | 6295 | } |
6296 | 6296 | |
6297 | 6297 | if (\stripos($str, $search, \strlen($str) - \strlen($search)) !== false) { |
6298 | - $str = \substr($str, 0, -\strlen($search)) . $replacement; |
|
6298 | + $str = \substr($str, 0, -\strlen($search)).$replacement; |
|
6299 | 6299 | } |
6300 | 6300 | |
6301 | 6301 | return $str; |
@@ -6387,15 +6387,15 @@ discard block |
||
6387 | 6387 | } |
6388 | 6388 | |
6389 | 6389 | if ($encoding === 'UTF-8') { |
6390 | - return (string) \mb_substr( |
|
6390 | + return (string)\mb_substr( |
|
6391 | 6391 | $str, |
6392 | - $offset + (int) \mb_strlen($separator) |
|
6392 | + $offset + (int)\mb_strlen($separator) |
|
6393 | 6393 | ); |
6394 | 6394 | } |
6395 | 6395 | |
6396 | - return (string) self::substr( |
|
6396 | + return (string)self::substr( |
|
6397 | 6397 | $str, |
6398 | - $offset + (int) self::strlen($separator, $encoding), |
|
6398 | + $offset + (int)self::strlen($separator, $encoding), |
|
6399 | 6399 | null, |
6400 | 6400 | $encoding |
6401 | 6401 | ); |
@@ -6427,15 +6427,15 @@ discard block |
||
6427 | 6427 | } |
6428 | 6428 | |
6429 | 6429 | if ($encoding === 'UTF-8') { |
6430 | - return (string) \mb_substr( |
|
6430 | + return (string)\mb_substr( |
|
6431 | 6431 | $str, |
6432 | - $offset + (int) self::strlen($separator) |
|
6432 | + $offset + (int)self::strlen($separator) |
|
6433 | 6433 | ); |
6434 | 6434 | } |
6435 | 6435 | |
6436 | - return (string) self::substr( |
|
6436 | + return (string)self::substr( |
|
6437 | 6437 | $str, |
6438 | - $offset + (int) self::strlen($separator, $encoding), |
|
6438 | + $offset + (int)self::strlen($separator, $encoding), |
|
6439 | 6439 | null, |
6440 | 6440 | $encoding |
6441 | 6441 | ); |
@@ -6467,10 +6467,10 @@ discard block |
||
6467 | 6467 | } |
6468 | 6468 | |
6469 | 6469 | if ($encoding === 'UTF-8') { |
6470 | - return (string) \mb_substr($str, 0, $offset); |
|
6470 | + return (string)\mb_substr($str, 0, $offset); |
|
6471 | 6471 | } |
6472 | 6472 | |
6473 | - return (string) self::substr($str, 0, $offset, $encoding); |
|
6473 | + return (string)self::substr($str, 0, $offset, $encoding); |
|
6474 | 6474 | } |
6475 | 6475 | |
6476 | 6476 | /** |
@@ -6499,7 +6499,7 @@ discard block |
||
6499 | 6499 | return ''; |
6500 | 6500 | } |
6501 | 6501 | |
6502 | - return (string) \mb_substr($str, 0, $offset); |
|
6502 | + return (string)\mb_substr($str, 0, $offset); |
|
6503 | 6503 | } |
6504 | 6504 | |
6505 | 6505 | $offset = self::strripos($str, $separator, 0, $encoding); |
@@ -6507,7 +6507,7 @@ discard block |
||
6507 | 6507 | return ''; |
6508 | 6508 | } |
6509 | 6509 | |
6510 | - return (string) self::substr($str, 0, $offset, $encoding); |
|
6510 | + return (string)self::substr($str, 0, $offset, $encoding); |
|
6511 | 6511 | } |
6512 | 6512 | |
6513 | 6513 | /** |
@@ -6609,12 +6609,12 @@ discard block |
||
6609 | 6609 | } |
6610 | 6610 | |
6611 | 6611 | if ($encoding === 'UTF-8') { |
6612 | - return (string) \mb_substr($str, -$n); |
|
6612 | + return (string)\mb_substr($str, -$n); |
|
6613 | 6613 | } |
6614 | 6614 | |
6615 | 6615 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
6616 | 6616 | |
6617 | - return (string) self::substr($str, -$n, null, $encoding); |
|
6617 | + return (string)self::substr($str, -$n, null, $encoding); |
|
6618 | 6618 | } |
6619 | 6619 | |
6620 | 6620 | /** |
@@ -6640,21 +6640,21 @@ discard block |
||
6640 | 6640 | } |
6641 | 6641 | |
6642 | 6642 | if ($encoding === 'UTF-8') { |
6643 | - if ((int) \mb_strlen($str) <= $length) { |
|
6643 | + if ((int)\mb_strlen($str) <= $length) { |
|
6644 | 6644 | return $str; |
6645 | 6645 | } |
6646 | 6646 | |
6647 | 6647 | /** @noinspection UnnecessaryCastingInspection */ |
6648 | - return (string) \mb_substr($str, 0, $length - (int) self::strlen($str_add_on)) . $str_add_on; |
|
6648 | + return (string)\mb_substr($str, 0, $length - (int)self::strlen($str_add_on)).$str_add_on; |
|
6649 | 6649 | } |
6650 | 6650 | |
6651 | 6651 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
6652 | 6652 | |
6653 | - if ((int) self::strlen($str, $encoding) <= $length) { |
|
6653 | + if ((int)self::strlen($str, $encoding) <= $length) { |
|
6654 | 6654 | return $str; |
6655 | 6655 | } |
6656 | 6656 | |
6657 | - return ((string) self::substr($str, 0, $length - (int) self::strlen($str_add_on), $encoding)) . $str_add_on; |
|
6657 | + return ((string)self::substr($str, 0, $length - (int)self::strlen($str_add_on), $encoding)).$str_add_on; |
|
6658 | 6658 | } |
6659 | 6659 | |
6660 | 6660 | /** |
@@ -6682,12 +6682,12 @@ discard block |
||
6682 | 6682 | } |
6683 | 6683 | |
6684 | 6684 | if ($encoding === 'UTF-8') { |
6685 | - if ((int) \mb_strlen($str) <= $length) { |
|
6685 | + if ((int)\mb_strlen($str) <= $length) { |
|
6686 | 6686 | return $str; |
6687 | 6687 | } |
6688 | 6688 | |
6689 | 6689 | if (\mb_substr($str, $length - 1, 1) === ' ') { |
6690 | - return ((string) \mb_substr($str, 0, $length - 1)) . $str_add_on; |
|
6690 | + return ((string)\mb_substr($str, 0, $length - 1)).$str_add_on; |
|
6691 | 6691 | } |
6692 | 6692 | |
6693 | 6693 | $str = \mb_substr($str, 0, $length); |
@@ -6696,32 +6696,32 @@ discard block |
||
6696 | 6696 | $new_str = \implode(' ', $array); |
6697 | 6697 | |
6698 | 6698 | if ($new_str === '') { |
6699 | - return ((string) \mb_substr($str, 0, $length - 1)) . $str_add_on; |
|
6699 | + return ((string)\mb_substr($str, 0, $length - 1)).$str_add_on; |
|
6700 | 6700 | } |
6701 | 6701 | } else { |
6702 | - if ((int) self::strlen($str, $encoding) <= $length) { |
|
6702 | + if ((int)self::strlen($str, $encoding) <= $length) { |
|
6703 | 6703 | return $str; |
6704 | 6704 | } |
6705 | 6705 | |
6706 | 6706 | if (self::substr($str, $length - 1, 1, $encoding) === ' ') { |
6707 | - return ((string) self::substr($str, 0, $length - 1, $encoding)) . $str_add_on; |
|
6707 | + return ((string)self::substr($str, 0, $length - 1, $encoding)).$str_add_on; |
|
6708 | 6708 | } |
6709 | 6709 | |
6710 | 6710 | /** @noinspection CallableParameterUseCaseInTypeContextInspection - FP */ |
6711 | 6711 | $str = self::substr($str, 0, $length, $encoding); |
6712 | 6712 | if ($str === false) { |
6713 | - return '' . $str_add_on; |
|
6713 | + return ''.$str_add_on; |
|
6714 | 6714 | } |
6715 | 6715 | |
6716 | 6716 | $array = \explode(' ', $str, -1); |
6717 | 6717 | $new_str = \implode(' ', $array); |
6718 | 6718 | |
6719 | 6719 | if ($new_str === '') { |
6720 | - return ((string) self::substr($str, 0, $length - 1, $encoding)) . $str_add_on; |
|
6720 | + return ((string)self::substr($str, 0, $length - 1, $encoding)).$str_add_on; |
|
6721 | 6721 | } |
6722 | 6722 | } |
6723 | 6723 | |
6724 | - return $new_str . $str_add_on; |
|
6724 | + return $new_str.$str_add_on; |
|
6725 | 6725 | } |
6726 | 6726 | |
6727 | 6727 | /** |
@@ -6744,7 +6744,7 @@ discard block |
||
6744 | 6744 | $longest_common_prefix = ''; |
6745 | 6745 | |
6746 | 6746 | if ($encoding === 'UTF-8') { |
6747 | - $max_length = (int) \min( |
|
6747 | + $max_length = (int)\min( |
|
6748 | 6748 | \mb_strlen($str1), |
6749 | 6749 | \mb_strlen($str2) |
6750 | 6750 | ); |
@@ -6765,7 +6765,7 @@ discard block |
||
6765 | 6765 | } else { |
6766 | 6766 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
6767 | 6767 | |
6768 | - $max_length = (int) \min( |
|
6768 | + $max_length = (int)\min( |
|
6769 | 6769 | self::strlen($str1, $encoding), |
6770 | 6770 | self::strlen($str2, $encoding) |
6771 | 6771 | ); |
@@ -6814,13 +6814,13 @@ discard block |
||
6814 | 6814 | // http://en.wikipedia.org/wiki/Longest_common_substring_problem |
6815 | 6815 | |
6816 | 6816 | if ($encoding === 'UTF-8') { |
6817 | - $str_length = (int) \mb_strlen($str1); |
|
6818 | - $other_length = (int) \mb_strlen($str2); |
|
6817 | + $str_length = (int)\mb_strlen($str1); |
|
6818 | + $other_length = (int)\mb_strlen($str2); |
|
6819 | 6819 | } else { |
6820 | 6820 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
6821 | 6821 | |
6822 | - $str_length = (int) self::strlen($str1, $encoding); |
|
6823 | - $other_length = (int) self::strlen($str2, $encoding); |
|
6822 | + $str_length = (int)self::strlen($str1, $encoding); |
|
6823 | + $other_length = (int)self::strlen($str2, $encoding); |
|
6824 | 6824 | } |
6825 | 6825 | |
6826 | 6826 | // Return if either string is empty |
@@ -6873,10 +6873,10 @@ discard block |
||
6873 | 6873 | } |
6874 | 6874 | |
6875 | 6875 | if ($encoding === 'UTF-8') { |
6876 | - return (string) \mb_substr($str1, $end - $len, $len); |
|
6876 | + return (string)\mb_substr($str1, $end - $len, $len); |
|
6877 | 6877 | } |
6878 | 6878 | |
6879 | - return (string) self::substr($str1, $end - $len, $len, $encoding); |
|
6879 | + return (string)self::substr($str1, $end - $len, $len, $encoding); |
|
6880 | 6880 | } |
6881 | 6881 | |
6882 | 6882 | /** |
@@ -6900,7 +6900,7 @@ discard block |
||
6900 | 6900 | } |
6901 | 6901 | |
6902 | 6902 | if ($encoding === 'UTF-8') { |
6903 | - $max_length = (int) \min( |
|
6903 | + $max_length = (int)\min( |
|
6904 | 6904 | \mb_strlen($str1, $encoding), |
6905 | 6905 | \mb_strlen($str2, $encoding) |
6906 | 6906 | ); |
@@ -6914,7 +6914,7 @@ discard block |
||
6914 | 6914 | && |
6915 | 6915 | $char === \mb_substr($str2, -$i, 1) |
6916 | 6916 | ) { |
6917 | - $longest_common_suffix = $char . $longest_common_suffix; |
|
6917 | + $longest_common_suffix = $char.$longest_common_suffix; |
|
6918 | 6918 | } else { |
6919 | 6919 | break; |
6920 | 6920 | } |
@@ -6922,7 +6922,7 @@ discard block |
||
6922 | 6922 | } else { |
6923 | 6923 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
6924 | 6924 | |
6925 | - $max_length = (int) \min( |
|
6925 | + $max_length = (int)\min( |
|
6926 | 6926 | self::strlen($str1, $encoding), |
6927 | 6927 | self::strlen($str2, $encoding) |
6928 | 6928 | ); |
@@ -6936,7 +6936,7 @@ discard block |
||
6936 | 6936 | && |
6937 | 6937 | $char === self::substr($str2, -$i, 1, $encoding) |
6938 | 6938 | ) { |
6939 | - $longest_common_suffix = $char . $longest_common_suffix; |
|
6939 | + $longest_common_suffix = $char.$longest_common_suffix; |
|
6940 | 6940 | } else { |
6941 | 6941 | break; |
6942 | 6942 | } |
@@ -6959,7 +6959,7 @@ discard block |
||
6959 | 6959 | */ |
6960 | 6960 | public static function str_matches_pattern(string $str, string $pattern): bool |
6961 | 6961 | { |
6962 | - return (bool) \preg_match('/' . $pattern . '/u', $str); |
|
6962 | + return (bool)\preg_match('/'.$pattern.'/u', $str); |
|
6963 | 6963 | } |
6964 | 6964 | |
6965 | 6965 | /** |
@@ -6979,7 +6979,7 @@ discard block |
||
6979 | 6979 | public static function str_offset_exists(string $str, int $offset, string $encoding = 'UTF-8'): bool |
6980 | 6980 | { |
6981 | 6981 | // init |
6982 | - $length = (int) self::strlen($str, $encoding); |
|
6982 | + $length = (int)self::strlen($str, $encoding); |
|
6983 | 6983 | |
6984 | 6984 | if ($offset >= 0) { |
6985 | 6985 | return $length > $offset; |
@@ -7008,7 +7008,7 @@ discard block |
||
7008 | 7008 | public static function str_offset_get(string $str, int $index, string $encoding = 'UTF-8'): string |
7009 | 7009 | { |
7010 | 7010 | // init |
7011 | - $length = (int) self::strlen($str); |
|
7011 | + $length = (int)self::strlen($str); |
|
7012 | 7012 | |
7013 | 7013 | if ( |
7014 | 7014 | ($index >= 0 && $length <= $index) |
@@ -7052,7 +7052,7 @@ discard block |
||
7052 | 7052 | return $str; |
7053 | 7053 | } |
7054 | 7054 | |
7055 | - if ($pad_type !== (int) $pad_type) { |
|
7055 | + if ($pad_type !== (int)$pad_type) { |
|
7056 | 7056 | if ($pad_type === 'left') { |
7057 | 7057 | $pad_type = \STR_PAD_LEFT; |
7058 | 7058 | } elseif ($pad_type === 'right') { |
@@ -7061,23 +7061,23 @@ discard block |
||
7061 | 7061 | $pad_type = \STR_PAD_BOTH; |
7062 | 7062 | } else { |
7063 | 7063 | throw new \InvalidArgumentException( |
7064 | - 'Pad expects $pad_type to be "STR_PAD_*" or ' . "to be one of 'left', 'right' or 'both'" |
|
7064 | + 'Pad expects $pad_type to be "STR_PAD_*" or '."to be one of 'left', 'right' or 'both'" |
|
7065 | 7065 | ); |
7066 | 7066 | } |
7067 | 7067 | } |
7068 | 7068 | |
7069 | 7069 | if ($encoding === 'UTF-8') { |
7070 | - $str_length = (int) \mb_strlen($str); |
|
7070 | + $str_length = (int)\mb_strlen($str); |
|
7071 | 7071 | |
7072 | 7072 | if ($pad_length >= $str_length) { |
7073 | 7073 | switch ($pad_type) { |
7074 | 7074 | case \STR_PAD_LEFT: |
7075 | - $ps_length = (int) \mb_strlen($pad_string); |
|
7075 | + $ps_length = (int)\mb_strlen($pad_string); |
|
7076 | 7076 | |
7077 | 7077 | $diff = ($pad_length - $str_length); |
7078 | 7078 | |
7079 | - $pre = (string) \mb_substr( |
|
7080 | - \str_repeat($pad_string, (int) \ceil($diff / $ps_length)), |
|
7079 | + $pre = (string)\mb_substr( |
|
7080 | + \str_repeat($pad_string, (int)\ceil($diff / $ps_length)), |
|
7081 | 7081 | 0, |
7082 | 7082 | $diff |
7083 | 7083 | ); |
@@ -7088,16 +7088,16 @@ discard block |
||
7088 | 7088 | case \STR_PAD_BOTH: |
7089 | 7089 | $diff = ($pad_length - $str_length); |
7090 | 7090 | |
7091 | - $ps_length_left = (int) \floor($diff / 2); |
|
7091 | + $ps_length_left = (int)\floor($diff / 2); |
|
7092 | 7092 | |
7093 | - $ps_length_right = (int) \ceil($diff / 2); |
|
7093 | + $ps_length_right = (int)\ceil($diff / 2); |
|
7094 | 7094 | |
7095 | - $pre = (string) \mb_substr( |
|
7095 | + $pre = (string)\mb_substr( |
|
7096 | 7096 | \str_repeat($pad_string, $ps_length_left), |
7097 | 7097 | 0, |
7098 | 7098 | $ps_length_left |
7099 | 7099 | ); |
7100 | - $post = (string) \mb_substr( |
|
7100 | + $post = (string)\mb_substr( |
|
7101 | 7101 | \str_repeat($pad_string, $ps_length_right), |
7102 | 7102 | 0, |
7103 | 7103 | $ps_length_right |
@@ -7107,19 +7107,19 @@ discard block |
||
7107 | 7107 | |
7108 | 7108 | case \STR_PAD_RIGHT: |
7109 | 7109 | default: |
7110 | - $ps_length = (int) \mb_strlen($pad_string); |
|
7110 | + $ps_length = (int)\mb_strlen($pad_string); |
|
7111 | 7111 | |
7112 | 7112 | $diff = ($pad_length - $str_length); |
7113 | 7113 | |
7114 | - $post = (string) \mb_substr( |
|
7115 | - \str_repeat($pad_string, (int) \ceil($diff / $ps_length)), |
|
7114 | + $post = (string)\mb_substr( |
|
7115 | + \str_repeat($pad_string, (int)\ceil($diff / $ps_length)), |
|
7116 | 7116 | 0, |
7117 | 7117 | $diff |
7118 | 7118 | ); |
7119 | 7119 | $pre = ''; |
7120 | 7120 | } |
7121 | 7121 | |
7122 | - return $pre . $str . $post; |
|
7122 | + return $pre.$str.$post; |
|
7123 | 7123 | } |
7124 | 7124 | |
7125 | 7125 | return $str; |
@@ -7127,17 +7127,17 @@ discard block |
||
7127 | 7127 | |
7128 | 7128 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
7129 | 7129 | |
7130 | - $str_length = (int) self::strlen($str, $encoding); |
|
7130 | + $str_length = (int)self::strlen($str, $encoding); |
|
7131 | 7131 | |
7132 | 7132 | if ($pad_length >= $str_length) { |
7133 | 7133 | switch ($pad_type) { |
7134 | 7134 | case \STR_PAD_LEFT: |
7135 | - $ps_length = (int) self::strlen($pad_string, $encoding); |
|
7135 | + $ps_length = (int)self::strlen($pad_string, $encoding); |
|
7136 | 7136 | |
7137 | 7137 | $diff = ($pad_length - $str_length); |
7138 | 7138 | |
7139 | - $pre = (string) self::substr( |
|
7140 | - \str_repeat($pad_string, (int) \ceil($diff / $ps_length)), |
|
7139 | + $pre = (string)self::substr( |
|
7140 | + \str_repeat($pad_string, (int)\ceil($diff / $ps_length)), |
|
7141 | 7141 | 0, |
7142 | 7142 | $diff, |
7143 | 7143 | $encoding |
@@ -7149,17 +7149,17 @@ discard block |
||
7149 | 7149 | case \STR_PAD_BOTH: |
7150 | 7150 | $diff = ($pad_length - $str_length); |
7151 | 7151 | |
7152 | - $ps_length_left = (int) \floor($diff / 2); |
|
7152 | + $ps_length_left = (int)\floor($diff / 2); |
|
7153 | 7153 | |
7154 | - $ps_length_right = (int) \ceil($diff / 2); |
|
7154 | + $ps_length_right = (int)\ceil($diff / 2); |
|
7155 | 7155 | |
7156 | - $pre = (string) self::substr( |
|
7156 | + $pre = (string)self::substr( |
|
7157 | 7157 | \str_repeat($pad_string, $ps_length_left), |
7158 | 7158 | 0, |
7159 | 7159 | $ps_length_left, |
7160 | 7160 | $encoding |
7161 | 7161 | ); |
7162 | - $post = (string) self::substr( |
|
7162 | + $post = (string)self::substr( |
|
7163 | 7163 | \str_repeat($pad_string, $ps_length_right), |
7164 | 7164 | 0, |
7165 | 7165 | $ps_length_right, |
@@ -7170,12 +7170,12 @@ discard block |
||
7170 | 7170 | |
7171 | 7171 | case \STR_PAD_RIGHT: |
7172 | 7172 | default: |
7173 | - $ps_length = (int) self::strlen($pad_string, $encoding); |
|
7173 | + $ps_length = (int)self::strlen($pad_string, $encoding); |
|
7174 | 7174 | |
7175 | 7175 | $diff = ($pad_length - $str_length); |
7176 | 7176 | |
7177 | - $post = (string) self::substr( |
|
7178 | - \str_repeat($pad_string, (int) \ceil($diff / $ps_length)), |
|
7177 | + $post = (string)self::substr( |
|
7178 | + \str_repeat($pad_string, (int)\ceil($diff / $ps_length)), |
|
7179 | 7179 | 0, |
7180 | 7180 | $diff, |
7181 | 7181 | $encoding |
@@ -7183,7 +7183,7 @@ discard block |
||
7183 | 7183 | $pre = ''; |
7184 | 7184 | } |
7185 | 7185 | |
7186 | - return $pre . $str . $post; |
|
7186 | + return $pre.$str.$post; |
|
7187 | 7187 | } |
7188 | 7188 | |
7189 | 7189 | return $str; |
@@ -7394,12 +7394,12 @@ discard block |
||
7394 | 7394 | } |
7395 | 7395 | |
7396 | 7396 | if ($search === '') { |
7397 | - return $str . $replacement; |
|
7397 | + return $str.$replacement; |
|
7398 | 7398 | } |
7399 | 7399 | |
7400 | 7400 | $searchLength = \strlen($search); |
7401 | 7401 | if (\strncmp($str, $search, $searchLength) === 0) { |
7402 | - return $replacement . \substr($str, $searchLength); |
|
7402 | + return $replacement.\substr($str, $searchLength); |
|
7403 | 7403 | } |
7404 | 7404 | |
7405 | 7405 | return $str; |
@@ -7433,11 +7433,11 @@ discard block |
||
7433 | 7433 | } |
7434 | 7434 | |
7435 | 7435 | if ($search === '') { |
7436 | - return $str . $replacement; |
|
7436 | + return $str.$replacement; |
|
7437 | 7437 | } |
7438 | 7438 | |
7439 | 7439 | if (\strpos($str, $search, \strlen($str) - \strlen($search)) !== false) { |
7440 | - $str = \substr($str, 0, -\strlen($search)) . $replacement; |
|
7440 | + $str = \substr($str, 0, -\strlen($search)).$replacement; |
|
7441 | 7441 | } |
7442 | 7442 | |
7443 | 7443 | return $str; |
@@ -7471,7 +7471,7 @@ discard block |
||
7471 | 7471 | $subject, |
7472 | 7472 | $replace, |
7473 | 7473 | $pos, |
7474 | - (int) self::strlen($search) |
|
7474 | + (int)self::strlen($search) |
|
7475 | 7475 | ); |
7476 | 7476 | } |
7477 | 7477 | |
@@ -7505,7 +7505,7 @@ discard block |
||
7505 | 7505 | $subject, |
7506 | 7506 | $replace, |
7507 | 7507 | $pos, |
7508 | - (int) self::strlen($search) |
|
7508 | + (int)self::strlen($search) |
|
7509 | 7509 | ); |
7510 | 7510 | } |
7511 | 7511 | |
@@ -7528,7 +7528,7 @@ discard block |
||
7528 | 7528 | public static function str_shuffle(string $str, string $encoding = 'UTF-8'): string |
7529 | 7529 | { |
7530 | 7530 | if ($encoding === 'UTF-8') { |
7531 | - $indexes = \range(0, (int) \mb_strlen($str) - 1); |
|
7531 | + $indexes = \range(0, (int)\mb_strlen($str) - 1); |
|
7532 | 7532 | \shuffle($indexes); |
7533 | 7533 | |
7534 | 7534 | // init |
@@ -7543,7 +7543,7 @@ discard block |
||
7543 | 7543 | } else { |
7544 | 7544 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
7545 | 7545 | |
7546 | - $indexes = \range(0, (int) self::strlen($str, $encoding) - 1); |
|
7546 | + $indexes = \range(0, (int)self::strlen($str, $encoding) - 1); |
|
7547 | 7547 | \shuffle($indexes); |
7548 | 7548 | |
7549 | 7549 | // init |
@@ -7585,11 +7585,11 @@ discard block |
||
7585 | 7585 | ) { |
7586 | 7586 | if ($encoding === 'UTF-8') { |
7587 | 7587 | if ($end === null) { |
7588 | - $length = (int) \mb_strlen($str); |
|
7588 | + $length = (int)\mb_strlen($str); |
|
7589 | 7589 | } elseif ($end >= 0 && $end <= $start) { |
7590 | 7590 | return ''; |
7591 | 7591 | } elseif ($end < 0) { |
7592 | - $length = (int) \mb_strlen($str) + $end - $start; |
|
7592 | + $length = (int)\mb_strlen($str) + $end - $start; |
|
7593 | 7593 | } else { |
7594 | 7594 | $length = $end - $start; |
7595 | 7595 | } |
@@ -7600,11 +7600,11 @@ discard block |
||
7600 | 7600 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
7601 | 7601 | |
7602 | 7602 | if ($end === null) { |
7603 | - $length = (int) self::strlen($str, $encoding); |
|
7603 | + $length = (int)self::strlen($str, $encoding); |
|
7604 | 7604 | } elseif ($end >= 0 && $end <= $start) { |
7605 | 7605 | return ''; |
7606 | 7606 | } elseif ($end < 0) { |
7607 | - $length = (int) self::strlen($str, $encoding) + $end - $start; |
|
7607 | + $length = (int)self::strlen($str, $encoding) + $end - $start; |
|
7608 | 7608 | } else { |
7609 | 7609 | $length = $end - $start; |
7610 | 7610 | } |
@@ -7639,7 +7639,7 @@ discard block |
||
7639 | 7639 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
7640 | 7640 | } |
7641 | 7641 | |
7642 | - $str = (string) \preg_replace_callback( |
|
7642 | + $str = (string)\preg_replace_callback( |
|
7643 | 7643 | '/([\\p{N}|\\p{Lu}])/u', |
7644 | 7644 | /** |
7645 | 7645 | * @param string[] $matches |
@@ -7648,28 +7648,28 @@ discard block |
||
7648 | 7648 | * |
7649 | 7649 | * @return string |
7650 | 7650 | */ |
7651 | - static function (array $matches) use ($encoding): string { |
|
7651 | + static function(array $matches) use ($encoding): string { |
|
7652 | 7652 | $match = $matches[1]; |
7653 | - $match_int = (int) $match; |
|
7653 | + $match_int = (int)$match; |
|
7654 | 7654 | |
7655 | - if ((string) $match_int === $match) { |
|
7656 | - return '_' . $match . '_'; |
|
7655 | + if ((string)$match_int === $match) { |
|
7656 | + return '_'.$match.'_'; |
|
7657 | 7657 | } |
7658 | 7658 | |
7659 | 7659 | if ($encoding === 'UTF-8') { |
7660 | - return '_' . \mb_strtolower($match); |
|
7660 | + return '_'.\mb_strtolower($match); |
|
7661 | 7661 | } |
7662 | 7662 | |
7663 | - return '_' . self::strtolower($match, $encoding); |
|
7663 | + return '_'.self::strtolower($match, $encoding); |
|
7664 | 7664 | }, |
7665 | 7665 | $str |
7666 | 7666 | ); |
7667 | 7667 | |
7668 | - $str = (string) \preg_replace( |
|
7668 | + $str = (string)\preg_replace( |
|
7669 | 7669 | [ |
7670 | - '/\\s+/u', // convert spaces to "_" |
|
7670 | + '/\\s+/u', // convert spaces to "_" |
|
7671 | 7671 | '/^\\s+|\\s+$/u', // trim leading & trailing spaces |
7672 | - '/_+/', // remove double "_" |
|
7672 | + '/_+/', // remove double "_" |
|
7673 | 7673 | ], |
7674 | 7674 | [ |
7675 | 7675 | '_', |
@@ -7797,7 +7797,7 @@ discard block |
||
7797 | 7797 | } |
7798 | 7798 | |
7799 | 7799 | // init |
7800 | - $input = (string) $input; |
|
7800 | + $input = (string)$input; |
|
7801 | 7801 | |
7802 | 7802 | if ($input === '') { |
7803 | 7803 | return []; |
@@ -7853,7 +7853,7 @@ discard block |
||
7853 | 7853 | ($input[$i] & "\xE0") === "\xC0" |
7854 | 7854 | ) { |
7855 | 7855 | if (($input[$i + 1] & "\xC0") === "\x80") { |
7856 | - $ret[] = $input[$i] . $input[$i + 1]; |
|
7856 | + $ret[] = $input[$i].$input[$i + 1]; |
|
7857 | 7857 | |
7858 | 7858 | ++$i; |
7859 | 7859 | } |
@@ -7867,7 +7867,7 @@ discard block |
||
7867 | 7867 | && |
7868 | 7868 | ($input[$i + 2] & "\xC0") === "\x80" |
7869 | 7869 | ) { |
7870 | - $ret[] = $input[$i] . $input[$i + 1] . $input[$i + 2]; |
|
7870 | + $ret[] = $input[$i].$input[$i + 1].$input[$i + 2]; |
|
7871 | 7871 | |
7872 | 7872 | $i += 2; |
7873 | 7873 | } |
@@ -7883,7 +7883,7 @@ discard block |
||
7883 | 7883 | && |
7884 | 7884 | ($input[$i + 3] & "\xC0") === "\x80" |
7885 | 7885 | ) { |
7886 | - $ret[] = $input[$i] . $input[$i + 1] . $input[$i + 2] . $input[$i + 3]; |
|
7886 | + $ret[] = $input[$i].$input[$i + 1].$input[$i + 2].$input[$i + 3]; |
|
7887 | 7887 | |
7888 | 7888 | $i += 3; |
7889 | 7889 | } |
@@ -7893,7 +7893,7 @@ discard block |
||
7893 | 7893 | |
7894 | 7894 | if ($length > 1) { |
7895 | 7895 | return \array_map( |
7896 | - static function (array $item): string { |
|
7896 | + static function(array $item): string { |
|
7897 | 7897 | return \implode('', $item); |
7898 | 7898 | }, |
7899 | 7899 | \array_chunk($ret, $length) |
@@ -7965,7 +7965,7 @@ discard block |
||
7965 | 7965 | $limit = -1; |
7966 | 7966 | } |
7967 | 7967 | |
7968 | - $array = \preg_split('/' . \preg_quote($pattern, '/') . '/u', $str, $limit); |
|
7968 | + $array = \preg_split('/'.\preg_quote($pattern, '/').'/u', $str, $limit); |
|
7969 | 7969 | if ($array === false) { |
7970 | 7970 | return []; |
7971 | 7971 | } |
@@ -8065,9 +8065,9 @@ discard block |
||
8065 | 8065 | return ''; |
8066 | 8066 | } |
8067 | 8067 | |
8068 | - return (string) \mb_substr( |
|
8068 | + return (string)\mb_substr( |
|
8069 | 8069 | $str, |
8070 | - $offset + (int) \mb_strlen($separator) |
|
8070 | + $offset + (int)\mb_strlen($separator) |
|
8071 | 8071 | ); |
8072 | 8072 | } |
8073 | 8073 | |
@@ -8076,9 +8076,9 @@ discard block |
||
8076 | 8076 | return ''; |
8077 | 8077 | } |
8078 | 8078 | |
8079 | - return (string) \mb_substr( |
|
8079 | + return (string)\mb_substr( |
|
8080 | 8080 | $str, |
8081 | - $offset + (int) self::strlen($separator, $encoding), |
|
8081 | + $offset + (int)self::strlen($separator, $encoding), |
|
8082 | 8082 | null, |
8083 | 8083 | $encoding |
8084 | 8084 | ); |
@@ -8110,9 +8110,9 @@ discard block |
||
8110 | 8110 | return ''; |
8111 | 8111 | } |
8112 | 8112 | |
8113 | - return (string) \mb_substr( |
|
8113 | + return (string)\mb_substr( |
|
8114 | 8114 | $str, |
8115 | - $offset + (int) \mb_strlen($separator) |
|
8115 | + $offset + (int)\mb_strlen($separator) |
|
8116 | 8116 | ); |
8117 | 8117 | } |
8118 | 8118 | |
@@ -8121,9 +8121,9 @@ discard block |
||
8121 | 8121 | return ''; |
8122 | 8122 | } |
8123 | 8123 | |
8124 | - return (string) self::substr( |
|
8124 | + return (string)self::substr( |
|
8125 | 8125 | $str, |
8126 | - $offset + (int) self::strlen($separator, $encoding), |
|
8126 | + $offset + (int)self::strlen($separator, $encoding), |
|
8127 | 8127 | null, |
8128 | 8128 | $encoding |
8129 | 8129 | ); |
@@ -8155,7 +8155,7 @@ discard block |
||
8155 | 8155 | return ''; |
8156 | 8156 | } |
8157 | 8157 | |
8158 | - return (string) \mb_substr( |
|
8158 | + return (string)\mb_substr( |
|
8159 | 8159 | $str, |
8160 | 8160 | 0, |
8161 | 8161 | $offset |
@@ -8167,7 +8167,7 @@ discard block |
||
8167 | 8167 | return ''; |
8168 | 8168 | } |
8169 | 8169 | |
8170 | - return (string) self::substr( |
|
8170 | + return (string)self::substr( |
|
8171 | 8171 | $str, |
8172 | 8172 | 0, |
8173 | 8173 | $offset, |
@@ -8198,7 +8198,7 @@ discard block |
||
8198 | 8198 | return ''; |
8199 | 8199 | } |
8200 | 8200 | |
8201 | - return (string) \mb_substr( |
|
8201 | + return (string)\mb_substr( |
|
8202 | 8202 | $str, |
8203 | 8203 | 0, |
8204 | 8204 | $offset |
@@ -8212,7 +8212,7 @@ discard block |
||
8212 | 8212 | |
8213 | 8213 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
8214 | 8214 | |
8215 | - return (string) self::substr( |
|
8215 | + return (string)self::substr( |
|
8216 | 8216 | $str, |
8217 | 8217 | 0, |
8218 | 8218 | $offset, |
@@ -8327,7 +8327,7 @@ discard block |
||
8327 | 8327 | */ |
8328 | 8328 | public static function str_surround(string $str, string $substring): string |
8329 | 8329 | { |
8330 | - return $substring . $str . $substring; |
|
8330 | + return $substring.$str.$substring; |
|
8331 | 8331 | } |
8332 | 8332 | |
8333 | 8333 | /** |
@@ -8389,9 +8389,9 @@ discard block |
||
8389 | 8389 | $word_define_chars = ''; |
8390 | 8390 | } |
8391 | 8391 | |
8392 | - $str = (string) \preg_replace_callback( |
|
8393 | - '/([^\\s' . $word_define_chars . ']+)/u', |
|
8394 | - static function (array $match) use ($try_to_keep_the_string_length, $lang, $ignore, $use_mb_functions, $encoding): string { |
|
8392 | + $str = (string)\preg_replace_callback( |
|
8393 | + '/([^\\s'.$word_define_chars.']+)/u', |
|
8394 | + static function(array $match) use ($try_to_keep_the_string_length, $lang, $ignore, $use_mb_functions, $encoding): string { |
|
8395 | 8395 | if ($ignore !== null && \in_array($match[0], $ignore, true)) { |
8396 | 8396 | return $match[0]; |
8397 | 8397 | } |
@@ -8557,16 +8557,16 @@ discard block |
||
8557 | 8557 | } |
8558 | 8558 | |
8559 | 8559 | // the main substitutions |
8560 | - $str = (string) \preg_replace_callback( |
|
8560 | + $str = (string)\preg_replace_callback( |
|
8561 | 8561 | '~\\b (_*) (?: # 1. Leading underscore and |
8562 | 8562 | ( (?<=[ ][/\\\\]) [[:alpha:]]+ [-_[:alpha:]/\\\\]+ | # 2. file path or |
8563 | - [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ ' . $apostrophe_rx . ' ) # URL, domain, or email |
|
8563 | + [-_[:alpha:]]+ [@.:] [-_[:alpha:]@.:/]+ ' . $apostrophe_rx.' ) # URL, domain, or email |
|
8564 | 8564 | | |
8565 | - ( (?i: ' . $small_words_rx . ' ) ' . $apostrophe_rx . ' ) # 3. or small word (case-insensitive) |
|
8565 | + ( (?i: ' . $small_words_rx.' ) '.$apostrophe_rx.' ) # 3. or small word (case-insensitive) |
|
8566 | 8566 | | |
8567 | - ( [[:alpha:]] [[:lower:]\'’()\[\]{}]* ' . $apostrophe_rx . ' ) # 4. or word w/o internal caps |
|
8567 | + ( [[:alpha:]] [[:lower:]\'’()\[\]{}]* ' . $apostrophe_rx.' ) # 4. or word w/o internal caps |
|
8568 | 8568 | | |
8569 | - ( [[:alpha:]] [[:alpha:]\'’()\[\]{}]* ' . $apostrophe_rx . ' ) # 5. or some other word |
|
8569 | + ( [[:alpha:]] [[:alpha:]\'’()\[\]{}]* ' . $apostrophe_rx.' ) # 5. or some other word |
|
8570 | 8570 | ) (_*) \\b # 6. With trailing underscore |
8571 | 8571 | ~ux', |
8572 | 8572 | /** |
@@ -8576,7 +8576,7 @@ discard block |
||
8576 | 8576 | * |
8577 | 8577 | * @return string |
8578 | 8578 | */ |
8579 | - static function (array $matches) use ($encoding): string { |
|
8579 | + static function(array $matches) use ($encoding): string { |
|
8580 | 8580 | // preserve leading underscore |
8581 | 8581 | $str = $matches[1]; |
8582 | 8582 | if ($matches[2]) { |
@@ -8601,11 +8601,11 @@ discard block |
||
8601 | 8601 | ); |
8602 | 8602 | |
8603 | 8603 | // Exceptions for small words: capitalize at start of title... |
8604 | - $str = (string) \preg_replace_callback( |
|
8604 | + $str = (string)\preg_replace_callback( |
|
8605 | 8605 | '~( \\A [[:punct:]]* # start of title... |
8606 | 8606 | | [:.;?!][ ]+ # or of subsentence... |
8607 | 8607 | | [ ][\'"“‘(\[][ ]* ) # or of inserted subphrase... |
8608 | - ( ' . $small_words_rx . ' ) \\b # ...followed by small word |
|
8608 | + ( ' . $small_words_rx.' ) \\b # ...followed by small word |
|
8609 | 8609 | ~uxi', |
8610 | 8610 | /** |
8611 | 8611 | * @param string[] $matches |
@@ -8614,15 +8614,15 @@ discard block |
||
8614 | 8614 | * |
8615 | 8615 | * @return string |
8616 | 8616 | */ |
8617 | - static function (array $matches) use ($encoding): string { |
|
8618 | - return $matches[1] . static::ucfirst($matches[2], $encoding); |
|
8617 | + static function(array $matches) use ($encoding): string { |
|
8618 | + return $matches[1].static::ucfirst($matches[2], $encoding); |
|
8619 | 8619 | }, |
8620 | 8620 | $str |
8621 | 8621 | ); |
8622 | 8622 | |
8623 | 8623 | // ...and end of title |
8624 | - $str = (string) \preg_replace_callback( |
|
8625 | - '~\\b ( ' . $small_words_rx . ' ) # small word... |
|
8624 | + $str = (string)\preg_replace_callback( |
|
8625 | + '~\\b ( '.$small_words_rx.' ) # small word... |
|
8626 | 8626 | (?= [[:punct:]]* \Z # ...at the end of the title... |
8627 | 8627 | | [\'"’”)\]] [ ] ) # ...or of an inserted subphrase? |
8628 | 8628 | ~uxi', |
@@ -8633,7 +8633,7 @@ discard block |
||
8633 | 8633 | * |
8634 | 8634 | * @return string |
8635 | 8635 | */ |
8636 | - static function (array $matches) use ($encoding): string { |
|
8636 | + static function(array $matches) use ($encoding): string { |
|
8637 | 8637 | return static::ucfirst($matches[1], $encoding); |
8638 | 8638 | }, |
8639 | 8639 | $str |
@@ -8641,10 +8641,10 @@ discard block |
||
8641 | 8641 | |
8642 | 8642 | // Exceptions for small words in hyphenated compound words. |
8643 | 8643 | // e.g. "in-flight" -> In-Flight |
8644 | - $str = (string) \preg_replace_callback( |
|
8644 | + $str = (string)\preg_replace_callback( |
|
8645 | 8645 | '~\\b |
8646 | 8646 | (?<! -) # Negative lookbehind for a hyphen; we do not want to match man-in-the-middle but do want (in-flight) |
8647 | - ( ' . $small_words_rx . ' ) |
|
8647 | + ( ' . $small_words_rx.' ) |
|
8648 | 8648 | (?= -[[:alpha:]]+) # lookahead for "-someword" |
8649 | 8649 | ~uxi', |
8650 | 8650 | /** |
@@ -8654,18 +8654,18 @@ discard block |
||
8654 | 8654 | * |
8655 | 8655 | * @return string |
8656 | 8656 | */ |
8657 | - static function (array $matches) use ($encoding): string { |
|
8657 | + static function(array $matches) use ($encoding): string { |
|
8658 | 8658 | return static::ucfirst($matches[1], $encoding); |
8659 | 8659 | }, |
8660 | 8660 | $str |
8661 | 8661 | ); |
8662 | 8662 | |
8663 | 8663 | // e.g. "Stand-in" -> "Stand-In" (Stand is already capped at this point) |
8664 | - $str = (string) \preg_replace_callback( |
|
8664 | + $str = (string)\preg_replace_callback( |
|
8665 | 8665 | '~\\b |
8666 | 8666 | (?<!…) # Negative lookbehind for a hyphen; we do not want to match man-in-the-middle but do want (stand-in) |
8667 | 8667 | ( [[:alpha:]]+- ) # $1 = first word and hyphen, should already be properly capped |
8668 | - ( ' . $small_words_rx . ' ) # ...followed by small word |
|
8668 | + ( ' . $small_words_rx.' ) # ...followed by small word |
|
8669 | 8669 | (?! - ) # Negative lookahead for another - |
8670 | 8670 | ~uxi', |
8671 | 8671 | /** |
@@ -8675,8 +8675,8 @@ discard block |
||
8675 | 8675 | * |
8676 | 8676 | * @return string |
8677 | 8677 | */ |
8678 | - static function (array $matches) use ($encoding): string { |
|
8679 | - return $matches[1] . static::ucfirst($matches[2], $encoding); |
|
8678 | + static function(array $matches) use ($encoding): string { |
|
8679 | + return $matches[1].static::ucfirst($matches[2], $encoding); |
|
8680 | 8680 | }, |
8681 | 8681 | $str |
8682 | 8682 | ); |
@@ -8794,7 +8794,7 @@ discard block |
||
8794 | 8794 | ); |
8795 | 8795 | |
8796 | 8796 | foreach ($tmp_return as &$item) { |
8797 | - $item = (string) $item; |
|
8797 | + $item = (string)$item; |
|
8798 | 8798 | } |
8799 | 8799 | |
8800 | 8800 | return $tmp_return; |
@@ -8826,38 +8826,38 @@ discard block |
||
8826 | 8826 | } |
8827 | 8827 | |
8828 | 8828 | if ($encoding === 'UTF-8') { |
8829 | - if ($length >= (int) \mb_strlen($str)) { |
|
8829 | + if ($length >= (int)\mb_strlen($str)) { |
|
8830 | 8830 | return $str; |
8831 | 8831 | } |
8832 | 8832 | |
8833 | 8833 | if ($substring !== '') { |
8834 | - $length -= (int) \mb_strlen($substring); |
|
8834 | + $length -= (int)\mb_strlen($substring); |
|
8835 | 8835 | |
8836 | 8836 | /** @noinspection UnnecessaryCastingInspection */ |
8837 | - return (string) \mb_substr($str, 0, $length) . $substring; |
|
8837 | + return (string)\mb_substr($str, 0, $length).$substring; |
|
8838 | 8838 | } |
8839 | 8839 | |
8840 | - return (string) \mb_substr($str, 0, $length); |
|
8840 | + return (string)\mb_substr($str, 0, $length); |
|
8841 | 8841 | } |
8842 | 8842 | |
8843 | 8843 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
8844 | 8844 | |
8845 | - if ($length >= (int) self::strlen($str, $encoding)) { |
|
8845 | + if ($length >= (int)self::strlen($str, $encoding)) { |
|
8846 | 8846 | return $str; |
8847 | 8847 | } |
8848 | 8848 | |
8849 | 8849 | if ($substring !== '') { |
8850 | - $length -= (int) self::strlen($substring, $encoding); |
|
8850 | + $length -= (int)self::strlen($substring, $encoding); |
|
8851 | 8851 | } |
8852 | 8852 | |
8853 | 8853 | return ( |
8854 | - (string) self::substr( |
|
8854 | + (string)self::substr( |
|
8855 | 8855 | $str, |
8856 | 8856 | 0, |
8857 | 8857 | $length, |
8858 | 8858 | $encoding |
8859 | 8859 | ) |
8860 | - ) . $substring; |
|
8860 | + ).$substring; |
|
8861 | 8861 | } |
8862 | 8862 | |
8863 | 8863 | /** |
@@ -8891,12 +8891,12 @@ discard block |
||
8891 | 8891 | } |
8892 | 8892 | |
8893 | 8893 | if ($encoding === 'UTF-8') { |
8894 | - if ($length >= (int) \mb_strlen($str)) { |
|
8894 | + if ($length >= (int)\mb_strlen($str)) { |
|
8895 | 8895 | return $str; |
8896 | 8896 | } |
8897 | 8897 | |
8898 | 8898 | // need to further trim the string so we can append the substring |
8899 | - $length -= (int) \mb_strlen($substring); |
|
8899 | + $length -= (int)\mb_strlen($substring); |
|
8900 | 8900 | if ($length <= 0) { |
8901 | 8901 | return $substring; |
8902 | 8902 | } |
@@ -8922,18 +8922,18 @@ discard block |
||
8922 | 8922 | !$ignore_do_not_split_words_for_one_word |
8923 | 8923 | ) |
8924 | 8924 | ) { |
8925 | - $truncated = (string) \mb_substr($truncated, 0, (int) $last_position); |
|
8925 | + $truncated = (string)\mb_substr($truncated, 0, (int)$last_position); |
|
8926 | 8926 | } |
8927 | 8927 | } |
8928 | 8928 | } else { |
8929 | 8929 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
8930 | 8930 | |
8931 | - if ($length >= (int) self::strlen($str, $encoding)) { |
|
8931 | + if ($length >= (int)self::strlen($str, $encoding)) { |
|
8932 | 8932 | return $str; |
8933 | 8933 | } |
8934 | 8934 | |
8935 | 8935 | // need to further trim the string so we can append the substring |
8936 | - $length -= (int) self::strlen($substring, $encoding); |
|
8936 | + $length -= (int)self::strlen($substring, $encoding); |
|
8937 | 8937 | if ($length <= 0) { |
8938 | 8938 | return $substring; |
8939 | 8939 | } |
@@ -8959,12 +8959,12 @@ discard block |
||
8959 | 8959 | !$ignore_do_not_split_words_for_one_word |
8960 | 8960 | ) |
8961 | 8961 | ) { |
8962 | - $truncated = (string) self::substr($truncated, 0, (int) $last_position, $encoding); |
|
8962 | + $truncated = (string)self::substr($truncated, 0, (int)$last_position, $encoding); |
|
8963 | 8963 | } |
8964 | 8964 | } |
8965 | 8965 | } |
8966 | 8966 | |
8967 | - return $truncated . $substring; |
|
8967 | + return $truncated.$substring; |
|
8968 | 8968 | } |
8969 | 8969 | |
8970 | 8970 | /** |
@@ -9059,13 +9059,13 @@ discard block |
||
9059 | 9059 | } |
9060 | 9060 | } elseif ($format === 2) { |
9061 | 9061 | $number_of_words = []; |
9062 | - $offset = (int) self::strlen($str_parts[0]); |
|
9062 | + $offset = (int)self::strlen($str_parts[0]); |
|
9063 | 9063 | for ($i = 1; $i < $len; $i += 2) { |
9064 | 9064 | $number_of_words[$offset] = $str_parts[$i]; |
9065 | - $offset += (int) self::strlen($str_parts[$i]) + (int) self::strlen($str_parts[$i + 1]); |
|
9065 | + $offset += (int)self::strlen($str_parts[$i]) + (int)self::strlen($str_parts[$i + 1]); |
|
9066 | 9066 | } |
9067 | 9067 | } else { |
9068 | - $number_of_words = (int) (($len - 1) / 2); |
|
9068 | + $number_of_words = (int)(($len - 1) / 2); |
|
9069 | 9069 | } |
9070 | 9070 | |
9071 | 9071 | return $number_of_words; |
@@ -9168,7 +9168,7 @@ discard block |
||
9168 | 9168 | } |
9169 | 9169 | |
9170 | 9170 | if ($char_list === '') { |
9171 | - return (int) self::strlen($str, $encoding); |
|
9171 | + return (int)self::strlen($str, $encoding); |
|
9172 | 9172 | } |
9173 | 9173 | |
9174 | 9174 | if ($offset || $length !== null) { |
@@ -9194,7 +9194,7 @@ discard block |
||
9194 | 9194 | } |
9195 | 9195 | |
9196 | 9196 | $matches = []; |
9197 | - if (\preg_match('/^(.*?)' . self::rxClass($char_list) . '/us', $str, $matches)) { |
|
9197 | + if (\preg_match('/^(.*?)'.self::rxClass($char_list).'/us', $str, $matches)) { |
|
9198 | 9198 | $return = self::strlen($matches[1], $encoding); |
9199 | 9199 | if ($return === false) { |
9200 | 9200 | return 0; |
@@ -9203,7 +9203,7 @@ discard block |
||
9203 | 9203 | return $return; |
9204 | 9204 | } |
9205 | 9205 | |
9206 | - return (int) self::strlen($str, $encoding); |
|
9206 | + return (int)self::strlen($str, $encoding); |
|
9207 | 9207 | } |
9208 | 9208 | |
9209 | 9209 | /** |
@@ -9234,7 +9234,7 @@ discard block |
||
9234 | 9234 | |
9235 | 9235 | $str = ''; |
9236 | 9236 | foreach ($intOrHex as $strPart) { |
9237 | - $str .= '&#' . (int) $strPart . ';'; |
|
9237 | + $str .= '&#'.(int)$strPart.';'; |
|
9238 | 9238 | } |
9239 | 9239 | |
9240 | 9240 | // We cannot use html_entity_decode() here, as it will not return |
@@ -9332,7 +9332,7 @@ discard block |
||
9332 | 9332 | return ''; |
9333 | 9333 | } |
9334 | 9334 | |
9335 | - return (string) \preg_replace('/[[:space:]]+/u', '', $str); |
|
9335 | + return (string)\preg_replace('/[[:space:]]+/u', '', $str); |
|
9336 | 9336 | } |
9337 | 9337 | |
9338 | 9338 | /** |
@@ -9411,7 +9411,7 @@ discard block |
||
9411 | 9411 | // fallback for ascii only |
9412 | 9412 | // |
9413 | 9413 | |
9414 | - if (ASCII::is_ascii($haystack . $needle)) { |
|
9414 | + if (ASCII::is_ascii($haystack.$needle)) { |
|
9415 | 9415 | return \stripos($haystack, $needle, $offset); |
9416 | 9416 | } |
9417 | 9417 | |
@@ -9500,7 +9500,7 @@ discard block |
||
9500 | 9500 | /** |
9501 | 9501 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
9502 | 9502 | */ |
9503 | - \trigger_error('UTF8::stristr() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
9503 | + \trigger_error('UTF8::stristr() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
9504 | 9504 | } |
9505 | 9505 | |
9506 | 9506 | if ( |
@@ -9514,11 +9514,11 @@ discard block |
||
9514 | 9514 | } |
9515 | 9515 | } |
9516 | 9516 | |
9517 | - if (ASCII::is_ascii($needle . $haystack)) { |
|
9517 | + if (ASCII::is_ascii($needle.$haystack)) { |
|
9518 | 9518 | return \stristr($haystack, $needle, $before_needle); |
9519 | 9519 | } |
9520 | 9520 | |
9521 | - \preg_match('/^(.*?)' . \preg_quote($needle, '/') . '/usi', $haystack, $match); |
|
9521 | + \preg_match('/^(.*?)'.\preg_quote($needle, '/').'/usi', $haystack, $match); |
|
9522 | 9522 | |
9523 | 9523 | if (!isset($match[1])) { |
9524 | 9524 | return false; |
@@ -9528,7 +9528,7 @@ discard block |
||
9528 | 9528 | return $match[1]; |
9529 | 9529 | } |
9530 | 9530 | |
9531 | - return self::substr($haystack, (int) self::strlen($match[1], $encoding), null, $encoding); |
|
9531 | + return self::substr($haystack, (int)self::strlen($match[1], $encoding), null, $encoding); |
|
9532 | 9532 | } |
9533 | 9533 | |
9534 | 9534 | /** |
@@ -9611,7 +9611,7 @@ discard block |
||
9611 | 9611 | /** |
9612 | 9612 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
9613 | 9613 | */ |
9614 | - \trigger_error('UTF8::strlen() without mbstring / iconv cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
9614 | + \trigger_error('UTF8::strlen() without mbstring / iconv cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
9615 | 9615 | } |
9616 | 9616 | |
9617 | 9617 | // |
@@ -9749,8 +9749,8 @@ discard block |
||
9749 | 9749 | } |
9750 | 9750 | |
9751 | 9751 | return \strnatcmp( |
9752 | - (string) self::strtonatfold($str1), |
|
9753 | - (string) self::strtonatfold($str2) |
|
9752 | + (string)self::strtonatfold($str1), |
|
9753 | + (string)self::strtonatfold($str2) |
|
9754 | 9754 | ); |
9755 | 9755 | } |
9756 | 9756 | |
@@ -9820,11 +9820,11 @@ discard block |
||
9820 | 9820 | } |
9821 | 9821 | |
9822 | 9822 | if ($encoding === 'UTF-8') { |
9823 | - $str1 = (string) \mb_substr($str1, 0, $len); |
|
9824 | - $str2 = (string) \mb_substr($str2, 0, $len); |
|
9823 | + $str1 = (string)\mb_substr($str1, 0, $len); |
|
9824 | + $str2 = (string)\mb_substr($str2, 0, $len); |
|
9825 | 9825 | } else { |
9826 | - $str1 = (string) self::substr($str1, 0, $len, $encoding); |
|
9827 | - $str2 = (string) self::substr($str2, 0, $len, $encoding); |
|
9826 | + $str1 = (string)self::substr($str1, 0, $len, $encoding); |
|
9827 | + $str2 = (string)self::substr($str2, 0, $len, $encoding); |
|
9828 | 9828 | } |
9829 | 9829 | |
9830 | 9830 | return self::strcmp($str1, $str2); |
@@ -9851,8 +9851,8 @@ discard block |
||
9851 | 9851 | return false; |
9852 | 9852 | } |
9853 | 9853 | |
9854 | - if (\preg_match('/' . self::rxClass($char_list) . '/us', $haystack, $m)) { |
|
9855 | - return \substr($haystack, (int) \strpos($haystack, $m[0])); |
|
9854 | + if (\preg_match('/'.self::rxClass($char_list).'/us', $haystack, $m)) { |
|
9855 | + return \substr($haystack, (int)\strpos($haystack, $m[0])); |
|
9856 | 9856 | } |
9857 | 9857 | |
9858 | 9858 | return false; |
@@ -9897,10 +9897,10 @@ discard block |
||
9897 | 9897 | } |
9898 | 9898 | |
9899 | 9899 | // iconv and mbstring do not support integer $needle |
9900 | - if ((int) $needle === $needle) { |
|
9901 | - $needle = (string) self::chr($needle); |
|
9900 | + if ((int)$needle === $needle) { |
|
9901 | + $needle = (string)self::chr($needle); |
|
9902 | 9902 | } |
9903 | - $needle = (string) $needle; |
|
9903 | + $needle = (string)$needle; |
|
9904 | 9904 | |
9905 | 9905 | if ($haystack === '') { |
9906 | 9906 | if (\PHP_VERSION_ID >= 80000 && $needle === '') { |
@@ -9960,7 +9960,7 @@ discard block |
||
9960 | 9960 | /** |
9961 | 9961 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
9962 | 9962 | */ |
9963 | - \trigger_error('UTF8::strpos() without mbstring / iconv cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
9963 | + \trigger_error('UTF8::strpos() without mbstring / iconv cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
9964 | 9964 | } |
9965 | 9965 | |
9966 | 9966 | // |
@@ -10001,7 +10001,7 @@ discard block |
||
10001 | 10001 | // fallback for ascii only |
10002 | 10002 | // |
10003 | 10003 | |
10004 | - if (ASCII::is_ascii($haystack . $needle)) { |
|
10004 | + if (ASCII::is_ascii($haystack.$needle)) { |
|
10005 | 10005 | /** @noinspection PhpUsageOfSilenceOperatorInspection - Offset not contained in string */ |
10006 | 10006 | return @\strpos($haystack, $needle, $offset); |
10007 | 10007 | } |
@@ -10014,7 +10014,7 @@ discard block |
||
10014 | 10014 | if ($haystack_tmp === false) { |
10015 | 10015 | $haystack_tmp = ''; |
10016 | 10016 | } |
10017 | - $haystack = (string) $haystack_tmp; |
|
10017 | + $haystack = (string)$haystack_tmp; |
|
10018 | 10018 | |
10019 | 10019 | if ($offset < 0) { |
10020 | 10020 | $offset = 0; |
@@ -10026,7 +10026,7 @@ discard block |
||
10026 | 10026 | } |
10027 | 10027 | |
10028 | 10028 | if ($pos) { |
10029 | - return $offset + (int) self::strlen(\substr($haystack, 0, $pos), $encoding); |
|
10029 | + return $offset + (int)self::strlen(\substr($haystack, 0, $pos), $encoding); |
|
10030 | 10030 | } |
10031 | 10031 | |
10032 | 10032 | return $offset + 0; |
@@ -10181,7 +10181,7 @@ discard block |
||
10181 | 10181 | /** |
10182 | 10182 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
10183 | 10183 | */ |
10184 | - \trigger_error('UTF8::strrchr() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
10184 | + \trigger_error('UTF8::strrchr() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
10185 | 10185 | } |
10186 | 10186 | |
10187 | 10187 | // |
@@ -10256,7 +10256,7 @@ discard block |
||
10256 | 10256 | if ($encoding === 'UTF-8') { |
10257 | 10257 | if (self::$SUPPORT['intl'] === true) { |
10258 | 10258 | // try "grapheme" first: https://stackoverflow.com/questions/17496493/strrev-dosent-support-utf-8 |
10259 | - $i = (int) \grapheme_strlen($str); |
|
10259 | + $i = (int)\grapheme_strlen($str); |
|
10260 | 10260 | while ($i--) { |
10261 | 10261 | $reversed_tmp = \grapheme_substr($str, $i, 1); |
10262 | 10262 | if ($reversed_tmp !== false) { |
@@ -10264,7 +10264,7 @@ discard block |
||
10264 | 10264 | } |
10265 | 10265 | } |
10266 | 10266 | } else { |
10267 | - $i = (int) \mb_strlen($str); |
|
10267 | + $i = (int)\mb_strlen($str); |
|
10268 | 10268 | while ($i--) { |
10269 | 10269 | $reversed_tmp = \mb_substr($str, $i, 1); |
10270 | 10270 | if ($reversed_tmp !== false) { |
@@ -10275,7 +10275,7 @@ discard block |
||
10275 | 10275 | } else { |
10276 | 10276 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
10277 | 10277 | |
10278 | - $i = (int) self::strlen($str, $encoding); |
|
10278 | + $i = (int)self::strlen($str, $encoding); |
|
10279 | 10279 | while ($i--) { |
10280 | 10280 | $reversed_tmp = self::substr($str, $i, 1, $encoding); |
10281 | 10281 | if ($reversed_tmp !== false) { |
@@ -10403,10 +10403,10 @@ discard block |
||
10403 | 10403 | } |
10404 | 10404 | |
10405 | 10405 | // iconv and mbstring do not support integer $needle |
10406 | - if ((int) $needle === $needle && $needle >= 0) { |
|
10407 | - $needle = (string) self::chr($needle); |
|
10406 | + if ((int)$needle === $needle && $needle >= 0) { |
|
10407 | + $needle = (string)self::chr($needle); |
|
10408 | 10408 | } |
10409 | - $needle = (string) $needle; |
|
10409 | + $needle = (string)$needle; |
|
10410 | 10410 | |
10411 | 10411 | if ($haystack === '') { |
10412 | 10412 | if (\PHP_VERSION_ID >= 80000 && $needle === '') { |
@@ -10462,7 +10462,7 @@ discard block |
||
10462 | 10462 | /** |
10463 | 10463 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
10464 | 10464 | */ |
10465 | - \trigger_error('UTF8::strripos() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
10465 | + \trigger_error('UTF8::strripos() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
10466 | 10466 | } |
10467 | 10467 | |
10468 | 10468 | // |
@@ -10486,7 +10486,7 @@ discard block |
||
10486 | 10486 | // fallback for ascii only |
10487 | 10487 | // |
10488 | 10488 | |
10489 | - if (ASCII::is_ascii($haystack . $needle)) { |
|
10489 | + if (ASCII::is_ascii($haystack.$needle)) { |
|
10490 | 10490 | return \strripos($haystack, $needle, $offset); |
10491 | 10491 | } |
10492 | 10492 | |
@@ -10575,10 +10575,10 @@ discard block |
||
10575 | 10575 | } |
10576 | 10576 | |
10577 | 10577 | // iconv and mbstring do not support integer $needle |
10578 | - if ((int) $needle === $needle && $needle >= 0) { |
|
10579 | - $needle = (string) self::chr($needle); |
|
10578 | + if ((int)$needle === $needle && $needle >= 0) { |
|
10579 | + $needle = (string)self::chr($needle); |
|
10580 | 10580 | } |
10581 | - $needle = (string) $needle; |
|
10581 | + $needle = (string)$needle; |
|
10582 | 10582 | |
10583 | 10583 | if ($haystack === '') { |
10584 | 10584 | if (\PHP_VERSION_ID >= 80000 && $needle === '') { |
@@ -10634,7 +10634,7 @@ discard block |
||
10634 | 10634 | /** |
10635 | 10635 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
10636 | 10636 | */ |
10637 | - \trigger_error('UTF8::strrpos() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
10637 | + \trigger_error('UTF8::strrpos() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
10638 | 10638 | } |
10639 | 10639 | |
10640 | 10640 | // |
@@ -10658,7 +10658,7 @@ discard block |
||
10658 | 10658 | // fallback for ascii only |
10659 | 10659 | // |
10660 | 10660 | |
10661 | - if (ASCII::is_ascii($haystack . $needle)) { |
|
10661 | + if (ASCII::is_ascii($haystack.$needle)) { |
|
10662 | 10662 | return \strrpos($haystack, $needle, $offset); |
10663 | 10663 | } |
10664 | 10664 | |
@@ -10678,7 +10678,7 @@ discard block |
||
10678 | 10678 | if ($haystack_tmp === false) { |
10679 | 10679 | $haystack_tmp = ''; |
10680 | 10680 | } |
10681 | - $haystack = (string) $haystack_tmp; |
|
10681 | + $haystack = (string)$haystack_tmp; |
|
10682 | 10682 | } |
10683 | 10683 | |
10684 | 10684 | $pos = \strrpos($haystack, $needle); |
@@ -10692,7 +10692,7 @@ discard block |
||
10692 | 10692 | return false; |
10693 | 10693 | } |
10694 | 10694 | |
10695 | - return $offset + (int) self::strlen($str_tmp); |
|
10695 | + return $offset + (int)self::strlen($str_tmp); |
|
10696 | 10696 | } |
10697 | 10697 | |
10698 | 10698 | /** |
@@ -10760,12 +10760,12 @@ discard block |
||
10760 | 10760 | if ($offset || $length !== null) { |
10761 | 10761 | if ($encoding === 'UTF-8') { |
10762 | 10762 | if ($length === null) { |
10763 | - $str = (string) \mb_substr($str, $offset); |
|
10763 | + $str = (string)\mb_substr($str, $offset); |
|
10764 | 10764 | } else { |
10765 | - $str = (string) \mb_substr($str, $offset, $length); |
|
10765 | + $str = (string)\mb_substr($str, $offset, $length); |
|
10766 | 10766 | } |
10767 | 10767 | } else { |
10768 | - $str = (string) self::substr($str, $offset, $length, $encoding); |
|
10768 | + $str = (string)self::substr($str, $offset, $length, $encoding); |
|
10769 | 10769 | } |
10770 | 10770 | } |
10771 | 10771 | |
@@ -10775,7 +10775,7 @@ discard block |
||
10775 | 10775 | |
10776 | 10776 | $matches = []; |
10777 | 10777 | |
10778 | - return \preg_match('/^' . self::rxClass($mask) . '+/u', $str, $matches) ? (int) self::strlen($matches[0], $encoding) : 0; |
|
10778 | + return \preg_match('/^'.self::rxClass($mask).'+/u', $str, $matches) ? (int)self::strlen($matches[0], $encoding) : 0; |
|
10779 | 10779 | } |
10780 | 10780 | |
10781 | 10781 | /** |
@@ -10869,7 +10869,7 @@ discard block |
||
10869 | 10869 | /** |
10870 | 10870 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
10871 | 10871 | */ |
10872 | - \trigger_error('UTF8::strstr() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
10872 | + \trigger_error('UTF8::strstr() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
10873 | 10873 | } |
10874 | 10874 | |
10875 | 10875 | // |
@@ -10891,7 +10891,7 @@ discard block |
||
10891 | 10891 | // fallback for ascii only |
10892 | 10892 | // |
10893 | 10893 | |
10894 | - if (ASCII::is_ascii($haystack . $needle)) { |
|
10894 | + if (ASCII::is_ascii($haystack.$needle)) { |
|
10895 | 10895 | return \strstr($haystack, $needle, $before_needle); |
10896 | 10896 | } |
10897 | 10897 | |
@@ -10899,7 +10899,7 @@ discard block |
||
10899 | 10899 | // fallback via vanilla php |
10900 | 10900 | // |
10901 | 10901 | |
10902 | - \preg_match('/^(.*?)' . \preg_quote($needle, '/') . '/us', $haystack, $match); |
|
10902 | + \preg_match('/^(.*?)'.\preg_quote($needle, '/').'/us', $haystack, $match); |
|
10903 | 10903 | |
10904 | 10904 | if (!isset($match[1])) { |
10905 | 10905 | return false; |
@@ -10909,7 +10909,7 @@ discard block |
||
10909 | 10909 | return $match[1]; |
10910 | 10910 | } |
10911 | 10911 | |
10912 | - return self::substr($haystack, (int) self::strlen($match[1])); |
|
10912 | + return self::substr($haystack, (int)self::strlen($match[1])); |
|
10913 | 10913 | } |
10914 | 10914 | |
10915 | 10915 | /** |
@@ -11039,7 +11039,7 @@ discard block |
||
11039 | 11039 | bool $try_to_keep_the_string_length = false |
11040 | 11040 | ): string { |
11041 | 11041 | // init |
11042 | - $str = (string) $str; |
|
11042 | + $str = (string)$str; |
|
11043 | 11043 | |
11044 | 11044 | if ($str === '') { |
11045 | 11045 | return ''; |
@@ -11068,23 +11068,23 @@ discard block |
||
11068 | 11068 | self::$INTL_TRANSLITERATOR_LIST = self::getData('transliterator_list'); |
11069 | 11069 | } |
11070 | 11070 | |
11071 | - $language_code = $lang . '-Lower'; |
|
11071 | + $language_code = $lang.'-Lower'; |
|
11072 | 11072 | if (!\in_array($language_code, self::$INTL_TRANSLITERATOR_LIST, true)) { |
11073 | 11073 | /** |
11074 | 11074 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
11075 | 11075 | */ |
11076 | - \trigger_error('UTF8::strtolower() cannot handle special language: ' . $lang . ' | supported: ' . \print_r(self::$INTL_TRANSLITERATOR_LIST, true), \E_USER_WARNING); |
|
11076 | + \trigger_error('UTF8::strtolower() cannot handle special language: '.$lang.' | supported: '.\print_r(self::$INTL_TRANSLITERATOR_LIST, true), \E_USER_WARNING); |
|
11077 | 11077 | |
11078 | 11078 | $language_code = 'Any-Lower'; |
11079 | 11079 | } |
11080 | 11080 | |
11081 | - return (string) \transliterator_transliterate($language_code, $str); |
|
11081 | + return (string)\transliterator_transliterate($language_code, $str); |
|
11082 | 11082 | } |
11083 | 11083 | |
11084 | 11084 | /** |
11085 | 11085 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
11086 | 11086 | */ |
11087 | - \trigger_error('UTF8::strtolower() without intl cannot handle the "lang" parameter: ' . $lang, \E_USER_WARNING); |
|
11087 | + \trigger_error('UTF8::strtolower() without intl cannot handle the "lang" parameter: '.$lang, \E_USER_WARNING); |
|
11088 | 11088 | } |
11089 | 11089 | |
11090 | 11090 | // always fallback via symfony polyfill |
@@ -11119,7 +11119,7 @@ discard block |
||
11119 | 11119 | bool $try_to_keep_the_string_length = false |
11120 | 11120 | ): string { |
11121 | 11121 | // init |
11122 | - $str = (string) $str; |
|
11122 | + $str = (string)$str; |
|
11123 | 11123 | |
11124 | 11124 | if ($str === '') { |
11125 | 11125 | return ''; |
@@ -11148,23 +11148,23 @@ discard block |
||
11148 | 11148 | self::$INTL_TRANSLITERATOR_LIST = self::getData('transliterator_list'); |
11149 | 11149 | } |
11150 | 11150 | |
11151 | - $language_code = $lang . '-Upper'; |
|
11151 | + $language_code = $lang.'-Upper'; |
|
11152 | 11152 | if (!\in_array($language_code, self::$INTL_TRANSLITERATOR_LIST, true)) { |
11153 | 11153 | /** |
11154 | 11154 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
11155 | 11155 | */ |
11156 | - \trigger_error('UTF8::strtoupper() without intl for special language: ' . $lang, \E_USER_WARNING); |
|
11156 | + \trigger_error('UTF8::strtoupper() without intl for special language: '.$lang, \E_USER_WARNING); |
|
11157 | 11157 | |
11158 | 11158 | $language_code = 'Any-Upper'; |
11159 | 11159 | } |
11160 | 11160 | |
11161 | - return (string) \transliterator_transliterate($language_code, $str); |
|
11161 | + return (string)\transliterator_transliterate($language_code, $str); |
|
11162 | 11162 | } |
11163 | 11163 | |
11164 | 11164 | /** |
11165 | 11165 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
11166 | 11166 | */ |
11167 | - \trigger_error('UTF8::strtolower() without intl cannot handle the "lang"-parameter: ' . $lang, \E_USER_WARNING); |
|
11167 | + \trigger_error('UTF8::strtolower() without intl cannot handle the "lang"-parameter: '.$lang, \E_USER_WARNING); |
|
11168 | 11168 | } |
11169 | 11169 | |
11170 | 11170 | // always fallback via symfony polyfill |
@@ -11227,7 +11227,7 @@ discard block |
||
11227 | 11227 | |
11228 | 11228 | $from = \array_combine($from, $to); |
11229 | 11229 | if ($from === false) { |
11230 | - throw new \InvalidArgumentException('The number of elements for each array isn\'t equal or the arrays are empty: (from: ' . \print_r($from, true) . ' | to: ' . \print_r($to, true) . ')'); |
|
11230 | + throw new \InvalidArgumentException('The number of elements for each array isn\'t equal or the arrays are empty: (from: '.\print_r($from, true).' | to: '.\print_r($to, true).')'); |
|
11231 | 11231 | } |
11232 | 11232 | } |
11233 | 11233 | |
@@ -11293,9 +11293,9 @@ discard block |
||
11293 | 11293 | } |
11294 | 11294 | |
11295 | 11295 | $wide = 0; |
11296 | - $str = (string) \preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $str, -1, $wide); |
|
11296 | + $str = (string)\preg_replace('/[\x{1100}-\x{115F}\x{2329}\x{232A}\x{2E80}-\x{303E}\x{3040}-\x{A4CF}\x{AC00}-\x{D7A3}\x{F900}-\x{FAFF}\x{FE10}-\x{FE19}\x{FE30}-\x{FE6F}\x{FF00}-\x{FF60}\x{FFE0}-\x{FFE6}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}]/u', '', $str, -1, $wide); |
|
11297 | 11297 | |
11298 | - return ($wide << 1) + (int) self::strlen($str); |
|
11298 | + return ($wide << 1) + (int)self::strlen($str); |
|
11299 | 11299 | } |
11300 | 11300 | |
11301 | 11301 | /** |
@@ -11404,7 +11404,7 @@ discard block |
||
11404 | 11404 | /** |
11405 | 11405 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
11406 | 11406 | */ |
11407 | - \trigger_error('UTF8::substr() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
11407 | + \trigger_error('UTF8::substr() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
11408 | 11408 | } |
11409 | 11409 | |
11410 | 11410 | // |
@@ -11499,16 +11499,16 @@ discard block |
||
11499 | 11499 | ) { |
11500 | 11500 | if ($encoding === 'UTF-8') { |
11501 | 11501 | if ($length === null) { |
11502 | - $str1 = (string) \mb_substr($str1, $offset); |
|
11502 | + $str1 = (string)\mb_substr($str1, $offset); |
|
11503 | 11503 | } else { |
11504 | - $str1 = (string) \mb_substr($str1, $offset, $length); |
|
11504 | + $str1 = (string)\mb_substr($str1, $offset, $length); |
|
11505 | 11505 | } |
11506 | - $str2 = (string) \mb_substr($str2, 0, (int) self::strlen($str1)); |
|
11506 | + $str2 = (string)\mb_substr($str2, 0, (int)self::strlen($str1)); |
|
11507 | 11507 | } else { |
11508 | 11508 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
11509 | 11509 | |
11510 | - $str1 = (string) self::substr($str1, $offset, $length, $encoding); |
|
11511 | - $str2 = (string) self::substr($str2, 0, (int) self::strlen($str1), $encoding); |
|
11510 | + $str1 = (string)self::substr($str1, $offset, $length, $encoding); |
|
11511 | + $str2 = (string)self::substr($str2, 0, (int)self::strlen($str1), $encoding); |
|
11512 | 11512 | } |
11513 | 11513 | } |
11514 | 11514 | |
@@ -11587,9 +11587,9 @@ discard block |
||
11587 | 11587 | } |
11588 | 11588 | |
11589 | 11589 | if ($encoding === 'UTF-8') { |
11590 | - $haystack = (string) \mb_substr($haystack, $offset, $length); |
|
11590 | + $haystack = (string)\mb_substr($haystack, $offset, $length); |
|
11591 | 11591 | } else { |
11592 | - $haystack = (string) \mb_substr($haystack, $offset, $length, $encoding); |
|
11592 | + $haystack = (string)\mb_substr($haystack, $offset, $length, $encoding); |
|
11593 | 11593 | } |
11594 | 11594 | } |
11595 | 11595 | |
@@ -11601,7 +11601,7 @@ discard block |
||
11601 | 11601 | /** |
11602 | 11602 | * @psalm-suppress ImpureFunctionCall - is is only a warning |
11603 | 11603 | */ |
11604 | - \trigger_error('UTF8::substr_count() without mbstring cannot handle "' . $encoding . '" encoding', \E_USER_WARNING); |
|
11604 | + \trigger_error('UTF8::substr_count() without mbstring cannot handle "'.$encoding.'" encoding', \E_USER_WARNING); |
|
11605 | 11605 | } |
11606 | 11606 | |
11607 | 11607 | if (self::$SUPPORT['mbstring'] === true) { |
@@ -11612,7 +11612,7 @@ discard block |
||
11612 | 11612 | return \mb_substr_count($haystack, $needle, $encoding); |
11613 | 11613 | } |
11614 | 11614 | |
11615 | - \preg_match_all('/' . \preg_quote($needle, '/') . '/us', $haystack, $matches, \PREG_SET_ORDER); |
|
11615 | + \preg_match_all('/'.\preg_quote($needle, '/').'/us', $haystack, $matches, \PREG_SET_ORDER); |
|
11616 | 11616 | |
11617 | 11617 | return \count($matches); |
11618 | 11618 | } |
@@ -11684,7 +11684,7 @@ discard block |
||
11684 | 11684 | if ($haystack_tmp === false) { |
11685 | 11685 | $haystack_tmp = ''; |
11686 | 11686 | } |
11687 | - $haystack = (string) $haystack_tmp; |
|
11687 | + $haystack = (string)$haystack_tmp; |
|
11688 | 11688 | } |
11689 | 11689 | |
11690 | 11690 | if (self::$SUPPORT['mbstring_func_overload'] === true) { |
@@ -11725,10 +11725,10 @@ discard block |
||
11725 | 11725 | |
11726 | 11726 | if ($encoding === 'UTF-8') { |
11727 | 11727 | if ($case_sensitive) { |
11728 | - return (int) \mb_substr_count($str, $substring); |
|
11728 | + return (int)\mb_substr_count($str, $substring); |
|
11729 | 11729 | } |
11730 | 11730 | |
11731 | - return (int) \mb_substr_count( |
|
11731 | + return (int)\mb_substr_count( |
|
11732 | 11732 | \mb_strtoupper($str), |
11733 | 11733 | \mb_strtoupper($substring) |
11734 | 11734 | ); |
@@ -11737,10 +11737,10 @@ discard block |
||
11737 | 11737 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
11738 | 11738 | |
11739 | 11739 | if ($case_sensitive) { |
11740 | - return (int) \mb_substr_count($str, $substring, $encoding); |
|
11740 | + return (int)\mb_substr_count($str, $substring, $encoding); |
|
11741 | 11741 | } |
11742 | 11742 | |
11743 | - return (int) \mb_substr_count( |
|
11743 | + return (int)\mb_substr_count( |
|
11744 | 11744 | self::strtocasefold($str, true, false, $encoding, null, false), |
11745 | 11745 | self::strtocasefold($substring, true, false, $encoding, null, false), |
11746 | 11746 | $encoding |
@@ -11774,7 +11774,7 @@ discard block |
||
11774 | 11774 | } |
11775 | 11775 | |
11776 | 11776 | if (self::str_istarts_with($haystack, $needle)) { |
11777 | - $haystack = (string) \mb_substr($haystack, (int) self::strlen($needle)); |
|
11777 | + $haystack = (string)\mb_substr($haystack, (int)self::strlen($needle)); |
|
11778 | 11778 | } |
11779 | 11779 | |
11780 | 11780 | return $haystack; |
@@ -11841,7 +11841,7 @@ discard block |
||
11841 | 11841 | } |
11842 | 11842 | |
11843 | 11843 | if (self::str_iends_with($haystack, $needle)) { |
11844 | - $haystack = (string) \mb_substr($haystack, 0, (int) self::strlen($haystack) - (int) self::strlen($needle)); |
|
11844 | + $haystack = (string)\mb_substr($haystack, 0, (int)self::strlen($haystack) - (int)self::strlen($needle)); |
|
11845 | 11845 | } |
11846 | 11846 | |
11847 | 11847 | return $haystack; |
@@ -11874,7 +11874,7 @@ discard block |
||
11874 | 11874 | } |
11875 | 11875 | |
11876 | 11876 | if (self::str_starts_with($haystack, $needle)) { |
11877 | - $haystack = (string) \mb_substr($haystack, (int) self::strlen($needle)); |
|
11877 | + $haystack = (string)\mb_substr($haystack, (int)self::strlen($needle)); |
|
11878 | 11878 | } |
11879 | 11879 | |
11880 | 11880 | return $haystack; |
@@ -11935,7 +11935,7 @@ discard block |
||
11935 | 11935 | if (\is_array($offset)) { |
11936 | 11936 | $offset = \array_slice($offset, 0, $num); |
11937 | 11937 | foreach ($offset as &$value_tmp) { |
11938 | - $value_tmp = (int) $value_tmp === $value_tmp ? $value_tmp : 0; |
|
11938 | + $value_tmp = (int)$value_tmp === $value_tmp ? $value_tmp : 0; |
|
11939 | 11939 | } |
11940 | 11940 | unset($value_tmp); |
11941 | 11941 | } else { |
@@ -11948,7 +11948,7 @@ discard block |
||
11948 | 11948 | } elseif (\is_array($length)) { |
11949 | 11949 | $length = \array_slice($length, 0, $num); |
11950 | 11950 | foreach ($length as &$value_tmp_V2) { |
11951 | - $value_tmp_V2 = (int) $value_tmp_V2 === $value_tmp_V2 ? $value_tmp_V2 : $num; |
|
11951 | + $value_tmp_V2 = (int)$value_tmp_V2 === $value_tmp_V2 ? $value_tmp_V2 : $num; |
|
11952 | 11952 | } |
11953 | 11953 | unset($value_tmp_V2); |
11954 | 11954 | } else { |
@@ -11969,8 +11969,8 @@ discard block |
||
11969 | 11969 | } |
11970 | 11970 | |
11971 | 11971 | // init |
11972 | - $str = (string) $str; |
|
11973 | - $replacement = (string) $replacement; |
|
11972 | + $str = (string)$str; |
|
11973 | + $replacement = (string)$replacement; |
|
11974 | 11974 | |
11975 | 11975 | if (\is_array($length)) { |
11976 | 11976 | throw new \InvalidArgumentException('Parameter "$length" can only be an array, if "$str" is also an array.'); |
@@ -11985,16 +11985,16 @@ discard block |
||
11985 | 11985 | } |
11986 | 11986 | |
11987 | 11987 | if (self::$SUPPORT['mbstring'] === true) { |
11988 | - $string_length = (int) self::strlen($str, $encoding); |
|
11988 | + $string_length = (int)self::strlen($str, $encoding); |
|
11989 | 11989 | |
11990 | 11990 | if ($offset < 0) { |
11991 | - $offset = (int) \max(0, $string_length + $offset); |
|
11991 | + $offset = (int)\max(0, $string_length + $offset); |
|
11992 | 11992 | } elseif ($offset > $string_length) { |
11993 | 11993 | $offset = $string_length; |
11994 | 11994 | } |
11995 | 11995 | |
11996 | 11996 | if ($length !== null && $length < 0) { |
11997 | - $length = (int) \max(0, $string_length - $offset + $length); |
|
11997 | + $length = (int)\max(0, $string_length - $offset + $length); |
|
11998 | 11998 | } elseif ($length === null || $length > $string_length) { |
11999 | 11999 | $length = $string_length; |
12000 | 12000 | } |
@@ -12003,9 +12003,9 @@ discard block |
||
12003 | 12003 | $length = $string_length - $offset; |
12004 | 12004 | } |
12005 | 12005 | |
12006 | - return ((string) \mb_substr($str, 0, $offset, $encoding)) . |
|
12007 | - $replacement . |
|
12008 | - ((string) \mb_substr($str, $offset + $length, $string_length - $offset - $length, $encoding)); |
|
12006 | + return ((string)\mb_substr($str, 0, $offset, $encoding)). |
|
12007 | + $replacement. |
|
12008 | + ((string)\mb_substr($str, $offset + $length, $string_length - $offset - $length, $encoding)); |
|
12009 | 12009 | } |
12010 | 12010 | |
12011 | 12011 | // |
@@ -12014,8 +12014,7 @@ discard block |
||
12014 | 12014 | |
12015 | 12015 | if (ASCII::is_ascii($str)) { |
12016 | 12016 | return ($length === null) ? |
12017 | - \substr_replace($str, $replacement, $offset) : |
|
12018 | - \substr_replace($str, $replacement, $offset, $length); |
|
12017 | + \substr_replace($str, $replacement, $offset) : \substr_replace($str, $replacement, $offset, $length); |
|
12019 | 12018 | } |
12020 | 12019 | |
12021 | 12020 | // |
@@ -12074,14 +12073,14 @@ discard block |
||
12074 | 12073 | && |
12075 | 12074 | \substr($haystack, -\strlen($needle)) === $needle |
12076 | 12075 | ) { |
12077 | - return (string) \mb_substr($haystack, 0, (int) \mb_strlen($haystack) - (int) \mb_strlen($needle)); |
|
12076 | + return (string)\mb_substr($haystack, 0, (int)\mb_strlen($haystack) - (int)\mb_strlen($needle)); |
|
12078 | 12077 | } |
12079 | 12078 | |
12080 | 12079 | if (\substr($haystack, -\strlen($needle)) === $needle) { |
12081 | - return (string) self::substr( |
|
12080 | + return (string)self::substr( |
|
12082 | 12081 | $haystack, |
12083 | 12082 | 0, |
12084 | - (int) self::strlen($haystack, $encoding) - (int) self::strlen($needle, $encoding), |
|
12083 | + (int)self::strlen($haystack, $encoding) - (int)self::strlen($needle, $encoding), |
|
12085 | 12084 | $encoding |
12086 | 12085 | ); |
12087 | 12086 | } |
@@ -12116,10 +12115,10 @@ discard block |
||
12116 | 12115 | } |
12117 | 12116 | |
12118 | 12117 | if ($encoding === 'UTF-8') { |
12119 | - return (string) (\mb_strtolower($str) ^ \mb_strtoupper($str) ^ $str); |
|
12118 | + return (string)(\mb_strtolower($str) ^ \mb_strtoupper($str) ^ $str); |
|
12120 | 12119 | } |
12121 | 12120 | |
12122 | - return (string) (self::strtolower($str, $encoding) ^ self::strtoupper($str, $encoding) ^ $str); |
|
12121 | + return (string)(self::strtolower($str, $encoding) ^ self::strtoupper($str, $encoding) ^ $str); |
|
12123 | 12122 | } |
12124 | 12123 | |
12125 | 12124 | /** |
@@ -12258,7 +12257,7 @@ discard block |
||
12258 | 12257 | public static function to_boolean($str): bool |
12259 | 12258 | { |
12260 | 12259 | // init |
12261 | - $str = (string) $str; |
|
12260 | + $str = (string)$str; |
|
12262 | 12261 | |
12263 | 12262 | if ($str === '') { |
12264 | 12263 | return false; |
@@ -12286,10 +12285,10 @@ discard block |
||
12286 | 12285 | } |
12287 | 12286 | |
12288 | 12287 | if (\is_numeric($str)) { |
12289 | - return ((float) $str) > 0; |
|
12288 | + return ((float)$str) > 0; |
|
12290 | 12289 | } |
12291 | 12290 | |
12292 | - return (bool) \trim($str); |
|
12291 | + return (bool)\trim($str); |
|
12293 | 12292 | } |
12294 | 12293 | |
12295 | 12294 | /** |
@@ -12341,7 +12340,7 @@ discard block |
||
12341 | 12340 | return $str; |
12342 | 12341 | } |
12343 | 12342 | |
12344 | - $str = (string) $str; |
|
12343 | + $str = (string)$str; |
|
12345 | 12344 | if ($str === '') { |
12346 | 12345 | return ''; |
12347 | 12346 | } |
@@ -12429,7 +12428,7 @@ discard block |
||
12429 | 12428 | $c2 = $i + 1 >= $max ? "\x00" : $str[$i + 1]; |
12430 | 12429 | |
12431 | 12430 | if ($c2 >= "\x80" && $c2 <= "\xBF") { // yeah, almost sure it's UTF8 already |
12432 | - $buf .= $c1 . $c2; |
|
12431 | + $buf .= $c1.$c2; |
|
12433 | 12432 | ++$i; |
12434 | 12433 | } else { // not valid UTF8 - convert it |
12435 | 12434 | $buf .= self::to_utf8_convert_helper($c1); |
@@ -12440,7 +12439,7 @@ discard block |
||
12440 | 12439 | $c3 = $i + 2 >= $max ? "\x00" : $str[$i + 2]; |
12441 | 12440 | |
12442 | 12441 | if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF") { // yeah, almost sure it's UTF8 already |
12443 | - $buf .= $c1 . $c2 . $c3; |
|
12442 | + $buf .= $c1.$c2.$c3; |
|
12444 | 12443 | $i += 2; |
12445 | 12444 | } else { // not valid UTF8 - convert it |
12446 | 12445 | $buf .= self::to_utf8_convert_helper($c1); |
@@ -12452,7 +12451,7 @@ discard block |
||
12452 | 12451 | $c4 = $i + 3 >= $max ? "\x00" : $str[$i + 3]; |
12453 | 12452 | |
12454 | 12453 | if ($c2 >= "\x80" && $c2 <= "\xBF" && $c3 >= "\x80" && $c3 <= "\xBF" && $c4 >= "\x80" && $c4 <= "\xBF") { // yeah, almost sure it's UTF8 already |
12455 | - $buf .= $c1 . $c2 . $c3 . $c4; |
|
12454 | + $buf .= $c1.$c2.$c3.$c4; |
|
12456 | 12455 | $i += 3; |
12457 | 12456 | } else { // not valid UTF8 - convert it |
12458 | 12457 | $buf .= self::to_utf8_convert_helper($c1); |
@@ -12480,13 +12479,13 @@ discard block |
||
12480 | 12479 | * |
12481 | 12480 | * @return string |
12482 | 12481 | */ |
12483 | - static function (array $matches): string { |
|
12482 | + static function(array $matches): string { |
|
12484 | 12483 | if (isset($matches[3])) { |
12485 | - $cp = (int) \hexdec($matches[3]); |
|
12484 | + $cp = (int)\hexdec($matches[3]); |
|
12486 | 12485 | } else { |
12487 | 12486 | // http://unicode.org/faq/utf_bom.html#utf16-4 |
12488 | - $cp = ((int) \hexdec($matches[1]) << 10) |
|
12489 | - + (int) \hexdec($matches[2]) |
|
12487 | + $cp = ((int)\hexdec($matches[1]) << 10) |
|
12488 | + + (int)\hexdec($matches[2]) |
|
12490 | 12489 | + 0x10000 |
12491 | 12490 | - (0xD800 << 10) |
12492 | 12491 | - 0xDC00; |
@@ -12497,12 +12496,12 @@ discard block |
||
12497 | 12496 | // php_utf32_utf8(unsigned char *buf, unsigned k) |
12498 | 12497 | |
12499 | 12498 | if ($cp < 0x80) { |
12500 | - return (string) self::chr($cp); |
|
12499 | + return (string)self::chr($cp); |
|
12501 | 12500 | } |
12502 | 12501 | |
12503 | 12502 | if ($cp < 0xA0) { |
12504 | 12503 | /** @noinspection UnnecessaryCastingInspection */ |
12505 | - return (string) self::chr(0xC0 | $cp >> 6) . (string) self::chr(0x80 | $cp & 0x3F); |
|
12504 | + return (string)self::chr(0xC0 | $cp >> 6).(string)self::chr(0x80 | $cp & 0x3F); |
|
12506 | 12505 | } |
12507 | 12506 | |
12508 | 12507 | return self::decimal_to_chr($cp); |
@@ -12535,7 +12534,7 @@ discard block |
||
12535 | 12534 | public static function to_int(string $str) |
12536 | 12535 | { |
12537 | 12536 | if (\is_numeric($str)) { |
12538 | - return (int) $str; |
|
12537 | + return (int)$str; |
|
12539 | 12538 | } |
12540 | 12539 | |
12541 | 12540 | return null; |
@@ -12570,12 +12569,12 @@ discard block |
||
12570 | 12569 | || |
12571 | 12570 | $input_type === 'double' |
12572 | 12571 | ) { |
12573 | - return (string) $input; |
|
12572 | + return (string)$input; |
|
12574 | 12573 | } |
12575 | 12574 | |
12576 | 12575 | /** @phpstan-ignore-next-line - "gettype": FP? */ |
12577 | 12576 | if ($input_type === 'object' && \method_exists($input, '__toString')) { |
12578 | - return (string) $input; |
|
12577 | + return (string)$input; |
|
12579 | 12578 | } |
12580 | 12579 | |
12581 | 12580 | return null; |
@@ -12614,7 +12613,7 @@ discard block |
||
12614 | 12613 | $pattern = '^[\\s]+|[\\s]+$'; |
12615 | 12614 | } |
12616 | 12615 | |
12617 | - return (string) \mb_ereg_replace($pattern, '', $str); |
|
12616 | + return (string)\mb_ereg_replace($pattern, '', $str); |
|
12618 | 12617 | } |
12619 | 12618 | |
12620 | 12619 | if ($chars !== null) { |
@@ -12665,15 +12664,15 @@ discard block |
||
12665 | 12664 | $use_mb_functions = $lang === null && !$try_to_keep_the_string_length; |
12666 | 12665 | |
12667 | 12666 | if ($encoding === 'UTF-8') { |
12668 | - $str_part_two = (string) \mb_substr($str, 1); |
|
12667 | + $str_part_two = (string)\mb_substr($str, 1); |
|
12669 | 12668 | |
12670 | 12669 | if ($use_mb_functions) { |
12671 | 12670 | $str_part_one = \mb_strtoupper( |
12672 | - (string) \mb_substr($str, 0, 1) |
|
12671 | + (string)\mb_substr($str, 0, 1) |
|
12673 | 12672 | ); |
12674 | 12673 | } else { |
12675 | 12674 | $str_part_one = self::strtoupper( |
12676 | - (string) \mb_substr($str, 0, 1), |
|
12675 | + (string)\mb_substr($str, 0, 1), |
|
12677 | 12676 | $encoding, |
12678 | 12677 | false, |
12679 | 12678 | $lang, |
@@ -12683,16 +12682,16 @@ discard block |
||
12683 | 12682 | } else { |
12684 | 12683 | $encoding = self::normalize_encoding($encoding, 'UTF-8'); |
12685 | 12684 | |
12686 | - $str_part_two = (string) self::substr($str, 1, null, $encoding); |
|
12685 | + $str_part_two = (string)self::substr($str, 1, null, $encoding); |
|
12687 | 12686 | |
12688 | 12687 | if ($use_mb_functions) { |
12689 | 12688 | $str_part_one = \mb_strtoupper( |
12690 | - (string) \mb_substr($str, 0, 1, $encoding), |
|
12689 | + (string)\mb_substr($str, 0, 1, $encoding), |
|
12691 | 12690 | $encoding |
12692 | 12691 | ); |
12693 | 12692 | } else { |
12694 | 12693 | $str_part_one = self::strtoupper( |
12695 | - (string) self::substr($str, 0, 1, $encoding), |
|
12694 | + (string)self::substr($str, 0, 1, $encoding), |
|
12696 | 12695 | $encoding, |
12697 | 12696 | false, |
12698 | 12697 | $lang, |
@@ -12701,7 +12700,7 @@ discard block |
||
12701 | 12700 | } |
12702 | 12701 | } |
12703 | 12702 | |
12704 | - return $str_part_one . $str_part_two; |
|
12703 | + return $str_part_one.$str_part_two; |
|
12705 | 12704 | } |
12706 | 12705 | |
12707 | 12706 | /** |
@@ -12740,7 +12739,7 @@ discard block |
||
12740 | 12739 | $str = self::clean($str); |
12741 | 12740 | } |
12742 | 12741 | |
12743 | - $use_php_default_functions = !(bool) ($char_list . \implode('', $exceptions)); |
|
12742 | + $use_php_default_functions = !(bool)($char_list.\implode('', $exceptions)); |
|
12744 | 12743 | |
12745 | 12744 | if ( |
12746 | 12745 | $use_php_default_functions |
@@ -12898,7 +12897,7 @@ discard block |
||
12898 | 12897 | if ( |
12899 | 12898 | $keep_utf8_chars |
12900 | 12899 | && |
12901 | - (int) self::strlen($return) >= (int) self::strlen($str_backup) |
|
12900 | + (int)self::strlen($return) >= (int)self::strlen($str_backup) |
|
12902 | 12901 | ) { |
12903 | 12902 | return $str_backup; |
12904 | 12903 | } |
@@ -12971,17 +12970,17 @@ discard block |
||
12971 | 12970 | return ''; |
12972 | 12971 | } |
12973 | 12972 | |
12974 | - \preg_match('/^\\s*+(?:[^\\s]++\\s*+){1,' . $limit . '}/u', $str, $matches); |
|
12973 | + \preg_match('/^\\s*+(?:[^\\s]++\\s*+){1,'.$limit.'}/u', $str, $matches); |
|
12975 | 12974 | |
12976 | 12975 | if ( |
12977 | 12976 | !isset($matches[0]) |
12978 | 12977 | || |
12979 | - \mb_strlen($str) === (int) \mb_strlen($matches[0]) |
|
12978 | + \mb_strlen($str) === (int)\mb_strlen($matches[0]) |
|
12980 | 12979 | ) { |
12981 | 12980 | return $str; |
12982 | 12981 | } |
12983 | 12982 | |
12984 | - return \rtrim($matches[0]) . $str_add_on; |
|
12983 | + return \rtrim($matches[0]).$str_add_on; |
|
12985 | 12984 | } |
12986 | 12985 | |
12987 | 12986 | /** |
@@ -13074,7 +13073,7 @@ discard block |
||
13074 | 13073 | } |
13075 | 13074 | } |
13076 | 13075 | |
13077 | - return $str_return . \implode('', $charsArray); |
|
13076 | + return $str_return.\implode('', $charsArray); |
|
13078 | 13077 | } |
13079 | 13078 | |
13080 | 13079 | /** |
@@ -13128,7 +13127,7 @@ discard block |
||
13128 | 13127 | $final_break = ''; |
13129 | 13128 | } |
13130 | 13129 | |
13131 | - return \implode($delimiter ?? "\n", $string_helper_array) . $final_break; |
|
13130 | + return \implode($delimiter ?? "\n", $string_helper_array).$final_break; |
|
13132 | 13131 | } |
13133 | 13132 | |
13134 | 13133 | /** |
@@ -13164,14 +13163,14 @@ discard block |
||
13164 | 13163 | { |
13165 | 13164 | // find all utf-8 characters |
13166 | 13165 | $matches = []; |
13167 | - if (! preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) { |
|
13166 | + if (!preg_match_all('/[\xC0-\xF7][\x80-\xBF]+/', $str, $matches)) { |
|
13168 | 13167 | return; // plain ascii string |
13169 | 13168 | } |
13170 | 13169 | |
13171 | 13170 | // update the encoding map with the characters not already met |
13172 | 13171 | $mapCount = \count($map); |
13173 | 13172 | foreach ($matches[0] as $mbc) { |
13174 | - if (! isset($map[$mbc])) { |
|
13173 | + if (!isset($map[$mbc])) { |
|
13175 | 13174 | $map[$mbc] = \chr(128 + $mapCount); |
13176 | 13175 | $mapCount++; |
13177 | 13176 | } |
@@ -13406,7 +13405,7 @@ discard block |
||
13406 | 13405 | /** @noinspection PhpIncludeInspection */ |
13407 | 13406 | /** @noinspection UsingInclusionReturnValueInspection */ |
13408 | 13407 | /** @psalm-suppress UnresolvableInclude */ |
13409 | - return include __DIR__ . '/data/' . $file . '.php'; |
|
13408 | + return include __DIR__.'/data/'.$file.'.php'; |
|
13410 | 13409 | } |
13411 | 13410 | |
13412 | 13411 | /** |
@@ -13428,7 +13427,7 @@ discard block |
||
13428 | 13427 | */ |
13429 | 13428 | \uksort( |
13430 | 13429 | self::$EMOJI, |
13431 | - static function (string $a, string $b): int { |
|
13430 | + static function(string $a, string $b): int { |
|
13432 | 13431 | return \strlen($b) <=> \strlen($a); |
13433 | 13432 | } |
13434 | 13433 | ); |
@@ -13438,7 +13437,7 @@ discard block |
||
13438 | 13437 | |
13439 | 13438 | foreach (self::$EMOJI_KEYS_CACHE as $key) { |
13440 | 13439 | $tmp_key = \crc32($key); |
13441 | - self::$EMOJI_KEYS_REVERSIBLE_CACHE[] = '_-_PORTABLE_UTF8_-_' . $tmp_key . '_-_' . \strrev((string) $tmp_key) . '_-_8FTU_ELBATROP_-_'; |
|
13440 | + self::$EMOJI_KEYS_REVERSIBLE_CACHE[] = '_-_PORTABLE_UTF8_-_'.$tmp_key.'_-_'.\strrev((string)$tmp_key).'_-_8FTU_ELBATROP_-_'; |
|
13442 | 13441 | } |
13443 | 13442 | |
13444 | 13443 | return true; |
@@ -13465,7 +13464,7 @@ discard block |
||
13465 | 13464 | /** @noinspection DeprecatedIniOptionsInspection */ |
13466 | 13465 | return \defined('MB_OVERLOAD_STRING') |
13467 | 13466 | && |
13468 | - ((int) @\ini_get('mbstring.func_overload') & \MB_OVERLOAD_STRING); |
|
13467 | + ((int)@\ini_get('mbstring.func_overload') & \MB_OVERLOAD_STRING); |
|
13469 | 13468 | } |
13470 | 13469 | |
13471 | 13470 | /** |
@@ -13529,7 +13528,7 @@ discard block |
||
13529 | 13528 | */ |
13530 | 13529 | static $RX_CLASS_CACHE = []; |
13531 | 13530 | |
13532 | - $cache_key = $s . '_' . $class; |
|
13531 | + $cache_key = $s.'_'.$class; |
|
13533 | 13532 | |
13534 | 13533 | if (isset($RX_CLASS_CACHE[$cache_key])) { |
13535 | 13534 | return $RX_CLASS_CACHE[$cache_key]; |
@@ -13541,7 +13540,7 @@ discard block |
||
13541 | 13540 | /** @noinspection AlterInForeachInspection */ |
13542 | 13541 | foreach (self::str_split($s) as &$s) { |
13543 | 13542 | if ($s === '-') { |
13544 | - $class_array[0] = '-' . $class_array[0]; |
|
13543 | + $class_array[0] = '-'.$class_array[0]; |
|
13545 | 13544 | } elseif (!isset($s[2])) { |
13546 | 13545 | $class_array[0] .= \preg_quote($s, '/'); |
13547 | 13546 | } elseif (self::strlen($s) === 1) { |
@@ -13552,13 +13551,13 @@ discard block |
||
13552 | 13551 | } |
13553 | 13552 | |
13554 | 13553 | if ($class_array[0]) { |
13555 | - $class_array[0] = '[' . $class_array[0] . ']'; |
|
13554 | + $class_array[0] = '['.$class_array[0].']'; |
|
13556 | 13555 | } |
13557 | 13556 | |
13558 | 13557 | if (\count($class_array) === 1) { |
13559 | 13558 | $return = $class_array[0]; |
13560 | 13559 | } else { |
13561 | - $return = '(?:' . \implode('|', $class_array) . ')'; |
|
13560 | + $return = '(?:'.\implode('|', $class_array).')'; |
|
13562 | 13561 | } |
13563 | 13562 | |
13564 | 13563 | $RX_CLASS_CACHE[$cache_key] = $return; |
@@ -13638,7 +13637,7 @@ discard block |
||
13638 | 13637 | $continue = false; |
13639 | 13638 | |
13640 | 13639 | if ($delimiter === '-') { |
13641 | - foreach ((array) $special_cases['names'] as &$beginning) { |
|
13640 | + foreach ((array)$special_cases['names'] as &$beginning) { |
|
13642 | 13641 | if (\strncmp($name, $beginning, \strlen($beginning)) === 0) { |
13643 | 13642 | $continue = true; |
13644 | 13643 | |
@@ -13648,7 +13647,7 @@ discard block |
||
13648 | 13647 | unset($beginning); |
13649 | 13648 | } |
13650 | 13649 | |
13651 | - foreach ((array) $special_cases['prefixes'] as &$beginning) { |
|
13650 | + foreach ((array)$special_cases['prefixes'] as &$beginning) { |
|
13652 | 13651 | if (\strncmp($name, $beginning, \strlen($beginning)) === 0) { |
13653 | 13652 | $continue = true; |
13654 | 13653 | |
@@ -13724,8 +13723,8 @@ discard block |
||
13724 | 13723 | } else { |
13725 | 13724 | /** @noinspection OffsetOperationsInspection */ |
13726 | 13725 | $cc1 = self::$CHR[$ordC1 / 64] | "\xC0"; |
13727 | - $cc2 = ((string) $input & "\x3F") | "\x80"; |
|
13728 | - $buf .= $cc1 . $cc2; |
|
13726 | + $cc2 = ((string)$input & "\x3F") | "\x80"; |
|
13727 | + $buf .= $cc1.$cc2; |
|
13729 | 13728 | } |
13730 | 13729 | |
13731 | 13730 | return $buf; |
@@ -13748,7 +13747,7 @@ discard block |
||
13748 | 13747 | |
13749 | 13748 | $pattern = '/%u([0-9a-fA-F]{3,4})/'; |
13750 | 13749 | if (\preg_match($pattern, $str)) { |
13751 | - $str = (string) \preg_replace($pattern, '&#x\\1;', $str); |
|
13750 | + $str = (string)\preg_replace($pattern, '&#x\\1;', $str); |
|
13752 | 13751 | } |
13753 | 13752 | |
13754 | 13753 | return $str; |