@@ -17,9 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * Make an iterator that applies $strategy to every entry in this iterable |
19 | 19 | * |
20 | - * @param null|string|\Closure $strategy |
|
21 | - * @param array|string|\Iterator $iterable |
|
22 | - * @param array|string|\Iterator $iterable2 |
|
20 | + * @param \Closure $strategy |
|
23 | 21 | * @return Itertools\lib\MapIterator |
24 | 22 | * |
25 | 23 | * @see Itertools\lib\Traits\MapTrait::map |
@@ -17,8 +17,6 @@ |
||
17 | 17 | /** |
18 | 18 | * Returns an iterator where one or more iterables are zipped together |
19 | 19 | * |
20 | - * @param array|string|\Iterator $iterable |
|
21 | - * @param array|string|\Iterator $iterable2 |
|
22 | 20 | * @return Itertools\lib\ZipIterator |
23 | 21 | * |
24 | 22 | * @see Itertools\lib\Traits\ZipTrait::zip |
@@ -36,8 +36,6 @@ |
||
36 | 36 | * 2.5 3.5 4.5 |
37 | 37 | * |
38 | 38 | * @param null|string|\Closure $strategy |
39 | - * @param array|string|\Iterator $iterable |
|
40 | - * @param array|string|\Iterator $iterable2 |
|
41 | 39 | * @return MapIterator |
42 | 40 | */ |
43 | 41 | public function map($strategy /*, $iterable, $iterable2, ... */) |
@@ -23,8 +23,6 @@ |
||
23 | 23 | * > zip([1, 2, 3], ['a', 'b', 'c']) |
24 | 24 | * [1, 'a'] [2, 'b'] [3, 'c'] |
25 | 25 | * |
26 | - * @param array|string|\Iterator $iterable |
|
27 | - * @param array|string|\Iterator $iterable2 |
|
28 | 26 | * @return ZipIterator |
29 | 27 | */ |
30 | 28 | public function zip(/* $iterable, $iterable2, ... */) |
@@ -17,7 +17,7 @@ |
||
17 | 17 | |
18 | 18 | public function __construct() |
19 | 19 | { |
20 | - parent::__construct(\MultipleIterator::MIT_NEED_ALL | \MultipleIterator::MIT_KEYS_NUMERIC); |
|
20 | + parent::__construct(\MultipleIterator::MIT_NEED_ALL|\MultipleIterator::MIT_KEYS_NUMERIC); |
|
21 | 21 | foreach (func_get_args() as $iterable) { |
22 | 22 | if (!$iterable instanceof \Iterator) { |
23 | 23 | throw new \InvalidArgumentException(sprintf('Not all arguments are iterators')); |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | function lstrip($chars = " \t\n\r\0\x0B") |
17 | 17 | { |
18 | - return function ($value) use ($chars) { |
|
18 | + return function($value) use ($chars) { |
|
19 | 19 | return ltrim($value, $chars); |
20 | 20 | }; |
21 | 21 | } |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | */ |
29 | 29 | function rstrip($chars = " \t\n\r\0\x0B") |
30 | 30 | { |
31 | - return function ($value) use ($chars) { |
|
31 | + return function($value) use ($chars) { |
|
32 | 32 | return rtrim($value, $chars); |
33 | 33 | }; |
34 | 34 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function strip($chars = " \t\n\r\0\x0B") |
43 | 43 | { |
44 | - return function ($value) use ($chars) { |
|
44 | + return function($value) use ($chars) { |
|
45 | 45 | return trim($value, $chars); |
46 | 46 | }; |
47 | 47 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | */ |
54 | 54 | function length() |
55 | 55 | { |
56 | - return function ($value) { |
|
56 | + return function($value) { |
|
57 | 57 | if (is_null($value)) { |
58 | 58 | return 0; |
59 | 59 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | function key() |
75 | 75 | { |
76 | - return function ($value, $key) { |
|
76 | + return function($value, $key) { |
|
77 | 77 | return $key; |
78 | 78 | }; |
79 | 79 | } |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function lower() |
87 | 87 | { |
88 | - return function ($value) { |
|
88 | + return function($value) { |
|
89 | 89 | return strtolower($value); |
90 | 90 | }; |
91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | function upper() |
99 | 99 | { |
100 | - return function ($value) { |
|
100 | + return function($value) { |
|
101 | 101 | return strtoupper($value); |
102 | 102 | }; |
103 | 103 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | */ |
110 | 110 | function string() |
111 | 111 | { |
112 | - return function ($value) { |
|
112 | + return function($value) { |
|
113 | 113 | return (string)$value; |
114 | 114 | }; |
115 | 115 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | */ |
124 | 124 | function json_encode($options = 0, $depth = 512) |
125 | 125 | { |
126 | - return function ($value) use ($options, $depth) { |
|
126 | + return function($value) use ($options, $depth) { |
|
127 | 127 | return \json_encode($value, $options, $depth); |
128 | 128 | }; |
129 | 129 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | */ |
139 | 139 | function json_decode($assoc = false, $depth = 512, $options = 0) |
140 | 140 | { |
141 | - return function ($value) use ($assoc, $depth, $options) { |
|
141 | + return function($value) use ($assoc, $depth, $options) { |
|
142 | 142 | return \json_decode($value, $assoc, $depth, $options); |
143 | 143 | }; |
144 | 144 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $mappings = array_map('\Zicht\Itertools\conversions\mixed_to_value_getter', (array)$mappings); |
180 | 180 | $strategy = conversions\mixed_to_value_getter($strategy); |
181 | 181 | |
182 | - return function ($value, $key) use ($mappings, $strategy, $discardNull, $discardEmptyContainer, $castToObject) { |
|
182 | + return function($value, $key) use ($mappings, $strategy, $discardNull, $discardEmptyContainer, $castToObject) { |
|
183 | 183 | $value = $strategy($value); |
184 | 184 | $res = []; |
185 | 185 | foreach ($mappings as $strategyKey => $strategy) { |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | if ($discardNull || $discardEmptyContainer) { |
189 | 189 | $res = array_filter( |
190 | 190 | $res, |
191 | - function ($value) use ($discardNull, $discardEmptyContainer) { |
|
191 | + function($value) use ($discardNull, $discardEmptyContainer) { |
|
192 | 192 | if (null === $value) { |
193 | 193 | return !$discardNull; |
194 | 194 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | $max = getrandmax(); |
219 | 219 | } |
220 | 220 | |
221 | - return function () use ($min, $max) { |
|
221 | + return function() use ($min, $max) { |
|
222 | 222 | return rand($min, $max); |
223 | 223 | }; |
224 | 224 | } |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | function type($strategy = null) |
233 | 233 | { |
234 | 234 | $strategy = conversions\mixed_to_value_getter($strategy); |
235 | - return function ($value) use ($strategy) { |
|
235 | + return function($value) use ($strategy) { |
|
236 | 236 | $value = $strategy($value); |
237 | 237 | return is_object($value) ? get_class($value) : gettype($value); |
238 | 238 | }; |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | $mapping = conversions\mixed_to_value_getter($mapping); |
262 | 262 | $strategy = conversions\mixed_to_value_getter($strategy); |
263 | 263 | $cache = []; |
264 | - return function ($value, $key = null) use ($mapping, $strategy, &$cache) { |
|
264 | + return function($value, $key = null) use ($mapping, $strategy, &$cache) { |
|
265 | 265 | $cacheKey = \json_encode($strategy($value, $key)); |
266 | 266 | if (!array_key_exists($cacheKey, $cache)) { |
267 | 267 | $cache[$cacheKey] = $mapping($value, $key); |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | function type($class, $strategy = null) |
32 | 32 | { |
33 | 33 | $strategy = conversions\mixed_to_value_getter($strategy); |
34 | - return function ($value, $key = null) use ($class, $strategy) { |
|
34 | + return function($value, $key = null) use ($class, $strategy) { |
|
35 | 35 | return $strategy($value, $key) instanceof $class; |
36 | 36 | }; |
37 | 37 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $haystack = Itertools\iterable($haystack)->values(); |
66 | 66 | } |
67 | 67 | $strategy = conversions\mixed_to_value_getter($strategy); |
68 | - return function ($value, $key = null) use ($haystack, $strategy, $strict) { |
|
68 | + return function($value, $key = null) use ($haystack, $strategy, $strict) { |
|
69 | 69 | return in_array($strategy($value, $key), $haystack, $strict); |
70 | 70 | }; |
71 | 71 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $haystack = Itertools\iterable($haystack)->values(); |
90 | 90 | } |
91 | 91 | $strategy = conversions\mixed_to_value_getter($strategy); |
92 | - return function ($value, $key = null) use ($haystack, $strategy, $strict) { |
|
92 | + return function($value, $key = null) use ($haystack, $strategy, $strict) { |
|
93 | 93 | return !in_array($strategy($value, $key), $haystack, $strict); |
94 | 94 | }; |
95 | 95 | } |
@@ -121,11 +121,11 @@ discard block |
||
121 | 121 | } |
122 | 122 | $strategy = conversions\mixed_to_value_getter($strategy); |
123 | 123 | if ($strict) { |
124 | - return function ($value, $key = null) use ($expected, $strategy) { |
|
124 | + return function($value, $key = null) use ($expected, $strategy) { |
|
125 | 125 | return $expected === $strategy($value, $key); |
126 | 126 | }; |
127 | 127 | } else { |
128 | - return function ($value, $key = null) use ($expected, $strategy) { |
|
128 | + return function($value, $key = null) use ($expected, $strategy) { |
|
129 | 129 | return $expected == $strategy($value, $key); |
130 | 130 | }; |
131 | 131 | } |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | // Support DateTimeInterface |
153 | 153 | if ($expected instanceof \DateTimeInterface) { |
154 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
154 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
155 | 155 | $value = $strategy($value, $key); |
156 | 156 | // Try to convert strings that look like ISO date format |
157 | 157 | if (is_string($value) && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | |
167 | 167 | // Support numbers |
168 | 168 | if (is_int($expected) || is_float($expected)) { |
169 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
169 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
170 | 170 | $value = $strategy($value, $key); |
171 | 171 | return (is_int($value) || is_float($value)) && ($orEqual ? $expected <= $value : $expected < $value); |
172 | 172 | }; |
173 | 173 | } |
174 | 174 | |
175 | 175 | // Everything else fails |
176 | - return function () { |
|
176 | + return function() { |
|
177 | 177 | return false; |
178 | 178 | }; |
179 | 179 | } |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | |
199 | 199 | // Support DateTimeInterface |
200 | 200 | if ($expected instanceof \DateTimeInterface) { |
201 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
201 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
202 | 202 | $value = $strategy($value, $key); |
203 | 203 | // Try to convert strings that look like ISO date format |
204 | 204 | if (is_string($value) && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
@@ -213,14 +213,14 @@ discard block |
||
213 | 213 | |
214 | 214 | // Support numbers |
215 | 215 | if (is_int($expected) || is_float($expected)) { |
216 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
216 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
217 | 217 | $value = $strategy($value, $key); |
218 | 218 | return (is_int($value) || is_float($value)) && ($orEqual ? $expected >= $value : $expected > $value); |
219 | 219 | }; |
220 | 220 | } |
221 | 221 | |
222 | 222 | // Everything else fails |
223 | - return function () { |
|
223 | + return function() { |
|
224 | 224 | return false; |
225 | 225 | }; |
226 | 226 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | function not($strategy = null) |
241 | 241 | { |
242 | 242 | $strategy = conversions\mixed_to_value_getter($strategy); |
243 | - return function ($value, $key = null) use ($strategy) { |
|
243 | + return function($value, $key = null) use ($strategy) { |
|
244 | 244 | return !($strategy($value, $key)); |
245 | 245 | }; |
246 | 246 | } |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | } |
266 | 266 | |
267 | 267 | $strategy = conversions\mixed_to_value_getter($strategy); |
268 | - return function ($value, $key = null) use ($pattern, $strategy) { |
|
268 | + return function($value, $key = null) use ($pattern, $strategy) { |
|
269 | 269 | return (bool)preg_match($pattern, $strategy($value, $key)); |
270 | 270 | }; |
271 | 271 | } |