Completed
Pull Request — master (#6)
by
unknown
03:41 queued 01:28
created
src/Internal/_functions.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -314,11 +314,11 @@
 block discarded – undo
314 314
 }
315 315
 
316 316
 function _iterable_reduce(callable $reducer, $acc, \Iterator $iterator) {
317
-	$iterator->rewind();
318
-	while ($iterator->valid()) {
319
-		$acc = $reducer($acc, $iterator->current(), $iterator->key());
320
-		$iterator->next();
321
-	}
322
-	return $acc;
317
+    $iterator->rewind();
318
+    while ($iterator->valid()) {
319
+        $acc = $reducer($acc, $iterator->current(), $iterator->key());
320
+        $iterator->next();
321
+    }
322
+    return $acc;
323 323
 }
324 324
 
Please login to merge, or discard this patch.
src/Internal/_IteratorAdapter.php 1 patch
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -13,66 +13,66 @@
 block discarded – undo
13 13
  */
14 14
 class _IteratorAdapter implements \Iterator
15 15
 {
16
-	private $objectStorage;
16
+    private $objectStorage;
17 17
 
18
-	public function __construct(\SplObjectStorage $theObjectStorage)
19
-	{
20
-		$this->objectStorage = $theObjectStorage;
21
-	}
18
+    public function __construct(\SplObjectStorage $theObjectStorage)
19
+    {
20
+        $this->objectStorage = $theObjectStorage;
21
+    }
22 22
 
23
-	/**
24
-	 * Return the current element
25
-	 * @link http://php.net/manual/en/iterator.current.php
26
-	 * @return mixed Can return any type.
27
-	 * @since 5.0.0
28
-	 */
29
-	public function current()
30
-	{
31
-		return $this->objectStorage->getInfo();
32
-	}
23
+    /**
24
+     * Return the current element
25
+     * @link http://php.net/manual/en/iterator.current.php
26
+     * @return mixed Can return any type.
27
+     * @since 5.0.0
28
+     */
29
+    public function current()
30
+    {
31
+        return $this->objectStorage->getInfo();
32
+    }
33 33
 
34
-	/**
35
-	 * Move forward to next element
36
-	 * @link http://php.net/manual/en/iterator.next.php
37
-	 * @return void Any returned value is ignored.
38
-	 * @since 5.0.0
39
-	 */
40
-	public function next()
41
-	{
42
-		return $this->objectStorage->next();
43
-	}
34
+    /**
35
+     * Move forward to next element
36
+     * @link http://php.net/manual/en/iterator.next.php
37
+     * @return void Any returned value is ignored.
38
+     * @since 5.0.0
39
+     */
40
+    public function next()
41
+    {
42
+        return $this->objectStorage->next();
43
+    }
44 44
 
45
-	/**
46
-	 * Return the key of the current element
47
-	 * @link http://php.net/manual/en/iterator.key.php
48
-	 * @return mixed scalar on success, or null on failure.
49
-	 * @since 5.0.0
50
-	 */
51
-	public function key()
52
-	{
53
-		return $this->objectStorage->current();
54
-	}
45
+    /**
46
+     * Return the key of the current element
47
+     * @link http://php.net/manual/en/iterator.key.php
48
+     * @return mixed scalar on success, or null on failure.
49
+     * @since 5.0.0
50
+     */
51
+    public function key()
52
+    {
53
+        return $this->objectStorage->current();
54
+    }
55 55
 
56
-	/**
57
-	 * Checks if current position is valid
58
-	 * @link http://php.net/manual/en/iterator.valid.php
59
-	 * @return boolean The return value will be casted to boolean and then evaluated.
60
-	 * Returns true on success or false on failure.
61
-	 * @since 5.0.0
62
-	 */
63
-	public function valid()
64
-	{
65
-		return $this->objectStorage->valid();
66
-	}
56
+    /**
57
+     * Checks if current position is valid
58
+     * @link http://php.net/manual/en/iterator.valid.php
59
+     * @return boolean The return value will be casted to boolean and then evaluated.
60
+     * Returns true on success or false on failure.
61
+     * @since 5.0.0
62
+     */
63
+    public function valid()
64
+    {
65
+        return $this->objectStorage->valid();
66
+    }
67 67
 
68
-	/**
69
-	 * Rewind the Iterator to the first element
70
-	 * @link http://php.net/manual/en/iterator.rewind.php
71
-	 * @return void Any returned value is ignored.
72
-	 * @since 5.0.0
73
-	 */
74
-	public function rewind()
75
-	{
76
-		return $this->objectStorage->rewind();
77
-	}
68
+    /**
69
+     * Rewind the Iterator to the first element
70
+     * @link http://php.net/manual/en/iterator.rewind.php
71
+     * @return void Any returned value is ignored.
72
+     * @since 5.0.0
73
+     */
74
+    public function rewind()
75
+    {
76
+        return $this->objectStorage->rewind();
77
+    }
78 78
 }
