@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | if (is_object($class)) { |
53 | 53 | $class = get_class($class); |
54 | 54 | } |
55 | - if (! class_exists($class)) { |
|
55 | + if (!class_exists($class)) { |
|
56 | 56 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Class or Class Name'); |
57 | 57 | } |
58 | 58 | |
@@ -60,11 +60,11 @@ discard block |
||
60 | 60 | * @param Class $value |
61 | 61 | * @return bool |
62 | 62 | */ |
63 | - return function ($value) use ($class): bool { |
|
63 | + return function($value) use ($class): bool { |
|
64 | 64 | if (is_object($value)) { |
65 | 65 | $value = get_class($value); |
66 | 66 | } |
67 | - if (! class_exists($value)) { |
|
67 | + if (!class_exists($value)) { |
|
68 | 68 | throw new InvalidArgumentException(__FUNCTION__ . 'only accepts a Class or Class Name'); |
69 | 69 | } |
70 | 70 | return is_a($value, $class, true); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @param Class $class |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - return function ($class) use ($interface): bool { |
|
87 | + return function($class) use ($interface): bool { |
|
88 | 88 | return in_array( |
89 | 89 | $interface, |
90 | 90 | class_implements($class, false) ?: array(), |
@@ -105,18 +105,18 @@ discard block |
||
105 | 105 | * @param object $object |
106 | 106 | * @return array<string, mixed> |
107 | 107 | */ |
108 | - return function ($object): array { |
|
108 | + return function($object): array { |
|
109 | 109 | |
110 | 110 | // If not object, return empty array. |
111 | - if (! is_object($object)) { |
|
111 | + if (!is_object($object)) { |
|
112 | 112 | return array(); |
113 | 113 | } |
114 | 114 | |
115 | 115 | $objectVars = get_object_vars($object); |
116 | 116 | return array_reduce( |
117 | 117 | array_keys($objectVars), |
118 | - function (array $array, $key) use ($objectVars): array { |
|
119 | - $array[ ltrim((string) $key, '_') ] = $objectVars[ $key ]; |
|
118 | + function(array $array, $key) use ($objectVars): array { |
|
119 | + $array[ltrim((string) $key, '_')] = $objectVars[$key]; |
|
120 | 120 | return $array; |
121 | 121 | }, |
122 | 122 | array() |
@@ -138,9 +138,9 @@ discard block |
||
138 | 138 | * @param object|class-string $object |
139 | 139 | * @return bool |
140 | 140 | */ |
141 | - return function ($object) use ($trait, $autoload): bool { |
|
141 | + return function($object) use ($trait, $autoload): bool { |
|
142 | 142 | // Throw type error if not object or class-string. |
143 | - if (! is_object($object) && ! class_exists($object, false)) { |
|
143 | + if (!is_object($object) && !class_exists($object, false)) { |
|
144 | 144 | throw new InvalidArgumentException(__FUNCTION__ . ' only accepts an object or class-string'); |
145 | 145 | } |
146 | 146 |
@@ -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 | $chunks = explode($separator, $string, $limit); |
333 | 333 | return is_array($chunks) ? $chunks : []; |
334 | 334 | }; |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | * @param string $string The string to be split |
347 | 347 | * @return array<int, string> |
348 | 348 | */ |
349 | - return function (string $string) use ($length): array { |
|
349 | + return function(string $string) use ($length): array { |
|
350 | 350 | return \str_split($string, max(1, $length)) ?: array(); // @phpstan-ignore-line, inconsistent errors with differing php versions. |
351 | 351 | }; |
352 | 352 | } |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | * @param string $string The string to be chunked |
366 | 366 | * @return string |
367 | 367 | */ |
368 | - return function (string $string) use ($length, $end): string { |
|
368 | + return function(string $string) use ($length, $end): string { |
|
369 | 369 | return \chunk_split($string, max(1, $length), $end); |
370 | 370 | }; |
371 | 371 | } |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | * @param string $string The string to be wrapped |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - return function (string $string) use ($width, $break, $cut): string { |
|
387 | + return function(string $string) use ($width, $break, $cut): string { |
|
388 | 388 | return \wordwrap($string, $width, $break, $cut); |
389 | 389 | }; |
390 | 390 | } |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | function countChars(int $mode = 1): Closure |
400 | 400 | { |
401 | 401 | // Throw an exception if the mode is not supported. |
402 | - if (! in_array($mode, array( 0, 1, 2, 3, 4 ), true)) { |
|
402 | + if (!in_array($mode, array(0, 1, 2, 3, 4), true)) { |
|
403 | 403 | throw new \InvalidArgumentException('Invalid mode'); |
404 | 404 | } |
405 | 405 | |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | * @param string $string The string to have its char counted. |
408 | 408 | * @return int[]|string |
409 | 409 | */ |
410 | - return function (string $string) use ($mode) { |
|
410 | + return function(string $string) use ($mode) { |
|
411 | 411 | return \count_chars($string, $mode); |
412 | 412 | }; |
413 | 413 | } |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | * @param string $haystack |
427 | 427 | * @return int |
428 | 428 | */ |
429 | - return function (string $haystack) use ($needle, $offset, $length): int { |
|
429 | + return function(string $haystack) use ($needle, $offset, $length) : int { |
|
430 | 430 | return $length |
431 | 431 | ? \substr_count($haystack, $needle, $offset, $length) |
432 | 432 | : \substr_count($haystack, $needle, $offset); |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | * @param string $string The string to be trimmed |
446 | 446 | * @return string |
447 | 447 | */ |
448 | - return function (string $string) use ($mask): string { |
|
448 | + return function(string $string) use ($mask): string { |
|
449 | 449 | return \trim($string, $mask); |
450 | 450 | }; |
451 | 451 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @param string $string The string to be trimmed |
463 | 463 | * @return string |
464 | 464 | */ |
465 | - return function (string $string) use ($mask): string { |
|
465 | + return function(string $string) use ($mask): string { |
|
466 | 466 | return \ltrim($string, $mask); |
467 | 467 | }; |
468 | 468 | } |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param string $string The string to be trimmed |
480 | 480 | * @return string |
481 | 481 | */ |
482 | - return function (string $string) use ($mask): string { |
|
482 | + return function(string $string) use ($mask): string { |
|
483 | 483 | return \rtrim($string, $mask); |
484 | 484 | }; |
485 | 485 | } |
@@ -498,7 +498,7 @@ discard block |
||
498 | 498 | * @param string $comparisonString The string to compare against base. |
499 | 499 | * @return Number |
500 | 500 | */ |
501 | - return function (string $comparisonString) use ($base, $asPc) { |
|
501 | + return function(string $comparisonString) use ($base, $asPc) { |
|
502 | 502 | $pc = 0.00; |
503 | 503 | $matching = similar_text($base, $comparisonString, $pc); |
504 | 504 | return $asPc ? $pc : $matching; |
@@ -519,7 +519,7 @@ discard block |
||
519 | 519 | * @param string $comparisonString The string to act as the base. |
520 | 520 | * @return Number |
521 | 521 | */ |
522 | - return function (string $base) use ($comparisonString, $asPc) { |
|
522 | + return function(string $base) use ($comparisonString, $asPc) { |
|
523 | 523 | $pc = 0.00; |
524 | 524 | $matching = similar_text($base, $comparisonString, $pc); |
525 | 525 | return $asPc ? $pc : $matching; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @param string $string The string to pad out. |
541 | 541 | * @return string |
542 | 542 | */ |
543 | - return function (string $string) use ($length, $padContent, $type): string { |
|
543 | + return function(string $string) use ($length, $padContent, $type): string { |
|
544 | 544 | return \str_pad($string, $length, $padContent, $type); |
545 | 545 | }; |
546 | 546 | } |
@@ -557,7 +557,7 @@ discard block |
||
557 | 557 | * @param string $string The string to repeat |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - return function (string $string) use ($count): string { |
|
560 | + return function(string $string) use ($count): string { |
|
561 | 561 | return \str_repeat($string, $count); |
562 | 562 | }; |
563 | 563 | } |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | * @param string $string The string to pad out. |
576 | 576 | * @return int|string[] |
577 | 577 | */ |
578 | - return function (string $string) use ($format, $charList) { |
|
578 | + return function(string $string) use ($format, $charList) { |
|
579 | 579 | return $charList |
580 | 580 | ? (\str_word_count($string, $format, $charList) ?: 0) |
581 | 581 | : (\str_word_count($string, $format) ?: 0); |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | * @param string $string The string to strip tags from. |
595 | 595 | * @return string |
596 | 596 | */ |
597 | - return function (string $string) use ($allowedTags): string { |
|
597 | + return function(string $string) use ($allowedTags) : string { |
|
598 | 598 | return $allowedTags |
599 | 599 | ? \strip_tags($string, $allowedTags) |
600 | 600 | : \strip_tags($string); |
@@ -611,13 +611,13 @@ discard block |
||
611 | 611 | */ |
612 | 612 | function firstPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
613 | 613 | { |
614 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
614 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
615 | 615 | |
616 | 616 | /** |
617 | 617 | * @param string $haystack The haystack to look through. |
618 | 618 | * @return int|null |
619 | 619 | */ |
620 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
620 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
621 | 621 | $pos = $caseSensitive |
622 | 622 | ? strpos($haystack, $needle, $offset) |
623 | 623 | : stripos($haystack, $needle, $offset); |
@@ -635,13 +635,13 @@ discard block |
||
635 | 635 | */ |
636 | 636 | function lastPosition(string $needle, int $offset = 0, int $flags = STRINGS_CASE_SENSITIVE): Closure |
637 | 637 | { |
638 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
638 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
639 | 639 | |
640 | 640 | /** |
641 | 641 | * @param string $haystack The haystack to look through. |
642 | 642 | * @return int|null |
643 | 643 | */ |
644 | - return function (string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
644 | + return function(string $haystack) use ($needle, $offset, $caseSensitive): ?int { |
|
645 | 645 | $pos = $caseSensitive |
646 | 646 | ? strrpos($haystack, $needle, $offset) |
647 | 647 | : strripos($haystack, $needle, $offset); |
@@ -663,13 +663,13 @@ discard block |
||
663 | 663 | |
664 | 664 | // Decode flags, only look for none defaults. |
665 | 665 | $beforeNeedle = (bool) ($flags & STRINGS_BEFORE_NEEDLE); |
666 | - $caseSensitive = ! (bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
666 | + $caseSensitive = !(bool) ($flags & STRINGS_CASE_INSENSITIVE); // Assumes true unless INSESNITVE passed |
|
667 | 667 | |
668 | 668 | /** |
669 | 669 | * @param string $haystack The haystack to look through. |
670 | 670 | * @return string |
671 | 671 | */ |
672 | - return function (string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
672 | + return function(string $haystack) use ($needle, $beforeNeedle, $caseSensitive): string { |
|
673 | 673 | $result = $caseSensitive |
674 | 674 | ? strstr($haystack, $needle, $beforeNeedle) |
675 | 675 | : stristr($haystack, $needle, $beforeNeedle); |
@@ -690,7 +690,7 @@ discard block |
||
690 | 690 | * @param string $haystack |
691 | 691 | * @return string |
692 | 692 | */ |
693 | - return function (string $haystack) use ($chars): string { |
|
693 | + return function(string $haystack) use ($chars): string { |
|
694 | 694 | $result = strpbrk($haystack, $chars); |
695 | 695 | return is_string($result) ? $result : ''; |
696 | 696 | }; |
@@ -709,7 +709,7 @@ discard block |
||
709 | 709 | * @param string $haystack |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - return function (string $haystack) use ($char): string { |
|
712 | + return function(string $haystack) use ($char): string { |
|
713 | 713 | $result = strrchr($haystack, $char); |
714 | 714 | return is_string($result) ? $result : ''; |
715 | 715 | }; |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | * @param string $haystack |
729 | 729 | * @return string |
730 | 730 | */ |
731 | - return function (string $haystack) use ($dictionary): string { |
|
731 | + return function(string $haystack) use ($dictionary): string { |
|
732 | 732 | $result = strtr($haystack, $dictionary); |
733 | 733 | return $result; |
734 | 734 | }; |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | * @param string|null $value |
759 | 759 | * @return Closure|string |
760 | 760 | */ |
761 | - return function (?string $value = null) use ($initial) { |
|
761 | + return function(?string $value = null) use ($initial) { |
|
762 | 762 | if ($value) { |
763 | 763 | $initial .= $value; |
764 | 764 | } |