@@ -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,9 +121,9 @@ discard block |
||
| 121 | 121 | * @param string $string |
| 122 | 122 | * @return string Will return original string if false. |
| 123 | 123 | */ |
| 124 | - return function (string $string) use ($args): string { |
|
| 124 | + return function(string $string) use ($args): string { |
|
| 125 | 125 | $result = \vsprintf($string, $args); |
| 126 | - return ! C\isFalse($result) ? $result : $string; |
|
| 126 | + return !C\isFalse($result) ? $result : $string; |
|
| 127 | 127 | }; |
| 128 | 128 | } |
| 129 | 129 | |
@@ -139,12 +139,12 @@ discard block |
||
| 139 | 139 | * @param string $replace value to replace with |
| 140 | 140 | * @return Closure(string):string |
| 141 | 141 | */ |
| 142 | - return function (string $replace) use ($find): Closure { |
|
| 142 | + return function(string $replace) use ($find): Closure { |
|
| 143 | 143 | /** |
| 144 | 144 | * @param string $subject String to carry out find and replace. |
| 145 | 145 | * @return string |
| 146 | 146 | */ |
| 147 | - return function ($subject) use ($find, $replace): string { |
|
| 147 | + return function($subject) use ($find, $replace): string { |
|
| 148 | 148 | return \str_replace($find, $replace, $subject); |
| 149 | 149 | }; |
| 150 | 150 | }; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | * @param string $source |
| 164 | 164 | * @return string |
| 165 | 165 | */ |
| 166 | - return function ($source) use ($find, $replace): string { |
|
| 166 | + return function($source) use ($find, $replace): string { |
|
| 167 | 167 | return \str_replace($find, $replace, $source); |
| 168 | 168 | }; |
| 169 | 169 | } |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | * @param string $string |
| 183 | 183 | * @return string |
| 184 | 184 | */ |
| 185 | - return function (string $string) use ($replace, $offset, $length): string { |
|
| 185 | + return function(string $string) use ($replace, $offset, $length) : string { |
|
| 186 | 186 | return $length |
| 187 | 187 | ? \substr_replace($string, $replace, $offset, $length) |
| 188 | 188 | : \substr_replace($string, $replace, $offset); |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @param string $source |
| 202 | 202 | * @return bool |
| 203 | 203 | */ |
| 204 | - return function (string $source) use ($find): bool { |
|
| 204 | + return function(string $source) use ($find): bool { |
|
| 205 | 205 | return (\substr($source, 0, \strlen($find)) === $find); |
| 206 | 206 | }; |
| 207 | 207 | } |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | * @param string $source |
| 219 | 219 | * @return bool |
| 220 | 220 | */ |
| 221 | - return function (string $source) use ($find): bool { |
|
| 221 | + return function(string $source) use ($find): bool { |
|
| 222 | 222 | if (\strlen($find) === 0) { |
| 223 | 223 | return true; |
| 224 | 224 | } |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | * @param string $haystack String to look in. |
| 239 | 239 | * @return bool |
| 240 | 240 | */ |
| 241 | - return function (string $haystack) use ($needle): bool { |
|
| 241 | + return function(string $haystack) use ($needle): bool { |
|
| 242 | 242 | return \stringContains($haystack, $needle); |
| 243 | 243 | }; |
| 244 | 244 | } |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * @param string $source String to look in. |
| 256 | 256 | * @return bool |
| 257 | 257 | */ |
| 258 | - return function (string $source) use ($pattern): bool { |
|
| 258 | + return function(string $source) use ($pattern): bool { |
|
| 259 | 259 | return (bool) \preg_match($pattern, $source); |
| 260 | 260 | }; |
| 261 | 261 | } |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param string $name |
| 273 | 273 | * @return string[] |
| 274 | 274 | */ |
| 275 | - return function (string $string) use ($pattern): ?array { |
|
| 275 | + return function(string $string) use ($pattern): ?array { |
|
| 276 | 276 | return \preg_split($pattern, $string) ?: null; |
| 277 | 277 | }; |
| 278 | 278 | } |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * @param string|int|float $number |
| 292 | 292 | * @return string |
| 293 | 293 | */ |
| 294 | - return function ($number) use ($precision, $point, $thousands): string { |
|
| 294 | + return function($number) use ($precision, $point, $thousands): string { |
|
| 295 | 295 | return \is_numeric($number) |
| 296 | 296 | ? \number_format((float) $number, (int) $precision, $point, $thousands) |
| 297 | 297 | : ''; |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | * @param string $string The string to have char, slash escaped. |
| 313 | 313 | * @return string |
| 314 | 314 | */ |
| 315 | - return function (string $string) use ($charList): string { |
|
| 315 | + return function(string $string) use ($charList): string { |
|
| 316 | 316 | return \addcslashes($string, $charList); |
| 317 | 317 | }; |
| 318 | 318 | } |
@@ -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 ($length): array { |
|
| 332 | + return function(string $string) use ($length): array { |
|
| 333 | 333 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
| 334 | 334 | }; |
| 335 | 335 | } |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | * @param string $string The string to be chunked |
| 348 | 348 | * @return string |
| 349 | 349 | */ |
| 350 | - return function (string $string) use ($length, $end): string { |
|
| 350 | + return function(string $string) use ($length, $end): string { |
|
| 351 | 351 | return \chunk_split($string, max(1, $length), $end); |
| 352 | 352 | }; |
| 353 | 353 | } |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @param string $string The string to be wrapped |
| 367 | 367 | * @return string |
| 368 | 368 | */ |
| 369 | - return function (string $string) use ($width, $break, $cut): string { |
|
| 369 | + return function(string $string) use ($width, $break, $cut): string { |
|
| 370 | 370 | return \wordwrap($string, $width, $break, $cut); |
| 371 | 371 | }; |
| 372 | 372 | } |
@@ -381,7 +381,7 @@ discard block |
||
| 381 | 381 | function countChars(int $mode = 1): Closure |
| 382 | 382 | { |
| 383 | 383 | // Throw an exception if the mode is not supported. |
| 384 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
| 384 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
| 385 | 385 | throw new \InvalidArgumentException('Invalid mode'); |
| 386 | 386 | } |
| 387 | 387 | |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * @param string $string The string to have its char counted. |
| 390 | 390 | * @return int[]|string |
| 391 | 391 | */ |
| 392 | - return function (string $string) use ($mode) { |
|
| 392 | + return function(string $string) use ($mode) { |
|
| 393 | 393 | return \count_chars($string, $mode); |
| 394 | 394 | }; |
| 395 | 395 | } |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | * @param string $haystack |
| 409 | 409 | * @return int |
| 410 | 410 | */ |
| 411 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
| 411 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
| 412 | 412 | return $length |
| 413 | 413 | ? \substr_count($haystack, $needle, $offset, $length) |
| 414 | 414 | : \substr_count($haystack, $needle, $offset); |
@@ -427,7 +427,7 @@ discard block |
||
| 427 | 427 | * @param string $string The string to be trimmed |
| 428 | 428 | * @return string |
| 429 | 429 | */ |
| 430 | - return function (string $string) use ($mask): string { |
|
| 430 | + return function(string $string) use ($mask): string { |
|
| 431 | 431 | return \trim($string, $mask); |
| 432 | 432 | }; |
| 433 | 433 | } |
@@ -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 \ltrim($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 \rtrim($string, $mask); |
| 466 | 466 | }; |
| 467 | 467 | } |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * @param string $comparisonString The string to compare against base. |
| 481 | 481 | * @return Number |
| 482 | 482 | */ |
| 483 | - return function (string $comparisonString) use ($base, $asPc) { |
|
| 483 | + return function(string $comparisonString) use ($base, $asPc) { |
|
| 484 | 484 | $pc = 0.00; |
| 485 | 485 | $matching = similar_text($base, $comparisonString, $pc); |
| 486 | 486 | return $asPc ? $pc : $matching; |
@@ -501,7 +501,7 @@ discard block |
||
| 501 | 501 | * @param string $comparisonString The string to act as the base. |
| 502 | 502 | * @return Number |
| 503 | 503 | */ |
| 504 | - return function (string $base) use ($comparisonString, $asPc) { |
|
| 504 | + return function(string $base) use ($comparisonString, $asPc) { |
|
| 505 | 505 | $pc = 0.00; |
| 506 | 506 | $matching = similar_text($base, $comparisonString, $pc); |
| 507 | 507 | return $asPc ? $pc : $matching; |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | * @param string $string The string to pad out. |
| 523 | 523 | * @return string |
| 524 | 524 | */ |
| 525 | - return function (string $string) use ($length, $padContent, $type): string { |
|
| 525 | + return function(string $string) use ($length, $padContent, $type): string { |
|
| 526 | 526 | return \str_pad($string, $length, $padContent, $type); |
| 527 | 527 | }; |
| 528 | 528 | } |
@@ -539,7 +539,7 @@ discard block |
||
| 539 | 539 | * @param string $string The string to repeat |
| 540 | 540 | * @return string |
| 541 | 541 | */ |
| 542 | - return function (string $string) use ($count): string { |
|
| 542 | + return function(string $string) use ($count): string { |
|
| 543 | 543 | return \str_repeat($string, $count); |
| 544 | 544 | }; |
| 545 | 545 | } |
@@ -557,7 +557,7 @@ discard block |
||
| 557 | 557 | * @param string $string The string to pad out. |
| 558 | 558 | * @return int|string[] |
| 559 | 559 | */ |
| 560 | - return function (string $string) use ($format, $charList) { |
|
| 560 | + return function(string $string) use ($format, $charList) { |
|
| 561 | 561 | return $charList |
| 562 | 562 | ? (\str_word_count($string, $format, $charList) ?: 0) |
| 563 | 563 | : (\str_word_count($string, $format) ?: 0); |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | * @param string $string The string to strip tags from. |
| 577 | 577 | * @return string |
| 578 | 578 | */ |
| 579 | - return function (string $string) use ($allowedTags): string { |
|
| 579 | + return function(string $string) use ($allowedTags) : string { |
|
| 580 | 580 | return $allowedTags |
| 581 | 581 | ? \strip_tags($string, $allowedTags) |
| 582 | 582 | : \strip_tags($string); |
@@ -593,13 +593,13 @@ discard block |
||
| 593 | 593 | */ |
| 594 | 594 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 595 | 595 | { |
| 596 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 596 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 597 | 597 | |
| 598 | 598 | /** |
| 599 | 599 | * @param string $haystack The haystack to look through. |
| 600 | 600 | * @return int|null |
| 601 | 601 | */ |
| 602 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 602 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 603 | 603 | $pos = $caseSensitive |
| 604 | 604 | ? strpos($haystack, $needle, $offset) |
| 605 | 605 | : stripos($haystack, $needle, $offset); |
@@ -617,13 +617,13 @@ discard block |
||
| 617 | 617 | */ |
| 618 | 618 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
| 619 | 619 | { |
| 620 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 620 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
| 621 | 621 | |
| 622 | 622 | /** |
| 623 | 623 | * @param string $haystack The haystack to look through. |
| 624 | 624 | * @return int|null |
| 625 | 625 | */ |
| 626 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 626 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
| 627 | 627 | $pos = $caseSensitive |
| 628 | 628 | ? strrpos($haystack, $needle, $offset) |
| 629 | 629 | : strripos($haystack, $needle, $offset); |
@@ -645,13 +645,13 @@ discard block |
||
| 645 | 645 | |
| 646 | 646 | // Decode flags, only look for none defaults. |
| 647 | 647 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
| 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 string |
| 653 | 653 | */ |
| 654 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 654 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
| 655 | 655 | $result = $caseSensitive |
| 656 | 656 | ? strstr($haystack, $needle, $beforeNeedle) |
| 657 | 657 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -672,7 +672,7 @@ discard block |
||
| 672 | 672 | * @param string $haystack |
| 673 | 673 | * @return string |
| 674 | 674 | */ |
| 675 | - return function (string $haystack) use ($chars): string { |
|
| 675 | + return function(string $haystack) use ($chars): string { |
|
| 676 | 676 | $result = strpbrk($haystack, $chars); |
| 677 | 677 | return is_string($result) ? $result : ''; |
| 678 | 678 | }; |
@@ -691,7 +691,7 @@ discard block |
||
| 691 | 691 | * @param string $haystack |
| 692 | 692 | * @return string |
| 693 | 693 | */ |
| 694 | - return function (string $haystack) use ($char): string { |
|
| 694 | + return function(string $haystack) use ($char): string { |
|
| 695 | 695 | $result = strrchr($haystack, $char); |
| 696 | 696 | return is_string($result) ? $result : ''; |
| 697 | 697 | }; |
@@ -710,7 +710,7 @@ discard block |
||
| 710 | 710 | * @param string $haystack |
| 711 | 711 | * @return string |
| 712 | 712 | */ |
| 713 | - return function (string $haystack) use ($dictionary): string { |
|
| 713 | + return function(string $haystack) use ($dictionary): string { |
|
| 714 | 714 | $result = strtr($haystack, $dictionary); |
| 715 | 715 | return $result; |
| 716 | 716 | }; |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | * @param string|null $value |
| 741 | 741 | * @return Closure|string |
| 742 | 742 | */ |
| 743 | - return function (?string $value = null) use ($initial) { |
|
| 743 | + return function(?string $value = null) use ($initial) { |
|
| 744 | 744 | if ($value) { |
| 745 | 745 | $initial .= $value; |
| 746 | 746 | } |