@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | * @param callable $predicate the filter function |
| 113 | 113 | * @return \Closure |
| 114 | 114 | */ |
| 115 | -function _make_filterer (callable $append, callable $predicate) { |
|
| 116 | - return function ($acc, ...$entry) use ($append, $predicate) { |
|
| 115 | +function _make_filterer(callable $append, callable $predicate) { |
|
| 116 | + return function($acc, ...$entry) use ($append, $predicate) { |
|
| 117 | 117 | if ($predicate($entry[0])) { |
| 118 | 118 | $append($acc, ...$entry); |
| 119 | 119 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | */ |
| 203 | 203 | function reduce() { |
| 204 | 204 | static $reduce = false; |
| 205 | - $reduce = $reduce ?: curry(function($fn, $initial, $list){ |
|
| 205 | + $reduce = $reduce ?: curry(function($fn, $initial, $list) { |
|
| 206 | 206 | return array_reduce($list, $fn, $initial); |
| 207 | 207 | }); |
| 208 | 208 | return _apply($reduce, func_get_args()); |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | function each() { |
| 231 | 231 | static $each = false; |
| 232 | - $each = $each ?: curry(function($fn, $list){ |
|
| 232 | + $each = $each ?: curry(function($fn, $list) { |
|
| 233 | 233 | foreach ($list as $item) { |
| 234 | 234 | $fn($item); |
| 235 | 235 | } |
@@ -279,10 +279,10 @@ discard block |
||
| 279 | 279 | * @param array|string $list |
| 280 | 280 | * @return mixed |
| 281 | 281 | */ |
| 282 | -function last () { |
|
| 282 | +function last() { |
|
| 283 | 283 | static $last = false; |
| 284 | 284 | $last = $last ?: curry(function($list) { |
| 285 | - if(is_string($list)) |
|
| 285 | + if (is_string($list)) |
|
| 286 | 286 | return substr($list, -1); |
| 287 | 287 | $size = count($list); |
| 288 | 288 | return ($size > 0) |
@@ -309,10 +309,10 @@ discard block |
||
| 309 | 309 | * @param array|string $list |
| 310 | 310 | * @return array |
| 311 | 311 | */ |
| 312 | -function init () { |
|
| 312 | +function init() { |
|
| 313 | 313 | static $init = false; |
| 314 | 314 | $init = $init ?: curry(function($list) { |
| 315 | - if(is_string($list)) { |
|
| 315 | + if (is_string($list)) { |
|
| 316 | 316 | $size = strlen($list); |
| 317 | 317 | return ($size > 1) |
| 318 | 318 | ? substr($list, 0, $size - 1) |
@@ -343,10 +343,10 @@ discard block |
||
| 343 | 343 | * @param array|string $list |
| 344 | 344 | * @return array |
| 345 | 345 | */ |
| 346 | -function tail () { |
|
| 346 | +function tail() { |
|
| 347 | 347 | static $tail = false; |
| 348 | 348 | $tail = $tail ?: curry(function($list) { |
| 349 | - if(is_string($list)) |
|
| 349 | + if (is_string($list)) |
|
| 350 | 350 | return (strlen($list) > 1) |
| 351 | 351 | ? substr($list, 1) |
| 352 | 352 | : ''; |
@@ -371,7 +371,7 @@ discard block |
||
| 371 | 371 | * @param array|string $list |
| 372 | 372 | * @return array |
| 373 | 373 | */ |
| 374 | -function reverse () { |
|
| 374 | +function reverse() { |
|
| 375 | 375 | static $reverse = false; |
| 376 | 376 | $reverse = $reverse ?: curry(function($list) { |
| 377 | 377 | return is_string($list) |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | static $allSatisfies = false; |
| 425 | 425 | $allSatisfies = $allSatisfies ?: curry(function($predicate, $list) { |
| 426 | 426 | foreach ($list as $item) { |
| 427 | - if (! $predicate($item)) |
|
| 427 | + if (!$predicate($item)) |
|
| 428 | 428 | return false; |
| 429 | 429 | } |
| 430 | 430 | return true; |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | */ |
| 601 | 601 | function append() { |
| 602 | 602 | static $append = false; |
| 603 | - $append = $append ?: curry(function ($item, $list) { |
|
| 603 | + $append = $append ?: curry(function($item, $list) { |
|
| 604 | 604 | return is_string($list) |
| 605 | 605 | ? $list . $item |
| 606 | 606 | : array_merge($list, [$item]); |
@@ -626,7 +626,7 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | function prepend() { |
| 628 | 628 | static $prepend = false; |
| 629 | - $prepend = $prepend ?: curry(function ($item, $list) { |
|
| 629 | + $prepend = $prepend ?: curry(function($item, $list) { |
|
| 630 | 630 | return is_string($list) |
| 631 | 631 | ? $item . $list |
| 632 | 632 | : array_merge([$item], $list); |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | $length = length($list); |
| 662 | 662 | if ($count > $length || $count < -$length) |
| 663 | 663 | return $list; |
| 664 | - if(is_string($list)) { |
|
| 664 | + if (is_string($list)) { |
|
| 665 | 665 | return ($count >= 0) |
| 666 | 666 | ? substr($list, 0, $count) |
| 667 | 667 | : substr($list, $count); |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | $count = ($count > 0) |
| 813 | 813 | ? $count - $length |
| 814 | 814 | : $count + $length; |
| 815 | - if(is_string($list)) { |
|
| 815 | + if (is_string($list)) { |
|
| 816 | 816 | return ($count >= 0) |
| 817 | 817 | ? substr($list, 0, $count) |
| 818 | 818 | : substr($list, $count); |
@@ -1169,7 +1169,7 @@ discard block |
||
| 1169 | 1169 | $indexOf = $indexOf ?: curry(function($item, $list) { |
| 1170 | 1170 | if (is_string($list)) { |
| 1171 | 1171 | $index = strpos($list, $item); |
| 1172 | - return $index === false ? -1 : $index; |
|
| 1172 | + return $index === false ? - 1 : $index; |
|
| 1173 | 1173 | } |
| 1174 | 1174 | $list = (array) $list; |
| 1175 | 1175 | $index = 0; |
@@ -1180,7 +1180,7 @@ discard block |
||
| 1180 | 1180 | return $keys[$index]; |
| 1181 | 1181 | $index ++; |
| 1182 | 1182 | } |
| 1183 | - return -1; |
|
| 1183 | + return - 1; |
|
| 1184 | 1184 | }); |
| 1185 | 1185 | return _apply($indexOf, func_get_args()); |
| 1186 | 1186 | } |
@@ -1209,7 +1209,7 @@ discard block |
||
| 1209 | 1209 | $lastIndexOf = $lastIndexOf ?: curry(function($item, $list) { |
| 1210 | 1210 | if (is_string($list)) { |
| 1211 | 1211 | $index = strrpos($list, $item); |
| 1212 | - return $index === false ? -1 : $index; |
|
| 1212 | + return $index === false ? - 1 : $index; |
|
| 1213 | 1213 | } |
| 1214 | 1214 | $list = (array) $list; |
| 1215 | 1215 | $keys = array_keys($list); |
@@ -1219,7 +1219,7 @@ discard block |
||
| 1219 | 1219 | return $keys[$index]; |
| 1220 | 1220 | $index --; |
| 1221 | 1221 | } |
| 1222 | - return -1; |
|
| 1222 | + return - 1; |
|
| 1223 | 1223 | }); |
| 1224 | 1224 | return _apply($lastIndexOf, func_get_args()); |
| 1225 | 1225 | } |
@@ -1254,7 +1254,7 @@ discard block |
||
| 1254 | 1254 | } |
| 1255 | 1255 | $index ++; |
| 1256 | 1256 | } |
| 1257 | - if (! $found) { |
|
| 1257 | + if (!$found) { |
|
| 1258 | 1258 | $result[$size] = $item; |
| 1259 | 1259 | $size ++; |
| 1260 | 1260 | } |
@@ -1314,9 +1314,9 @@ discard block |
||
| 1314 | 1314 | static $groupBy = false; |
| 1315 | 1315 | $groupBy = $groupBy ?: curry(function($fn, $list) { |
| 1316 | 1316 | $result = []; |
| 1317 | - foreach($list as $item) { |
|
| 1317 | + foreach ($list as $item) { |
|
| 1318 | 1318 | $index = $fn($item); |
| 1319 | - if (! isset($result[$index])) |
|
| 1319 | + if (!isset($result[$index])) |
|
| 1320 | 1320 | $result[$index] = []; |
| 1321 | 1321 | $result[$index][] = $item; |
| 1322 | 1322 | } |
@@ -83,8 +83,9 @@ discard block |
||
| 83 | 83 | if ($isArray) |
| 84 | 84 | { |
| 85 | 85 | foreach ($list as $item) { |
| 86 | - if ($fn($item)) |
|
| 87 | - $result[] = $item; |
|
| 86 | + if ($fn($item)) { |
|
| 87 | + $result[] = $item; |
|
| 88 | + } |
|
| 88 | 89 | } |
| 89 | 90 | return $result; |
| 90 | 91 | } |
@@ -257,7 +258,9 @@ discard block |
||
| 257 | 258 | function head() { |
| 258 | 259 | static $head = false; |
| 259 | 260 | $head = $head ?: curry(function($list) { |
| 260 | - if (isset($list[0])) return $list[0]; |
|
| 261 | + if (isset($list[0])) { |
|
| 262 | + return $list[0]; |
|
| 263 | + } |
|
| 261 | 264 | return is_string($list) ? '' : null; |
| 262 | 265 | }); |
| 263 | 266 | return _apply($head, func_get_args()); |
@@ -282,8 +285,9 @@ discard block |
||
| 282 | 285 | function last () { |
| 283 | 286 | static $last = false; |
| 284 | 287 | $last = $last ?: curry(function($list) { |
| 285 | - if(is_string($list)) |
|
| 286 | - return substr($list, -1); |
|
| 288 | + if(is_string($list)) { |
|
| 289 | + return substr($list, -1); |
|
| 290 | + } |
|
| 287 | 291 | $size = count($list); |
| 288 | 292 | return ($size > 0) |
| 289 | 293 | ? $list[$size - 1] |
@@ -346,10 +350,11 @@ discard block |
||
| 346 | 350 | function tail () { |
| 347 | 351 | static $tail = false; |
| 348 | 352 | $tail = $tail ?: curry(function($list) { |
| 349 | - if(is_string($list)) |
|
| 350 | - return (strlen($list) > 1) |
|
| 353 | + if(is_string($list)) { |
|
| 354 | + return (strlen($list) > 1) |
|
| 351 | 355 | ? substr($list, 1) |
| 352 | 356 | : ''; |
| 357 | + } |
|
| 353 | 358 | return (count($list) > 1) |
| 354 | 359 | ? array_slice($list, 1) |
| 355 | 360 | : []; |
@@ -424,8 +429,9 @@ discard block |
||
| 424 | 429 | static $allSatisfies = false; |
| 425 | 430 | $allSatisfies = $allSatisfies ?: curry(function($predicate, $list) { |
| 426 | 431 | foreach ($list as $item) { |
| 427 | - if (! $predicate($item)) |
|
| 428 | - return false; |
|
| 432 | + if (! $predicate($item)) { |
|
| 433 | + return false; |
|
| 434 | + } |
|
| 429 | 435 | } |
| 430 | 436 | return true; |
| 431 | 437 | }); |
@@ -451,8 +457,9 @@ discard block |
||
| 451 | 457 | static $anySatisfies = false; |
| 452 | 458 | $anySatisfies = $anySatisfies ?: curry(function($predicate, $list) { |
| 453 | 459 | foreach ($list as $item) { |
| 454 | - if ($predicate($item)) |
|
| 455 | - return true; |
|
| 460 | + if ($predicate($item)) { |
|
| 461 | + return true; |
|
| 462 | + } |
|
| 456 | 463 | } |
| 457 | 464 | return false; |
| 458 | 465 | }); |
@@ -477,8 +484,9 @@ discard block |
||
| 477 | 484 | function concat() { |
| 478 | 485 | static $concat = false; |
| 479 | 486 | $concat = $concat ?: curry(function($list1, $list2) { |
| 480 | - if (is_string($list1) && is_string($list2)) |
|
| 481 | - return $list1 . $list2; |
|
| 487 | + if (is_string($list1) && is_string($list2)) { |
|
| 488 | + return $list1 . $list2; |
|
| 489 | + } |
|
| 482 | 490 | return array_merge($list1, $list2); |
| 483 | 491 | }); |
| 484 | 492 | return _apply($concat, func_get_args()); |
@@ -500,10 +508,12 @@ discard block |
||
| 500 | 508 | function concatAll() { |
| 501 | 509 | static $concatAll = false; |
| 502 | 510 | $concatAll = $concatAll ?: curry(function($lists) { |
| 503 | - if (count($lists) == 0) |
|
| 504 | - return []; |
|
| 505 | - if (is_string($lists[0])) |
|
| 506 | - return implode('', $lists); |
|
| 511 | + if (count($lists) == 0) { |
|
| 512 | + return []; |
|
| 513 | + } |
|
| 514 | + if (is_string($lists[0])) { |
|
| 515 | + return implode('', $lists); |
|
| 516 | + } |
|
| 507 | 517 | return _apply('array_merge', $lists); |
| 508 | 518 | }); |
| 509 | 519 | return _apply($concatAll, func_get_args()); |
@@ -568,14 +578,17 @@ discard block |
||
| 568 | 578 | static $insertAll = false; |
| 569 | 579 | $insertAll = $insertAll ?: curry(function($position, $items, $list) { |
| 570 | 580 | $size = length($list); |
| 571 | - if ($position < 0) |
|
| 572 | - $position = $size + $position; |
|
| 573 | - if ($position < 0) |
|
| 574 | - $position = 0; |
|
| 575 | - if (is_string($list)) |
|
| 576 | - return ($position >= $size) |
|
| 581 | + if ($position < 0) { |
|
| 582 | + $position = $size + $position; |
|
| 583 | + } |
|
| 584 | + if ($position < 0) { |
|
| 585 | + $position = 0; |
|
| 586 | + } |
|
| 587 | + if (is_string($list)) { |
|
| 588 | + return ($position >= $size) |
|
| 577 | 589 | ? $list . $items |
| 578 | 590 | : substr($list, 0, $position) . $items . substr($list, $position); |
| 591 | + } |
|
| 579 | 592 | return ($position >= $size) |
| 580 | 593 | ? array_merge($list, $items) |
| 581 | 594 | : array_merge(array_slice($list, 0, $position), $items, array_slice($list, $position)); |
@@ -659,8 +672,9 @@ discard block |
||
| 659 | 672 | static $take = false; |
| 660 | 673 | $take = $take ?: curry(function($count, $list) { |
| 661 | 674 | $length = length($list); |
| 662 | - if ($count > $length || $count < -$length) |
|
| 663 | - return $list; |
|
| 675 | + if ($count > $length || $count < -$length) { |
|
| 676 | + return $list; |
|
| 677 | + } |
|
| 664 | 678 | if(is_string($list)) { |
| 665 | 679 | return ($count >= 0) |
| 666 | 680 | ? substr($list, 0, $count) |
@@ -694,8 +708,9 @@ discard block |
||
| 694 | 708 | $takeWhile = $takeWhile ?: curry(function($predicate, $list) { |
| 695 | 709 | $index = 0; |
| 696 | 710 | $size = length($list); |
| 697 | - while ($index < $size && $predicate($list[$index])) |
|
| 698 | - $index ++; |
|
| 711 | + while ($index < $size && $predicate($list[$index])) { |
|
| 712 | + $index ++; |
|
| 713 | + } |
|
| 699 | 714 | return array_slice($list, 0, $index); |
| 700 | 715 | }); |
| 701 | 716 | return _apply($takeWhile, func_get_args()); |
@@ -720,8 +735,9 @@ discard block |
||
| 720 | 735 | static $takeLastWhile = false; |
| 721 | 736 | $takeLastWhile = $takeLastWhile ?: curry(function($predicate, $list) { |
| 722 | 737 | $index = length($list) - 1; |
| 723 | - while ($index >= 0 && $predicate($list[$index])) |
|
| 724 | - $index --; |
|
| 738 | + while ($index >= 0 && $predicate($list[$index])) { |
|
| 739 | + $index --; |
|
| 740 | + } |
|
| 725 | 741 | return array_slice($list, $index + 1); |
| 726 | 742 | }); |
| 727 | 743 | return _apply($takeLastWhile, func_get_args()); |
@@ -748,8 +764,9 @@ discard block |
||
| 748 | 764 | $takeUntil = $takeUntil ?: curry(function($predicate, $list) { |
| 749 | 765 | $index = 0; |
| 750 | 766 | $size = length($list); |
| 751 | - while ($index < $size && !$predicate($list[$index])) |
|
| 752 | - $index ++; |
|
| 767 | + while ($index < $size && !$predicate($list[$index])) { |
|
| 768 | + $index ++; |
|
| 769 | + } |
|
| 753 | 770 | return array_slice($list, 0, $index); |
| 754 | 771 | }); |
| 755 | 772 | return _apply($takeUntil, func_get_args()); |
@@ -774,8 +791,9 @@ discard block |
||
| 774 | 791 | static $takeLastUntil = false; |
| 775 | 792 | $takeLastUntil = $takeLastUntil ?: curry(function($predicate, $list) { |
| 776 | 793 | $index = length($list) - 1; |
| 777 | - while ($index >= 0 && !$predicate($list[$index])) |
|
| 778 | - $index --; |
|
| 794 | + while ($index >= 0 && !$predicate($list[$index])) { |
|
| 795 | + $index --; |
|
| 796 | + } |
|
| 779 | 797 | return array_slice($list, $index + 1); |
| 780 | 798 | }); |
| 781 | 799 | return _apply($takeLastUntil, func_get_args()); |
@@ -807,8 +825,9 @@ discard block |
||
| 807 | 825 | $remove = $remove ?: curry(function($count, $list) { |
| 808 | 826 | // ... |
| 809 | 827 | $length = length($list); |
| 810 | - if ($count > $length || $count < -$length) |
|
| 811 | - return []; |
|
| 828 | + if ($count > $length || $count < -$length) { |
|
| 829 | + return []; |
|
| 830 | + } |
|
| 812 | 831 | $count = ($count > 0) |
| 813 | 832 | ? $count - $length |
| 814 | 833 | : $count + $length; |
@@ -845,8 +864,9 @@ discard block |
||
| 845 | 864 | $removeWhile = $removeWhile ?: curry(function($predicate, $list) { |
| 846 | 865 | $index = 0; |
| 847 | 866 | $size = length($list); |
| 848 | - while ($index < $size && $predicate($list[$index])) |
|
| 849 | - $index ++; |
|
| 867 | + while ($index < $size && $predicate($list[$index])) { |
|
| 868 | + $index ++; |
|
| 869 | + } |
|
| 850 | 870 | return array_slice($list, $index); |
| 851 | 871 | }); |
| 852 | 872 | return _apply($removeWhile, func_get_args()); |
@@ -871,8 +891,9 @@ discard block |
||
| 871 | 891 | static $removeLastWhile = false; |
| 872 | 892 | $removeLastWhile = $removeLastWhile ?: curry(function($predicate, $list) { |
| 873 | 893 | $index = length($list) - 1; |
| 874 | - while ($index >= 0 && $predicate($list[$index])) |
|
| 875 | - $index --; |
|
| 894 | + while ($index >= 0 && $predicate($list[$index])) { |
|
| 895 | + $index --; |
|
| 896 | + } |
|
| 876 | 897 | return array_slice($list, 0, $index + 1); |
| 877 | 898 | }); |
| 878 | 899 | return _apply($removeLastWhile, func_get_args()); |
@@ -900,8 +921,9 @@ discard block |
||
| 900 | 921 | $removeUntil = $removeUntil ?: curry(function($predicate, $list) { |
| 901 | 922 | $index = 0; |
| 902 | 923 | $size = length($list); |
| 903 | - while ($index < $size && !$predicate($list[$index])) |
|
| 904 | - $index ++; |
|
| 924 | + while ($index < $size && !$predicate($list[$index])) { |
|
| 925 | + $index ++; |
|
| 926 | + } |
|
| 905 | 927 | return array_slice($list, $index); |
| 906 | 928 | }); |
| 907 | 929 | return _apply($removeUntil, func_get_args()); |
@@ -927,8 +949,9 @@ discard block |
||
| 927 | 949 | static $removeLastUntil = false; |
| 928 | 950 | $removeLastUntil = $removeLastUntil ?: curry(function($predicate, $list) { |
| 929 | 951 | $index = length($list) - 1; |
| 930 | - while ($index >= 0 && !$predicate($list[$index])) |
|
| 931 | - $index --; |
|
| 952 | + while ($index >= 0 && !$predicate($list[$index])) { |
|
| 953 | + $index --; |
|
| 954 | + } |
|
| 932 | 955 | return array_slice($list, 0, $index + 1); |
| 933 | 956 | }); |
| 934 | 957 | return _apply($removeLastUntil, func_get_args()); |
@@ -981,8 +1004,9 @@ discard block |
||
| 981 | 1004 | static $slices = false; |
| 982 | 1005 | $slices = $slices ?: curry(function($size, &$list) { |
| 983 | 1006 | $length = length($list); |
| 984 | - if ($length == 0) |
|
| 985 | - return is_string($list) ? [''] : []; |
|
| 1007 | + if ($length == 0) { |
|
| 1008 | + return is_string($list) ? [''] : []; |
|
| 1009 | + } |
|
| 986 | 1010 | $start = 0; |
| 987 | 1011 | $result = []; |
| 988 | 1012 | $slicer = is_string($list) ? 'substr' : 'array_slice'; |
@@ -1043,8 +1067,9 @@ discard block |
||
| 1043 | 1067 | static $findIndex = false; |
| 1044 | 1068 | $findIndex = $findIndex ?: curry(function($predicate, $list) { |
| 1045 | 1069 | foreach ($list as $key => &$value) { |
| 1046 | - if ($predicate($value)) |
|
| 1047 | - return $key; |
|
| 1070 | + if ($predicate($value)) { |
|
| 1071 | + return $key; |
|
| 1072 | + } |
|
| 1048 | 1073 | } |
| 1049 | 1074 | return null; |
| 1050 | 1075 | }); |
@@ -1074,8 +1099,9 @@ discard block |
||
| 1074 | 1099 | $keys = array_keys($list); |
| 1075 | 1100 | $index = count($keys) - 1; |
| 1076 | 1101 | while ($index >= 0) { |
| 1077 | - if ($predicate($list[$keys[$index]])) |
|
| 1078 | - return $keys[$index]; |
|
| 1102 | + if ($predicate($list[$keys[$index]])) { |
|
| 1103 | + return $keys[$index]; |
|
| 1104 | + } |
|
| 1079 | 1105 | $index --; |
| 1080 | 1106 | } |
| 1081 | 1107 | return null; |
@@ -1102,8 +1128,9 @@ discard block |
||
| 1102 | 1128 | static $find = false; |
| 1103 | 1129 | $find = $find ?: curry(function($predicate, $list) { |
| 1104 | 1130 | foreach ($list as $key => &$value) { |
| 1105 | - if ($predicate($value)) |
|
| 1106 | - return $value; |
|
| 1131 | + if ($predicate($value)) { |
|
| 1132 | + return $value; |
|
| 1133 | + } |
|
| 1107 | 1134 | } |
| 1108 | 1135 | return null; |
| 1109 | 1136 | }); |
@@ -1131,8 +1158,9 @@ discard block |
||
| 1131 | 1158 | $keys = array_keys($list); |
| 1132 | 1159 | $index = count($keys) - 1; |
| 1133 | 1160 | while ($index >= 0) { |
| 1134 | - if ($predicate($list[$keys[$index]])) |
|
| 1135 | - return $list[$keys[$index]]; |
|
| 1161 | + if ($predicate($list[$keys[$index]])) { |
|
| 1162 | + return $list[$keys[$index]]; |
|
| 1163 | + } |
|
| 1136 | 1164 | $index --; |
| 1137 | 1165 | } |
| 1138 | 1166 | return null; |
@@ -1176,8 +1204,9 @@ discard block |
||
| 1176 | 1204 | $keys = array_keys($list); |
| 1177 | 1205 | $length = count($keys); |
| 1178 | 1206 | while ($index < $length) { |
| 1179 | - if (_equals($item, $list[$keys[$index]])) |
|
| 1180 | - return $keys[$index]; |
|
| 1207 | + if (_equals($item, $list[$keys[$index]])) { |
|
| 1208 | + return $keys[$index]; |
|
| 1209 | + } |
|
| 1181 | 1210 | $index ++; |
| 1182 | 1211 | } |
| 1183 | 1212 | return -1; |
@@ -1215,8 +1244,9 @@ discard block |
||
| 1215 | 1244 | $keys = array_keys($list); |
| 1216 | 1245 | $index = count($list) - 1; |
| 1217 | 1246 | while ($index >= 0) { |
| 1218 | - if (_equals($list[$keys[$index]], $item)) |
|
| 1219 | - return $keys[$index]; |
|
| 1247 | + if (_equals($list[$keys[$index]], $item)) { |
|
| 1248 | + return $keys[$index]; |
|
| 1249 | + } |
|
| 1220 | 1250 | $index --; |
| 1221 | 1251 | } |
| 1222 | 1252 | return -1; |
@@ -1316,8 +1346,9 @@ discard block |
||
| 1316 | 1346 | $result = []; |
| 1317 | 1347 | foreach($list as $item) { |
| 1318 | 1348 | $index = $fn($item); |
| 1319 | - if (! isset($result[$index])) |
|
| 1320 | - $result[$index] = []; |
|
| 1349 | + if (! isset($result[$index])) { |
|
| 1350 | + $result[$index] = []; |
|
| 1351 | + } |
|
| 1321 | 1352 | $result[$index][] = $item; |
| 1322 | 1353 | } |
| 1323 | 1354 | return $result; |
@@ -1346,8 +1377,9 @@ discard block |
||
| 1346 | 1377 | $pairsFrom = $pairsFrom ?: curry(function($list1, $list2) { |
| 1347 | 1378 | $length1 = count($list1); |
| 1348 | 1379 | $length2 = count($list2); |
| 1349 | - if (0 == $length1 || 0 == $length2) |
|
| 1350 | - return []; |
|
| 1380 | + if (0 == $length1 || 0 == $length2) { |
|
| 1381 | + return []; |
|
| 1382 | + } |
|
| 1351 | 1383 | $result = []; |
| 1352 | 1384 | $index = 0; |
| 1353 | 1385 | $length = min($length1, $length2); |