@@ -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 | return $value instanceof \DateTimeInterface && ($orEqual ? $expected <= $value : $expected < $value); |
157 | 157 | }; |
@@ -159,14 +159,14 @@ discard block |
||
159 | 159 | |
160 | 160 | // Support numbers |
161 | 161 | if (is_int($expected) || is_float($expected)) { |
162 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
162 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
163 | 163 | $value = $strategy($value, $key); |
164 | 164 | return (is_int($value) || is_float($value)) && ($orEqual ? $expected <= $value : $expected < $value); |
165 | 165 | }; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Everything else fails |
169 | - return function () { |
|
169 | + return function() { |
|
170 | 170 | return false; |
171 | 171 | }; |
172 | 172 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | |
192 | 192 | // Support DateTimeInterface |
193 | 193 | if ($expected instanceof \DateTimeInterface) { |
194 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
194 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
195 | 195 | $value = $strategy($value, $key); |
196 | 196 | return $value instanceof \DateTimeInterface && ($orEqual ? $expected >= $value : $expected > $value); |
197 | 197 | }; |
@@ -199,14 +199,14 @@ discard block |
||
199 | 199 | |
200 | 200 | // Support numbers |
201 | 201 | if (is_int($expected) || is_float($expected)) { |
202 | - return function ($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
202 | + return function($value, $key = null) use ($expected, $strategy, $orEqual) { |
|
203 | 203 | $value = $strategy($value, $key); |
204 | 204 | return (is_int($value) || is_float($value)) && ($orEqual ? $expected >= $value : $expected > $value); |
205 | 205 | }; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Everything else fails |
209 | - return function () { |
|
209 | + return function() { |
|
210 | 210 | return false; |
211 | 211 | }; |
212 | 212 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | function not($strategy = null) |
227 | 227 | { |
228 | 228 | $strategy = conversions\mixed_to_value_getter($strategy); |
229 | - return function ($value, $key = null) use ($strategy) { |
|
229 | + return function($value, $key = null) use ($strategy) { |
|
230 | 230 | return !($strategy($value, $key)); |
231 | 231 | }; |
232 | 232 | } |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | } |
252 | 252 | |
253 | 253 | $strategy = conversions\mixed_to_value_getter($strategy); |
254 | - return function ($value, $key = null) use ($pattern, $strategy) { |
|
254 | + return function($value, $key = null) use ($pattern, $strategy) { |
|
255 | 255 | return (bool)preg_match($pattern, $strategy($value, $key)); |
256 | 256 | }; |
257 | 257 | } |