@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | * @param string $string |
| 49 | 49 | * @return string |
| 50 | 50 | */ |
| 51 | - return function (string $string) use ($opening, $closing): string { |
|
| 51 | + return function(string $string) use ($opening, $closing) : string { |
|
| 52 | 52 | return \sprintf('%s%s%s', $opening, $string, $closing ?? $opening); |
| 53 | 53 | }; |
| 54 | 54 | } |
@@ -68,8 +68,8 @@ discard block |
||
| 68 | 68 | * @param string $string |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | - return function (string $string) use ($start, $finish): string { |
|
| 72 | - return ! $finish |
|
| 71 | + return function(string $string) use ($start, $finish) : string { |
|
| 72 | + return !$finish |
|
| 73 | 73 | ? substr($string, $start) |
| 74 | 74 | : substr($string, $start, $finish); |
| 75 | 75 | }; |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | * @param string $string |
| 88 | 88 | * @return string |
| 89 | 89 | */ |
| 90 | - return function (string $string) use ($prepend): string { |
|
| 90 | + return function(string $string) use ($prepend): string { |
|
| 91 | 91 | return \sprintf('%s%s', $prepend, $string); |
| 92 | 92 | }; |
| 93 | 93 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | * @param string $string |
| 105 | 105 | * @return string |
| 106 | 106 | */ |
| 107 | - return function (string $string) use ($append): string { |
|
| 107 | + return function(string $string) use ($append): string { |
|
| 108 | 108 | return \sprintf('%s%s', $string, $append); |
| 109 | 109 | }; |
| 110 | 110 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param array<string, mixed> $values |
| 122 | 122 | * @return string Will return original string if false. |
| 123 | 123 | */ |
| 124 | - return function (array $values = array()) use ($template): string { |
|
| 124 | + return function(array $values = array()) use ($template): string { |
|
| 125 | 125 | return \vsprintf($template, $values); |
| 126 | 126 | }; |
| 127 | 127 | } |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | * @param string $replace value to replace with |
| 139 | 139 | * @return Closure(string):string |
| 140 | 140 | */ |
| 141 | - return function (string $replace) use ($find): Closure { |
|
| 141 | + return function(string $replace) use ($find): Closure { |
|
| 142 | 142 | /** |
| 143 | 143 | * @param string $subject String to carry out find and replace. |
| 144 | 144 | * @return string |
| 145 | 145 | */ |
| 146 | - return function ($subject) use ($find, $replace): string { |
|
| 146 | + return function($subject) use ($find, $replace): string { |
|
| 147 | 147 | return \str_replace($find, $replace, $subject); |
| 148 | 148 | }; |
| 149 | 149 | }; |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * @param string $source |
| 163 | 163 | * @return string |
| 164 | 164 | */ |
| 165 | - return function ($source) use ($find, $replace): string { |
|
| 165 | + return function($source) use ($find, $replace): string { |
|
| 166 | 166 | return \str_replace($find, $replace, $source); |
| 167 | 167 | }; |
| 168 | 168 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @param string $string |
| 182 | 182 | * @return string |
| 183 | 183 | */ |
| 184 | - return function (string $string) use ($replace, $offset, $length): string { |
|
| 184 | + return function(string $string) use ($replace, $offset, $length) : string { |
|
| 185 | 185 | return $length |
| 186 | 186 | ? \substr_replace($string, $replace, $offset, $length) |
| 187 | 187 | : \substr_replace($string, $replace, $offset); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | * @param string $source |
| 201 | 201 | * @return bool |
| 202 | 202 | */ |
| 203 | - return function (string $source) use ($find): bool { |
|
| 203 | + return function(string $source) use ($find): bool { |
|
| 204 | 204 | return (\substr($source, 0, \strlen($find)) === $find); |
| 205 | 205 | }; |
| 206 | 206 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | * @param string $source |
| 218 | 218 | * @return bool |
| 219 | 219 | */ |
| 220 | - return function (string $source) use ($find): bool { |
|
| 220 | + return function(string $source) use ($find): bool { |
|
| 221 | 221 | if (\strlen($find) === 0) { |
| 222 | 222 | return true; |
| 223 | 223 | } |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | * @param string $haystack String to look in. |
| 238 | 238 | * @return bool |
| 239 | 239 | */ |
| 240 | - return function (string $haystack) use ($needle): bool { |
|
| 240 | + return function(string $haystack) use ($needle): bool { |
|
| 241 | 241 | return \stringContains($haystack, $needle); |
| 242 | 242 | }; |
| 243 | 243 | } |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | * @param string $source String to look in. |
| 255 | 255 | * @return bool |
| 256 | 256 | */ |
| 257 | - return function (string $source) use ($pattern): bool { |
|
| 257 | + return function(string $source) use ($pattern): bool { |
|
| 258 | 258 | return (bool) \preg_match($pattern, $source); |
| 259 | 259 | }; |
| 260 | 260 | } |
@@ -271,7 +271,7 @@ discard block |
||
| 271 | 271 | * @param string $name |
| 272 | 272 | * @return string[] |
| 273 | 273 | */ |
| 274 | - return function (string $string) use ($pattern): ?array { |
|
| 274 | + return function(string $string) use ($pattern): ?array { |
|
| 275 | 275 | return \preg_split($pattern, $string) ?: null; |
| 276 | 276 | }; |
| 277 | 277 | } |
@@ -290,7 +290,7 @@ discard block |
||
| 290 | 290 | * @param string|int|float $number |
| 291 | 291 | * @return string |
| 292 | 292 | */ |
| 293 | - return function ($number) use ($precision, $point, $thousands): string { |
|
| 293 | + return function($number) use ($precision, $point, $thousands): string { |
|
| 294 | 294 | return \is_numeric($number) |
| 295 | 295 | ? \number_format((float) $number, (int) $precision, $point, $thousands) |
| 296 | 296 | : ''; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param string $string The string to have char, slash escaped. |
| 312 | 312 | * @return string |
| 313 | 313 | */ |
| 314 | - return function (string $string) use ($charList): string { |
|
| 314 | + return function(string $string) use ($charList): string { |
|
| 315 | 315 | return \addcslashes($string, $charList); |
| 316 | 316 | }; |
| 317 | 317 | } |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | * @param string $string The string to be split |
| 330 | 330 | * @return array<int, string> |
| 331 | 331 | */ |
| 332 | - return function (string $string) use ($separator, $limit): array { |
|
| 332 | + return function(string $string) use ($separator, $limit): array { |
|
| 333 | 333 | $chunks = explode($separator, $string, $limit); |
| 334 | 334 | return is_array($chunks) ? $chunks : array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
| 335 | 335 | }; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @param string $string The string to be split |
| 348 | 348 | * @return array<int, string> |
| 349 | 349 | */ |
| 350 | - return function (string $string) use ($length): array { |
|
| 350 | + return function(string $string) use ($length): array { |
|
| 351 | 351 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
| 352 | 352 | }; |
| 353 | 353 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @param string $string The string to be chunked |
| 367 | 367 | * @return string |
| 368 | 368 | */ |
| 369 | - return function (string $string) use ($length, $end): string { |
|
| 369 | + return function(string $string) use ($length, $end): string { |
|
| 370 | 370 | return \chunk_split($string, max(1, $length), $end); |
| 371 | 371 | }; |
| 372 | 372 | } |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | * @param string $string The string to be wrapped |
| 386 | 386 | * @return string |
| 387 | 387 | */ |
| 388 | - return function (string $string) use ($width, $break, $cut): string { |
|
| 388 | + return function(string $string) use ($width, $break, $cut): string { |
|
| 389 | 389 | return \wordwrap($string, $width, $break, $cut); |
| 390 | 390 | }; |
| 391 | 391 | } |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | function countChars(int $mode = 1): Closure |
| 401 | 401 | { |
| 402 | 402 | // Throw an exception if the mode is not supported. |
| 403 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
| 403 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
| 404 | 404 | throw new \InvalidArgumentException('Invalid mode'); |
| 405 | 405 | } |
| 406 | 406 | |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param string $string The string to have its char counted. |
| 409 | 409 | * @return int[]|string |
| 410 | 410 | */ |
| 411 | - return function (string $string) use ($mode) { |
|
| 411 | + return function(string $string) use ($mode) { |
|
| 412 | 412 | return \count_chars($string, $mode); |
| 413 | 413 | }; |
| 414 | 414 | } |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @param string $haystack |
| 428 | 428 | * @return int |
| 429 | 429 | */ |
| 430 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
| 430 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
| 431 | 431 | return $length |
| 432 | 432 | ? \substr_count($haystack, $needle, $offset, $length) |
| 433 | 433 | : \substr_count($haystack, $needle, $offset); |
@@ -446,7 +446,7 @@ discard block |
||
| 446 | 446 | * @param string $string The string to be trimmed |
| 447 | 447 | * @return string |
| 448 | 448 | */ |
| 449 | - return function (string $string) use ($mask): string { |
|
| 449 | + return function(string $string) use ($mask): string { |
|
| 450 | 450 | return \trim($string, $mask); |
| 451 | 451 | }; |
| 452 | 452 | } |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | * @param string $string The string to be trimmed |
| 464 | 464 | * @return string |
| 465 | 465 | */ |
| 466 | - return function (string $string) use ($mask): string { |
|
| 466 | + return function(string $string) use ($mask): string { |
|
| 467 | 467 | return \ltrim($string, $mask); |
| 468 | 468 | }; |
| 469 | 469 | } |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * @param string $string The string to be trimmed |
| 481 | 481 | * @return string |
| 482 | 482 | */ |
| 483 | - return function (string $string) use ($mask): string { |
|
| 483 | + return function(string $string) use ($mask): string { |
|
| 484 | 484 | return \rtrim($string, $mask); |
| 485 | 485 | }; |
| 486 | 486 | } |
@@ -499,7 +499,7 @@ discard block |
||
| 499 | 499 | * @param string $comparisonString The string to compare against base. |
| 500 | 500 | * @return Number |
| 501 | 501 | */ |
| 502 | - return function (string $comparisonString) use ($base, $asPc) { |
|
| 502 | + return function(string $comparisonString) use ($base, $asPc) { |
|
| 503 | 503 | $pc = 0.00; |
| 504 | 504 | $matching = similar_text($base, $comparisonString, $pc); |
| 505 | 505 | return $asPc ? $pc : $matching; |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | * @param string $string The string to pad out. |
| 551 | 551 | * @return string |
| 552 | 552 | */ |
| 553 | - return function (string $string) use ($length, $padContent, $type): string { |
|
| 553 | + return function(string $string) use ($length, $padContent, $type): string { |
|
| 554 | 554 | return \str_pad($string, $length, $padContent, $type); |
| 555 | 555 | }; |
| 556 | 556 | } |
@@ -567,7 +567,7 @@ discard block |
||
| 567 | 567 | * @param string $string The string to repeat |
| 568 | 568 | * @return string |
| 569 | 569 | */ |
| 570 | - return function (string $string) use ($count): string { |
|
| 570 | + return function(string $string) use ($count): string { |
|
| 571 | 571 | return \str_repeat($string, $count); |
| 572 | 572 | }; |
| 573 | 573 | } |
@@ -585,7 +585,7 @@ discard block |
||
| 585 | 585 | * @param string $string The string to pad out. |
| 586 | 586 | * @return int|string[] |
| 587 | 587 | */ |
| 588 | - return function (string $string) use ($format, $charList) { |
|
| 588 | + return function(string $string) use ($format, $charList) { |
|
| 589 | 589 | return $charList |
| 590 | 590 | ? (\str_word_count($string, $format, $charList) ?: 0) |
| 591 | 591 | : (\str_word_count($string, $format) ?: 0); |
@@ -604,7 +604,7 @@ discard block |
||
| 604 | 604 | * @param string $string The string to strip tags from. |
| 605 | 605 | * @return string |
| 606 | 606 | */ |
| 607 | - return function (string $string) use ($allowedTags): string { |
|
| 607 | + return function(string $string) use ($allowedTags) : string { |
|
| 608 | 608 | return $allowedTags |
| 609 | 609 | ? \strip_tags($string, $allowedTags) |
| 610 | 610 | : \strip_tags($string); |
@@ -621,13 +621,13 @@ discard block |
||
| 621 | 621 | */ |
| 622 | 622 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 623 | 623 | { |
| 624 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 624 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 625 | 625 | |
| 626 | 626 | /** |
| 627 | 627 | * @param string $haystack The haystack to look through. |
| 628 | 628 | * @return int|null |
| 629 | 629 | */ |
| 630 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 630 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 631 | 631 | $pos = $caseSensitive |
| 632 | 632 | ? strpos($haystack, $needle, $offset) |
| 633 | 633 | : stripos($haystack, $needle, $offset); |
@@ -645,13 +645,13 @@ discard block |
||
| 645 | 645 | */ |
| 646 | 646 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 647 | 647 | { |
| 648 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 648 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 649 | 649 | |
| 650 | 650 | /** |
| 651 | 651 | * @param string $haystack The haystack to look through. |
| 652 | 652 | * @return int|null |
| 653 | 653 | */ |
| 654 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 654 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 655 | 655 | $pos = $caseSensitive |
| 656 | 656 | ? strrpos($haystack, $needle, $offset) |
| 657 | 657 | : strripos($haystack, $needle, $offset); |
@@ -672,13 +672,13 @@ discard block |
||
| 672 | 672 | { |
| 673 | 673 | // Decode flags, only look for none defaults. |
| 674 | 674 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
| 675 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 675 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 676 | 676 | |
| 677 | 677 | /** |
| 678 | 678 | * @param string $haystack The haystack to look through. |
| 679 | 679 | * @return string |
| 680 | 680 | */ |
| 681 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 681 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 682 | 682 | $result = $caseSensitive |
| 683 | 683 | ? strstr($haystack, $needle, $beforeNeedle) |
| 684 | 684 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -699,7 +699,7 @@ discard block |
||
| 699 | 699 | * @param string $haystack |
| 700 | 700 | * @return string |
| 701 | 701 | */ |
| 702 | - return function (string $haystack) use ($chars): string { |
|
| 702 | + return function(string $haystack) use ($chars): string { |
|
| 703 | 703 | $result = strpbrk($haystack, $chars); |
| 704 | 704 | return is_string($result) ? $result : ''; |
| 705 | 705 | }; |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | * @param string $haystack |
| 719 | 719 | * @return string |
| 720 | 720 | */ |
| 721 | - return function (string $haystack) use ($char): string { |
|
| 721 | + return function(string $haystack) use ($char): string { |
|
| 722 | 722 | $result = strrchr($haystack, $char); |
| 723 | 723 | return is_string($result) ? $result : ''; |
| 724 | 724 | }; |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * @param string $haystack |
| 738 | 738 | * @return string |
| 739 | 739 | */ |
| 740 | - return function (string $haystack) use ($dictionary): string { |
|
| 740 | + return function(string $haystack) use ($dictionary): string { |
|
| 741 | 741 | $result = strtr($haystack, $dictionary); |
| 742 | 742 | return $result; |
| 743 | 743 | }; |
@@ -767,7 +767,7 @@ discard block |
||
| 767 | 767 | * @param string|null $value |
| 768 | 768 | * @return Closure|string |
| 769 | 769 | */ |
| 770 | - return function (?string $value = null) use ($initial) { |
|
| 770 | + return function(?string $value = null) use ($initial) { |
|
| 771 | 771 | if ($value) { |
| 772 | 772 | $initial .= $value; |
| 773 | 773 | } |