79 79
\ No newline at end of file
Please login to merge, or discard this patch.
src/list.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -73,35 +73,35 @@  discard block
 block discarded – undo
73 73
 function filter() {
74 74
     static $filter = false;
75 75
     $filter = $filter ?: curry(function(callable $fn, $list) {
76
-    	$isArray = is_array($list);
77
-    	$isObjectStorage = $list instanceof \SplObjectStorage;
76
+        $isArray = is_array($list);
77
+        $isObjectStorage = $list instanceof \SplObjectStorage;
78 78
 
79
-    	$result = $isArray ? []
80
-		    : ($isObjectStorage ? new \SplObjectStorage()
81
-			    : new \ArrayObject());
79
+        $result = $isArray ? []
80
+            : ($isObjectStorage ? new \SplObjectStorage()
81
+                : new \ArrayObject());
82 82
 
83
-    	if ($isArray)
84
-	    {
85
-	    	foreach ($list as $item) {
86
-	            if ($fn($item))
87
-	                $result[] = $item;
88
-	        }
89
-	        return $result;
90
-	    }
83
+        if ($isArray)
84
+        {
85
+            foreach ($list as $item) {
86
+                if ($fn($item))
87
+                    $result[] = $item;
88
+            }
89
+            return $result;
90
+        }
91 91
 
92
-    	return _iterable_reduce(
93
-    		_make_filterer($isObjectStorage ?
94
-			    function(\ArrayAccess $xs, $value) {
95
-	                $xs->offsetSet($value);
96
-		        } :
97
-			    function(\ArrayObject $xs, $value) {
98
-	                $xs->append($value);
99
-			    },
100
-		        $fn
101
-		    ),
102
-		    $result,
103
-			    $isObjectStorage ? $list : $list->getIterator()
104
-	    );
92
+        return _iterable_reduce(
93
+            _make_filterer($isObjectStorage ?
94
+                function(\ArrayAccess $xs, $value) {
95
+                    $xs->offsetSet($value);
96
+                } :
97
+                function(\ArrayObject $xs, $value) {
98
+                    $xs->append($value);
99
+                },
100
+                $fn
101
+            ),
102
+            $result,
103
+                $isObjectStorage ? $list : $list->getIterator()
104
+        );
105 105
     });
106 106
     return _apply($filter, func_get_args());
107 107
 }
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
  * @return \Closure
114 114
  */
115 115
 function _make_filterer (callable $append, callable $predicate) {
116
-	return function ($acc, ...$entry) use ($append, $predicate) {
117
-		if ($predicate($entry[0])) {
118
-			$append($acc, ...$entry);
119
-		}
120
-		return $acc;
121
-	};
116
+    return function ($acc, ...$entry) use ($append, $predicate) {
117
+        if ($predicate($entry[0])) {
118
+            $append($acc, ...$entry);
119
+        }
120
+        return $acc;
121
+    };
122 122
 }
123 123
 
124 124
 /**
@@ -155,30 +155,30 @@  discard block
 block discarded – undo
155 155
  * @return array|\ArrayObject|\SplObjectStorage|callable
156 156
  */
