@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @param Error|null $error |
25 | 25 | * @return Error |
26 | 26 | */ |
27 | - public static function of ($message, Error $error = null) |
|
27 | + public static function of($message, Error $error = null) |
|
28 | 28 | { |
29 | 29 | return new Error($message, $error); |
30 | 30 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * @param string $message |
36 | 36 | * @param Error|null $error |
37 | 37 | */ |
38 | - protected function __construct ($message, Error $error = null) |
|
38 | + protected function __construct($message, Error $error = null) |
|
39 | 39 | { |
40 | 40 | if (null != $error) |
41 | 41 | $message = $error->message() . ' -> ' . $message; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @signature Error -> String |
53 | 53 | * @return string |
54 | 54 | */ |
55 | - public function message () |
|
55 | + public function message() |
|
56 | 56 | { |
57 | 57 | return $this->message; |
58 | 58 | } |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return int|float |
17 | 17 | */ |
18 | 18 | function plus() { |
19 | - $plus = curry(function($x, $y){ |
|
19 | + $plus = curry(function($x, $y) { |
|
20 | 20 | return $x + $y; |
21 | 21 | }); |
22 | 22 | return apply($plus, func_get_args()); |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | * @return int|float |
35 | 35 | */ |
36 | 36 | function minus() { |
37 | - $minus = curry(function($x, $y){ |
|
37 | + $minus = curry(function($x, $y) { |
|
38 | 38 | return $x - $y; |
39 | 39 | }); |
40 | 40 | return apply($minus, func_get_args()); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * @return int|float |
53 | 53 | */ |
54 | 54 | function negate($x) { |
55 | - return -$x; |
|
55 | + return - $x; |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @return int|float |
69 | 69 | */ |
70 | 70 | function multiply() { |
71 | - $multiply = curry(function($x, $y){ |
|
71 | + $multiply = curry(function($x, $y) { |
|
72 | 72 | return $y * $x; |
73 | 73 | }); |
74 | 74 | return apply($multiply, func_get_args()); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @return int|float |
87 | 87 | */ |
88 | 88 | function divide() { |
89 | - $divide = curry(function($x, $y){ |
|
89 | + $divide = curry(function($x, $y) { |
|
90 | 90 | return $x / $y; |
91 | 91 | }); |
92 | 92 | return apply($divide, func_get_args()); |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | * @return int|float |
105 | 105 | */ |
106 | 106 | function modulo() { |
107 | - $modulo = curry(function($x, $y){ |
|
107 | + $modulo = curry(function($x, $y) { |
|
108 | 108 | return $x % $y; |
109 | 109 | }); |
110 | 110 | return apply($modulo, func_get_args()); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @return string |
33 | 33 | */ |
34 | 34 | function join() { |
35 | - return apply(curry(function($glue, $pieces){ |
|
35 | + return apply(curry(function($glue, $pieces) { |
|
36 | 36 | return implode($glue, $pieces); |
37 | 37 | }), func_get_args()); |
38 | 38 | } |
@@ -285,8 +285,7 @@ discard block |
||
285 | 285 | $count = occurences(__(), $item); |
286 | 286 | $counts = map(function($index) use ($result, $count) { |
287 | 287 | return ($result->openings[$index] == $result->closings[$index]) ? |
288 | - ($result->counts[$index] + $count($result->openings[$index])) % 2 : |
|
289 | - $result->counts[$index] + $count($result->openings[$index]) - $count($result->closings[$index]); |
|
288 | + ($result->counts[$index] + $count($result->openings[$index])) % 2 : $result->counts[$index] + $count($result->openings[$index]) - $count($result->closings[$index]); |
|
290 | 289 | }, range(0, length($result->counts) - 1)); |
291 | 290 | if (0 == $result->total) { |
292 | 291 | return (object) [ |
@@ -311,7 +310,7 @@ discard block |
||
311 | 310 | 'counts' => array_fill(0, length($surrounders), 0), |
312 | 311 | 'total' => 0 |
313 | 312 | ]) |
314 | - ->then(function($data){ |
|
313 | + ->then(function($data) { |
|
315 | 314 | return $data->items; |
316 | 315 | }) |
317 | 316 | ->get(); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @param mixed $something |
72 | 72 | * @return string |
73 | 73 | */ |
74 | -function toString ($something) { |
|
74 | +function toString($something) { |
|
75 | 75 | switch (type($something)) { |
76 | 76 | case 'String': |
77 | 77 | return $something; |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | break; |
91 | 91 | case 'ArrayObject': |
92 | 92 | case 'Array': |
93 | - return '[' . join(', ', map(function($pair){ |
|
94 | - return $pair[0].' => '. toString($pair[1]); |
|
93 | + return '[' . join(', ', map(function($pair) { |
|
94 | + return $pair[0] . ' => ' . toString($pair[1]); |
|
95 | 95 | }, toPairs($something))) . ']'; |
96 | 96 | break; |
97 | 97 | case 'Error': |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return is_callable([$something, '__toString']) ? $something->__toString() : '[Object]'; |
101 | 101 | break; |
102 | 102 | default: |
103 | - return '['.type($something).']'; |
|
103 | + return '[' . type($something) . ']'; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | // Reads the list of sources files from 'composer.json' |
18 | 18 | // * -> IO [String] |
19 | 19 | function modules() { |
20 | - $composer = json_decode(file_get_contents(__DIR__.'/composer.json')); |
|
20 | + $composer = json_decode(file_get_contents(__DIR__ . '/composer.json')); |
|
21 | 21 | return $composer->autoload->files; |
22 | 22 | } |
23 | 23 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @field type String |
40 | 40 | */ |
41 | 41 | function argsOf($data) { |
42 | - return F\map(function($tag){ |
|
42 | + return F\map(function($tag) { |
|
43 | 43 | return (object) [ |
44 | 44 | 'type' => $tag->name, |
45 | 45 | 'name' => $tag->description |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | // Extracts signatures of a function. |
51 | 51 | // Object -> [String] |
52 | 52 | function signaturesOf($data) { |
53 | - return F\map(function($tag){ |
|
53 | + return F\map(function($tag) { |
|
54 | 54 | return $tag->string; |
55 | 55 | }, tags('signature', $data)); |
56 | 56 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | // Get a markdown code block |
125 | 125 | // String -> String -> String |
126 | 126 | function code($lang, $text) { |
127 | - if(trim($text) == '') |
|
127 | + if (trim($text) == '') |
|
128 | 128 | return ''; |
129 | 129 | return "```{$lang}\n{$text}\n```"; |
130 | 130 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $args = F\map(function($arg) { |
139 | 139 | return $arg->type . ' ' . $arg->name; |
140 | 140 | }, $fn->args); |
141 | - $proto = $fn->name . '('. F\join(', ', $args) .') : ' . $fn->return; |
|
141 | + $proto = $fn->name . '(' . F\join(', ', $args) . ') : ' . $fn->return; |
|
142 | 142 | return F\join("\n\n", [ |
143 | 143 | "## {$fn->name}", |
144 | 144 | code('php', $proto), |
@@ -153,11 +153,11 @@ discard block |
||
153 | 153 | function addContents() { |
154 | 154 | $addContents = function($name, $parts) { |
155 | 155 | $names = F\filter(F\notEq($name), F\map(F\value('name'), $parts)); |
156 | - $contents = F\map(function ($partname) use($name) { |
|
156 | + $contents = F\map(function($partname) use($name) { |
|
157 | 157 | $link = URL . "/docs/{$name}.md#{$partname}"; |
158 | 158 | return "- [{$partname}]($link)"; |
159 | 159 | }, $names); |
160 | - file_put_contents ("docs/README.md", |
|
160 | + file_put_contents("docs/README.md", |
|
161 | 161 | F\join("\n\n", F\concat(["## {$name}"], $contents)) . "\n\n" |
162 | 162 | , FILE_APPEND); |
163 | 163 | return array_merge(['# ' . $name, '## Table Of Contents'], $contents, F\map(F\value('md'), $parts)); |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | function generateModule($file) { |
170 | 170 | $content = F\pipe( |
171 | 171 | F\map('Demo\\block'), |
172 | - F\filter(function($block){ |
|
172 | + F\filter(function($block) { |
|
173 | 173 | return $block->type == 'function' && !$block->is_internal; |
174 | 174 | }), |
175 | - F\map(function($block){ |
|
175 | + F\map(function($block) { |
|
176 | 176 | return [ |
177 | 177 | 'name' => $block->name, |
178 | 178 | 'md' => markdown($block) |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | F\join("\n\n") |
183 | 183 | ); |
184 | 184 | |
185 | - file_put_contents ( |
|
185 | + file_put_contents( |
|
186 | 186 | F\replace(['src', '.php'], ['docs', '.md'], $file), |
187 | 187 | $content(json_decode(shell_exec("dox -r < {$file}"))) |
188 | 188 | ); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | function generateClass($name) { |
194 | 194 | $content = F\pipe( |
195 | 195 | F\map('Demo\\block'), |
196 | - F\filter(function($block){ |
|
196 | + F\filter(function($block) { |
|
197 | 197 | return in_array($block->type, ['method', 'class']) && !$block->is_internal; |
198 | 198 | }), |
199 | 199 | f\map(function($block) use ($name) { |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | } |
203 | 203 | return $block; |
204 | 204 | }), |
205 | - F\map(function($block){ |
|
205 | + F\map(function($block) { |
|
206 | 206 | return [ |
207 | 207 | 'name' => $block->name, |
208 | 208 | 'md' => markdown($block) |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | F\join("\n\n") |
213 | 213 | ); |
214 | 214 | |
215 | - file_put_contents ( |
|
215 | + file_put_contents( |
|
216 | 216 | "docs/{$name}.md", |
217 | 217 | $content(json_decode(shell_exec("dox -r < src/{$name}.php"))) |
218 | 218 | ); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | |
221 | 221 | // The entry point |
222 | 222 | file_put_contents('docs/README.md', "# Reference Documentation \n\n"); |
223 | -file_put_contents ("docs/README.md", "# Function Modules\n\n" , FILE_APPEND); |
|
223 | +file_put_contents("docs/README.md", "# Function Modules\n\n", FILE_APPEND); |
|
224 | 224 | F\each('Demo\\generateModule', modules()); |
225 | -file_put_contents ("docs/README.md", "# Containers\n\n" , FILE_APPEND); |
|
225 | +file_put_contents("docs/README.md", "# Containers\n\n", FILE_APPEND); |
|
226 | 226 | F\each('Demo\\generateClass', ['Stream', 'Error']); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | * @return bool |
156 | 156 | */ |
157 | 157 | function has() { |
158 | - $has = function($name, $object){ |
|
158 | + $has = function($name, $object) { |
|
159 | 159 | return contains($name, keys($object)); |
160 | 160 | }; |
161 | 161 | return apply(curry($has), func_get_args()); |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | * @return mixed |
186 | 186 | */ |
187 | 187 | function get() { |
188 | - $get = function($name, $object){ |
|
188 | + $get = function($name, $object) { |
|
189 | 189 | $object = attributes($object); |
190 | 190 | return has($name, $object) |
191 | 191 | ? $object[$name] |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * @return mixed |
214 | 214 | */ |
215 | 215 | function getPath() { |
216 | - $getPath = function($path, $object){ |
|
216 | + $getPath = function($path, $object) { |
|
217 | 217 | |
218 | 218 | }; |
219 | 219 | return apply(curry($getPath), func_get_args()); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * @return bool |
14 | 14 | */ |
15 | 15 | function and_() { |
16 | - return apply(curry(function($a, $b){ |
|
16 | + return apply(curry(function($a, $b) { |
|
17 | 17 | return $a && $b; |
18 | 18 | }), func_get_args()); |
19 | 19 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @return bool |
28 | 28 | */ |
29 | 29 | function or_() { |
30 | - return apply(curry(function($a, $b){ |
|
30 | + return apply(curry(function($a, $b) { |
|
31 | 31 | return $a || $b; |
32 | 32 | }), func_get_args()); |
33 | 33 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return bool |
56 | 56 | */ |
57 | 57 | function eq() { |
58 | - return apply(curry(function($a, $b){ |
|
58 | + return apply(curry(function($a, $b) { |
|
59 | 59 | return $a == $b; |
60 | 60 | }), func_get_args()); |
61 | 61 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return bool |
70 | 70 | */ |
71 | 71 | function notEq() { |
72 | - return apply(curry(function($a, $b){ |
|
72 | + return apply(curry(function($a, $b) { |
|
73 | 73 | return $a != $b; |
74 | 74 | }), func_get_args()); |
75 | 75 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return bool |
84 | 84 | */ |
85 | 85 | function eqq() { |
86 | - return apply(curry(function($a, $b){ |
|
86 | + return apply(curry(function($a, $b) { |
|
87 | 87 | return $a === $b; |
88 | 88 | }), func_get_args()); |
89 | 89 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return bool |
98 | 98 | */ |
99 | 99 | function notEqq() { |
100 | - return apply(curry(function($a, $b){ |
|
100 | + return apply(curry(function($a, $b) { |
|
101 | 101 | return $a !== $b; |
102 | 102 | }), func_get_args()); |
103 | 103 | } |
@@ -140,9 +140,7 @@ discard block |
||
140 | 140 | return $a == $b; |
141 | 141 | case 'List': |
142 | 142 | $length = length($a); |
143 | - return length($b) != $length ? false : |
|
144 | - 0 == $length ? true : |
|
145 | - equals(head($a), head($b)) && equals(tail($a), tail($b)); |
|
143 | + return length($b) != $length ? false : 0 == $length ? true : equals(head($a), head($b)) && equals(tail($a), tail($b)); |
|
146 | 144 | case 'Array': |
147 | 145 | case 'ArrayObject': |
148 | 146 | case 'Object': |
@@ -162,7 +160,7 @@ discard block |
||
162 | 160 | * @return bool |
163 | 161 | */ |
164 | 162 | function lt() { |
165 | - return apply(curry(function($a, $b){ |
|
163 | + return apply(curry(function($a, $b) { |
|
166 | 164 | return $a < $b; |
167 | 165 | }), func_get_args()); |
168 | 166 | } |
@@ -176,7 +174,7 @@ discard block |
||
176 | 174 | * @return bool |
177 | 175 | */ |
178 | 176 | function lte() { |
179 | - return apply(curry(function($a, $b){ |
|
177 | + return apply(curry(function($a, $b) { |
|
180 | 178 | return $a <= $b; |
181 | 179 | }), func_get_args()); |
182 | 180 | } |
@@ -190,7 +188,7 @@ discard block |
||
190 | 188 | * @return bool |
191 | 189 | */ |
192 | 190 | function gt() { |
193 | - return apply(curry(function($a, $b){ |
|
191 | + return apply(curry(function($a, $b) { |
|
194 | 192 | return $a > $b; |
195 | 193 | }), func_get_args()); |
196 | 194 | } |
@@ -204,7 +202,7 @@ discard block |
||
204 | 202 | * @return bool |
205 | 203 | */ |
206 | 204 | function gte() { |
207 | - return apply(curry(function($a, $b){ |
|
205 | + return apply(curry(function($a, $b) { |
|
208 | 206 | return $a >= $b; |
209 | 207 | }), func_get_args()); |
210 | 208 | } |
@@ -8,14 +8,14 @@ |
||
8 | 8 | */ |
9 | 9 | class Placeholder { |
10 | 10 | private static $instance; |
11 | - private function __construct(){} |
|
11 | + private function __construct() {} |
|
12 | 12 | public static function get() |
13 | 13 | { |
14 | - if(static::$instance === null) |
|
14 | + if (static::$instance === null) |
|
15 | 15 | static::$instance = new Placeholder; |
16 | 16 | return static::$instance; |
17 | 17 | } |
18 | - public function __toString(){ |
|
18 | + public function __toString() { |
|
19 | 19 | return '__'; |
20 | 20 | } |
21 | 21 | } |
@@ -2,8 +2,7 @@ |
||
2 | 2 | |
3 | 3 | function numberOfArgs($fn) { |
4 | 4 | $reflector = is_array($fn) ? |
5 | - new ReflectionMethod($fn[0], $fn[1]) : |
|
6 | - new ReflectionFunction($fn); |
|
5 | + new ReflectionMethod($fn[0], $fn[1]) : new ReflectionFunction($fn); |
|
7 | 6 | return $reflector->getNumberOfParameters(); |
8 | 7 | } |
9 | 8 |