@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $string |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - return function (string $string) use ($opening, $closing): string { |
|
| 52 | + return function(string $string) use ($opening, $closing) : string { |
|
| 53 | 53 | return \sprintf('%s%s%s', $opening, $string, $closing ?? $opening); |
| 54 | 54 | }; |
| 55 | 55 | } |
@@ -68,10 +68,10 @@ discard block |
||
| 68 | 68 | * @param string $string |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | - return function (string $string) use ($tag, $attributes): string { |
|
| 71 | + return function(string $string) use ($tag, $attributes) : string { |
|
| 72 | 72 | |
| 73 | 73 | // Parse attributes into strings. |
| 74 | - $attributes = array_map(function (string $key, ?string $value): string { |
|
| 74 | + $attributes = array_map(function(string $key, ?string $value): string { |
|
| 75 | 75 | // If the value is null, treat as a key only attribute. |
| 76 | 76 | return null === $value |
| 77 | 77 | ? \sprintf('%s', $key) |
@@ -99,15 +99,14 @@ discard block |
||
| 99 | 99 | * @param string $string |
| 100 | 100 | * @return string |
| 101 | 101 | */ |
| 102 | - return function (string $string) use ($url, $target): string { |
|
| 102 | + return function(string $string) use ($url, $target) : string { |
|
| 103 | 103 | return $target ? |
| 104 | 104 | \sprintf( |
| 105 | 105 | "<a href='%s' target='%s'>%s</a>", |
| 106 | 106 | $url, |
| 107 | 107 | $target, |
| 108 | 108 | $string |
| 109 | - ) : |
|
| 110 | - \sprintf( |
|
| 109 | + ) : \sprintf( |
|
| 111 | 110 | "<a href='%s'>%s</a>", |
| 112 | 111 | $url, |
| 113 | 112 | $string |
@@ -131,8 +130,8 @@ discard block |
||
| 131 | 130 | * @param string $string |
| 132 | 131 | * @return string |
| 133 | 132 | */ |
| 134 | - return function (string $string) use ($start, $finish): string { |
|
| 135 | - return ! $finish |
|
| 133 | + return function(string $string) use ($start, $finish) : string { |
|
| 134 | + return !$finish |
|
| 136 | 135 | ? substr($string, $start) |
| 137 | 136 | : substr($string, $start, $finish); |
| 138 | 137 | }; |
@@ -150,7 +149,7 @@ discard block |
||
| 150 | 149 | * @param string $string |
| 151 | 150 | * @return string |
| 152 | 151 | */ |
| 153 | - return function (string $string) use ($prepend): string { |
|
| 152 | + return function(string $string) use ($prepend): string { |
|
| 154 | 153 | return \sprintf('%s%s', $prepend, $string); |
| 155 | 154 | }; |
| 156 | 155 | } |
@@ -167,7 +166,7 @@ discard block |
||
| 167 | 166 | * @param string $string |
| 168 | 167 | * @return string |
| 169 | 168 | */ |
| 170 | - return function (string $string) use ($append): string { |
|
| 169 | + return function(string $string) use ($append): string { |
|
| 171 | 170 | return \sprintf('%s%s', $string, $append); |
| 172 | 171 | }; |
| 173 | 172 | } |
@@ -184,9 +183,9 @@ discard block |
||
| 184 | 183 | * @param string $string |
| 185 | 184 | * @return string Will return original string if false. |
| 186 | 185 | */ |
| 187 | - return function (string $string) use ($args): string { |
|
| 186 | + return function(string $string) use ($args): string { |
|
| 188 | 187 | $result = \vsprintf($string, $args); |
| 189 | - return ! C\isFalse($result) ? $result : $string; |
|
| 188 | + return !C\isFalse($result) ? $result : $string; |
|
| 190 | 189 | }; |
| 191 | 190 | } |
| 192 | 191 | |
@@ -202,12 +201,12 @@ discard block |
||
| 202 | 201 | * @param string $replace value to replace with |
| 203 | 202 | * @return Closure(string):string |
| 204 | 203 | */ |
| 205 | - return function (string $replace) use ($find): Closure { |
|
| 204 | + return function(string $replace) use ($find): Closure { |
|
| 206 | 205 | /** |
| 207 | 206 | * @param string $subject String to carry out find and replace. |
| 208 | 207 | * @return string |
| 209 | 208 | */ |
| 210 | - return function ($subject) use ($find, $replace): string { |
|
| 209 | + return function($subject) use ($find, $replace): string { |
|
| 211 | 210 | return \str_replace($find, $replace, $subject); |
| 212 | 211 | }; |
| 213 | 212 | }; |
@@ -226,7 +225,7 @@ discard block |
||
| 226 | 225 | * @param string $source |
| 227 | 226 | * @return string |
| 228 | 227 | */ |
| 229 | - return function ($source) use ($find, $replace): string { |
|
| 228 | + return function($source) use ($find, $replace): string { |
|
| 230 | 229 | return \str_replace($find, $replace, $source); |
| 231 | 230 | }; |
| 232 | 231 | } |
@@ -245,7 +244,7 @@ discard block |
||
| 245 | 244 | * @param string $string |
| 246 | 245 | * @return string |
| 247 | 246 | */ |
| 248 | - return function (string $string) use ($replace, $offset, $length): string { |
|
| 247 | + return function(string $string) use ($replace, $offset, $length) : string { |
|
| 249 | 248 | return $length |
| 250 | 249 | ? \substr_replace($string, $replace, $offset, $length) |
| 251 | 250 | : \substr_replace($string, $replace, $offset); |
@@ -264,7 +263,7 @@ discard block |
||
| 264 | 263 | * @param string $source |
| 265 | 264 | * @return bool |
| 266 | 265 | */ |
| 267 | - return function (string $source) use ($find): bool { |
|
| 266 | + return function(string $source) use ($find): bool { |
|
| 268 | 267 | return (\substr($source, 0, \strlen($find)) === $find); |
| 269 | 268 | }; |
| 270 | 269 | } |
@@ -281,7 +280,7 @@ discard block |
||
| 281 | 280 | * @param string $source |
| 282 | 281 | * @return bool |
| 283 | 282 | */ |
| 284 | - return function (string $source) use ($find): bool { |
|
| 283 | + return function(string $source) use ($find): bool { |
|
| 285 | 284 | if (\strlen($find) === 0) { |
| 286 | 285 | return true; |
| 287 | 286 | } |
@@ -301,7 +300,7 @@ discard block |
||
| 301 | 300 | * @param string $haystack String to look in. |
| 302 | 301 | * @return bool |
| 303 | 302 | */ |
| 304 | - return function (string $haystack) use ($needle): bool { |
|
| 303 | + return function(string $haystack) use ($needle): bool { |
|
| 305 | 304 | return \stringContains($haystack, $needle); |
| 306 | 305 | }; |
| 307 | 306 | } |
@@ -318,7 +317,7 @@ discard block |
||
| 318 | 317 | * @param string $source String to look in. |
| 319 | 318 | * @return bool |
| 320 | 319 | */ |
| 321 | - return function (string $source) use ($pattern): bool { |
|
| 320 | + return function(string $source) use ($pattern): bool { |
|
| 322 | 321 | return (bool) \preg_match($pattern, $source); |
| 323 | 322 | }; |
| 324 | 323 | } |
@@ -335,7 +334,7 @@ discard block |
||
| 335 | 334 | * @param string $name |
| 336 | 335 | * @return string[] |
| 337 | 336 | */ |
| 338 | - return function (string $string) use ($pattern): ?array { |
|
| 337 | + return function(string $string) use ($pattern): ?array { |
|
| 339 | 338 | return \preg_split($pattern, $string) ?: null; |
| 340 | 339 | }; |
| 341 | 340 | } |
@@ -354,7 +353,7 @@ discard block |
||
| 354 | 353 | * @param string|int|float $number |
| 355 | 354 | * @return string |
| 356 | 355 | */ |
| 357 | - return function ($number) use ($precision, $point, $thousands): string { |
|
| 356 | + return function($number) use ($precision, $point, $thousands): string { |
|
| 358 | 357 | return \is_numeric($number) |
| 359 | 358 | ? \number_format((float) $number, (int) $precision, $point, $thousands) |
| 360 | 359 | : ''; |
@@ -375,7 +374,7 @@ discard block |
||
| 375 | 374 | * @param string $string The string to have char, slash escaped. |
| 376 | 375 | * @return string |
| 377 | 376 | */ |
| 378 | - return function (string $string) use ($charList): string { |
|
| 377 | + return function(string $string) use ($charList): string { |
|
| 379 | 378 | return \addcslashes($string, $charList); |
| 380 | 379 | }; |
| 381 | 380 | } |
@@ -392,7 +391,7 @@ discard block |
||
| 392 | 391 | * @param string $string The string to be split |
| 393 | 392 | * @return array<int, string> |
| 394 | 393 | */ |
| 395 | - return function (string $string) use ($length): array { |
|
| 394 | + return function(string $string) use ($length): array { |
|
| 396 | 395 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
| 397 | 396 | }; |
| 398 | 397 | } |
@@ -410,7 +409,7 @@ discard block |
||
| 410 | 409 | * @param string $string The string to be chunked |
| 411 | 410 | * @return string |
| 412 | 411 | */ |
| 413 | - return function (string $string) use ($length, $end): string { |
|
| 412 | + return function(string $string) use ($length, $end): string { |
|
| 414 | 413 | return \chunk_split($string, max(1, $length), $end); |
| 415 | 414 | }; |
| 416 | 415 | } |
@@ -429,7 +428,7 @@ discard block |
||
| 429 | 428 | * @param string $string The string to be wrapped |
| 430 | 429 | * @return string |
| 431 | 430 | */ |
| 432 | - return function (string $string) use ($width, $break, $cut): string { |
|
| 431 | + return function(string $string) use ($width, $break, $cut): string { |
|
| 433 | 432 | return \wordwrap($string, $width, $break, $cut); |
| 434 | 433 | }; |
| 435 | 434 | } |
@@ -444,7 +443,7 @@ discard block |
||
| 444 | 443 | function countChars(int $mode = 1): Closure |
| 445 | 444 | { |
| 446 | 445 | // Throw an exception if the mode is not supported. |
| 447 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
| 446 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
| 448 | 447 | throw new \InvalidArgumentException('Invalid mode'); |
| 449 | 448 | } |
| 450 | 449 | |
@@ -452,7 +451,7 @@ discard block |
||
| 452 | 451 | * @param string $string The string to have its char counted. |
| 453 | 452 | * @return int[]|string |
| 454 | 453 | */ |
| 455 | - return function (string $string) use ($mode) { |
|
| 454 | + return function(string $string) use ($mode) { |
|
| 456 | 455 | return \count_chars($string, $mode); |
| 457 | 456 | }; |
| 458 | 457 | } |
@@ -471,7 +470,7 @@ discard block |
||
| 471 | 470 | * @param string $haystack |
| 472 | 471 | * @return int |
| 473 | 472 | */ |
| 474 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
| 473 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
| 475 | 474 | return $length |
| 476 | 475 | ? \substr_count($haystack, $needle, $offset, $length) |
| 477 | 476 | : \substr_count($haystack, $needle, $offset); |
@@ -490,7 +489,7 @@ discard block |
||
| 490 | 489 | * @param string $string The string to be trimmed |
| 491 | 490 | * @return string |
| 492 | 491 | */ |
| 493 | - return function (string $string) use ($mask): string { |
|
| 492 | + return function(string $string) use ($mask): string { |
|
| 494 | 493 | return \trim($string, $mask); |
| 495 | 494 | }; |
| 496 | 495 | } |
@@ -507,7 +506,7 @@ discard block |
||
| 507 | 506 | * @param string $string The string to be trimmed |
| 508 | 507 | * @return string |
| 509 | 508 | */ |
| 510 | - return function (string $string) use ($mask): string { |
|
| 509 | + return function(string $string) use ($mask): string { |
|
| 511 | 510 | return \ltrim($string, $mask); |
| 512 | 511 | }; |
| 513 | 512 | } |
@@ -524,7 +523,7 @@ discard block |
||
| 524 | 523 | * @param string $string The string to be trimmed |
| 525 | 524 | * @return string |
| 526 | 525 | */ |
| 527 | - return function (string $string) use ($mask): string { |
|
| 526 | + return function(string $string) use ($mask): string { |
|
| 528 | 527 | return \rtrim($string, $mask); |
| 529 | 528 | }; |
| 530 | 529 | } |
@@ -543,7 +542,7 @@ discard block |
||
| 543 | 542 | * @param string $comparisonString The string to compare against base. |
| 544 | 543 | * @return Number |
| 545 | 544 | */ |
| 546 | - return function (string $comparisonString) use ($base, $asPc) { |
|
| 545 | + return function(string $comparisonString) use ($base, $asPc) { |
|
| 547 | 546 | $pc = 0.00; |
| 548 | 547 | $matching = similar_text($base, $comparisonString, $pc); |
| 549 | 548 | return $asPc ? $pc : $matching; |
@@ -564,7 +563,7 @@ discard block |
||
| 564 | 563 | * @param string $comparisonString The string to act as the base. |
| 565 | 564 | * @return Number |
| 566 | 565 | */ |
| 567 | - return function (string $base) use ($comparisonString, $asPc) { |
|
| 566 | + return function(string $base) use ($comparisonString, $asPc) { |
|
| 568 | 567 | $pc = 0.00; |
| 569 | 568 | $matching = similar_text($base, $comparisonString, $pc); |
| 570 | 569 | return $asPc ? $pc : $matching; |
@@ -585,7 +584,7 @@ discard block |
||
| 585 | 584 | * @param string $string The string to pad out. |
| 586 | 585 | * @return string |
| 587 | 586 | */ |
| 588 | - return function (string $string) use ($length, $padContent, $type): string { |
|
| 587 | + return function(string $string) use ($length, $padContent, $type): string { |
|
| 589 | 588 | return \str_pad($string, $length, $padContent, $type); |
| 590 | 589 | }; |
| 591 | 590 | } |
@@ -602,7 +601,7 @@ discard block |
||
| 602 | 601 | * @param string $string The string to repeat |
| 603 | 602 | * @return string |
| 604 | 603 | */ |
| 605 | - return function (string $string) use ($count): string { |
|
| 604 | + return function(string $string) use ($count): string { |
|
| 606 | 605 | return \str_repeat($string, $count); |
| 607 | 606 | }; |
| 608 | 607 | } |
@@ -620,7 +619,7 @@ discard block |
||
| 620 | 619 | * @param string $string The string to pad out. |
| 621 | 620 | * @return int|string[] |
| 622 | 621 | */ |
| 623 | - return function (string $string) use ($format, $charList) { |
|
| 622 | + return function(string $string) use ($format, $charList) { |
|
| 624 | 623 | return $charList |
| 625 | 624 | ? (\str_word_count($string, $format, $charList) ?: 0) |
| 626 | 625 | : (\str_word_count($string, $format) ?: 0); |
@@ -639,7 +638,7 @@ discard block |
||
| 639 | 638 | * @param string $string The string to strip tags from. |
| 640 | 639 | * @return string |
| 641 | 640 | */ |
| 642 | - return function (string $string) use ($allowedTags): string { |
|
| 641 | + return function(string $string) use ($allowedTags) : string { |
|
| 643 | 642 | return $allowedTags |
| 644 | 643 | ? \strip_tags($string, $allowedTags) |
| 645 | 644 | : \strip_tags($string); |
@@ -656,13 +655,13 @@ discard block |
||
| 656 | 655 | */ |
| 657 | 656 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 658 | 657 | { |
| 659 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 658 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 660 | 659 | |
| 661 | 660 | /** |
| 662 | 661 | * @param string $haystack The haystack to look through. |
| 663 | 662 | * @return int|null |
| 664 | 663 | */ |
| 665 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 664 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 666 | 665 | $pos = $caseSensitive |
| 667 | 666 | ? strpos($haystack, $needle, $offset) |
| 668 | 667 | : stripos($haystack, $needle, $offset); |
@@ -680,13 +679,13 @@ discard block |
||
| 680 | 679 | */ |
| 681 | 680 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 682 | 681 | { |
| 683 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 682 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 684 | 683 | |
| 685 | 684 | /** |
| 686 | 685 | * @param string $haystack The haystack to look through. |
| 687 | 686 | * @return int|null |
| 688 | 687 | */ |
| 689 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 688 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 690 | 689 | $pos = $caseSensitive |
| 691 | 690 | ? strrpos($haystack, $needle, $offset) |
| 692 | 691 | : strripos($haystack, $needle, $offset); |
@@ -708,13 +707,13 @@ discard block |
||
| 708 | 707 | |
| 709 | 708 | // Decode flags, only look for none defaults. |
| 710 | 709 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
| 711 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 710 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 712 | 711 | |
| 713 | 712 | /** |
| 714 | 713 | * @param string $haystack The haystack to look through. |
| 715 | 714 | * @return string |
| 716 | 715 | */ |
| 717 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 716 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 718 | 717 | $result = $caseSensitive |
| 719 | 718 | ? strstr($haystack, $needle, $beforeNeedle) |
| 720 | 719 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -735,7 +734,7 @@ discard block |
||
| 735 | 734 | * @param string $haystack |
| 736 | 735 | * @return string |
| 737 | 736 | */ |
| 738 | - return function (string $haystack) use ($chars): string { |
|
| 737 | + return function(string $haystack) use ($chars): string { |
|
| 739 | 738 | $result = strpbrk($haystack, $chars); |
| 740 | 739 | return is_string($result) ? $result : ''; |
| 741 | 740 | }; |
@@ -754,7 +753,7 @@ discard block |
||
| 754 | 753 | * @param string $haystack |
| 755 | 754 | * @return string |
| 756 | 755 | */ |
| 757 | - return function (string $haystack) use ($char): string { |
|
| 756 | + return function(string $haystack) use ($char): string { |
|
| 758 | 757 | $result = strrchr($haystack, $char); |
| 759 | 758 | return is_string($result) ? $result : ''; |
| 760 | 759 | }; |
@@ -773,7 +772,7 @@ discard block |
||
| 773 | 772 | * @param string $haystack |
| 774 | 773 | * @return string |
| 775 | 774 | */ |
| 776 | - return function (string $haystack) use ($dictionary): string { |
|
| 775 | + return function(string $haystack) use ($dictionary): string { |
|
| 777 | 776 | $result = strtr($haystack, $dictionary); |
| 778 | 777 | return $result; |
| 779 | 778 | }; |
@@ -803,7 +802,7 @@ discard block |
||
| 803 | 802 | * @param string|null $value |
| 804 | 803 | * @return Closure|string |
| 805 | 804 | */ |
| 806 | - return function (?string $value = null) use ($initial) { |
|
| 805 | + return function(?string $value = null) use ($initial) { |
|
| 807 | 806 | if ($value) { |
| 808 | 807 | $initial .= $value; |
| 809 | 808 | } |