157 157
 function filter_values() {
158
-	static $filter_values = false;
158
+    static $filter_values = false;
159 159
     $filter_values = $filter_values ?: curry(function(callable $predicate, $list) {
160
-    	$isArray = is_array($list);
161
-    	$isObjectStorage = $list instanceof \SplObjectStorage;
160
+        $isArray = is_array($list);
161
+        $isObjectStorage = $list instanceof \SplObjectStorage;
162 162
 
163
-	    $result = $isArray ? []
164
-		    : ($isObjectStorage ? new \SplObjectStorage()
165
-			    : new \ArrayObject());
163
+        $result = $isArray ? []
164
+            : ($isObjectStorage ? new \SplObjectStorage()
165
+                : new \ArrayObject());
166 166
 
167
-    	return _iterable_reduce(
168
-    		_make_filterer($isArray ?
169
-			    function(array &$xs, $value, $key) {
170
-	                $xs[$key] = $value;
171
-		        } :
172
-			    function(\ArrayAccess $xs, $value, $key) {
173
-	                $xs->offsetSet($key, $value);
174
-			    },
175
-		        $predicate
176
-		    ),
177
-		    $result,
178
-		    $isArray ? new \ArrayIterator($list)
179
-			    : ($isObjectStorage ? new _IteratorAdapter($list)
180
-			    : $list->getIterator())
181
-	    );
167
+        return _iterable_reduce(
168
+            _make_filterer($isArray ?
169
+                function(array &$xs, $value, $key) {
170
+                    $xs[$key] = $value;
171
+                } :
172
+                function(\ArrayAccess $xs, $value, $key) {
173
+                    $xs->offsetSet($key, $value);
174
+                },
175
+                $predicate
176
+            ),
177
+            $result,
178
+            $isArray ? new \ArrayIterator($list)
179
+                : ($isObjectStorage ? new _IteratorAdapter($list)
180
+                : $list->getIterator())
181
+        );
182 182
     });
183 183
     return _apply($filter_values, func_get_args());
184 184
 }
Please login to merge, or discard this patch.
Doc Comments   -82 removed lines patch added patch discarded remove patch
@@ -15,8 +15,6 @@  discard block
 block discarded – undo
15 15
  * @stream
16 16
  * @signature (a -> b) -> [a] -> [b]
17 17
  * @signature (a -> b) -> {k: a} -> {k: b}
18
- * @param  callable $fn
19
- * @param  array $list
20 18
  * @return array
21 19
  */
