@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | function add() |
| 11 | 11 | { |
| 12 | - $add = function ($firstValue, $secondValue) { |
|
| 12 | + $add = function($firstValue, $secondValue) { |
|
| 13 | 13 | return $firstValue + $secondValue; |
| 14 | 14 | }; |
| 15 | 15 | $arguments = func_get_args(); |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | */ |
| 26 | 26 | function divide() |
| 27 | 27 | { |
| 28 | - $divide = function ($firstValue, $secondValue) { |
|
| 28 | + $divide = function($firstValue, $secondValue) { |
|
| 29 | 29 | return $firstValue / $secondValue; |
| 30 | 30 | }; |
| 31 | 31 | $arguments = func_get_args(); |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function multiply() |
| 43 | 43 | { |
| 44 | - $multiply = function ($firstValue, $secondValue) { |
|
| 44 | + $multiply = function($firstValue, $secondValue) { |
|
| 45 | 45 | return $firstValue * $secondValue; |
| 46 | 46 | }; |
| 47 | 47 | $arguments = func_get_args(); |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | */ |
| 58 | 58 | function subtract() |
| 59 | 59 | { |
| 60 | - $subtract = function ($firstValue, $secondValue) { |
|
| 60 | + $subtract = function($firstValue, $secondValue) { |
|
| 61 | 61 | return $firstValue - $secondValue; |
| 62 | 62 | }; |
| 63 | 63 | $arguments = func_get_args(); |
@@ -7,8 +7,8 @@ discard block |
||
| 7 | 7 | */ |
| 8 | 8 | function always() |
| 9 | 9 | { |
| 10 | - $always = function ($data) { |
|
| 11 | - return function () use ($data) { |
|
| 10 | + $always = function($data) { |
|
| 11 | + return function() use ($data) { |
|
| 12 | 12 | return $data; |
| 13 | 13 | }; |
| 14 | 14 | }; |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function apply() |
| 26 | 26 | { |
| 27 | - $apply = function (callable $fn, array $args) { |
|
| 27 | + $apply = function(callable $fn, array $args) { |
|
| 28 | 28 | return call_user_func_array($fn, $args); |
| 29 | 29 | }; |
| 30 | 30 | $arguments = func_get_args(); |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | return __FUNCTION__; |
| 47 | 47 | case 1: |
| 48 | 48 | $fn = $arguments[0]; |
| 49 | - return function (...$arguments) use ($fn) { |
|
| 49 | + return function(...$arguments) use ($fn) { |
|
| 50 | 50 | return call_user_func_array($fn, $arguments); |
| 51 | 51 | }; |
| 52 | 52 | default: |
@@ -72,8 +72,8 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | function construct() |
| 74 | 74 | { |
| 75 | - $construct = function ($class) { |
|
| 76 | - return function () use ($class) { |
|
| 75 | + $construct = function($class) { |
|
| 76 | + return function() use ($class) { |
|
| 77 | 77 | return new $class(); |
| 78 | 78 | }; |
| 79 | 79 | }; |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | |
| 85 | 85 | function curryN(callable $fn, int $numberOfArguments) |
| 86 | 86 | { |
| 87 | - return function () use ($fn, $numberOfArguments) { |
|
| 87 | + return function() use ($fn, $numberOfArguments) { |
|
| 88 | 88 | $arguments = func_get_args(); |
| 89 | 89 | $length = count($arguments); |
| 90 | 90 | if ($length > $numberOfArguments) { |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return call_user_func_array($fn, $arguments); |
| 98 | 98 | } |
| 99 | 99 | // AUTO CURRY |
| 100 | - $curriedFn = function () use ($fn, $arguments) { |
|
| 100 | + $curriedFn = function() use ($fn, $arguments) { |
|
| 101 | 101 | $curriedArguments = func_get_args(); |
| 102 | 102 | return call_user_func_array($fn, array_merge($arguments, $curriedArguments)); |
| 103 | 103 | }; |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | */ |
| 114 | 114 | function partial(callable $fn, array $args) |
| 115 | 115 | { |
| 116 | - return function () use ($fn, $args) { |
|
| 116 | + return function() use ($fn, $args) { |
|
| 117 | 117 | $arguments = func_get_args(); |
| 118 | 118 | return call_user_func_array($fn, array_merge($args, $arguments)); |
| 119 | 119 | }; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | */ |
| 128 | 128 | function partialRight(callable $fn, array $args) |
| 129 | 129 | { |
| 130 | - return function () use ($fn, $args) { |
|
| 130 | + return function() use ($fn, $args) { |
|
| 131 | 131 | $arguments = func_get_args(); |
| 132 | 132 | return call_user_func_array($fn, array_merge($arguments, $args)); |
| 133 | 133 | }; |
@@ -144,10 +144,10 @@ discard block |
||
| 144 | 144 | if ($length === 0) { |
| 145 | 145 | throw new \Exception("pipe requires at least one argument"); |
| 146 | 146 | } |
| 147 | - return function () use ($arguments) { |
|
| 147 | + return function() use ($arguments) { |
|
| 148 | 148 | $internalArguments = func_get_args(); |
| 149 | 149 | $initialValue = call_user_func_array($arguments[0], $internalArguments); |
| 150 | - $accumulator = function ($acc, $it) { |
|
| 150 | + $accumulator = function($acc, $it) { |
|
| 151 | 151 | return call_user_func_array($it, [$acc]); |
| 152 | 152 | }; |
| 153 | 153 | return array_reduce(drop(0, $arguments), $accumulator, $initialValue); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function equals() |
| 10 | 10 | { |
| 11 | - $equals = function ($a, $b) { |
|
| 11 | + $equals = function($a, $b) { |
|
| 12 | 12 | return $a == $b; |
| 13 | 13 | }; |
| 14 | 14 | $arguments = func_get_args(); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | function gt() |
| 20 | 20 | { |
| 21 | - $gt = function ($a, $b) { |
|
| 21 | + $gt = function($a, $b) { |
|
| 22 | 22 | return $a > $b; |
| 23 | 23 | }; |
| 24 | 24 | $arguments = func_get_args(); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | function gte() |
| 30 | 30 | { |
| 31 | - $gte = function ($a, $b) { |
|
| 31 | + $gte = function($a, $b) { |
|
| 32 | 32 | return $a >= $b; |
| 33 | 33 | }; |
| 34 | 34 | $arguments = func_get_args(); |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | function lt() |
| 40 | 40 | { |
| 41 | - $lt = function ($a, $b) { |
|
| 41 | + $lt = function($a, $b) { |
|
| 42 | 42 | return $a < $b; |
| 43 | 43 | }; |
| 44 | 44 | $arguments = func_get_args(); |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | function lte() |
| 50 | 50 | { |
| 51 | - $lte = function ($a, $b) { |
|
| 51 | + $lte = function($a, $b) { |
|
| 52 | 52 | return $a <= $b; |
| 53 | 53 | }; |
| 54 | 54 | $arguments = func_get_args(); |
@@ -3,7 +3,7 @@ |
||
| 3 | 3 | |
| 4 | 4 | function defaultTo() |
| 5 | 5 | { |
| 6 | - $defaultTo = function ($defaultValue, $value) { |
|
| 6 | + $defaultTo = function($defaultValue, $value) { |
|
| 7 | 7 | return $value ? $value : $defaultValue; |
| 8 | 8 | }; |
| 9 | 9 | $arguments = func_get_args(); |
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | */ |
| 9 | 9 | function all() |
| 10 | 10 | { |
| 11 | - $all = function (callable $predicateFunction, array $array): bool { |
|
| 11 | + $all = function(callable $predicateFunction, array $array): bool { |
|
| 12 | 12 | if (empty($array)) { |
| 13 | 13 | return false; |
| 14 | 14 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function any() |
| 33 | 33 | { |
| 34 | - $any = function (callable $predicateFunction, array $array) { |
|
| 34 | + $any = function(callable $predicateFunction, array $array) { |
|
| 35 | 35 | if (empty($array)) { |
| 36 | 36 | return false; |
| 37 | 37 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | */ |
| 56 | 56 | function append() |
| 57 | 57 | { |
| 58 | - $append = function ($item, array $array) { |
|
| 58 | + $append = function($item, array $array) { |
|
| 59 | 59 | return array_merge($array, [$item]); |
| 60 | 60 | }; |
| 61 | 61 | $arguments = func_get_args(); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | function concat() |
| 73 | 73 | { |
| 74 | - $concat = function (array $firstArray, array $secondArray) { |
|
| 74 | + $concat = function(array $firstArray, array $secondArray) { |
|
| 75 | 75 | return array_merge($firstArray, $secondArray); |
| 76 | 76 | }; |
| 77 | 77 | $arguments = func_get_args(); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function drop() |
| 88 | 88 | { |
| 89 | - $drop = function (int $index, array $array) { |
|
| 89 | + $drop = function(int $index, array $array) { |
|
| 90 | 90 | return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1)); |
| 91 | 91 | }; |
| 92 | 92 | $arguments = func_get_args(); |
@@ -112,8 +112,8 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | function dropLast() |
| 114 | 114 | { |
| 115 | - $dropLast = function (array $array) { |
|
| 116 | - $index = count($array)-1; |
|
| 115 | + $dropLast = function(array $array) { |
|
| 116 | + $index = count($array) - 1; |
|
| 117 | 117 | return array_merge(array_slice($array, 0, $index), array_slice($array, $index + 1)); |
| 118 | 118 | }; |
| 119 | 119 | |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | */ |
| 130 | 130 | function filter() |
| 131 | 131 | { |
| 132 | - $filter = function (callable $predicateFunction, array $array) { |
|
| 132 | + $filter = function(callable $predicateFunction, array $array) { |
|
| 133 | 133 | return array_values(array_filter($array, $predicateFunction)); |
| 134 | 134 | }; |
| 135 | 135 | $arguments = func_get_args(); |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | */ |
| 145 | 145 | function filterPreserveKey() |
| 146 | 146 | { |
| 147 | - $filter = function (callable $predicateFunction, array $array) { |
|
| 147 | + $filter = function(callable $predicateFunction, array $array) { |
|
| 148 | 148 | return array_filter($array, $predicateFunction); |
| 149 | 149 | }; |
| 150 | 150 | $arguments = func_get_args(); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | |
| 155 | 155 | function first() |
| 156 | 156 | { |
| 157 | - $first = function (array $array) { |
|
| 157 | + $first = function(array $array) { |
|
| 158 | 158 | if (empty($array)) { |
| 159 | 159 | return null; |
| 160 | 160 | } |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | function head() |
| 169 | 169 | { |
| 170 | - $head = function (array $array) { |
|
| 170 | + $head = function(array $array) { |
|
| 171 | 171 | if (empty($array)) { |
| 172 | 172 | return null; |
| 173 | 173 | } |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | |
| 181 | 181 | function last() |
| 182 | 182 | { |
| 183 | - $last = function (array $array) { |
|
| 183 | + $last = function(array $array) { |
|
| 184 | 184 | if (empty($array)) { |
| 185 | 185 | return null; |
| 186 | 186 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | */ |
| 212 | 212 | function prepend() |
| 213 | 213 | { |
| 214 | - $prepend = function ($item, array $array) { |
|
| 214 | + $prepend = function($item, array $array) { |
|
| 215 | 215 | return array_merge([$item], $array); |
| 216 | 216 | }; |
| 217 | 217 | $arguments = func_get_args(); |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | */ |
| 228 | 228 | function reduce() |
| 229 | 229 | { |
| 230 | - $reduce = function (callable $accumulator, $initialValue, array $array) { |
|
| 230 | + $reduce = function(callable $accumulator, $initialValue, array $array) { |
|
| 231 | 231 | return array_reduce($array, $accumulator, $initialValue); |
| 232 | 232 | }; |
| 233 | 233 | $arguments = func_get_args(); |
@@ -237,7 +237,7 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | function tail() |
| 239 | 239 | { |
| 240 | - $tail = function (array $array) { |
|
| 240 | + $tail = function(array $array) { |
|
| 241 | 241 | if (empty($array)) { |
| 242 | 242 | return null; |
| 243 | 243 | } |