@@ -221,8 +221,8 @@ |
||
221 | 221 | * > count(2.5, 0.5) |
222 | 222 | * 2.5 3.0 3.5 4.0 ... |
223 | 223 | * |
224 | - * @param int|float $start |
|
225 | - * @param int|float $step |
|
224 | + * @param integer $start |
|
225 | + * @param integer $step |
|
226 | 226 | * @return CountIterator |
227 | 227 | * @deprecated Use new CountIterator($start, $step), will be removed in version 3.0 |
228 | 228 | */ |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | switch (sizeof($args)) { |
603 | 603 | case 2: |
604 | 604 | $strategy = Conversions::mixedToValueGetter($args[0]); |
605 | - $closure = function ($value, $key) use ($strategy) { |
|
605 | + $closure = function($value, $key) use ($strategy) { |
|
606 | 606 | $tempVarPhp54 = call_user_func($strategy, $value, $key); |
607 | 607 | return !empty($tempVarPhp54); |
608 | 608 | }; |
@@ -612,7 +612,7 @@ discard block |
||
612 | 612 | case 3: |
613 | 613 | $strategy = Conversions::mixedToValueGetter($args[0]); |
614 | 614 | $userClosure = $args[1]; |
615 | - $closure = function ($value, $key) use ($strategy, $userClosure) { |
|
615 | + $closure = function($value, $key) use ($strategy, $userClosure) { |
|
616 | 616 | return call_user_func($userClosure, call_user_func($strategy, $value, $key)); |
617 | 617 | }; |
618 | 618 | $iterable = Conversions::mixedToIterator($args[2]); |
@@ -79,7 +79,7 @@ |
||
79 | 79 | $haystack = Itertools\iterable($haystack)->values(); |
80 | 80 | } |
81 | 81 | $strategy = conversions\mixed_to_value_getter($strategy); |
82 | - return function ($value, $key = null) use ($haystack, $strategy, $strict) { |
|
82 | + return function($value, $key = null) use ($haystack, $strategy, $strict) { |
|
83 | 83 | return !in_array($strategy($value, $key), $haystack, $strict); |
84 | 84 | }; |
85 | 85 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public static 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 | public static 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 | public static 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 | public static function length() |
55 | 55 | { |
56 | - return function ($value) { |
|
56 | + return function($value) { |
|
57 | 57 | if (is_null($value)) { |
58 | 58 | return 0; |
59 | 59 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | */ |
72 | 72 | public static function key() |
73 | 73 | { |
74 | - return function ($value, $key) { |
|
74 | + return function($value, $key) { |
|
75 | 75 | return $key; |
76 | 76 | }; |
77 | 77 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | */ |
84 | 84 | public static function lower() |
85 | 85 | { |
86 | - return function ($value) { |
|
86 | + return function($value) { |
|
87 | 87 | return strtolower($value); |
88 | 88 | }; |
89 | 89 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public static function upper() |
97 | 97 | { |
98 | - return function ($value) { |
|
98 | + return function($value) { |
|
99 | 99 | return strtoupper($value); |
100 | 100 | }; |
101 | 101 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | public static function string() |
109 | 109 | { |
110 | - return function ($value) { |
|
110 | + return function($value) { |
|
111 | 111 | return (string)$value; |
112 | 112 | }; |
113 | 113 | } |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | */ |
122 | 122 | public static function jsonEncode($options = 0, $depth = 512) |
123 | 123 | { |
124 | - return function ($value) use ($options, $depth) { |
|
124 | + return function($value) use ($options, $depth) { |
|
125 | 125 | return \json_encode($value, $options, $depth); |
126 | 126 | }; |
127 | 127 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | */ |
137 | 137 | public static function jsonDecode($associative = false, $options = 0, $depth = 512) |
138 | 138 | { |
139 | - return function ($value) use ($associative, $options, $depth) { |
|
139 | + return function($value) use ($associative, $options, $depth) { |
|
140 | 140 | return \json_decode($value, $associative, $depth, $options); |
141 | 141 | }; |
142 | 142 | } |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $mappings = array_map('\Zicht\Itertools\util\Conversions::mixedToValueGetter', (array)$mappings); |
178 | 178 | $strategy = Conversions::mixedToValueGetter($strategy); |
179 | 179 | |
180 | - return function ($value, $key) use ($mappings, $strategy, $discardNull, $discardEmptyContainer, $castToObject) { |
|
180 | + return function($value, $key) use ($mappings, $strategy, $discardNull, $discardEmptyContainer, $castToObject) { |
|
181 | 181 | $value = $strategy($value); |
182 | 182 | $res = []; |
183 | 183 | foreach ($mappings as $strategyKey => $strategy) { |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | if ($discardNull || $discardEmptyContainer) { |
187 | 187 | $res = array_filter( |
188 | 188 | $res, |
189 | - function ($value) use ($discardNull, $discardEmptyContainer) { |
|
189 | + function($value) use ($discardNull, $discardEmptyContainer) { |
|
190 | 190 | if (null === $value) { |
191 | 191 | return !$discardNull; |
192 | 192 | } |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | $max = getrandmax(); |
217 | 217 | } |
218 | 218 | |
219 | - return function () use ($min, $max) { |
|
219 | + return function() use ($min, $max) { |
|
220 | 220 | return rand($min, $max); |
221 | 221 | }; |
222 | 222 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | public static function type($strategy = null) |
231 | 231 | { |
232 | 232 | $strategy = Conversions::mixedToValueGetter($strategy); |
233 | - return function ($value) use ($strategy) { |
|
233 | + return function($value) use ($strategy) { |
|
234 | 234 | $value = $strategy($value); |
235 | 235 | return is_object($value) ? get_class($value) : gettype($value); |
236 | 236 | }; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | $mapping = Conversions::mixedToValueGetter($mapping); |
260 | 260 | $strategy = Conversions::mixedToValueGetter($strategy); |
261 | 261 | $cache = []; |
262 | - return function ($value, $key = null) use ($mapping, $strategy, &$cache) { |
|
262 | + return function($value, $key = null) use ($mapping, $strategy, &$cache) { |
|
263 | 263 | $cacheKey = \json_encode($strategy($value, $key)); |
264 | 264 | if (!array_key_exists($cacheKey, $cache)) { |
265 | 265 | $cache[$cacheKey] = $mapping($value, $key); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | */ |
277 | 277 | public static function constant($value) |
278 | 278 | { |
279 | - return function () use ($value) { |
|
279 | + return function() use ($value) { |
|
280 | 280 | return $value; |
281 | 281 | }; |
282 | 282 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | public static function mixedToClosure($closure) |
72 | 72 | { |
73 | 73 | if (is_null($closure)) { |
74 | - return function ($value) { |
|
74 | + return function($value) { |
|
75 | 75 | return $value; |
76 | 76 | }; |
77 | 77 | } |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | // A \Closure is always callable, but a callable is not always a \Closure. |
81 | 81 | // Checking within this if statement is a slight optimization, preventing an unnecessary function wrap |
82 | 82 | if (is_callable($closure)) { |
83 | - $closure = function () use ($closure) { |
|
83 | + $closure = function() use ($closure) { |
|
84 | 84 | return call_user_func_array($closure, func_get_args()); |
85 | 85 | }; |
86 | 86 | } else { |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | if (is_string($strategy)) { |
113 | 113 | $keyParts = explode('.', $strategy); |
114 | - $strategy = function ($value) use ($keyParts) { |
|
114 | + $strategy = function($value) use ($keyParts) { |
|
115 | 115 | foreach ($keyParts as $keyPart) { |
116 | 116 | if (is_array($value) && array_key_exists($keyPart, $value)) { |
117 | 117 | $value = $value[$keyPart]; |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public static function type($class, $strategy = null) |
33 | 33 | { |
34 | 34 | $strategy = Conversions::mixedToValueGetter($strategy); |
35 | - return function ($value, $key = null) use ($class, $strategy) { |
|
35 | + return function($value, $key = null) use ($class, $strategy) { |
|
36 | 36 | return $strategy($value, $key) instanceof $class; |
37 | 37 | }; |
38 | 38 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $haystack = iterable($haystack)->values(); |
67 | 67 | } |
68 | 68 | $strategy = Conversions::mixedToValueGetter($strategy); |
69 | - return function ($value, $key = null) use ($haystack, $strategy, $strict) { |
|
69 | + return function($value, $key = null) use ($haystack, $strategy, $strict) { |
|
70 | 70 | return in_array($strategy($value, $key), $haystack, $strict); |
71 | 71 | }; |
72 | 72 | } |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | } |
99 | 99 | $strategy = Conversions::mixedToValueGetter($strategy); |
100 | 100 | if ($strict) { |
101 | - return function ($value, $key = null) use ($expected, $strategy) { |
|
101 | + return function($value, $key = null) use ($expected, $strategy) { |
|
102 | 102 | return $expected === $strategy($value, $key); |
103 | 103 | }; |
104 | 104 | } else { |
105 | - return function ($value, $key = null) use ($expected, $strategy) { |
|
105 | + return function($value, $key = null) use ($expected, $strategy) { |
|
106 | 106 | return $expected == $strategy($value, $key); |
107 | 107 | }; |
108 | 108 | } |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | |
129 | 129 | // Support DateTimeInterface |
130 | 130 | if ($expected instanceof \DateTimeInterface) { |
131 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
131 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
132 | 132 | $value = $strategy($value, $key); |
133 | 133 | // Try to convert strings that look like ISO date format |
134 | 134 | if (is_string($value) && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | |
144 | 144 | // Support numbers |
145 | 145 | if (is_int($expected) || is_float($expected)) { |
146 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
146 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
147 | 147 | $value = $strategy($value, $key); |
148 | 148 | return (is_int($value) || is_float($value)) && ($orEqual ? $expected <= $value : $expected < $value); |
149 | 149 | }; |
150 | 150 | } |
151 | 151 | |
152 | 152 | // Everything else fails |
153 | - return function () { |
|
153 | + return function() { |
|
154 | 154 | return false; |
155 | 155 | }; |
156 | 156 | } |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | // Support DateTimeInterface |
177 | 177 | if ($expected instanceof \DateTimeInterface) { |
178 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
178 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
179 | 179 | $value = $strategy($value, $key); |
180 | 180 | // Try to convert strings that look like ISO date format |
181 | 181 | if (is_string($value) && preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/', $value)) { |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | |
191 | 191 | // Support numbers |
192 | 192 | if (is_int($expected) || is_float($expected)) { |
193 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
193 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
194 | 194 | $value = $strategy($value, $key); |
195 | 195 | return (is_int($value) || is_float($value)) && ($orEqual ? $expected >= $value : $expected > $value); |
196 | 196 | }; |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Everything else fails |
200 | - return function () { |
|
200 | + return function() { |
|
201 | 201 | return false; |
202 | 202 | }; |
203 | 203 | } |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | public static function not($strategy = null) |
218 | 218 | { |
219 | 219 | $strategy = Conversions::mixedToValueGetter($strategy); |
220 | - return function ($value, $key = null) use ($strategy) { |
|
220 | + return function($value, $key = null) use ($strategy) { |
|
221 | 221 | return !($strategy($value, $key)); |
222 | 222 | }; |
223 | 223 | } |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | } |
243 | 243 | |
244 | 244 | $strategy = Conversions::mixedToValueGetter($strategy); |
245 | - return function ($value, $key = null) use ($pattern, $strategy) { |
|
245 | + return function($value, $key = null) use ($pattern, $strategy) { |
|
246 | 246 | return (bool)preg_match($pattern, $strategy($value, $key)); |
247 | 247 | }; |
248 | 248 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public static function add() |
18 | 18 | { |
19 | - return function ($a, $b) { |
|
19 | + return function($a, $b) { |
|
20 | 20 | if (!is_numeric($a)) { |
21 | 21 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to perform addition, not %s', is_object($a) ? get_class($a) : gettype($a))); |
22 | 22 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public static function sub() |
36 | 36 | { |
37 | - return function ($a, $b) { |
|
37 | + return function($a, $b) { |
|
38 | 38 | if (!is_numeric($a)) { |
39 | 39 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to perform subtraction, not %s', is_object($a) ? get_class($a) : gettype($a))); |
40 | 40 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public static function mul() |
54 | 54 | { |
55 | - return function ($a, $b) { |
|
55 | + return function($a, $b) { |
|
56 | 56 | if (!is_numeric($a)) { |
57 | 57 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to perform multiplication, not %s', is_object($a) ? get_class($a) : gettype($a))); |
58 | 58 | } |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public static function min() |
72 | 72 | { |
73 | - return function ($a, $b) { |
|
73 | + return function($a, $b) { |
|
74 | 74 | if (!(is_numeric($a) || $a instanceof \DateTime)) { |
75 | 75 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to determine minimum, not %s', is_object($a) ? get_class($a) : gettype($a))); |
76 | 76 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | */ |
89 | 89 | public static function max() |
90 | 90 | { |
91 | - return function ($a, $b) { |
|
91 | + return function($a, $b) { |
|
92 | 92 | if (!(is_numeric($a) || $a instanceof \DateTime)) { |
93 | 93 | throw new \InvalidArgumentException(sprintf('Argument $A must be numeric to determine maximum, not %s', is_object($a) ? get_class($a) : gettype($a))); |
94 | 94 | } |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | if (!is_string($glue)) { |
111 | 111 | throw new \InvalidArgumentException(sprintf('Argument $GLUE must be a string to join, not %s', is_object($glue) ? get_class($glue) : gettype($glue))); |
112 | 112 | } |
113 | - return function ($a, $b) use ($glue) { |
|
113 | + return function($a, $b) use ($glue) { |
|
114 | 114 | if (!is_string($a)) { |
115 | 115 | throw new \InvalidArgumentException(sprintf('Argument $A must be a string to join, not %s', is_object($a) ? get_class($a) : gettype($a))); |
116 | 116 | } |
@@ -87,7 +87,7 @@ |
||
87 | 87 | */ |
88 | 88 | function chain() |
89 | 89 | { |
90 | - return function ($chainIterator, $b) { |
|
90 | + return function($chainIterator, $b) { |
|
91 | 91 | if (!($chainIterator instanceof ChainIterator)) { |
92 | 92 | throw new \InvalidArgumentException('Argument $A must be a ChainIterator. Did your call "reduce" with "new ChainIterator()" as the initial parameter?'); |
93 | 93 | } |