@@ -82,8 +82,6 @@ discard block |
||
| 82 | 82 | * ``` |
| 83 | 83 | * |
| 84 | 84 | * @signature (*... -> a) -> [*] -> a |
| 85 | - * @param callable $fn |
|
| 86 | - * @param array $args |
|
| 87 | 85 | * @return mixed |
| 88 | 86 | */ |
| 89 | 87 | function apply() { |
@@ -107,7 +105,6 @@ discard block |
||
| 107 | 105 | * ``` |
| 108 | 106 | * |
| 109 | 107 | * @signature (((a, b, ...) -> o), (o -> p), ..., (y -> z)) -> ((a, b, ...) -> z) |
| 110 | - * @param callable $fns... |
|
| 111 | 108 | * @return callable |
| 112 | 109 | */ |
| 113 | 110 | function pipe() { |
@@ -138,7 +135,6 @@ discard block |
||
| 138 | 135 | * ``` |
| 139 | 136 | * |
| 140 | 137 | * @signature (((a, b, ...) -> o), (o -> p), ..., (y -> z)) -> ((a, b, ...) -> z) |
| 141 | - * @param callable $fns... |
|
| 142 | 138 | * @return callable |
| 143 | 139 | */ |
| 144 | 140 | function compose() { |
@@ -186,7 +182,6 @@ discard block |
||
| 186 | 182 | * ``` |
| 187 | 183 | * |
| 188 | 184 | * @signature a -> (* -> a) |
| 189 | - * @param mixed $value |
|
| 190 | 185 | * @return callable |
| 191 | 186 | */ |
| 192 | 187 | function give() { |
@@ -215,7 +210,6 @@ discard block |
||
| 215 | 210 | * ``` |
| 216 | 211 | * |
| 217 | 212 | * @signature ((a -> Boolean), ..., (a -> Boolean)) -> (a -> Boolean) |
| 218 | - * @param callable $predicates... |
|
| 219 | 213 | * @return callable |
| 220 | 214 | */ |
| 221 | 215 | function all() { |
@@ -249,7 +243,6 @@ discard block |
||
| 249 | 243 | * ``` |
| 250 | 244 | * |
| 251 | 245 | * @signature ((a -> Boolean), ..., (a -> Boolean)) -> (a -> Boolean) |
| 252 | - * @param callable $predicates... |
|
| 253 | 246 | * @return callable |
| 254 | 247 | */ |
| 255 | 248 | function any() { |
@@ -280,7 +273,6 @@ discard block |
||
| 280 | 273 | * ``` |
| 281 | 274 | * |
| 282 | 275 | * @signature (* -> ... -> *) -> (* -> ... -> Boolean) |
| 283 | - * @param callable $fn |
|
| 284 | 276 | * @return callable |
| 285 | 277 | */ |
| 286 | 278 | function complement() { |
@@ -313,7 +305,6 @@ discard block |
||
| 313 | 305 | * ``` |
| 314 | 306 | * |
| 315 | 307 | * @signature (a -> a -> Boolean) -> (a -> a -> Number) |
| 316 | - * @param callable $fn |
|
| 317 | 308 | * @return callable |
| 318 | 309 | */ |
| 319 | 310 | function comparator() { |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function curry($fn) { |
| 39 | 39 | $n = _number_of_args($fn); |
| 40 | - switch($n) { |
|
| 40 | + switch ($n) { |
|
| 41 | 41 | case 0: return $fn; |
| 42 | 42 | case 1: return _curry_one($fn); |
| 43 | 43 | case 2: return _curry_two($fn); |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function pipe() { |
| 114 | 114 | $fns = func_get_args(); |
| 115 | - if(count($fns) < 1) |
|
| 115 | + if (count($fns) < 1) |
|
| 116 | 116 | return identity(); |
| 117 | - return function () use ($fns) { |
|
| 117 | + return function() use ($fns) { |
|
| 118 | 118 | $result = _apply(array_shift($fns), func_get_args()); |
| 119 | 119 | foreach ($fns as $fn) { |
| 120 | 120 | $result = $fn($result); |
@@ -143,9 +143,9 @@ discard block |
||
| 143 | 143 | */ |
| 144 | 144 | function compose() { |
| 145 | 145 | $fns = array_reverse(func_get_args()); |
| 146 | - if(count($fns) < 1) |
|
| 146 | + if (count($fns) < 1) |
|
| 147 | 147 | return identity(); |
| 148 | - return function () use ($fns) { |
|
| 148 | + return function() use ($fns) { |
|
| 149 | 149 | $result = _apply(array_shift($fns), func_get_args()); |
| 150 | 150 | foreach ($fns as $fn) { |
| 151 | 151 | $result = $fn($result); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | $predicates = func_get_args(); |
| 223 | 223 | return _curry_one(function($value) use(&$predicates) { |
| 224 | 224 | foreach ($predicates as $predicate) { |
| 225 | - if (! $predicate($value)) |
|
| 225 | + if (!$predicate($value)) |
|
| 226 | 226 | return false; |
| 227 | 227 | } |
| 228 | 228 | return true; |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | static $comparator = false; |
| 321 | 321 | $comparator = $comparator ?: curry(function($fn) { |
| 322 | 322 | return function($a, $b) use($fn) { |
| 323 | - if ($fn($a, $b)) return -1; |
|
| 323 | + if ($fn($a, $b)) return - 1; |
|
| 324 | 324 | if ($fn($b, $a)) return 1; |
| 325 | 325 | return 0; |
| 326 | 326 | }; |
@@ -112,8 +112,9 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function pipe() { |
| 114 | 114 | $fns = func_get_args(); |
| 115 | - if(count($fns) < 1) |
|
| 116 | - return identity(); |
|
| 115 | + if(count($fns) < 1) { |
|
| 116 | + return identity(); |
|
| 117 | + } |
|
| 117 | 118 | return function () use ($fns) { |
| 118 | 119 | $result = _apply(array_shift($fns), func_get_args()); |
| 119 | 120 | foreach ($fns as $fn) { |
@@ -143,8 +144,9 @@ discard block |
||
| 143 | 144 | */ |
| 144 | 145 | function compose() { |
| 145 | 146 | $fns = array_reverse(func_get_args()); |
| 146 | - if(count($fns) < 1) |
|
| 147 | - return identity(); |
|
| 147 | + if(count($fns) < 1) { |
|
| 148 | + return identity(); |
|
| 149 | + } |
|
| 148 | 150 | return function () use ($fns) { |
| 149 | 151 | $result = _apply(array_shift($fns), func_get_args()); |
| 150 | 152 | foreach ($fns as $fn) { |
@@ -222,8 +224,9 @@ discard block |
||
| 222 | 224 | $predicates = func_get_args(); |
| 223 | 225 | return _curry_one(function($value) use(&$predicates) { |
| 224 | 226 | foreach ($predicates as $predicate) { |
| 225 | - if (! $predicate($value)) |
|
| 226 | - return false; |
|
| 227 | + if (! $predicate($value)) { |
|
| 228 | + return false; |
|
| 229 | + } |
|
| 227 | 230 | } |
| 228 | 231 | return true; |
| 229 | 232 | }); |
@@ -256,8 +259,9 @@ discard block |
||
| 256 | 259 | $predicates = func_get_args(); |
| 257 | 260 | return _curry_one(function($value) use(&$predicates) { |
| 258 | 261 | foreach ($predicates as $predicate) { |
| 259 | - if ($predicate($value)) |
|
| 260 | - return true; |
|
| 262 | + if ($predicate($value)) { |
|
| 263 | + return true; |
|
| 264 | + } |
|
| 261 | 265 | } |
| 262 | 266 | return false; |
| 263 | 267 | }); |
@@ -320,8 +324,12 @@ discard block |
||
| 320 | 324 | static $comparator = false; |
| 321 | 325 | $comparator = $comparator ?: curry(function($fn) { |
| 322 | 326 | return function($a, $b) use($fn) { |
| 323 | - if ($fn($a, $b)) return -1; |
|
| 324 | - if ($fn($b, $a)) return 1; |
|
| 327 | + if ($fn($a, $b)) { |
|
| 328 | + return -1; |
|
| 329 | + } |
|
| 330 | + if ($fn($b, $a)) { |
|
| 331 | + return 1; |
|
| 332 | + } |
|
| 325 | 333 | return 0; |
| 326 | 334 | }; |
| 327 | 335 | }); |