@@ -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 | } |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | * @param string $string The string to be split |
| 329 | 329 | * @return array<int, string> |
| 330 | 330 | */ |
| 331 | - return function (string $string) use ($separator, $limit): array { |
|
| 331 | + return function(string $string) use ($separator, $limit): array { |
|
| 332 | 332 | return explode($separator, $string, $limit); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
| 333 | 333 | }; |
| 334 | 334 | } |
@@ -345,7 +345,7 @@ discard block |
||
| 345 | 345 | * @param string $string The string to be split |
| 346 | 346 | * @return array<int, string> |
| 347 | 347 | */ |
| 348 | - return function (string $string) use ($length): array { |
|
| 348 | + return function(string $string) use ($length): array { |
|
| 349 | 349 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
| 350 | 350 | }; |
| 351 | 351 | } |
@@ -364,7 +364,7 @@ discard block |
||
| 364 | 364 | * @param string $string The string to be chunked |
| 365 | 365 | * @return string |
| 366 | 366 | */ |
| 367 | - return function (string $string) use ($length, $end): string { |
|
| 367 | + return function(string $string) use ($length, $end): string { |
|
| 368 | 368 | return \chunk_split($string, max(1, $length), $end); |
| 369 | 369 | }; |
| 370 | 370 | } |
@@ -383,7 +383,7 @@ discard block |
||
| 383 | 383 | * @param string $string The string to be wrapped |
| 384 | 384 | * @return string |
| 385 | 385 | */ |
| 386 | - return function (string $string) use ($width, $break, $cut): string { |
|
| 386 | + return function(string $string) use ($width, $break, $cut): string { |
|
| 387 | 387 | return \wordwrap($string, $width, $break, $cut); |
| 388 | 388 | }; |
| 389 | 389 | } |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | function countChars(int $mode = 1): Closure |
| 399 | 399 | { |
| 400 | 400 | // Throw an exception if the mode is not supported. |
| 401 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
| 401 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
| 402 | 402 | throw new \InvalidArgumentException('Invalid mode'); |
| 403 | 403 | } |
| 404 | 404 | |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | * @param string $string The string to have its char counted. |
| 407 | 407 | * @return int[]|string |
| 408 | 408 | */ |
| 409 | - return function (string $string) use ($mode) { |
|
| 409 | + return function(string $string) use ($mode) { |
|
| 410 | 410 | return \count_chars($string, $mode); |
| 411 | 411 | }; |
| 412 | 412 | } |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | * @param string $haystack |
| 426 | 426 | * @return int |
| 427 | 427 | */ |
| 428 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
| 428 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
| 429 | 429 | return $length |
| 430 | 430 | ? \substr_count($haystack, $needle, $offset, $length) |
| 431 | 431 | : \substr_count($haystack, $needle, $offset); |
@@ -444,7 +444,7 @@ discard block |
||
| 444 | 444 | * @param string $string The string to be trimmed |
| 445 | 445 | * @return string |
| 446 | 446 | */ |
| 447 | - return function (string $string) use ($mask): string { |
|
| 447 | + return function(string $string) use ($mask): string { |
|
| 448 | 448 | return \trim($string, $mask); |
| 449 | 449 | }; |
| 450 | 450 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | * @param string $string The string to be trimmed |
| 462 | 462 | * @return string |
| 463 | 463 | */ |
| 464 | - return function (string $string) use ($mask): string { |
|
| 464 | + return function(string $string) use ($mask): string { |
|
| 465 | 465 | return \ltrim($string, $mask); |
| 466 | 466 | }; |
| 467 | 467 | } |
@@ -478,7 +478,7 @@ discard block |
||
| 478 | 478 | * @param string $string The string to be trimmed |
| 479 | 479 | * @return string |
| 480 | 480 | */ |
| 481 | - return function (string $string) use ($mask): string { |
|
| 481 | + return function(string $string) use ($mask): string { |
|
| 482 | 482 | return \rtrim($string, $mask); |
| 483 | 483 | }; |
| 484 | 484 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | * @param string $comparisonString The string to compare against base. |
| 498 | 498 | * @return Number |
| 499 | 499 | */ |
| 500 | - return function (string $comparisonString) use ($base, $asPc) { |
|
| 500 | + return function(string $comparisonString) use ($base, $asPc) { |
|
| 501 | 501 | $pc = 0.00; |
| 502 | 502 | $matching = similar_text($base, $comparisonString, $pc); |
| 503 | 503 | return $asPc ? $pc : $matching; |
@@ -518,7 +518,7 @@ discard block |
||
| 518 | 518 | * @param string $comparisonString The string to act as the base. |
| 519 | 519 | * @return Number |
| 520 | 520 | */ |
| 521 | - return function (string $base) use ($comparisonString, $asPc) { |
|
| 521 | + return function(string $base) use ($comparisonString, $asPc) { |
|
| 522 | 522 | $pc = 0.00; |
| 523 | 523 | $matching = similar_text($base, $comparisonString, $pc); |
| 524 | 524 | return $asPc ? $pc : $matching; |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param string $string The string to pad out. |
| 540 | 540 | * @return string |
| 541 | 541 | */ |
| 542 | - return function (string $string) use ($length, $padContent, $type): string { |
|
| 542 | + return function(string $string) use ($length, $padContent, $type): string { |
|
| 543 | 543 | return \str_pad($string, $length, $padContent, $type); |
| 544 | 544 | }; |
| 545 | 545 | } |
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | * @param string $string The string to repeat |
| 557 | 557 | * @return string |
| 558 | 558 | */ |
| 559 | - return function (string $string) use ($count): string { |
|
| 559 | + return function(string $string) use ($count): string { |
|
| 560 | 560 | return \str_repeat($string, $count); |
| 561 | 561 | }; |
| 562 | 562 | } |
@@ -574,7 +574,7 @@ discard block |
||
| 574 | 574 | * @param string $string The string to pad out. |
| 575 | 575 | * @return int|string[] |
| 576 | 576 | */ |
| 577 | - return function (string $string) use ($format, $charList) { |
|
| 577 | + return function(string $string) use ($format, $charList) { |
|
| 578 | 578 | return $charList |
| 579 | 579 | ? (\str_word_count($string, $format, $charList) ?: 0) |
| 580 | 580 | : (\str_word_count($string, $format) ?: 0); |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | * @param string $string The string to strip tags from. |
| 594 | 594 | * @return string |
| 595 | 595 | */ |
| 596 | - return function (string $string) use ($allowedTags): string { |
|
| 596 | + return function(string $string) use ($allowedTags) : string { |
|
| 597 | 597 | return $allowedTags |
| 598 | 598 | ? \strip_tags($string, $allowedTags) |
| 599 | 599 | : \strip_tags($string); |
@@ -610,13 +610,13 @@ discard block |
||
| 610 | 610 | */ |
| 611 | 611 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 612 | 612 | { |
| 613 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 613 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 614 | 614 | |
| 615 | 615 | /** |
| 616 | 616 | * @param string $haystack The haystack to look through. |
| 617 | 617 | * @return int|null |
| 618 | 618 | */ |
| 619 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 619 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 620 | 620 | $pos = $caseSensitive |
| 621 | 621 | ? strpos($haystack, $needle, $offset) |
| 622 | 622 | : stripos($haystack, $needle, $offset); |
@@ -634,13 +634,13 @@ discard block |
||
| 634 | 634 | */ |
| 635 | 635 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 636 | 636 | { |
| 637 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 637 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 638 | 638 | |
| 639 | 639 | /** |
| 640 | 640 | * @param string $haystack The haystack to look through. |
| 641 | 641 | * @return int|null |
| 642 | 642 | */ |
| 643 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 643 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 644 | 644 | $pos = $caseSensitive |
| 645 | 645 | ? strrpos($haystack, $needle, $offset) |
| 646 | 646 | : strripos($haystack, $needle, $offset); |
@@ -662,13 +662,13 @@ discard block |
||
| 662 | 662 | |
| 663 | 663 | // Decode flags, only look for none defaults. |
| 664 | 664 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
| 665 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 665 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 666 | 666 | |
| 667 | 667 | /** |
| 668 | 668 | * @param string $haystack The haystack to look through. |
| 669 | 669 | * @return string |
| 670 | 670 | */ |
| 671 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 671 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 672 | 672 | $result = $caseSensitive |
| 673 | 673 | ? strstr($haystack, $needle, $beforeNeedle) |
| 674 | 674 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -689,7 +689,7 @@ discard block |
||
| 689 | 689 | * @param string $haystack |
| 690 | 690 | * @return string |
| 691 | 691 | */ |
| 692 | - return function (string $haystack) use ($chars): string { |
|
| 692 | + return function(string $haystack) use ($chars): string { |
|
| 693 | 693 | $result = strpbrk($haystack, $chars); |
| 694 | 694 | return is_string($result) ? $result : ''; |
| 695 | 695 | }; |
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | * @param string $haystack |
| 709 | 709 | * @return string |
| 710 | 710 | */ |
| 711 | - return function (string $haystack) use ($char): string { |
|
| 711 | + return function(string $haystack) use ($char): string { |
|
| 712 | 712 | $result = strrchr($haystack, $char); |
| 713 | 713 | return is_string($result) ? $result : ''; |
| 714 | 714 | }; |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | * @param string $haystack |
| 728 | 728 | * @return string |
| 729 | 729 | */ |
| 730 | - return function (string $haystack) use ($dictionary): string { |
|
| 730 | + return function(string $haystack) use ($dictionary): string { |
|
| 731 | 731 | $result = strtr($haystack, $dictionary); |
| 732 | 732 | return $result; |
| 733 | 733 | }; |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | * @param string|null $value |
| 758 | 758 | * @return Closure|string |
| 759 | 759 | */ |
| 760 | - return function (?string $value = null) use ($initial) { |
|
| 760 | + return function(?string $value = null) use ($initial) { |
|
| 761 | 761 | if ($value) { |
| 762 | 762 | $initial .= $value; |
| 763 | 763 | } |