@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('any', function (callable $predicate, array $list): bool { |
|
6 | +P::macro('any', function(callable $predicate, array $list): bool { |
|
7 | 7 | foreach ($list as $value) { |
8 | 8 | if (true === $predicate($value)) { |
9 | 9 | return true; |
@@ -16,8 +16,8 @@ |
||
16 | 16 | * }; |
17 | 17 | * P::swap($serialize)(2, 1); // 'a:1,b:2' |
18 | 18 | */ |
19 | -P::macro('swap', function (callable $f): \Closure { |
|
20 | - return function ($second, $first, ...$tail) use ($f) { |
|
19 | +P::macro('swap', function(callable $f): \Closure { |
|
20 | + return function($second, $first, ...$tail) use ($f) { |
|
21 | 21 | $arguments = array_merge([$first, $second], $tail); |
22 | 22 | return $f(...$arguments); |
23 | 23 | }; |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('partial', function (callable $fn, array $args): \Closure { |
|
7 | - $mergeArguments = function (array $args, array $innerArgs) { |
|
6 | +P::macro('partial', function(callable $fn, array $args): \Closure { |
|
7 | + $mergeArguments = function(array $args, array $innerArgs) { |
|
8 | 8 | $mapped = []; |
9 | 9 | |
10 | 10 | foreach ($args as $value) { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | return array_merge($mapped, $innerArgs); |
19 | 19 | }; |
20 | 20 | |
21 | - return function (...$innerArgs) use ($fn, $args, $mergeArguments) { |
|
21 | + return function(...$innerArgs) use ($fn, $args, $mergeArguments) { |
|
22 | 22 | return $fn(...$mergeArguments($args, $innerArgs)); |
23 | 23 | }; |
24 | 24 | }); |
@@ -15,16 +15,16 @@ |
||
15 | 15 | * @return \Closure |
16 | 16 | * @throws \UnderflowException |
17 | 17 | */ |
18 | -P::macro('pipe', function (array $fns): \Closure { |
|
18 | +P::macro('pipe', function(array $fns): \Closure { |
|
19 | 19 | if (0 === count($fns)) { |
20 | 20 | throw new \UnderflowException('pipe requires at least one argument'); |
21 | 21 | } |
22 | 22 | |
23 | - return function (...$args) use ($fns) { |
|
23 | + return function(...$args) use ($fns) { |
|
24 | 24 | $head = $fns[0]; |
25 | 25 | $tail = array_slice($fns, 1); |
26 | 26 | |
27 | - return array_reduce($tail, function ($carry, callable $fn) { |
|
27 | + return array_reduce($tail, function($carry, callable $fn) { |
|
28 | 28 | return $fn($carry); |
29 | 29 | }, $head(... $args)); |
30 | 30 | }; |
@@ -16,12 +16,12 @@ |
||
16 | 16 | * $f(1, 100); // 4 |
17 | 17 | * $f(1, 100); // 4 |
18 | 18 | */ |
19 | -P::macro('once', function (callable $fn): \Closure { |
|
20 | - return function (... $args) use ($fn) { |
|
19 | +P::macro('once', function(callable $fn): \Closure { |
|
20 | + return function(... $args) use ($fn) { |
|
21 | 21 | static $result; |
22 | 22 | |
23 | 23 | if (false === is_object($result)) { |
24 | - $result = (object)['result' => $fn(... $args)]; |
|
24 | + $result = (object) ['result' => $fn(... $args)]; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | return $result->result; |
@@ -15,7 +15,7 @@ |
||
15 | 15 | * @return \Closure |
16 | 16 | * @throws \UnderflowException |
17 | 17 | */ |
18 | -P::macro('compose', function (array $fns): \Closure { |
|
18 | +P::macro('compose', function(array $fns): \Closure { |
|
19 | 19 | if (0 === count($fns)) { |
20 | 20 | throw new \UnderflowException('compose requires at least one argument'); |
21 | 21 | } |
@@ -3,8 +3,8 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('partialRight', function (callable $fn, array $args): \Closure { |
|
7 | - return function (...$innerArgs) use ($fn, $args) { |
|
6 | +P::macro('partialRight', function(callable $fn, array $args): \Closure { |
|
7 | + return function(...$innerArgs) use ($fn, $args) { |
|
8 | 8 | return $fn(...array_merge($innerArgs, $args)); |
9 | 9 | }; |
10 | 10 | }); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('tap', function (callable $fn, $value) { |
|
6 | +P::macro('tap', function(callable $fn, $value) { |
|
7 | 7 | $fn($value); |
8 | 8 | return $value; |
9 | 9 | }); |
@@ -3,7 +3,7 @@ |
||
3 | 3 | |
4 | 4 | use Baethon\Phln\Phln as P; |
5 | 5 | |
6 | -P::macro('invoker', function (int $arity, string $method): \Closure { |
|
6 | +P::macro('invoker', function(int $arity, string $method): \Closure { |
|
7 | 7 | $wrapper = function(...$args) use ($arity, $method) { |
8 | 8 | $args = array_slice($args, 0, $arity + 1); |
9 | 9 | $object = array_pop($args); |