22 20
 function map() {
@@ -36,8 +34,6 @@  discard block
 block discarded – undo
36 34
  *
37 35
  * @stream
38 36
  * @signature (a -> [b]) -> [a] -> [b]
39
- * @param  callable $fn
40
- * @param  array $list
41 37
  * @return array
42 38
  */
43 39
 function chain() {
@@ -66,8 +62,6 @@  discard block
 block discarded – undo
66 62
  * ```
67 63
  * @stream
68 64
  * @signature (a -> Boolean) -> [a] -> [a]
69
- * @param  callable $fn
70
- * @param  array|\ArrayObject|\SplObjectStorage $list
71 65
  * @return array|\ArrayObject|\SplObjectStorage|callable
72 66
  */
73 67
 function filter() {
@@ -150,8 +144,6 @@  discard block
 block discarded – undo
150 144
  * ```
151 145
  *
152 146
  * @signature (a -> Boolean) -> {k: a} -> {k: a}
153
- * @param callable $predicate
154
- * @param array|\ArrayObject|\SplObjectStorage $list
155 147
  * @return array|\ArrayObject|\SplObjectStorage|callable
156 148
  */
157 149
 function filter_values() {
@@ -195,9 +187,6 @@  discard block
 block discarded – undo
195 187
  *
196 188
  * @stream
197 189
  * @signature (* -> a -> *) -> * -> [a] -> *
198
- * @param  callable $fn
199
- * @param  mixed $initial
200
- * @param  array $list
201 190
  * @return array
202 191
  */
203 192
 function reduce() {
@@ -223,8 +212,6 @@  discard block
 block discarded – undo
223 212
  *
224 213
  * @stream
225 214
  * @signature (a -> *) -> [a] -> [a]
226
- * @param  callable $fn
227
- * @param  array $list
228 215
  * @return array
229 216
  */
230 217
 function each() {
@@ -251,7 +238,6 @@  discard block
 block discarded – undo
251 238
  * @stream
252 239
  * @signature [a] -> a
253 240
  * @signature String -> String
254
- * @param  array|string $list
255 241
  * @return mixed
256 242
  */
257 243
 function head() {
@@ -276,7 +262,6 @@  discard block
 block discarded – undo
276 262
  * @stream
277 263
  * @signature [a] -> a
278 264
  * @signature String -> String
279
- * @param  array|string $list
280 265
  * @return mixed
281 266
  */
282 267
 function last () {
@@ -306,7 +291,6 @@  discard block
 block discarded – undo
306 291
  * @stream
307 292
  * @signature [a] -> a
308 293
  * @signature String -> String
309
- * @param  array|string $list
310 294
  * @return array
311 295
  */
312 296
 function init () {
@@ -340,7 +324,6 @@  discard block
 block discarded – undo
340 324
  * @stream
341 325
  * @signature [a] -> a
342 326
  * @signature String -> String
343
- * @param  array|string $list
344 327
  * @return array
345 328
  */
346 329
 function tail () {
@@ -368,7 +351,6 @@  discard block
 block discarded – undo
368 351
  * @stream
369 352
  * @signature [a] -> [a]
370 353
  * @signature String -> String
371
- * @param  array|string $list
372 354
  * @return array
373 355
  */
374 356
 function reverse () {
@@ -392,7 +374,6 @@  discard block
 block discarded – undo
392 374
  * @stream
393 375
  * @signature [a] -> Number
394 376
  * @signature String -> Number
395
- * @param  array|string $list
396 377
  * @return int
397 378
  */
398 379
 function length() {
@@ -416,8 +397,6 @@  discard block
 block discarded – undo
416 397
  *
417 398
  * @stream
418 399
  * @signature (a -> Boolean) -> [a] -> Boolean
419
- * @param  callable $predicate
420
- * @param  array $list
421 400
  * @return bool
422 401
  */
423 402
 function allSatisfies() {
@@ -443,8 +422,6 @@  discard block
 block discarded – undo
443 422
  *
444 423
  * @stream
445 424
  * @signature (a -> Boolean) -> [a] -> Boolean
446
- * @param  callable $predicate
447
- * @param  array $list
448 425
  * @return bool
449 426
  */
450 427
 function anySatisfies() {
@@ -470,8 +447,6 @@  discard block
 block discarded – undo
470 447
  * @stream
471 448
  * @signature [*] -> [*] -> [*]
472 449
  * @signature String -> String -> String
473
- * @param  array $list1
474
- * @param  array $list2
475 450
  * @return array
476 451
  */
477 452
 function concat() {
@@ -494,7 +469,6 @@  discard block
 block discarded – undo
494 469
  *
495 470
  * @stream
496 471
  * @signature [[a]] -> [a]
497
- * @param  array $lists
498 472
  * @return array
499 473
  */
500 474
 function concatAll() {
@@ -529,9 +503,6 @@  discard block
 block discarded – undo
529 503
  * @stream
530 504
  * @signature Number -> a -> [a] -> [a]
531 505
  * @signature Number -> String -> String -> String
532
- * @param  int $position
533
- * @param  mixed $item
534
- * @param  array $list
535 506
  * @return array
536 507
  */
537 508
 function insert() {
@@ -559,9 +530,6 @@  discard block
 block discarded – undo
559 530
  * @stream
560 531
  * @signature Number -> [a] -> [a] -> [a]
561 532
  * @signature Number -> String -> String -> String
562
- * @param  int $position
563
- * @param  mixed $items
564
- * @param  array $list
565 533
  * @return array
566 534
  */
567 535
 function insertAll() {
@@ -594,8 +562,6 @@  discard block
 block discarded – undo
594 562
  * @stream
595 563
  * @signature * -> [*] -> [*]
596 564
  * @signature String -> String -> String
597
- * @param  mixed $item
598
- * @param  array $list
599 565
  * @return array
600 566
  */
601 567
 function append() {
@@ -620,8 +586,6 @@  discard block
 block discarded – undo
620 586
  * @stream
621 587
  * @signature a -> [a] -> [a]
622 588
  * @signature String -> String -> String
623
- * @param  mixed $item
624
- * @param  array $list
625 589
  * @return array
626 590
  */
627 591
 function prepend() {
@@ -651,8 +615,6 @@  discard block
 block discarded – undo
651 615
  * @stream
652 616
  * @signature Number -> [a] -> [a]
653 617
  * @signature Number -> String -> String
654
- * @param  int $count
655
- * @param  array $list
656 618
  * @return array
657 619
  */
658 620
 function take() {
@@ -685,8 +647,6 @@  discard block
 block discarded – undo
685 647
  *
686 648
  * @stream
687 649
  * @signature (a -> Boolean) -> [a] -> [a]
688
- * @param  callable $predicate
689
- * @param  array $list
690 650
  * @return array
691 651
  */
692 652
 function takeWhile() {
@@ -712,8 +672,6 @@  discard block
 block discarded – undo
712 672
  *
713 673
  * @stream
714 674
  * @signature (a -> Boolean) -> [a] -> [a]
715
- * @param  callable $predicate
716
- * @param  array $list
717 675
  * @return array
718 676
  */
719 677
 function takeLastWhile() {
@@ -739,8 +697,6 @@  discard block
 block discarded – undo
739 697
  *
740 698
  * @stream
741 699
  * @signature (a -> Boolean) -> [a] -> [a]
742
- * @param  callable $predicate
743
- * @param  array $list
744 700
  * @return array
745 701
  */
746 702
 function takeUntil() {
@@ -766,8 +722,6 @@  discard block
 block discarded – undo
766 722
  *
767 723
  * @stream
768 724
  * @signature (a -> Boolean) -> [a] -> [a]
769
- * @param  callable $predicate
770
- * @param  array $list
771 725
  * @return array
772 726
  */
773 727
 function takeLastUntil() {
@@ -798,8 +752,6 @@  discard block
 block discarded – undo
798 752
  * @stream
799 753
  * @signature Number -> [a] -> [a]
800 754
  * @signature Number -> String -> String
801
- * @param  int $count
802
- * @param  array $list
803 755
  * @return array
804 756
  */
805 757
 function remove() {
@@ -836,8 +788,6 @@  discard block
 block discarded – undo
836 788
  *
837 789
  * @stream
838 790
  * @signature (a -> Boolean) -> [a] -> [a]
839
- * @param  callable $predicate
840
- * @param  array $list
841 791
  * @return array
842 792
  */
843 793
 function removeWhile() {
@@ -863,8 +813,6 @@  discard block
 block discarded – undo
863 813
  *
864 814
  * @stream
865 815
  * @signature (a -> Boolean) -> [a] -> [a]
866
- * @param  callable $predicate
867
- * @param  array $list
868 816
  * @return array
869 817
  */
870 818
 function removeLastWhile() {
@@ -891,8 +839,6 @@  discard block
 block discarded – undo
891 839
  *
892 840
  * @stream
893 841
  * @signature (a -> Boolean) -> [a] -> [a]
894
- * @param  callable $predicate
895
- * @param  array $list
896 842
  * @return array
897 843
  */
898 844
 function removeUntil() {
@@ -919,8 +865,6 @@  discard block
 block discarded – undo
919 865
  *
920 866
  * @stream
921 867
  * @signature (a -> Boolean) -> [a] -> [a]
922
- * @param  callable $predicate
923
- * @param  array $list
924 868
  * @return array
925 869
  */
926 870
 function removeLastUntil() {
@@ -943,7 +887,6 @@  discard block
 block discarded – undo
943 887
  *
944 888
  * @stream
945 889
  * @signature [(k, v)] -> {k: v}
946
- * @param  array $pairs
947 890
  * @return stdClass
948 891
  */
949 892
 function fromPairs() {
@@ -973,8 +916,6 @@  discard block
 block discarded – undo
973 916
  * @stream
974 917
  * @signature Number -> [a] -> [[a]]
975 918
  * @signature Number -> String -> [String]
976
- * @param  int $size
977
- * @param  array $list
978 919
  * @return array
979 920
  */
980 921
 function slices() {
@@ -1008,8 +949,6 @@  discard block
 block discarded – undo
1008 949
  * @stream
1009 950
  * @signature a -> [a] -> Boolean
1010 951
  * @signature String -> String -> Boolean
1011
- * @param  mixed $item
1012
- * @param  array|string $list
1013 952
  * @return bool
1014 953
  */
1015 954
 function contains() {
@@ -1035,8 +974,6 @@  discard block
 block discarded – undo
1035 974
  * @stream
1036 975
  * @signature (a -> Boolean) -> [a] -> Maybe(Number)
1037 976
  * @signature (v -> Boolean) -> {k: v} -> Maybe(k)
1038
- * @param  callable $predicate
1039
- * @param  array $list
1040 977
  * @return mixed
1041 978
  */
1042 979
 function findIndex() {
@@ -1064,8 +1001,6 @@  discard block
 block discarded – undo
1064 1001
  * @stream
1065 1002
  * @signature (a -> Boolean) -> [a] -> Maybe(Number)
1066 1003
  * @signature (v -> Boolean) -> {k: v} -> Maybe(k)
1067
- * @param  callable $predicate
1068
- * @param  array $list
1069 1004
  * @return mixed
1070 1005
  */
1071 1006
 function findLastIndex() {
@@ -1094,8 +1029,6 @@  discard block
 block discarded – undo
1094 1029
  *
1095 1030
  * @stream
1096 1031
  * @signature (a -> Boolean) -> [a] -> Maybe(a)
1097
- * @param  callable $predicate
1098
- * @param  array $list
1099 1032
  * @return mixed
1100 1033
  */
1101 1034
 function find() {
@@ -1121,8 +1054,6 @@  discard block
 block discarded – undo
1121 1054
  *
1122 1055
  * @stream
1123 1056
  * @signature (a -> Boolean) -> [a] -> Maybe(a)
1124
- * @param  callable $predicate
1125
- * @param  array $list
1126 1057
  * @return mixed
1127 1058
  */
1128 1059
 function findLast() {
@@ -1160,8 +1091,6 @@  discard block
 block discarded – undo
1160 1091
  * @signature a -> [a] -> Number
1161 1092
  * @signature v -> {k: v} -> Maybe(k)
1162 1093
  * @signature String -> String -> Number
1163
- * @param  mixed $item
1164
- * @param  array $list
1165 1094
  * @return int
1166 1095
  */
1167 1096
 function indexOf() {
@@ -1200,8 +1129,6 @@  discard block
 block discarded – undo
1200 1129
  * @signature a -> [a] -> Number
1201 1130
  * @signature v -> {k: v} -> Maybe(k)
1202 1131
  * @signature String -> String -> Number
1203
- * @param  mixed $item
1204
- * @param  array $list
1205 1132
  * @return int
1206 1133
  */
1207 1134
 function lastIndexOf() {
@@ -1235,8 +1162,6 @@  discard block
 block discarded – undo
1235 1162
  *
1236 1163
  * @stream
1237 1164
  * @signature (a -> a -> Boolean) -> [a] -> [a]
1238
- * @param  callable $areEqual
1239
- * @param  array $list
1240 1165
  * @return array
1241 1166
  */
1242 1167
 function uniqueBy() {
@@ -1273,7 +1198,6 @@  discard block
 block discarded – undo
1273 1198
  *
1274 1199
  * @stream
1275 1200
  * @signature [a] -> [a]
1276
- * @param  array $list
1277 1201
  * @return array
1278 1202
  */
1279 1203
 function unique() {
@@ -1306,8 +1230,6 @@  discard block
 block discarded – undo
1306 1230
  *
1307 1231
  * @stream
1308 1232
  * @signature (a -> String) -> [a] -> {String: a}
1309
- * @param  callable $fn
1310
- * @param  array $list
1311 1233
  * @return array
1312 1234
  */
1313 1235
 function groupBy() {
@@ -1337,8 +1259,6 @@  discard block
 block discarded – undo
1337 1259
  *
1338 1260
  * @stream
1339 1261
  * @signature [a] -> [b] -> [[a,b]]
1340
- * @param  array $list1
1341
- * @param  array $list2
1342 1262
  * @return array
1343 1263
  */
1344 1264
 function pairsFrom() {
@@ -1383,8 +1303,6 @@  discard block
 block discarded – undo
1383 1303
  *
1384 1304
  * @stream
1385 1305
  * @signature (a -> a -> Boolean) -> [a] -> [a]
1386
- * @param  callable $compare
1387
- * @param  array $list
1388 1306
  * @return array
1389 1307
  */
1390 1308
 function sort() {
Please login to merge, or discard this patch.