@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @return array |
117 | 117 | */ |
118 | 118 | function get_modules() { |
119 | - $composer = json_decode(file_get_contents(__DIR__.'/composer.json')); |
|
119 | + $composer = json_decode(file_get_contents(__DIR__ . '/composer.json')); |
|
120 | 120 | return $composer->autoload->files; |
121 | 121 | } |
122 | 122 | |
@@ -147,10 +147,10 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function write_module($module) { |
149 | 149 | if ($module->docs) { |
150 | - $docsDir = dirname($module->docsPath); |
|
150 | + $docsDir = dirname($module->docsPath); |
|
151 | 151 | if (!is_dir($docsDir)) |
152 | 152 | mkdir($docsDir, 0777, true); |
153 | - file_put_contents($module->docsPath, $module->docs); |
|
153 | + file_put_contents($module->docsPath, $module->docs); |
|
154 | 154 | } |
155 | 155 | if ($module->tests) { |
156 | 156 | $testsDir = dirname($module->testsPath); |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | 'fill_docs_path', |
180 | 180 | 'fill_tests_path', |
181 | 181 | 'fill_blocks' |
182 | - ]), [(object)['path' => $path]]); |
|
182 | + ]), [(object) ['path' => $path]]); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | function fill_blocks($module) { |
234 | 234 | $module->blocks = apply(pipe( |
235 | 235 | prepend('dox -r < '), // "dox -r < src/...php" |
236 | - 'shell_exec', // "[{...}, ...]" |
|
237 | - 'json_decode', // [DoxBlock] |
|
236 | + 'shell_exec', // "[{...}, ...]" |
|
237 | + 'json_decode', // [DoxBlock] |
|
238 | 238 | map(_f('make_block')) |
239 | 239 | // sort() |
240 | 240 | ), [$module->path]); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | if (has('class', $tags)) $type = 'class'; |
257 | 257 | if (has('method', $tags)) $type = 'method'; |
258 | 258 | |
259 | - $params = map(function($tag){ |
|
259 | + $params = map(function($tag) { |
|
260 | 260 | $parts = split(' ', get('value', $tag)); |
261 | 261 | return [ |
262 | 262 | 'type' => $parts[0], |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | function tags_of($doxBlock) { |
294 | 294 | if ($doxBlock->tags) |
295 | - return map(function($tag){ |
|
295 | + return map(function($tag) { |
|
296 | 296 | return (object) [ |
297 | 297 | 'name' => $tag->type, |
298 | 298 | 'value' => $tag->string |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | * @return object |
342 | 342 | */ |
343 | 343 | function generate_docs_sommaire($module) { |
344 | - $blocks = filter ( |
|
344 | + $blocks = filter( |
|
345 | 345 | satisfiesAll(['ignore' => not(), 'internal' => not(), 'type' => equals('function')]), |
346 | 346 | $module->blocks |
347 | 347 | ); |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return object |
372 | 372 | */ |
373 | 373 | function generate_docs_contents($module) { |
374 | - $blocks = filter ( |
|
374 | + $blocks = filter( |
|
375 | 375 | satisfiesAll(['ignore' => not(), 'internal' => not()]), |
376 | 376 | $module->blocks |
377 | 377 | ); |
@@ -429,7 +429,7 @@ discard block |
||
429 | 429 | $additionalNamespace = replace("/", "\\", remove(6, dirname($module->testsPath))); |
430 | 430 | if ($additionalNamespace) |
431 | 431 | $namespace .= "\\" . $additionalNamespace; |
432 | - $name = remove(-4, last(split("/", $module->testsPath))); |
|
432 | + $name = remove(- 4, last(split("/", $module->testsPath))); |
|
433 | 433 | $module->tests .= "<?php namespace {$namespace};\n\nuse Tarsana\Functional as F;\n\nclass {$name} extends \Tarsana\UnitTests\Functional\UnitTest {\n"; |
434 | 434 | return $module; |
435 | 435 | } |
@@ -442,7 +442,7 @@ discard block |
||
442 | 442 | * @return object |
443 | 443 | */ |
444 | 444 | function generate_tests_contents($module) { |
445 | - $blocks = filter ( |
|
445 | + $blocks = filter( |
|
446 | 446 | satisfiesAll(['ignore' => not()]), |
447 | 447 | $module->blocks |
448 | 448 | ); |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | if (!contains('```php', $description)) |
500 | 500 | return ''; |
501 | 501 | $code = remove(7 + indexOf('```php', $description), $description); |
502 | - return remove(-4, trim($code)); |
|
502 | + return remove(- 4, trim($code)); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | * @return array |
553 | 553 | */ |
554 | 554 | function generate_stream_operations($module) { |
555 | - $blocks = filter ( |
|
555 | + $blocks = filter( |
|
556 | 556 | satisfiesAll(['ignore' => equals(false), 'stream' => equals(true)]), |
557 | 557 | $module->blocks |
558 | 558 | ); |
@@ -621,7 +621,7 @@ discard block |
||
621 | 621 | * @return array |
622 | 622 | */ |
623 | 623 | function generate_stream_methods($module) { |
624 | - $blocks = filter ( |
|
624 | + $blocks = filter( |
|
625 | 625 | satisfiesAll(['ignore' => equals(false), 'stream' => equals(true)]), |
626 | 626 | $module->blocks |
627 | 627 | ); |
@@ -18,7 +18,7 @@ |
||
18 | 18 | * @param Error|null $error |
19 | 19 | * @return Error |
20 | 20 | */ |
21 | - public static function of ($message, $code = 0, Error $error = null) |
|
21 | + public static function of($message, $code = 0, Error $error = null) |
|
22 | 22 | { |
23 | 23 | return new Error($message, $code, $error); |
24 | 24 | } |
@@ -53,7 +53,7 @@ |
||
53 | 53 | */ |
54 | 54 | public static function operation($name, $signatures, $fn = null) |
55 | 55 | { |
56 | - if (! is_array($signatures)) { |
|
56 | + if (!is_array($signatures)) { |
|
57 | 57 | $signatures = [$signatures]; |
58 | 58 | } |
59 | 59 | foreach ($signatures as $signature) { |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | if (length($parts) < 2) |
168 | 168 | _stream_throw_error('invalid-signature', $text); |
169 | 169 | |
170 | - return reduce(function($result, $part){ |
|
170 | + return reduce(function($result, $part) { |
|
171 | 171 | return chain(function($item) use($result){ |
172 | 172 | return map(append($item), $result); |
173 | 173 | }, $part); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | */ |
198 | 198 | function _stream_ensure_type() { |
199 | 199 | $ensureType = function($signature, $type) { |
200 | - if (! contains($type, _stream_types())) |
|
200 | + if (!contains($type, _stream_types())) |
|
201 | 201 | _stream_throw_error('invalid-signature', $signature); |
202 | 202 | return $type; |
203 | 203 | }; |
@@ -46,7 +46,7 @@ |
||
46 | 46 | */ |
47 | 47 | function join() { |
48 | 48 | static $join = false; |
49 | - $join = $join ?: curry(function($glue, $pieces){ |
|
49 | + $join = $join ?: curry(function($glue, $pieces) { |
|
50 | 50 | return implode($glue, $pieces); |
51 | 51 | }); |
52 | 52 | return _apply($join, func_get_args()); |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function plus() { |
22 | 22 | static $plus = false; |
23 | - $plus = $plus ?: curry(function($x, $y){ |
|
23 | + $plus = $plus ?: curry(function($x, $y) { |
|
24 | 24 | return $x + $y; |
25 | 25 | }); |
26 | 26 | return _apply($plus, func_get_args()); |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | function minus() { |
43 | 43 | static $minus = false; |
44 | - $minus = $minus ?: curry(function($x, $y){ |
|
44 | + $minus = $minus ?: curry(function($x, $y) { |
|
45 | 45 | return $x - $y; |
46 | 46 | }); |
47 | 47 | return _apply($minus, func_get_args()); |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | */ |
63 | 63 | function negate() { |
64 | 64 | static $negate = false; |
65 | - $negate = $negate ?: curry(function($x){ |
|
66 | - return -$x; |
|
65 | + $negate = $negate ?: curry(function($x) { |
|
66 | + return - $x; |
|
67 | 67 | }); |
68 | 68 | return _apply($negate, func_get_args()); |
69 | 69 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | */ |
85 | 85 | function multiply() { |
86 | 86 | static $multiply = false; |
87 | - $multiply = $multiply ?: curry(function($x, $y){ |
|
87 | + $multiply = $multiply ?: curry(function($x, $y) { |
|
88 | 88 | return $y * $x; |
89 | 89 | }); |
90 | 90 | return _apply($multiply, func_get_args()); |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | */ |
106 | 106 | function divide() { |
107 | 107 | static $divide = false; |
108 | - $divide = $divide ?: curry(function($x, $y){ |
|
108 | + $divide = $divide ?: curry(function($x, $y) { |
|
109 | 109 | return $x / $y; |
110 | 110 | }); |
111 | 111 | return _apply($divide, func_get_args()); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function modulo() { |
128 | 128 | static $modulo = false; |
129 | - $modulo = $modulo ?: curry(function($x, $y){ |
|
129 | + $modulo = $modulo ?: curry(function($x, $y) { |
|
130 | 130 | return $x % $y; |
131 | 131 | }); |
132 | 132 | return _apply($modulo, func_get_args()); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | function min() { |
188 | 188 | static $min = false; |
189 | - $min = $min ?: curry(function($a, $b){ |
|
189 | + $min = $min ?: curry(function($a, $b) { |
|
190 | 190 | return $a < $b ? $a : $b; |
191 | 191 | }); |
192 | 192 | return _apply($min, func_get_args()); |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | */ |
210 | 210 | function minBy() { |
211 | 211 | static $minBy = false; |
212 | - $minBy = $minBy ?: curry(function($fn, $a, $b){ |
|
212 | + $minBy = $minBy ?: curry(function($fn, $a, $b) { |
|
213 | 213 | return $fn($a) < $fn($b) ? $a : $b; |
214 | 214 | }); |
215 | 215 | return _apply($minBy, func_get_args()); |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | */ |
232 | 232 | function max() { |
233 | 233 | static $max = false; |
234 | - $max = $max ?: curry(function($a, $b){ |
|
234 | + $max = $max ?: curry(function($a, $b) { |
|
235 | 235 | return $a > $b ? $a : $b; |
236 | 236 | }); |
237 | 237 | return _apply($max, func_get_args()); |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | function maxBy() { |
256 | 256 | static $maxBy = false; |
257 | - $maxBy = $maxBy ?: curry(function($fn, $a, $b){ |
|
257 | + $maxBy = $maxBy ?: curry(function($fn, $a, $b) { |
|
258 | 258 | return $fn($a) > $fn($b) ? $a : $b; |
259 | 259 | }); |
260 | 260 | return _apply($maxBy, func_get_args()); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | function has() { |
175 | 175 | static $has = false; |
176 | - $has = $has ?: curry(function($name, $object){ |
|
176 | + $has = $has ?: curry(function($name, $object) { |
|
177 | 177 | if (is_object($object)) return isset($object->{$name}); |
178 | 178 | if (is_array($object)) return isset($object[$name]); |
179 | 179 | return false; |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | */ |
209 | 209 | function get() { |
210 | 210 | static $get = false; |
211 | - $get = $get ?: curry(function($name, $object){ |
|
211 | + $get = $get ?: curry(function($name, $object) { |
|
212 | 212 | return is_object($object) |
213 | 213 | ? (isset($object->{$name}) ? $object->{$name} : null) |
214 | 214 | : (isset($object[$name]) ? $object[$name] : null); |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | */ |
23 | 23 | function and_() { |
24 | 24 | static $and = false; |
25 | - $and = $and ?: curry(function($a, $b){ |
|
25 | + $and = $and ?: curry(function($a, $b) { |
|
26 | 26 | return $a && $b; |
27 | 27 | }); |
28 | 28 | return _apply($and, func_get_args()); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | */ |
46 | 46 | function or_() { |
47 | 47 | static $or = false; |
48 | - $or = $or ?: curry(function($a, $b){ |
|
48 | + $or = $or ?: curry(function($a, $b) { |
|
49 | 49 | return $a || $b; |
50 | 50 | }); |
51 | 51 | return _apply($or, func_get_args()); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * @return bool |
86 | 86 | */ |
87 | 87 | function eq() { |
88 | - $eq = curry(function($a, $b){ |
|
88 | + $eq = curry(function($a, $b) { |
|
89 | 89 | return $a == $b; |
90 | 90 | }); |
91 | 91 | return _apply($eq, func_get_args()); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | function notEq() { |
108 | 108 | static $notEq = false; |
109 | - $notEq = $notEq ?: curry(function($a, $b){ |
|
109 | + $notEq = $notEq ?: curry(function($a, $b) { |
|
110 | 110 | return $a != $b; |
111 | 111 | }); |
112 | 112 | return _apply($notEq, func_get_args()); |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | function eqq() { |
128 | 128 | static $eqq = false; |
129 | - $eqq = $eqq ?: curry(function($a, $b){ |
|
129 | + $eqq = $eqq ?: curry(function($a, $b) { |
|
130 | 130 | return $a === $b; |
131 | 131 | }); |
132 | 132 | return _apply($eqq, func_get_args()); |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | */ |
148 | 148 | function notEqq() { |
149 | 149 | static $notEqq = false; |
150 | - $notEqq = $notEqq ?: curry(function($a, $b){ |
|
150 | + $notEqq = $notEqq ?: curry(function($a, $b) { |
|
151 | 151 | return $a !== $b; |
152 | 152 | }); |
153 | 153 | return _apply($notEqq, func_get_args()); |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | function lt() { |
266 | 266 | static $lt = false; |
267 | - $lt = $lt ?: curry(function($a, $b){ |
|
267 | + $lt = $lt ?: curry(function($a, $b) { |
|
268 | 268 | return $a < $b; |
269 | 269 | }); |
270 | 270 | return _apply($lt, func_get_args()); |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | */ |
287 | 287 | function lte() { |
288 | 288 | static $lte = false; |
289 | - $lte = $lte ?: curry(function($a, $b){ |
|
289 | + $lte = $lte ?: curry(function($a, $b) { |
|
290 | 290 | return $a <= $b; |
291 | 291 | }); |
292 | 292 | return _apply($lte, func_get_args()); |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | */ |
309 | 309 | function gt() { |
310 | 310 | static $gt = false; |
311 | - $gt = $gt ?: curry(function($a, $b){ |
|
311 | + $gt = $gt ?: curry(function($a, $b) { |
|
312 | 312 | return $a > $b; |
313 | 313 | }); |
314 | 314 | return _apply($gt, func_get_args()); |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | */ |
331 | 331 | function gte() { |
332 | 332 | static $gte = false; |
333 | - $gte = $gte ?: curry(function($a, $b){ |
|
333 | + $gte = $gte ?: curry(function($a, $b) { |
|
334 | 334 | return $a >= $b; |
335 | 335 | }); |
336 | 336 | return _apply($gte, func_get_args()); |
@@ -35,8 +35,7 @@ discard block |
||
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 |
||
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 | }; |