Completed
Push — master ( d1fe82...d3deac )
by Amine
11s
created
src/list.php 3 patches
Doc Comments   -80 removed lines patch added patch discarded remove patch
@@ -14,8 +14,6 @@  discard block
 block discarded – undo
14 14
  *
15 15
  * @stream
16 16
  * @signature (a -> b) -> [a] -> [b]
17
- * @param  callable $fn
18
- * @param  array $list
19 17
  * @return array
20 18
  */
21 19
 function map() {
@@ -37,8 +35,6 @@  discard block
 block discarded – undo
37 35
  *
38 36
  * @stream
39 37
  * @signature (a -> [b]) -> [a] -> [b]
40
- * @param  callable $fn
41
- * @param  array $list
42 38
  * @return array
43 39
  */
44 40
 function chain() {
@@ -60,8 +56,6 @@  discard block
 block discarded – undo
60 56
  * ```
61 57
  * @stream
62 58
  * @signature (a -> Boolean) -> [a] -> [a]
63
- * @param  callable $fn
64
- * @param  array $list
65 59
  * @return array
66 60
  */
67 61
 function filter() {
@@ -84,9 +78,6 @@  discard block
 block discarded – undo
84 78
  *
85 79
  * @stream
86 80
  * @signature (* -> a -> *) -> * -> [a] -> *
87
- * @param  callable $fn
88
- * @param  mixed $initial
89
- * @param  array $list
90 81
  * @return array
91 82
  */
92 83
 function reduce() {
@@ -112,8 +103,6 @@  discard block
 block discarded – undo
112 103
  *
113 104
  * @stream
114 105
  * @signature (a -> *) -> [a] -> [a]
115
- * @param  callable $fn
116
- * @param  array $list
117 106
  * @return array
118 107
  */
119 108
 function each() {
@@ -140,7 +129,6 @@  discard block
 block discarded – undo
140 129
  * @stream
141 130
  * @signature [a] -> a
142 131
  * @signature String -> String
143
- * @param  array|string $list
144 132
  * @return mixed
145 133
  */
146 134
 function head() {
@@ -168,7 +156,6 @@  discard block
 block discarded – undo
168 156
  * @stream
169 157
  * @signature [a] -> a
170 158
  * @signature String -> String
171
- * @param  array|string $list
172 159
  * @return mixed
173 160
  */
174 161
 function last () {
@@ -197,7 +184,6 @@  discard block
 block discarded – undo
197 184
  * @stream
198 185
  * @signature [a] -> a
199 186
  * @signature String -> String
200
- * @param  array|string $list
201 187
  * @return array
202 188
  */
203 189
 function init () {
@@ -228,7 +214,6 @@  discard block
 block discarded – undo
228 214
  * @stream
229 215
  * @signature [a] -> a
230 216
  * @signature String -> String
231
- * @param  array|string $list
232 217
  * @return array
233 218
  */
234 219
 function tail () {
@@ -256,7 +241,6 @@  discard block
 block discarded – undo
256 241
  * @stream
257 242
  * @signature [a] -> [a]
258 243
  * @signature String -> String
259
- * @param  array|string $list
260 244
  * @return array
261 245
  */
262 246
 function reverse () {
@@ -280,7 +264,6 @@  discard block
 block discarded – undo
280 264
  * @stream
281 265
  * @signature [a] -> Number
282 266
  * @signature String -> Number
283
- * @param  array|string $list
284 267
  * @return int
285 268
  */
286 269
 function length() {
@@ -304,8 +287,6 @@  discard block
 block discarded – undo
304 287
  *
305 288
  * @stream
306 289
  * @signature (a -> Boolean) -> [a] -> Boolean
307
- * @param  callable $predicate
308
- * @param  array $list
309 290
  * @return bool
310 291
  */
311 292
 function allSatisfies() {
@@ -327,8 +308,6 @@  discard block
 block discarded – undo
327 308
  *
328 309
  * @stream
329 310
  * @signature (a -> Boolean) -> [a] -> Boolean
330
- * @param  callable $predicate
331
- * @param  array $list
332 311
  * @return bool
333 312
  */
334 313
 function anySatisfies() {
@@ -350,8 +329,6 @@  discard block
 block discarded – undo
350 329
  * @stream
351 330
  * @signature [*] -> [*] -> [*]
352 331
  * @signature String -> String -> String
353
- * @param  array $list1
354
- * @param  array $list2
355 332
  * @return array
356 333
  */
357 334
 function concat() {
@@ -376,7 +353,6 @@  discard block
 block discarded – undo
376 353
  *
377 354
  * @stream
378 355
  * @signature [[a]] -> [a]
379
- * @param  array $lists
380 356
  * @return array
381 357
  */
382 358
 function concatAll() {
@@ -404,9 +380,6 @@  discard block
 block discarded – undo
404 380
  * @stream
405 381
  * @signature Number -> a -> [a] -> [a]
406 382
  * @signature Number -> String -> String -> String
407
- * @param  int $position
408
- * @param  mixed $item
409
- * @param  array $list
410 383
  * @return array
411 384
  */
412 385
 function insert() {
@@ -434,9 +407,6 @@  discard block
 block discarded – undo
434 407
  * @stream
435 408
  * @signature Number -> [a] -> [a] -> [a]
436 409
  * @signature Number -> String -> String -> String
437
- * @param  int $position
438
- * @param  mixed $items
439
- * @param  array $list
440 410
  * @return array
441 411
  */
442 412
 function insertAll() {
@@ -465,8 +435,6 @@  discard block
 block discarded – undo
465 435
  * @stream
466 436
  * @signature * -> [*] -> [*]
467 437
  * @signature String -> String -> String
468
- * @param  mixed $item
469
- * @param  array $list
470 438
  * @return array
471 439
  */
472 440
 function append() {
@@ -489,8 +457,6 @@  discard block
 block discarded – undo
489 457
  * @stream
490 458
  * @signature a -> [a] -> [a]
491 459
  * @signature String -> String -> String
492
- * @param  mixed $item
493
- * @param  array $list
494 460
  * @return array
495 461
  */
496 462
 function prepend() {
@@ -513,8 +479,6 @@  discard block
 block discarded – undo
513 479
  * @stream
514 480
  * @signature Number -> [a] -> [a]
515 481
  * @signature Number -> String -> String
516
- * @param  int $count
517
- * @param  array $list
518 482
  * @return array
519 483
  */
520 484
 function take() {
@@ -547,8 +511,6 @@  discard block
 block discarded – undo
547 511
  *
548 512
  * @stream
549 513
  * @signature (a -> Boolean) -> [a] -> [a]
550
- * @param  callable $predicate
551
- * @param  array $list
552 514
  * @return array
553 515
  */
554 516
 function takeWhile() {
@@ -574,8 +536,6 @@  discard block
 block discarded – undo
574 536
  *
575 537
  * @stream
576 538
  * @signature (a -> Boolean) -> [a] -> [a]
577
- * @param  callable $predicate
578
- * @param  array $list
579 539
  * @return array
580 540
  */
581 541
 function takeLastWhile() {
@@ -602,8 +562,6 @@  discard block
 block discarded – undo
602 562
  *
603 563
  * @stream
604 564
  * @signature (a -> Boolean) -> [a] -> [a]
605
- * @param  callable $predicate
606
- * @param  array $list
607 565
  * @return array
608 566
  */
609 567
 function takeUntil() {
@@ -625,8 +583,6 @@  discard block
 block discarded – undo
625 583
  *
626 584
  * @stream
627 585
  * @signature (a -> Boolean) -> [a] -> [a]
628
- * @param  callable $predicate
629
- * @param  array $list
630 586
  * @return array
631 587
  */
632 588
 function takeLastUntil() {
@@ -654,8 +610,6 @@  discard block
 block discarded – undo
654 610
  * @stream
655 611
  * @signature Number -> [a] -> [a]
656 612
  * @signature Number -> String -> String
657
- * @param  int $count
658
- * @param  array $list
659 613
  * @return array
660 614
  */
661 615
 function remove() {
@@ -683,8 +637,6 @@  discard block
 block discarded – undo
683 637
  *
684 638
  * @stream
685 639
  * @signature (a -> Boolean) -> [a] -> [a]
686
- * @param  callable $predicate
687
- * @param  array $list
688 640
  * @return array
689 641
  */
690 642
 function removeWhile() {
@@ -706,8 +658,6 @@  discard block
 block discarded – undo
706 658
  *
707 659
  * @stream
708 660
  * @signature (a -> Boolean) -> [a] -> [a]
709
- * @param  callable $predicate
710
- * @param  array $list
711 661
  * @return array
712 662
  */
713 663
 function removeLastWhile() {
@@ -731,8 +681,6 @@  discard block
 block discarded – undo
731 681
  *
732 682
  * @stream
733 683
  * @signature (a -> Boolean) -> [a] -> [a]
734
- * @param  callable $predicate
735
- * @param  array $list
736 684
  * @return array
737 685
  */
738 686
 function removeUntil() {
@@ -755,8 +703,6 @@  discard block
 block discarded – undo
755 703
  *
756 704
  * @stream
757 705
  * @signature (a -> Boolean) -> [a] -> [a]
758
- * @param  callable $predicate
759
- * @param  array $list
760 706
  * @return array
761 707
  */
762 708
 function removeLastUntil() {
@@ -776,7 +722,6 @@  discard block
 block discarded – undo
776 722
  *
777 723
  * @stream
778 724
  * @signature [(k, v)] -> {k: v}
779
- * @param  array $pairs
780 725
  * @return stdClass
781 726
  */
782 727
 function fromPairs() {
@@ -805,8 +750,6 @@  discard block
 block discarded – undo
805 750
  * @stream
806 751
  * @signature Number -> [a] -> [[a]]
807 752
  * @signature Number -> String -> [String]
808
- * @param  int $size
809
- * @param  array $list
810 753
  * @return array
811 754
  */
812 755
 function slices() {
@@ -834,8 +777,6 @@  discard block
 block discarded – undo
834 777
  * @stream
835 778
  * @signature a -> [a] -> Boolean
836 779
  * @signature String -> String -> Boolean
837
- * @param  mixed $item
838
- * @param  array|string $list
839 780
  * @return bool
840 781
  */
841 782
 function contains() {
@@ -859,8 +800,6 @@  discard block
 block discarded – undo
859 800
  * @stream
860 801
  * @signature (a -> Boolean) -> [a] -> Maybe(Number)
861 802
  * @signature (v -> Boolean) -> {k: v} -> Maybe(k)
862
- * @param  callable $predicate
863
- * @param  array $list
864 803
  * @return mixed
865 804
  */
866 805
 function findIndex() {
@@ -888,8 +827,6 @@  discard block
 block discarded – undo
888 827
  * @stream
889 828
  * @signature (a -> Boolean) -> [a] -> Maybe(Number)
890 829
  * @signature (v -> Boolean) -> {k: v} -> Maybe(k)
891
- * @param  callable $predicate
892
- * @param  array $list
893 830
  * @return mixed
894 831
  */
895 832
 function findLastIndex() {
@@ -915,8 +852,6 @@  discard block
 block discarded – undo
915 852
  *
916 853
  * @stream
917 854
  * @signature (a -> Boolean) -> [a] -> Maybe(a)
918
- * @param  callable $predicate
919
- * @param  array $list
920 855
  * @return mixed
921 856
  */
922 857
 function find() {
@@ -938,8 +873,6 @@  discard block
 block discarded – undo
938 873
  *
939 874
  * @stream
940 875
  * @signature (a -> Boolean) -> [a] -> Maybe(a)
941
- * @param  callable $predicate
942
- * @param  array $list
943 876
  * @return mixed
944 877
  */
945 878
 function findLast() {
@@ -970,8 +903,6 @@  discard block
 block discarded – undo
970 903
  * @signature a -> [a] -> Number
971 904
  * @signature v -> {k: v} -> Maybe(k)
972 905
  * @signature String -> String -> Number
973
- * @param  mixed $item
974
- * @param  array $list
975 906
  * @return int
976 907
  */
977 908
 function indexOf() {
@@ -1003,8 +934,6 @@  discard block
 block discarded – undo
1003 934
  * @stream
1004 935
  * @signature a -> [a] -> Number
1005 936
  * @signature String -> String -> Number
1006
- * @param  mixed $item
1007
- * @param  array $list
1008 937
  * @return int
1009 938
  */
1010 939
 function lastIndexOf() {
@@ -1033,8 +962,6 @@  discard block
 block discarded – undo
1033 962
  *
1034 963
  * @stream
1035 964
  * @signature (a -> a -> Boolean) -> [a] -> [a]
1036
- * @param  callable $areEqual
1037
- * @param  array $list
1038 965
  * @return array
1039 966
  */
1040 967
 function uniqueBy() {
@@ -1065,7 +992,6 @@  discard block
 block discarded – undo
1065 992
  *
1066 993
  * @stream
1067 994
  * @signature [a] -> [a]
1068
- * @param  array $list
1069 995
  * @return array
1070 996
  */
1071 997
 function unique() {
@@ -1098,8 +1024,6 @@  discard block
 block discarded – undo
1098 1024
  *
1099 1025
  * @stream
1100 1026
  * @signature (a -> String) -> [a] -> {String: a}
1101
- * @param  callable $fn
1102
- * @param  array $list
1103 1027
  * @return array
1104 1028
  */
1105 1029
 function groupBy() {
@@ -1128,8 +1052,6 @@  discard block
 block discarded – undo
1128 1052
  *
1129 1053
  * @stream
1130 1054
  * @signature [a] -> [b] -> [[a,b]]
1131
- * @param  array $list1
1132
- * @param  array $list2
1133 1055
  * @return array
1134 1056
  */
1135 1057
 function pairsFrom() {
@@ -1171,8 +1093,6 @@  discard block
 block discarded – undo
1171 1093
  *
1172 1094
  * @stream
1173 1095
  * @signature (a -> a -> Boolean) -> [a] -> [a]
1174
- * @param  callable $compare
1175
- * @param  array $list
1176 1096
  * @return array
1177 1097
  */
1178 1098
 function sort() {
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
  */
100 100
 function reduce() {
101 101
     static $reduce = false;
102
-    $reduce = $reduce ?: curry(function($fn, $initial, $list){
102
+    $reduce = $reduce ?: curry(function($fn, $initial, $list) {
103 103
         return array_reduce($list, $fn, $initial);
104 104
     });
105 105
     return _apply($reduce, func_get_args());
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
  */
127 127
 function each() {
128 128
     static $each = false;
129
-    $each = $each ?: curry(function($fn, $list){
129
+    $each = $each ?: curry(function($fn, $list) {
130 130
         foreach ($list as $item) {
131 131
             $fn($item);
132 132
         }
@@ -176,10 +176,10 @@  discard block
 block discarded – undo
176 176
  * @param  array|string $list
177 177
  * @return mixed
178 178
  */
179
-function last () {
179
+function last() {
180 180
     static $last = false;
181 181
     $last = $last ?: curry(function($list) {
182
-        if(is_string($list))
182
+        if (is_string($list))
183 183
             return substr($list, -1);
184 184
         $size = count($list);
185 185
         return ($size > 0)
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
  * @param  array|string $list
207 207
  * @return array
208 208
  */
209
-function init () {
209
+function init() {
210 210
     static $init = false;
211 211
     $init = $init ?: curry(function($list) {
212
-        if(is_string($list)) {
212
+        if (is_string($list)) {
213 213
             $size = strlen($list);
214 214
             return ($size > 1)
215 215
                 ? substr($list, 0, $size - 1)
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
  * @param  array|string $list
241 241
  * @return array
242 242
  */
243
-function tail () {
243
+function tail() {
244 244
     static $tail = false;
245 245
     $tail = $tail ?: curry(function($list) {
246
-        if(is_string($list))
246
+        if (is_string($list))
247 247
             return (strlen($list) > 1)
248 248
                 ? substr($list, 1)
249 249
                 : '';
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
  * @param  array|string $list
269 269
  * @return array
270 270
  */
271
-function reverse () {
271
+function reverse() {
272 272
     static $reverse = false;
273 273
     $reverse = $reverse ?: curry(function($list) {
274 274
         return is_string($list)
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     static $allSatisfies = false;
322 322
     $allSatisfies = $allSatisfies ?: curry(function($predicate, $list) {
323 323
         foreach ($list as $item) {
324
-            if (! $predicate($item))
324
+            if (!$predicate($item))
325 325
                 return false;
326 326
         }
327 327
         return true;
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
  */
498 498
 function append() {
499 499
     static $append = false;
500
-    $append = $append ?: curry(function ($item, $list) {
500
+    $append = $append ?: curry(function($item, $list) {
501 501
         return is_string($list)
502 502
             ? $list . $item
503 503
             : array_merge($list, [$item]);
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
  */
524 524
 function prepend() {
525 525
     static $prepend = false;
526
-    $prepend = $prepend ?: curry(function ($item, $list) {
526
+    $prepend = $prepend ?: curry(function($item, $list) {
527 527
         return is_string($list)
528 528
             ? $item . $list
529 529
             : array_merge([$item], $list);
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
         $length = length($list);
559 559
         if ($count > $length || $count < -$length)
560 560
             return $list;
561
-        if(is_string($list)) {
561
+        if (is_string($list)) {
562 562
             return ($count >= 0)
563 563
                 ? substr($list, 0, $count)
564 564
                 : substr($list, $count);
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
         $count = ($count > 0)
710 710
             ? $count - $length
711 711
             : $count + $length;
712
-        if(is_string($list)) {
712
+        if (is_string($list)) {
713 713
             return ($count >= 0)
714 714
                 ? substr($list, 0, $count)
715 715
                 : substr($list, $count);
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
     $indexOf = $indexOf ?: curry(function($item, $list) {
1067 1067
         if (is_string($list)) {
1068 1068
             $index = strpos($list, $item);
1069
-            return $index === false ? -1 : $index;
1069
+            return $index === false ? - 1 : $index;
1070 1070
         }
1071 1071
         $list = (array) $list;
1072 1072
         $index = 0;
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
                 return $keys[$index];
1078 1078
             $index ++;
1079 1079
         }
1080
-        return -1;
1080
+        return - 1;
1081 1081
     });
1082 1082
     return _apply($indexOf, func_get_args());
1083 1083
 }
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
     $lastIndexOf = $lastIndexOf ?: curry(function($item, $list) {
1107 1107
         if (is_string($list)) {
1108 1108
             $index = strrpos($list, $item);
1109
-            return $index === false ? -1 : $index;
1109
+            return $index === false ? - 1 : $index;
1110 1110
         }
1111 1111
         $list = (array) $list;
1112 1112
         $keys = array_keys($list);
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
                 return $keys[$index];
1117 1117
             $index --;
1118 1118
         }
1119
-        return -1;
1119
+        return - 1;
1120 1120
     });
1121 1121
     return _apply($lastIndexOf, func_get_args());
1122 1122
 }
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
                 }
1152 1152
                 $index ++;
1153 1153
             }
1154
-            if (! $found) {
1154
+            if (!$found) {
1155 1155
                 $result[$size] = $item;
1156 1156
                 $size ++;
1157 1157
             }
@@ -1211,9 +1211,9 @@  discard block
 block discarded – undo
1211 1211
     static $groupBy = false;
1212 1212
     $groupBy = $groupBy ?: curry(function($fn, $list) {
1213 1213
         $result = [];
1214
-        foreach($list as $item) {
1214
+        foreach ($list as $item) {
1215 1215
             $index = $fn($item);
1216
-            if (! isset($result[$index]))
1216
+            if (!isset($result[$index]))
1217 1217
                 $result[$index] = [];
1218 1218
             $result[$index][] = $item;
1219 1219
         }
Please login to merge, or discard this patch.
Braces   +93 added lines, -61 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@  discard block
 block discarded – undo
72 72
     $filter = $filter ?: curry(function($fn, $list) {
73 73
         $result = [];
74 74
         foreach ($list as $item) {
75
-            if ($fn($item))
76
-                $result[] = $item;
75
+            if ($fn($item)) {
76
+                            $result[] = $item;
77
+            }
77 78
         }
78 79
         return $result;
79 80
     });
@@ -154,7 +155,9 @@  discard block
 block discarded – undo
154 155
 function head() {
155 156
     static $head = false;
156 157
     $head = $head ?: curry(function($list) {
157
-        if (isset($list[0])) return $list[0];
158
+        if (isset($list[0])) {
159
+            return $list[0];
160
+        }
158 161
         return is_string($list) ? '' : null;
159 162
     });
160 163
     return _apply($head, func_get_args());
@@ -179,8 +182,9 @@  discard block
 block discarded – undo
179 182
 function last () {
180 183
     static $last = false;
181 184
     $last = $last ?: curry(function($list) {
182
-        if(is_string($list))
183
-            return substr($list, -1);
185
+        if(is_string($list)) {
186
+                    return substr($list, -1);
187
+        }
184 188
         $size = count($list);
185 189
         return ($size > 0)
186 190
             ? $list[$size - 1]
@@ -243,10 +247,11 @@  discard block
 block discarded – undo
243 247
 function tail () {
244 248
     static $tail = false;
245 249
     $tail = $tail ?: curry(function($list) {
246
-        if(is_string($list))
247
-            return (strlen($list) > 1)
250
+        if(is_string($list)) {
251
+                    return (strlen($list) > 1)
248 252
                 ? substr($list, 1)
249 253
                 : '';
254
+        }
250 255
         return (count($list) > 1)
251 256
             ? array_slice($list, 1)
252 257
             : [];
@@ -321,8 +326,9 @@  discard block
 block discarded – undo
321 326
     static $allSatisfies = false;
322 327
     $allSatisfies = $allSatisfies ?: curry(function($predicate, $list) {
323 328
         foreach ($list as $item) {
324
-            if (! $predicate($item))
325
-                return false;
329
+            if (! $predicate($item)) {
330
+                            return false;
331
+            }
326 332
         }
327 333
         return true;
328 334
     });
@@ -348,8 +354,9 @@  discard block
 block discarded – undo
348 354
     static $anySatisfies = false;
349 355
     $anySatisfies = $anySatisfies ?: curry(function($predicate, $list) {
350 356
         foreach ($list as $item) {
351
-            if ($predicate($item))
352
-                return true;
357
+            if ($predicate($item)) {
358
+                            return true;
359
+            }
353 360
         }
354 361
         return false;
355 362
     });
@@ -374,8 +381,9 @@  discard block
 block discarded – undo
374 381
 function concat() {
375 382
     static $concat = false;
376 383
     $concat = $concat ?: curry(function($list1, $list2) {
377
-        if (is_string($list1) && is_string($list2))
378
-            return $list1 . $list2;
384
+        if (is_string($list1) && is_string($list2)) {
385
+                    return $list1 . $list2;
386
+        }
379 387
         return array_merge($list1, $list2);
380 388
     });
381 389
     return _apply($concat, func_get_args());
@@ -397,10 +405,12 @@  discard block
 block discarded – undo
397 405
 function concatAll() {
398 406
     static $concatAll = false;
399 407
     $concatAll = $concatAll ?: curry(function($lists) {
400
-        if (count($lists) == 0)
401
-            return [];
402
-        if (is_string($lists[0]))
403
-            return implode('', $lists);
408
+        if (count($lists) == 0) {
409
+                    return [];
410
+        }
411
+        if (is_string($lists[0])) {
412
+                    return implode('', $lists);
413
+        }
404 414
         return _apply('array_merge', $lists);
405 415
     });
406 416
     return _apply($concatAll, func_get_args());
@@ -465,14 +475,17 @@  discard block
 block discarded – undo
465 475
     static $insertAll = false;
466 476
     $insertAll = $insertAll ?: curry(function($position, $items, $list) {
467 477
         $size = length($list);
468
-        if ($position < 0)
469
-            $position = $size + $position;
470
-        if ($position < 0)
471
-            $position = 0;
472
-        if (is_string($list))
473
-            return ($position >= $size)
478
+        if ($position < 0) {
479
+                    $position = $size + $position;
480
+        }
481
+        if ($position < 0) {
482
+                    $position = 0;
483
+        }
484
+        if (is_string($list)) {
485
+                    return ($position >= $size)
474 486
                 ? $list . $items
475 487
                 : substr($list, 0, $position) . $items . substr($list, $position);
488
+        }
476 489
         return ($position >= $size)
477 490
             ? array_merge($list, $items)
478 491
             : array_merge(array_slice($list, 0, $position), $items, array_slice($list, $position));
@@ -556,8 +569,9 @@  discard block
 block discarded – undo
556 569
     static $take = false;
557 570
     $take = $take ?: curry(function($count, $list) {
558 571
         $length = length($list);
559
-        if ($count > $length || $count < -$length)
560
-            return $list;
572
+        if ($count > $length || $count < -$length) {
573
+                    return $list;
574
+        }
561 575
         if(is_string($list)) {
562 576
             return ($count >= 0)
563 577
                 ? substr($list, 0, $count)
@@ -591,8 +605,9 @@  discard block
 block discarded – undo
591 605
     $takeWhile = $takeWhile ?: curry(function($predicate, $list) {
592 606
         $index = 0;
593 607
         $size = length($list);
594
-        while ($index < $size && $predicate($list[$index]))
595
-            $index ++;
608
+        while ($index < $size && $predicate($list[$index])) {
609
+                    $index ++;
610
+        }
596 611
         return array_slice($list, 0, $index);
597 612
     });
598 613
     return _apply($takeWhile, func_get_args());
@@ -617,8 +632,9 @@  discard block
 block discarded – undo
617 632
     static $takeLastWhile = false;
618 633
     $takeLastWhile = $takeLastWhile ?: curry(function($predicate, $list) {
619 634
         $index = length($list) - 1;
620
-        while ($index >= 0 && $predicate($list[$index]))
621
-            $index --;
635
+        while ($index >= 0 && $predicate($list[$index])) {
636
+                    $index --;
637
+        }
622 638
         return array_slice($list, $index + 1);
623 639
     });
624 640
     return _apply($takeLastWhile, func_get_args());
@@ -645,8 +661,9 @@  discard block
 block discarded – undo
645 661
     $takeUntil = $takeUntil ?: curry(function($predicate, $list) {
646 662
         $index = 0;
647 663
         $size = length($list);
648
-        while ($index < $size && !$predicate($list[$index]))
649
-            $index ++;
664
+        while ($index < $size && !$predicate($list[$index])) {
665
+                    $index ++;
666
+        }
650 667
         return array_slice($list, 0, $index);
651 668
     });
652 669
     return _apply($takeUntil, func_get_args());
@@ -671,8 +688,9 @@  discard block
 block discarded – undo
671 688
     static $takeLastUntil = false;
672 689
     $takeLastUntil = $takeLastUntil ?: curry(function($predicate, $list) {
673 690
         $index = length($list) - 1;
674
-        while ($index >= 0 && !$predicate($list[$index]))
675
-            $index --;
691
+        while ($index >= 0 && !$predicate($list[$index])) {
692
+                    $index --;
693
+        }
676 694
         return array_slice($list, $index + 1);
677 695
     });
678 696
     return _apply($takeLastUntil, func_get_args());
@@ -704,8 +722,9 @@  discard block
 block discarded – undo
704 722
     $remove = $remove ?: curry(function($count, $list) {
705 723
         // ...
706 724
         $length = length($list);
707
-        if ($count > $length || $count < -$length)
708
-            return [];
725
+        if ($count > $length || $count < -$length) {
726
+                    return [];
727
+        }
709 728
         $count = ($count > 0)
710 729
             ? $count - $length
711 730
             : $count + $length;
@@ -742,8 +761,9 @@  discard block
 block discarded – undo
742 761
     $removeWhile = $removeWhile ?: curry(function($predicate, $list) {
743 762
         $index = 0;
744 763
         $size = length($list);
745
-        while ($index < $size && $predicate($list[$index]))
746
-            $index ++;
764
+        while ($index < $size && $predicate($list[$index])) {
765
+                    $index ++;
766
+        }
747 767
         return array_slice($list, $index);
748 768
     });
749 769
     return _apply($removeWhile, func_get_args());
@@ -768,8 +788,9 @@  discard block
 block discarded – undo
768 788
     static $removeLastWhile = false;
769 789
     $removeLastWhile = $removeLastWhile ?: curry(function($predicate, $list) {
770 790
         $index = length($list) - 1;
771
-        while ($index >= 0 && $predicate($list[$index]))
772
-            $index --;
791
+        while ($index >= 0 && $predicate($list[$index])) {
792
+                    $index --;
793
+        }
773 794
         return array_slice($list, 0, $index + 1);
774 795
     });
775 796
     return _apply($removeLastWhile, func_get_args());
@@ -797,8 +818,9 @@  discard block
 block discarded – undo
797 818
     $removeUntil = $removeUntil ?: curry(function($predicate, $list) {
798 819
         $index = 0;
799 820
         $size = length($list);
800
-        while ($index < $size && !$predicate($list[$index]))
801
-            $index ++;
821
+        while ($index < $size && !$predicate($list[$index])) {
822
+                    $index ++;
823
+        }
802 824
         return array_slice($list, $index);
803 825
     });
804 826
     return _apply($removeUntil, func_get_args());
@@ -824,8 +846,9 @@  discard block
 block discarded – undo
824 846
     static $removeLastUntil = false;
825 847
     $removeLastUntil = $removeLastUntil ?: curry(function($predicate, $list) {
826 848
         $index = length($list) - 1;
827
-        while ($index >= 0 && !$predicate($list[$index]))
828
-            $index --;
849
+        while ($index >= 0 && !$predicate($list[$index])) {
850
+                    $index --;
851
+        }
829 852
         return array_slice($list, 0, $index + 1);
830 853
     });
831 854
     return _apply($removeLastUntil, func_get_args());
@@ -878,8 +901,9 @@  discard block
 block discarded – undo
878 901
     static $slices = false;
879 902
     $slices = $slices ?: curry(function($size, &$list) {
880 903
         $length = length($list);
881
-        if ($length == 0)
882
-            return is_string($list) ? [''] : [];
904
+        if ($length == 0) {
905
+                    return is_string($list) ? [''] : [];
906
+        }
883 907
         $start = 0;
884 908
         $result = [];
885 909
         $slicer = is_string($list) ? 'substr' : 'array_slice';
@@ -940,8 +964,9 @@  discard block
 block discarded – undo
940 964
     static $findIndex = false;
941 965
     $findIndex = $findIndex ?: curry(function($predicate, $list) {
942 966
         foreach ($list as $key => &$value) {
943
-            if ($predicate($value))
944
-                return $key;
967
+            if ($predicate($value)) {
968
+                            return $key;
969
+            }
945 970
         }
946 971
         return null;
947 972
     });
@@ -971,8 +996,9 @@  discard block
 block discarded – undo
971 996
         $keys = array_keys($list);
972 997
         $index = count($keys) - 1;
973 998
         while ($index >= 0) {
974
-            if ($predicate($list[$keys[$index]]))
975
-                return $keys[$index];
999
+            if ($predicate($list[$keys[$index]])) {
1000
+                            return $keys[$index];
1001
+            }
976 1002
             $index --;
977 1003
         }
978 1004
         return null;
@@ -999,8 +1025,9 @@  discard block
 block discarded – undo
999 1025
     static $find = false;
1000 1026
     $find = $find ?: curry(function($predicate, $list) {
1001 1027
         foreach ($list as $key => &$value) {
1002
-            if ($predicate($value))
1003
-                return $value;
1028
+            if ($predicate($value)) {
1029
+                            return $value;
1030
+            }
1004 1031
         }
1005 1032
         return null;
1006 1033
     });
@@ -1028,8 +1055,9 @@  discard block
 block discarded – undo
1028 1055
         $keys = array_keys($list);
1029 1056
         $index = count($keys) - 1;
1030 1057
         while ($index >= 0) {
1031
-            if ($predicate($list[$keys[$index]]))
1032
-                return $list[$keys[$index]];
1058
+            if ($predicate($list[$keys[$index]])) {
1059
+                            return $list[$keys[$index]];
1060
+            }
1033 1061
             $index --;
1034 1062
         }
1035 1063
         return null;
@@ -1073,8 +1101,9 @@  discard block
 block discarded – undo
1073 1101
         $keys = array_keys($list);
1074 1102
         $length = count($keys);
1075 1103
         while ($index < $length) {
1076
-            if (_equals($item, $list[$keys[$index]]))
1077
-                return $keys[$index];
1104
+            if (_equals($item, $list[$keys[$index]])) {
1105
+                            return $keys[$index];
1106
+            }
1078 1107
             $index ++;
1079 1108
         }
1080 1109
         return -1;
@@ -1112,8 +1141,9 @@  discard block
 block discarded – undo
1112 1141
         $keys = array_keys($list);
1113 1142
         $index = count($list) - 1;
1114 1143
         while ($index >= 0) {
1115
-            if (_equals($list[$keys[$index]], $item))
1116
-                return $keys[$index];
1144
+            if (_equals($list[$keys[$index]], $item)) {
1145
+                            return $keys[$index];
1146
+            }
1117 1147
             $index --;
1118 1148
         }
1119 1149
         return -1;
@@ -1213,8 +1243,9 @@  discard block
 block discarded – undo
1213 1243
         $result = [];
1214 1244
         foreach($list as $item) {
1215 1245
             $index = $fn($item);
1216
-            if (! isset($result[$index]))
1217
-                $result[$index] = [];
1246
+            if (! isset($result[$index])) {
1247
+                            $result[$index] = [];
1248
+            }
1218 1249
             $result[$index][] = $item;
1219 1250
         }
1220 1251
         return $result;
@@ -1243,8 +1274,9 @@  discard block
 block discarded – undo
1243 1274
     $pairsFrom = $pairsFrom ?: curry(function($list1, $list2) {
1244 1275
         $length1 = count($list1);
1245 1276
         $length2 = count($list2);
1246
-        if (0 == $length1 || 0 == $length2)
1247
-            return [];
1277
+        if (0 == $length1 || 0 == $length2) {
1278
+                    return [];
1279
+        }
1248 1280
         $result = [];
1249 1281
         $index = 0;
1250 1282
         $length = min($length1, $length2);
Please login to merge, or discard this patch.
performance/run.php 2 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Returns the list of scripts to compare.
5 5
  *
6
- * @return array
6
+ * @return string[]
7 7
  */
8 8
 function scripts() {
9 9
     return [
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
  * and returns its running time in miliseconds.
102 102
  *
103 103
  * @param  string $path
104
- * @return array
104
+ * @return double
105 105
  */
106 106
 function execute($path, $input) {
107 107
     $start = microtime(true);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,8 +79,8 @@
 block discarded – undo
79 79
  */
80 80
 function averageTime($n, $path, $test) {
81 81
     $s = 0;
82
-    for ($i=0; $i < $n; $i++) {
83
-        $s =+ execute($path, $test->input);
82
+    for ($i = 0; $i < $n; $i ++) {
83
+        $s = + execute($path, $test->input);
84 84
     }
85 85
     return $s / $n;
86 86
 }
Please login to merge, or discard this patch.
src/functions.php 3 patches
Doc Comments   -8 removed lines patch added patch discarded remove patch
@@ -72,8 +72,6 @@  discard block
 block discarded – undo
72 72
  * ```
73 73
  *
74 74
  * @signature (*... -> a) -> [*] -> a
75
- * @param  callable $fn
76
- * @param  array    $args
77 75
  * @return mixed
78 76
  */
79 77
 function apply() {
@@ -97,7 +95,6 @@  discard block
 block discarded – undo
97 95
  * ```
98 96
  *
99 97
  * @signature (((a, b, ...) -> o), (o -> p), ..., (y -> z)) -> ((a, b, ...) -> z)
100
- * @param  callable $fns...
101 98
  * @return callable
102 99
  */
103 100
 function pipe() {
@@ -145,7 +142,6 @@  discard block
 block discarded – undo
145 142
  * ```
146 143
  *
147 144
  * @signature a -> (* -> a)
148
- * @param  mixed $value
149 145
  * @return callable
150 146
  */
151 147
 function give() {
@@ -174,7 +170,6 @@  discard block
 block discarded – undo
174 170
  * ```
175 171
  *
176 172
  * @signature ((a -> Boolean), ..., (a -> Boolean)) -> (a -> Boolean)
177
- * @param  callable $predicates...
178 173
  * @return callable
179 174
  */
180 175
 function all() {
@@ -208,7 +203,6 @@  discard block
 block discarded – undo
208 203
  * ```
209 204
  *
210 205
  * @signature ((a -> Boolean), ..., (a -> Boolean)) -> (a -> Boolean)
211
- * @param  callable $predicates...
212 206
  * @return callable
213 207
  */
214 208
 function any() {
@@ -239,7 +233,6 @@  discard block
 block discarded – undo
239 233
  * ```
240 234
  *
241 235
  * @signature (* -> ... -> *) -> (* -> ... -> Boolean)
242
- * @param  callable $fn
243 236
  * @return callable
244 237
  */
245 238
 function complement() {
@@ -272,7 +265,6 @@  discard block
 block discarded – undo
272 265
  * ```
273 266
  *
274 267
  * @signature (a -> a -> Boolean) -> (a -> a -> Number)
275
- * @param  callable $fn
276 268
  * @return callable
277 269
  */
278 270
 function comparator() {
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
  */
34 34
 function curry($fn) {
35 35
     $n = _number_of_args($fn);
36
-    switch($n) {
36
+    switch ($n) {
37 37
         case 0: return $fn;
38 38
         case 1: return _curry_one($fn);
39 39
         case 2: return _curry_two($fn);
@@ -102,9 +102,9 @@  discard block
 block discarded – undo
102 102
  */
103 103
 function pipe() {
104 104
     $fns = func_get_args();
105
-    if(count($fns) < 1)
105
+    if (count($fns) < 1)
106 106
         return identity();
107
-    return function () use ($fns) {
107
+    return function() use ($fns) {
108 108
         $result = _apply(array_shift($fns), func_get_args());
109 109
         foreach ($fns as $fn) {
110 110
             $result = $fn($result);
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     $predicates = func_get_args();
182 182
     return _curry_one(function($value) use(&$predicates) {
183 183
         foreach ($predicates as $predicate) {
184
-            if (! $predicate($value))
184
+            if (!$predicate($value))
185 185
                 return false;
186 186
         }
187 187
         return true;
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
     static $comparator = false;
280 280
     $comparator = $comparator ?: curry(function($fn) {
281 281
         return function($a, $b) use($fn) {
282
-            if ($fn($a, $b)) return -1;
282
+            if ($fn($a, $b)) return - 1;
283 283
             if ($fn($b, $a)) return 1;
284 284
             return 0;
285 285
         };
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -102,8 +102,9 @@  discard block
 block discarded – undo
102 102
  */
103 103
 function pipe() {
104 104
     $fns = func_get_args();
105
-    if(count($fns) < 1)
106
-        return identity();
105
+    if(count($fns) < 1) {
106
+            return identity();
107
+    }
107 108
     return function () use ($fns) {
108 109
         $result = _apply(array_shift($fns), func_get_args());
109 110
         foreach ($fns as $fn) {
@@ -181,8 +182,9 @@  discard block
 block discarded – undo
181 182
     $predicates = func_get_args();
182 183
     return _curry_one(function($value) use(&$predicates) {
183 184
         foreach ($predicates as $predicate) {
184
-            if (! $predicate($value))
185
-                return false;
185
+            if (! $predicate($value)) {
186
+                            return false;
187
+            }
186 188
         }
187 189
         return true;
188 190
     });
@@ -215,8 +217,9 @@  discard block
 block discarded – undo
215 217
     $predicates = func_get_args();
216 218
     return _curry_one(function($value) use(&$predicates) {
217 219
         foreach ($predicates as $predicate) {
218
-            if ($predicate($value))
219
-                return true;
220
+            if ($predicate($value)) {
221
+                            return true;
222
+            }
220 223
         }
221 224
         return false;
222 225
     });
@@ -279,8 +282,12 @@  discard block
 block discarded – undo
279 282
     static $comparator = false;
280 283
     $comparator = $comparator ?: curry(function($fn) {
281 284
         return function($a, $b) use($fn) {
282
-            if ($fn($a, $b)) return -1;
283
-            if ($fn($b, $a)) return 1;
285
+            if ($fn($a, $b)) {
286
+                return -1;
287
+            }
288
+            if ($fn($b, $a)) {
289
+                return 1;
290
+            }
284 291
             return 0;
285 292
         };
286 293
     });
Please login to merge, or discard this patch.
src/Internal/_stream_operations.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -3,127 +3,127 @@
 block discarded – undo
3 3
 use Tarsana\Functional as F;
4 4
 
5 5
 return F\map(F\apply(F\_f('_stream_operation')), [
6
-	['then', 'Function -> Any -> Any', F\_f('_stream_then')],
7
-	['and', 'Boolean -> Boolean -> Boolean', F\and_()],
8
-	['or', 'Boolean -> Boolean -> Boolean', F\or_()],
9
-	['not', 'Boolean -> Boolean', F\not()],
10
-	['eq', 'Any -> Any -> Boolean', F\eq()],
11
-	['notEq', 'Any -> Any -> Boolean', F\notEq()],
12
-	['eqq', 'Any -> Any -> Boolean', F\eqq()],
13
-	['notEqq', 'Any -> Any -> Boolean', F\notEqq()],
14
-	['equals', 'Any -> Any -> Boolean', F\equals()],
15
-	['equalBy', 'Function -> Any -> Any -> Boolean', F\equalBy()],
16
-	['lt', 'Any -> Any -> Boolean', F\lt()],
17
-	['lte', 'Any -> Any -> Boolean', F\lte()],
18
-	['gt', 'Any -> Any -> Boolean', F\gt()],
19
-	['gte', 'Any -> Any -> Boolean', F\gte()],
20
-	['is', 'String -> Any -> Boolean', F\is()],
21
-	['toString', 'Any -> String', F\toString()],
22
-	['attributes', 'Object|Array -> Object|Array', F\attributes()],
23
-	['keys', 'List -> List', F\keys()],
24
-	['keys', 'Object|Array -> List', F\keys()],
25
-	['values', 'List -> List', F\values()],
26
-	['values', 'Object|Array -> List', F\values()],
27
-	['has', 'Any -> Object|Array -> Boolean', F\has()],
28
-	['get', 'Any -> Object|Array -> Any', F\get()],
29
-	['getPath', 'List -> Object|Array -> Any', F\getPath()],
30
-	['set', 'Any -> Any -> Object|Array -> Object|Array', F\set()],
31
-	['update', 'Any -> Function -> Object|Array -> Object|Array', F\update()],
32
-	['satisfies', 'Function -> Any -> Object|Array -> Boolean', F\satisfies()],
33
-	['satisfiesAll', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAll()],
34
-	['satisfiesAny', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAny()],
35
-	['toPairs', 'Object|Array -> List', F\toPairs()],
36
-	['toPairs', 'List -> List', F\toPairs()],
37
-	['split', 'String -> String -> List', F\split()],
38
-	['join', 'String -> List -> String', F\join()],
39
-	['replace', 'String|List -> String|List -> String -> String', F\replace()],
40
-	['regReplace', 'String -> String -> String -> String', F\regReplace()],
41
-	['upperCase', 'String -> String', F\upperCase()],
42
-	['lowerCase', 'String -> String', F\lowerCase()],
43
-	['camelCase', 'String -> String', F\camelCase()],
44
-	['snakeCase', 'String -> String -> String', F\snakeCase()],
45
-	['startsWith', 'String -> String -> Boolean', F\startsWith()],
46
-	['endsWith', 'String -> String -> Boolean', F\endsWith()],
47
-	['test', 'String -> String -> Boolean', F\test()],
48
-	['match', 'String -> String -> List', F\match()],
49
-	['occurences', 'String -> String -> Number', F\occurences()],
50
-	['chunks', 'String -> String -> String -> List', F\chunks()],
51
-	['map', 'Function -> List -> List', F\map()],
52
-	['map', 'Function -> Object|Array -> Object|Array', F\map()],
53
-	['chain', 'Function -> List -> List', F\chain()],
54
-	['filter', 'Function -> List -> List', F\filter()],
55
-	['reduce', 'Function -> Any -> List -> Any', F\reduce()],
56
-	['each', 'Function -> List -> List', F\each()],
57
-	['head', 'List -> Any', F\head()],
58
-	['head', 'String -> String', F\head()],
59
-	['last', 'List -> Any', F\last()],
60
-	['last', 'String -> String', F\last()],
61
-	['init', 'List -> Any', F\init()],
62
-	['init', 'String -> String', F\init()],
63
-	['tail', 'List -> Any', F\tail()],
64
-	['tail', 'String -> String', F\tail()],
65
-	['reverse', 'List -> List', F\reverse()],
66
-	['reverse', 'String -> String', F\reverse()],
67
-	['length', 'List -> Number', F\length()],
68
-	['length', 'String -> Number', F\length()],
69
-	['allSatisfies', 'Function -> List -> Boolean', F\allSatisfies()],
70
-	['anySatisfies', 'Function -> List -> Boolean', F\anySatisfies()],
71
-	['concat', 'List -> List -> List', F\concat()],
72
-	['concat', 'String -> String -> String', F\concat()],
73
-	['concatAll', 'List -> List', F\concatAll()],
74
-	['insert', 'Number -> Any -> List -> List', F\insert()],
75
-	['insert', 'Number -> String -> String -> String', F\insert()],
76
-	['insertAll', 'Number -> List -> List -> List', F\insertAll()],
77
-	['insertAll', 'Number -> String -> String -> String', F\insertAll()],
78
-	['append', 'Any -> List -> List', F\append()],
79
-	['append', 'String -> String -> String', F\append()],
80
-	['prepend', 'Any -> List -> List', F\prepend()],
81
-	['prepend', 'String -> String -> String', F\prepend()],
82
-	['take', 'Number -> List -> List', F\take()],
83
-	['take', 'Number -> String -> String', F\take()],
84
-	['takeWhile', 'Function -> List -> List', F\takeWhile()],
85
-	['takeLastWhile', 'Function -> List -> List', F\takeLastWhile()],
86
-	['takeUntil', 'Function -> List -> List', F\takeUntil()],
87
-	['takeLastUntil', 'Function -> List -> List', F\takeLastUntil()],
88
-	['remove', 'Number -> List -> List', F\remove()],
89
-	['remove', 'Number -> String -> String', F\remove()],
90
-	['removeWhile', 'Function -> List -> List', F\removeWhile()],
91
-	['removeLastWhile', 'Function -> List -> List', F\removeLastWhile()],
92
-	['removeUntil', 'Function -> List -> List', F\removeUntil()],
93
-	['removeLastUntil', 'Function -> List -> List', F\removeLastUntil()],
94
-	['fromPairs', 'List -> Object|Array', F\fromPairs()],
95
-	['slices', 'Number -> List -> List', F\slices()],
96
-	['slices', 'Number -> String -> List', F\slices()],
97
-	['contains', 'Any -> List -> Boolean', F\contains()],
98
-	['contains', 'String -> String -> Boolean', F\contains()],
99
-	['findIndex', 'Function -> List -> Number|Null', F\findIndex()],
100
-	['findIndex', 'Function -> Object|Array -> Any', F\findIndex()],
101
-	['findLastIndex', 'Function -> List -> Number|Null', F\findLastIndex()],
102
-	['findLastIndex', 'Function -> Object|Array -> Any', F\findLastIndex()],
103
-	['find', 'Function -> List -> Any', F\find()],
104
-	['findLast', 'Function -> List -> Any', F\findLast()],
105
-	['indexOf', 'Any -> List -> Number', F\indexOf()],
106
-	['indexOf', 'Any -> Object|Array -> Any', F\indexOf()],
107
-	['indexOf', 'String -> String -> Number', F\indexOf()],
108
-	['lastIndexOf', 'Any -> List -> Number', F\lastIndexOf()],
109
-	['lastIndexOf', 'Any -> Object|Array -> Any', F\lastIndexOf()],
110
-	['lastIndexOf', 'String -> String -> Number', F\lastIndexOf()],
111
-	['uniqueBy', 'Function -> List -> List', F\uniqueBy()],
112
-	['unique', 'List -> List', F\unique()],
113
-	['groupBy', 'Function -> List -> Object|Array', F\groupBy()],
114
-	['pairsFrom', 'List -> List -> List', F\pairsFrom()],
115
-	['sort', 'Function -> List -> List', F\sort()],
116
-	['plus', 'Number -> Number -> Number', F\plus()],
117
-	['minus', 'Number -> Number -> Number', F\minus()],
118
-	['negate', 'Number -> Number', F\negate()],
119
-	['multiply', 'Number -> Number -> Number', F\multiply()],
120
-	['divide', 'Number -> Number -> Number', F\divide()],
121
-	['modulo', 'Number -> Number -> Number', F\modulo()],
122
-	['sum', 'List -> Number', F\sum()],
123
-	['product', 'List -> Number', F\product()],
124
-	['min', 'Number -> Number -> Number', F\min()],
125
-	['minBy', 'Function -> Any -> Any -> Any', F\minBy()],
126
-	['max', 'Number -> Number -> Number', F\max()],
127
-	['maxBy', 'Function -> Any -> Any -> Any', F\maxBy()],
6
+    ['then', 'Function -> Any -> Any', F\_f('_stream_then')],
7
+    ['and', 'Boolean -> Boolean -> Boolean', F\and_()],
8
+    ['or', 'Boolean -> Boolean -> Boolean', F\or_()],
9
+    ['not', 'Boolean -> Boolean', F\not()],
10
+    ['eq', 'Any -> Any -> Boolean', F\eq()],
11
+    ['notEq', 'Any -> Any -> Boolean', F\notEq()],
12
+    ['eqq', 'Any -> Any -> Boolean', F\eqq()],
13
+    ['notEqq', 'Any -> Any -> Boolean', F\notEqq()],
14
+    ['equals', 'Any -> Any -> Boolean', F\equals()],
15
+    ['equalBy', 'Function -> Any -> Any -> Boolean', F\equalBy()],
16
+    ['lt', 'Any -> Any -> Boolean', F\lt()],
17
+    ['lte', 'Any -> Any -> Boolean', F\lte()],
18
+    ['gt', 'Any -> Any -> Boolean', F\gt()],
19
+    ['gte', 'Any -> Any -> Boolean', F\gte()],
20
+    ['is', 'String -> Any -> Boolean', F\is()],
21
+    ['toString', 'Any -> String', F\toString()],
22
+    ['attributes', 'Object|Array -> Object|Array', F\attributes()],
23
+    ['keys', 'List -> List', F\keys()],
24
+    ['keys', 'Object|Array -> List', F\keys()],
25
+    ['values', 'List -> List', F\values()],
26
+    ['values', 'Object|Array -> List', F\values()],
27
+    ['has', 'Any -> Object|Array -> Boolean', F\has()],
28
+    ['get', 'Any -> Object|Array -> Any', F\get()],
29
+    ['getPath', 'List -> Object|Array -> Any', F\getPath()],
30
+    ['set', 'Any -> Any -> Object|Array -> Object|Array', F\set()],
31
+    ['update', 'Any -> Function -> Object|Array -> Object|Array', F\update()],
32
+    ['satisfies', 'Function -> Any -> Object|Array -> Boolean', F\satisfies()],
33
+    ['satisfiesAll', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAll()],
34
+    ['satisfiesAny', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAny()],
35
+    ['toPairs', 'Object|Array -> List', F\toPairs()],
36
+    ['toPairs', 'List -> List', F\toPairs()],
37
+    ['split', 'String -> String -> List', F\split()],
38
+    ['join', 'String -> List -> String', F\join()],
39
+    ['replace', 'String|List -> String|List -> String -> String', F\replace()],
40
+    ['regReplace', 'String -> String -> String -> String', F\regReplace()],
41
+    ['upperCase', 'String -> String', F\upperCase()],
42
+    ['lowerCase', 'String -> String', F\lowerCase()],
43
+    ['camelCase', 'String -> String', F\camelCase()],
44
+    ['snakeCase', 'String -> String -> String', F\snakeCase()],
45
+    ['startsWith', 'String -> String -> Boolean', F\startsWith()],
46
+    ['endsWith', 'String -> String -> Boolean', F\endsWith()],
47
+    ['test', 'String -> String -> Boolean', F\test()],
48
+    ['match', 'String -> String -> List', F\match()],
49
+    ['occurences', 'String -> String -> Number', F\occurences()],
50
+    ['chunks', 'String -> String -> String -> List', F\chunks()],
51
+    ['map', 'Function -> List -> List', F\map()],
52
+    ['map', 'Function -> Object|Array -> Object|Array', F\map()],
53
+    ['chain', 'Function -> List -> List', F\chain()],
54
+    ['filter', 'Function -> List -> List', F\filter()],
55
+    ['reduce', 'Function -> Any -> List -> Any', F\reduce()],
56
+    ['each', 'Function -> List -> List', F\each()],
57
+    ['head', 'List -> Any', F\head()],
58
+    ['head', 'String -> String', F\head()],
59
+    ['last', 'List -> Any', F\last()],
60
+    ['last', 'String -> String', F\last()],
61
+    ['init', 'List -> Any', F\init()],
62
+    ['init', 'String -> String', F\init()],
63
+    ['tail', 'List -> Any', F\tail()],
64
+    ['tail', 'String -> String', F\tail()],
65
+    ['reverse', 'List -> List', F\reverse()],
66
+    ['reverse', 'String -> String', F\reverse()],
67
+    ['length', 'List -> Number', F\length()],
68
+    ['length', 'String -> Number', F\length()],
69
+    ['allSatisfies', 'Function -> List -> Boolean', F\allSatisfies()],
70
+    ['anySatisfies', 'Function -> List -> Boolean', F\anySatisfies()],
71
+    ['concat', 'List -> List -> List', F\concat()],
72
+    ['concat', 'String -> String -> String', F\concat()],
73
+    ['concatAll', 'List -> List', F\concatAll()],
74
+    ['insert', 'Number -> Any -> List -> List', F\insert()],
75
+    ['insert', 'Number -> String -> String -> String', F\insert()],
76
+    ['insertAll', 'Number -> List -> List -> List', F\insertAll()],
77
+    ['insertAll', 'Number -> String -> String -> String', F\insertAll()],
78
+    ['append', 'Any -> List -> List', F\append()],
79
+    ['append', 'String -> String -> String', F\append()],
80
+    ['prepend', 'Any -> List -> List', F\prepend()],
81
+    ['prepend', 'String -> String -> String', F\prepend()],
82
+    ['take', 'Number -> List -> List', F\take()],
83
+    ['take', 'Number -> String -> String', F\take()],
84
+    ['takeWhile', 'Function -> List -> List', F\takeWhile()],
85
+    ['takeLastWhile', 'Function -> List -> List', F\takeLastWhile()],
86
+    ['takeUntil', 'Function -> List -> List', F\takeUntil()],
87
+    ['takeLastUntil', 'Function -> List -> List', F\takeLastUntil()],
88
+    ['remove', 'Number -> List -> List', F\remove()],
89
+    ['remove', 'Number -> String -> String', F\remove()],
90
+    ['removeWhile', 'Function -> List -> List', F\removeWhile()],
91
+    ['removeLastWhile', 'Function -> List -> List', F\removeLastWhile()],
92
+    ['removeUntil', 'Function -> List -> List', F\removeUntil()],
93
+    ['removeLastUntil', 'Function -> List -> List', F\removeLastUntil()],
94
+    ['fromPairs', 'List -> Object|Array', F\fromPairs()],
95
+    ['slices', 'Number -> List -> List', F\slices()],
96
+    ['slices', 'Number -> String -> List', F\slices()],
97
+    ['contains', 'Any -> List -> Boolean', F\contains()],
98
+    ['contains', 'String -> String -> Boolean', F\contains()],
99
+    ['findIndex', 'Function -> List -> Number|Null', F\findIndex()],
100
+    ['findIndex', 'Function -> Object|Array -> Any', F\findIndex()],
101
+    ['findLastIndex', 'Function -> List -> Number|Null', F\findLastIndex()],
102
+    ['findLastIndex', 'Function -> Object|Array -> Any', F\findLastIndex()],
103
+    ['find', 'Function -> List -> Any', F\find()],
104
+    ['findLast', 'Function -> List -> Any', F\findLast()],
105
+    ['indexOf', 'Any -> List -> Number', F\indexOf()],
106
+    ['indexOf', 'Any -> Object|Array -> Any', F\indexOf()],
107
+    ['indexOf', 'String -> String -> Number', F\indexOf()],
108
+    ['lastIndexOf', 'Any -> List -> Number', F\lastIndexOf()],
109
+    ['lastIndexOf', 'Any -> Object|Array -> Any', F\lastIndexOf()],
110
+    ['lastIndexOf', 'String -> String -> Number', F\lastIndexOf()],
111
+    ['uniqueBy', 'Function -> List -> List', F\uniqueBy()],
112
+    ['unique', 'List -> List', F\unique()],
113
+    ['groupBy', 'Function -> List -> Object|Array', F\groupBy()],
114
+    ['pairsFrom', 'List -> List -> List', F\pairsFrom()],
115
+    ['sort', 'Function -> List -> List', F\sort()],
116
+    ['plus', 'Number -> Number -> Number', F\plus()],
117
+    ['minus', 'Number -> Number -> Number', F\minus()],
118
+    ['negate', 'Number -> Number', F\negate()],
119
+    ['multiply', 'Number -> Number -> Number', F\multiply()],
120
+    ['divide', 'Number -> Number -> Number', F\divide()],
121
+    ['modulo', 'Number -> Number -> Number', F\modulo()],
122
+    ['sum', 'List -> Number', F\sum()],
123
+    ['product', 'List -> Number', F\product()],
124
+    ['min', 'Number -> Number -> Number', F\min()],
125
+    ['minBy', 'Function -> Any -> Any -> Any', F\minBy()],
126
+    ['max', 'Number -> Number -> Number', F\max()],
127
+    ['maxBy', 'Function -> Any -> Any -> Any', F\maxBy()],
128 128
 
129 129
 ]);
Please login to merge, or discard this patch.
src/Internal/_functions.php 3 patches
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -35,8 +35,7 @@  discard block
 block discarded – undo
35 35
  */
36 36
 function _number_of_args($fn) {
37 37
     $reflector = is_array($fn) ?
38
-        new \ReflectionMethod($fn[0], $fn[1]) :
39
-        new \ReflectionFunction($fn);
38
+        new \ReflectionMethod($fn[0], $fn[1]) : new \ReflectionFunction($fn);
40 39
     return $reflector->getNumberOfRequiredParameters();
41 40
 }
42 41
 
@@ -85,7 +84,7 @@  discard block
 block discarded – undo
85 84
 function _curry_one($fn) {
86 85
     return function() use($fn) {
87 86
         $args = func_get_args();
88
-        return (count($args) > 0 && ! _is_placeholder($args[0]))
87
+        return (count($args) > 0 && !_is_placeholder($args[0]))
89 88
             ? $fn($args[0])
90 89
             : _curry_one($fn);
91 90
     };
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
  * @ignore
81 81
  * @signature (a -> b) -> (a -> b)
82 82
  * @param  callable $fn
83
- * @return callable
83
+ * @return \Closure
84 84
  */
85 85
 function _curry_one($fn) {
86 86
     return function() use($fn) {
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  * @ignore
98 98
  * @signature (a,b -> c) -> (a -> b -> c)
99 99
  * @param  callable $fn
100
- * @return callable
100
+ * @return \Closure
101 101
  */
102 102
 function _curry_two($fn) {
103 103
     return function() use($fn) {
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
  * @ignore
136 136
  * @signature (a,b,c -> d) -> (a -> b -> c -> d)
137 137
  * @param  callable $fn
138
- * @return callable
138
+ * @return \Closure
139 139
  */
140 140
 function _curry_three($fn) {
141 141
     return function() use($fn) {
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
  * @param  callable $fn
191 191
  * @param  int $n
192 192
  * @param  array $given
193
- * @return callable
193
+ * @return \Closure
194 194
  */
195 195
 function _curry_n($fn, $n, $given = []) {
196 196
     return function() use($fn, $n, $given) {
Please login to merge, or discard this patch.
Braces   +39 added lines, -26 removed lines patch added patch discarded remove patch
@@ -119,25 +119,30 @@  discard block
 block discarded – undo
119 119
     return function() use($fn) {
120 120
         $args = func_get_args();
121 121
         $n = count($args);
122
-        while ($n > 0 && _is_placeholder($args[$n - 1]))
123
-            $n --;
124
-        if ($n == 0)
125
-            return _curry_two($fn);
122
+        while ($n > 0 && _is_placeholder($args[$n - 1])) {
123
+                    $n --;
124
+        }
125
+        if ($n == 0) {
126
+                    return _curry_two($fn);
127
+        }
126 128
         if ($n == 1) {
127 129
             $a = &$args[0];
128
-            if (_is_placeholder($a))
129
-                return _curry_two($fn);
130
+            if (_is_placeholder($a)) {
131
+                            return _curry_two($fn);
132
+            }
130 133
             return _curry_one(function($b) use($fn, &$a) {
131 134
                 return $fn($a, $b);
132 135
             });
133 136
         }
134 137
         $a = &$args[0];
135 138
         $b = &$args[1];
136
-        if (_is_placeholder($a) && _is_placeholder($b))
137
-            return _curry_two($fn);
138
-        if (_is_placeholder($a))
139
-            return _curry_one(function($_a) use($fn, &$b) {
139
+        if (_is_placeholder($a) && _is_placeholder($b)) {
140
+                    return _curry_two($fn);
141
+        }
142
+        if (_is_placeholder($a)) {
143
+                    return _curry_one(function($_a) use($fn, &$b) {
140 144
                 return $fn($_a, $b);
145
+        }
141 146
             });
142 147
         return $fn($args[0], $args[1]);
143 148
     };
@@ -168,10 +173,12 @@  discard block
 block discarded – undo
168 173
     return function() use($fn) {
169 174
         $args = func_get_args();
170 175
         $n = count($args);
171
-        while ($n > 0 && _is_placeholder($args[$n - 1]))
172
-            $n --;
173
-        if ($n == 0)
174
-            return _curry_three($fn);
176
+        while ($n > 0 && _is_placeholder($args[$n - 1])) {
177
+                    $n --;
178
+        }
179
+        if ($n == 0) {
180
+                    return _curry_three($fn);
181
+        }
175 182
         if ($n == 1) {
176 183
             $a = &$args[0];
177 184
             return _curry_two(function($b, $c) use($fn, &$a) {
@@ -181,9 +188,10 @@  discard block
 block discarded – undo
181 188
         if ($n == 2) {
182 189
             $a = &$args[0]; $b = &$args[1];
183 190
 
184
-            if (_is_placeholder($a))
185
-                return _curry_two(function($_a, $c) use($fn, &$b) {
191
+            if (_is_placeholder($a)) {
192
+                            return _curry_two(function($_a, $c) use($fn, &$b) {
186 193
                     return $fn($_a, $b, $c);
194
+            }
187 195
                 });
188 196
             return _curry_one(function($c) use($fn, &$a, &$b) {
189 197
                 return $fn($a, $b, $c);
@@ -192,17 +200,20 @@  discard block
 block discarded – undo
192 200
 
193 201
         $a = &$args[0]; $b = &$args[1]; $c = &$args[2];
194 202
 
195
-        if (_is_placeholder($a) && _is_placeholder($b))
196
-            return _curry_two(function($_a, $_b) use($fn, &$c) {
203
+        if (_is_placeholder($a) && _is_placeholder($b)) {
204
+                    return _curry_two(function($_a, $_b) use($fn, &$c) {
197 205
                 return $fn($_a, $_b, $c);
206
+        }
198 207
             });
199
-        if (_is_placeholder($a))
200
-            return _curry_one(function($_a) use($fn, &$b, &$c) {
208
+        if (_is_placeholder($a)) {
209
+                    return _curry_one(function($_a) use($fn, &$b, &$c) {
201 210
                 return $fn($_a, $b, $c);
211
+        }
202 212
             });
203
-        if (_is_placeholder($b))
204
-            return _curry_one(function($_b) use($fn, &$a, &$c) {
213
+        if (_is_placeholder($b)) {
214
+                    return _curry_one(function($_b) use($fn, &$a, &$c) {
205 215
                 return $fn($a, $_b, $c);
216
+        }
206 217
             });
207 218
 
208 219
         return $fn($a, $b, $c);
@@ -284,8 +295,9 @@  discard block
 block discarded – undo
284 295
             $merged->args[$mergedIndex] = $given[$givenIndex];
285 296
         }
286 297
 
287
-        if (_is_placeholder($merged->args[$mergedIndex]))
288
-            $merged->placeholders ++;
298
+        if (_is_placeholder($merged->args[$mergedIndex])) {
299
+                    $merged->placeholders ++;
300
+        }
289 301
 
290 302
         $givenIndex ++;
291 303
         $mergedIndex ++;
@@ -303,8 +315,9 @@  discard block
 block discarded – undo
303 315
     $argsCount = count($args);
304 316
     $fillersCount = count($fillers);
305 317
     while ($fillersIndex < $fillersCount) {
306
-        while (!_is_placeholder($args[$argsIndex]))
307
-            $argsIndex ++;
318
+        while (!_is_placeholder($args[$argsIndex])) {
319
+                    $argsIndex ++;
320
+        }
308 321
         $args[$argsIndex] = $fillers[$fillersIndex];
309 322
         $fillersIndex ++;
310 323
     }
Please login to merge, or discard this patch.
performance/scripts/functional.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-require __DIR__.'/../../vendor/autoload.php';
2
+require __DIR__ . '/../../vendor/autoload.php';
3 3
 
4 4
 use Tarsana\Functional as F;
5 5
 use Tarsana\Functional\Stream;
Please login to merge, or discard this patch.
performance/scripts/imperative.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
 
7 7
 $words = [];
8 8
 foreach ($text as $word => $occ) {
9
-    if (! isset($words[$occ])) {
9
+    if (!isset($words[$occ])) {
10 10
         $words[$occ] = [];
11 11
     }
12 12
     $words[$occ][] = $word;
Please login to merge, or discard this patch.
performance/scripts/object-oriented.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,9 @@
 block discarded – undo
103 103
     protected function getWordsHavingOccurrences($number) {
104 104
         $result = [];
105 105
         foreach ($this->list as $word) {
106
-            if ($word->occurrences() == $number)
107
-                $result[] = $word;
106
+            if ($word->occurrences() == $number) {
107
+                            $result[] = $word;
108
+            }
108 109
         }
109 110
         usort($result, function(Word $w1, Word $w2) {
110 111
             return strcmp($w1->value(), $w2->value());
Please login to merge, or discard this patch.