@@ -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()); |
@@ -184,17 +184,20 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | function _equals($a, $b) { |
| 186 | 186 | $type = type($a); |
| 187 | - if ($type != type($b)) |
|
| 188 | - return false; |
|
| 187 | + if ($type != type($b)) { |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 189 | 190 | switch ($type) { |
| 190 | 191 | case 'List': |
| 191 | 192 | $length = count($a); |
| 192 | - if (count($b) != $length) |
|
| 193 | - return false; |
|
| 193 | + if (count($b) != $length) { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 194 | 196 | $index = 0; |
| 195 | 197 | while ($index < $length) { |
| 196 | - if (!_equals($a[$index], $b[$index])) |
|
| 197 | - return false; |
|
| 198 | + if (!_equals($a[$index], $b[$index])) { |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 198 | 201 | $index ++; |
| 199 | 202 | } |
| 200 | 203 | return true; |
@@ -204,14 +207,17 @@ discard block |
||
| 204 | 207 | $keysA = keys($a); |
| 205 | 208 | $keysB = keys($b); |
| 206 | 209 | $length = count($keysA); |
| 207 | - if (count($keysB) != $length) |
|
| 208 | - return false; |
|
| 210 | + if (count($keysB) != $length) { |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 209 | 213 | $index = 0; |
| 210 | 214 | while ($index < $length) { |
| 211 | - if (!_equals($keysA[$index], $keysB[$index])) |
|
| 212 | - return false; |
|
| 213 | - if (!_equals(get($keysA[$index], $a), get($keysB[$index], $b))) |
|
| 214 | - return false; |
|
| 215 | + if (!_equals($keysA[$index], $keysB[$index])) { |
|
| 216 | + return false; |
|
| 217 | + } |
|
| 218 | + if (!_equals(get($keysA[$index], $a), get($keysB[$index], $b))) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 215 | 221 | $index ++; |
| 216 | 222 | } |
| 217 | 223 | return true; |
@@ -16,8 +16,6 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @stream |
| 18 | 18 | * @signature Boolean -> Boolean -> Boolean |
| 19 | - * @param bool $a |
|
| 20 | - * @param bool $b |
|
| 21 | 19 | * @return bool |
| 22 | 20 | */ |
| 23 | 21 | function and_() { |
@@ -39,8 +37,6 @@ discard block |
||
| 39 | 37 | * |
| 40 | 38 | * @stream |
| 41 | 39 | * @signature Boolean -> Boolean -> Boolean |
| 42 | - * @param bool $a |
|
| 43 | - * @param bool $b |
|
| 44 | 40 | * @return bool |
| 45 | 41 | */ |
| 46 | 42 | function or_() { |
@@ -60,7 +56,6 @@ discard block |
||
| 60 | 56 | * |
| 61 | 57 | * @stream |
| 62 | 58 | * @signature Boolean -> Boolean |
| 63 | - * @param bool $x |
|
| 64 | 59 | * @return bool |
| 65 | 60 | */ |
| 66 | 61 | function not() { |
@@ -80,8 +75,6 @@ discard block |
||
| 80 | 75 | * |
| 81 | 76 | * @stream |
| 82 | 77 | * @signature * -> * -> Boolean |
| 83 | - * @param mixed $a |
|
| 84 | - * @param mixed $b |
|
| 85 | 78 | * @return bool |
| 86 | 79 | */ |
| 87 | 80 | function eq() { |
@@ -100,8 +93,6 @@ discard block |
||
| 100 | 93 | * |
| 101 | 94 | * @stream |
| 102 | 95 | * @signature * -> * -> Boolean |
| 103 | - * @param mixed $a |
|
| 104 | - * @param mixed $b |
|
| 105 | 96 | * @return bool |
| 106 | 97 | */ |
| 107 | 98 | function notEq() { |
@@ -120,8 +111,6 @@ discard block |
||
| 120 | 111 | * ``` |
| 121 | 112 | * @stream |
| 122 | 113 | * @signature * -> * -> Boolean |
| 123 | - * @param mixed $a |
|
| 124 | - * @param mixed $b |
|
| 125 | 114 | * @return bool |
| 126 | 115 | */ |
| 127 | 116 | function eqq() { |
@@ -141,8 +130,6 @@ discard block |
||
| 141 | 130 | * |
| 142 | 131 | * @stream |
| 143 | 132 | * @signature * -> * -> Boolean |
| 144 | - * @param mixed $a |
|
| 145 | - * @param mixed $b |
|
| 146 | 133 | * @return bool |
| 147 | 134 | */ |
| 148 | 135 | function notEqq() { |
@@ -173,8 +160,6 @@ discard block |
||
| 173 | 160 | * |
| 174 | 161 | * @stream |
| 175 | 162 | * @signature * -> * -> Boolean |
| 176 | - * @param mixed $a |
|
| 177 | - * @param mixed $b |
|
| 178 | 163 | * @return bool |
| 179 | 164 | */ |
| 180 | 165 | function equals() { |
@@ -258,8 +243,6 @@ discard block |
||
| 258 | 243 | * |
| 259 | 244 | * @stream |
| 260 | 245 | * @signature * -> * -> Boolean |
| 261 | - * @param mixed $a |
|
| 262 | - * @param mixed $b |
|
| 263 | 246 | * @return bool |
| 264 | 247 | */ |
| 265 | 248 | function lt() { |
@@ -280,8 +263,6 @@ discard block |
||
| 280 | 263 | * |
| 281 | 264 | * @stream |
| 282 | 265 | * @signature * -> * -> Boolean |
| 283 | - * @param mixed $a |
|
| 284 | - * @param mixed $b |
|
| 285 | 266 | * @return bool |
| 286 | 267 | */ |
| 287 | 268 | function lte() { |
@@ -302,8 +283,6 @@ discard block |
||
| 302 | 283 | * |
| 303 | 284 | * @stream |
| 304 | 285 | * @signature * -> * -> Boolean |
| 305 | - * @param mixed $a |
|
| 306 | - * @param mixed $b |
|
| 307 | 286 | * @return bool |
| 308 | 287 | */ |
| 309 | 288 | function gt() { |
@@ -324,8 +303,6 @@ discard block |
||
| 324 | 303 | * |
| 325 | 304 | * @stream |
| 326 | 305 | * @signature * -> * -> Boolean |
| 327 | - * @param mixed $a |
|
| 328 | - * @param mixed $b |
|
| 329 | 306 | * @return bool |
| 330 | 307 | */ |
| 331 | 308 | function gte() { |
@@ -3,127 +3,127 @@ |
||
| 3 | 3 | use Tarsana\Functional as F; |
| 4 | 4 | |
| 5 | 5 | return F\map(F\apply(F\_f('_stream_operation')), [ |
| 6 | - ['then', 'Function -> Any -> Any', F\_f('_stream_then')], |
|
| 7 | - ['and', 'Boolean -> Boolean -> Boolean', F\and_()], |
|
| 8 | - ['or', 'Boolean -> Boolean -> Boolean', F\or_()], |
|
| 9 | - ['not', 'Boolean -> Boolean', F\not()], |
|
| 10 | - ['eq', 'Any -> Any -> Boolean', F\eq()], |
|
| 11 | - ['notEq', 'Any -> Any -> Boolean', F\notEq()], |
|
| 12 | - ['eqq', 'Any -> Any -> Boolean', F\eqq()], |
|
| 13 | - ['notEqq', 'Any -> Any -> Boolean', F\notEqq()], |
|
| 14 | - ['equals', 'Any -> Any -> Boolean', F\equals()], |
|
| 15 | - ['equalBy', 'Function -> Any -> Any -> Boolean', F\equalBy()], |
|
| 16 | - ['lt', 'Any -> Any -> Boolean', F\lt()], |
|
| 17 | - ['lte', 'Any -> Any -> Boolean', F\lte()], |
|
| 18 | - ['gt', 'Any -> Any -> Boolean', F\gt()], |
|
| 19 | - ['gte', 'Any -> Any -> Boolean', F\gte()], |
|
| 20 | - ['is', 'String -> Any -> Boolean', F\is()], |
|
| 21 | - ['toString', 'Any -> String', F\toString()], |
|
| 22 | - ['attributes', 'Object|Array -> Object|Array', F\attributes()], |
|
| 23 | - ['keys', 'List -> List', F\keys()], |
|
| 24 | - ['keys', 'Object|Array -> List', F\keys()], |
|
| 25 | - ['values', 'List -> List', F\values()], |
|
| 26 | - ['values', 'Object|Array -> List', F\values()], |
|
| 27 | - ['has', 'Any -> Object|Array -> Boolean', F\has()], |
|
| 28 | - ['get', 'Any -> Object|Array -> Any', F\get()], |
|
| 29 | - ['getPath', 'List -> Object|Array -> Any', F\getPath()], |
|
| 30 | - ['set', 'Any -> Any -> Object|Array -> Object|Array', F\set()], |
|
| 31 | - ['update', 'Any -> Function -> Object|Array -> Object|Array', F\update()], |
|
| 32 | - ['satisfies', 'Function -> Any -> Object|Array -> Boolean', F\satisfies()], |
|
| 33 | - ['satisfiesAll', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAll()], |
|
| 34 | - ['satisfiesAny', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAny()], |
|
| 35 | - ['toPairs', 'Object|Array -> List', F\toPairs()], |
|
| 36 | - ['toPairs', 'List -> List', F\toPairs()], |
|
| 37 | - ['split', 'String -> String -> List', F\split()], |
|
| 38 | - ['join', 'String -> List -> String', F\join()], |
|
| 39 | - ['replace', 'String|List -> String|List -> String -> String', F\replace()], |
|
| 40 | - ['regReplace', 'String -> String -> String -> String', F\regReplace()], |
|
| 41 | - ['upperCase', 'String -> String', F\upperCase()], |
|
| 42 | - ['lowerCase', 'String -> String', F\lowerCase()], |
|
| 43 | - ['camelCase', 'String -> String', F\camelCase()], |
|
| 44 | - ['snakeCase', 'String -> String -> String', F\snakeCase()], |
|
| 45 | - ['startsWith', 'String -> String -> Boolean', F\startsWith()], |
|
| 46 | - ['endsWith', 'String -> String -> Boolean', F\endsWith()], |
|
| 47 | - ['test', 'String -> String -> Boolean', F\test()], |
|
| 48 | - ['match', 'String -> String -> List', F\match()], |
|
| 49 | - ['occurences', 'String -> String -> Number', F\occurences()], |
|
| 50 | - ['chunks', 'String -> String -> String -> List', F\chunks()], |
|
| 51 | - ['map', 'Function -> List -> List', F\map()], |
|
| 52 | - ['map', 'Function -> Object|Array -> Object|Array', F\map()], |
|
| 53 | - ['chain', 'Function -> List -> List', F\chain()], |
|
| 54 | - ['filter', 'Function -> List -> List', F\filter()], |
|
| 55 | - ['reduce', 'Function -> Any -> List -> Any', F\reduce()], |
|
| 56 | - ['each', 'Function -> List -> List', F\each()], |
|
| 57 | - ['head', 'List -> Any', F\head()], |
|
| 58 | - ['head', 'String -> String', F\head()], |
|
| 59 | - ['last', 'List -> Any', F\last()], |
|
| 60 | - ['last', 'String -> String', F\last()], |
|
| 61 | - ['init', 'List -> Any', F\init()], |
|
| 62 | - ['init', 'String -> String', F\init()], |
|
| 63 | - ['tail', 'List -> Any', F\tail()], |
|
| 64 | - ['tail', 'String -> String', F\tail()], |
|
| 65 | - ['reverse', 'List -> List', F\reverse()], |
|
| 66 | - ['reverse', 'String -> String', F\reverse()], |
|
| 67 | - ['length', 'List -> Number', F\length()], |
|
| 68 | - ['length', 'String -> Number', F\length()], |
|
| 69 | - ['allSatisfies', 'Function -> List -> Boolean', F\allSatisfies()], |
|
| 70 | - ['anySatisfies', 'Function -> List -> Boolean', F\anySatisfies()], |
|
| 71 | - ['concat', 'List -> List -> List', F\concat()], |
|
| 72 | - ['concat', 'String -> String -> String', F\concat()], |
|
| 73 | - ['concatAll', 'List -> List', F\concatAll()], |
|
| 74 | - ['insert', 'Number -> Any -> List -> List', F\insert()], |
|
| 75 | - ['insert', 'Number -> String -> String -> String', F\insert()], |
|
| 76 | - ['insertAll', 'Number -> List -> List -> List', F\insertAll()], |
|
| 77 | - ['insertAll', 'Number -> String -> String -> String', F\insertAll()], |
|
| 78 | - ['append', 'Any -> List -> List', F\append()], |
|
| 79 | - ['append', 'String -> String -> String', F\append()], |
|
| 80 | - ['prepend', 'Any -> List -> List', F\prepend()], |
|
| 81 | - ['prepend', 'String -> String -> String', F\prepend()], |
|
| 82 | - ['take', 'Number -> List -> List', F\take()], |
|
| 83 | - ['take', 'Number -> String -> String', F\take()], |
|
| 84 | - ['takeWhile', 'Function -> List -> List', F\takeWhile()], |
|
| 85 | - ['takeLastWhile', 'Function -> List -> List', F\takeLastWhile()], |
|
| 86 | - ['takeUntil', 'Function -> List -> List', F\takeUntil()], |
|
| 87 | - ['takeLastUntil', 'Function -> List -> List', F\takeLastUntil()], |
|
| 88 | - ['remove', 'Number -> List -> List', F\remove()], |
|
| 89 | - ['remove', 'Number -> String -> String', F\remove()], |
|
| 90 | - ['removeWhile', 'Function -> List -> List', F\removeWhile()], |
|
| 91 | - ['removeLastWhile', 'Function -> List -> List', F\removeLastWhile()], |
|
| 92 | - ['removeUntil', 'Function -> List -> List', F\removeUntil()], |
|
| 93 | - ['removeLastUntil', 'Function -> List -> List', F\removeLastUntil()], |
|
| 94 | - ['fromPairs', 'List -> Object|Array', F\fromPairs()], |
|
| 95 | - ['slices', 'Number -> List -> List', F\slices()], |
|
| 96 | - ['slices', 'Number -> String -> List', F\slices()], |
|
| 97 | - ['contains', 'Any -> List -> Boolean', F\contains()], |
|
| 98 | - ['contains', 'String -> String -> Boolean', F\contains()], |
|
| 99 | - ['findIndex', 'Function -> List -> Number|Null', F\findIndex()], |
|
| 100 | - ['findIndex', 'Function -> Object|Array -> Any', F\findIndex()], |
|
| 101 | - ['findLastIndex', 'Function -> List -> Number|Null', F\findLastIndex()], |
|
| 102 | - ['findLastIndex', 'Function -> Object|Array -> Any', F\findLastIndex()], |
|
| 103 | - ['find', 'Function -> List -> Any', F\find()], |
|
| 104 | - ['findLast', 'Function -> List -> Any', F\findLast()], |
|
| 105 | - ['indexOf', 'Any -> List -> Number', F\indexOf()], |
|
| 106 | - ['indexOf', 'Any -> Object|Array -> Any', F\indexOf()], |
|
| 107 | - ['indexOf', 'String -> String -> Number', F\indexOf()], |
|
| 108 | - ['lastIndexOf', 'Any -> List -> Number', F\lastIndexOf()], |
|
| 109 | - ['lastIndexOf', 'Any -> Object|Array -> Any', F\lastIndexOf()], |
|
| 110 | - ['lastIndexOf', 'String -> String -> Number', F\lastIndexOf()], |
|
| 111 | - ['uniqueBy', 'Function -> List -> List', F\uniqueBy()], |
|
| 112 | - ['unique', 'List -> List', F\unique()], |
|
| 113 | - ['groupBy', 'Function -> List -> Object|Array', F\groupBy()], |
|
| 114 | - ['pairsFrom', 'List -> List -> List', F\pairsFrom()], |
|
| 115 | - ['sort', 'Function -> List -> List', F\sort()], |
|
| 116 | - ['plus', 'Number -> Number -> Number', F\plus()], |
|
| 117 | - ['minus', 'Number -> Number -> Number', F\minus()], |
|
| 118 | - ['negate', 'Number -> Number', F\negate()], |
|
| 119 | - ['multiply', 'Number -> Number -> Number', F\multiply()], |
|
| 120 | - ['divide', 'Number -> Number -> Number', F\divide()], |
|
| 121 | - ['modulo', 'Number -> Number -> Number', F\modulo()], |
|
| 122 | - ['sum', 'List -> Number', F\sum()], |
|
| 123 | - ['product', 'List -> Number', F\product()], |
|
| 124 | - ['min', 'Number -> Number -> Number', F\min()], |
|
| 125 | - ['minBy', 'Function -> Any -> Any -> Any', F\minBy()], |
|
| 126 | - ['max', 'Number -> Number -> Number', F\max()], |
|
| 127 | - ['maxBy', 'Function -> Any -> Any -> Any', F\maxBy()], |
|
| 6 | + ['then', 'Function -> Any -> Any', F\_f('_stream_then')], |
|
| 7 | + ['and', 'Boolean -> Boolean -> Boolean', F\and_()], |
|
| 8 | + ['or', 'Boolean -> Boolean -> Boolean', F\or_()], |
|
| 9 | + ['not', 'Boolean -> Boolean', F\not()], |
|
| 10 | + ['eq', 'Any -> Any -> Boolean', F\eq()], |
|
| 11 | + ['notEq', 'Any -> Any -> Boolean', F\notEq()], |
|
| 12 | + ['eqq', 'Any -> Any -> Boolean', F\eqq()], |
|
| 13 | + ['notEqq', 'Any -> Any -> Boolean', F\notEqq()], |
|
| 14 | + ['equals', 'Any -> Any -> Boolean', F\equals()], |
|
| 15 | + ['equalBy', 'Function -> Any -> Any -> Boolean', F\equalBy()], |
|
| 16 | + ['lt', 'Any -> Any -> Boolean', F\lt()], |
|
| 17 | + ['lte', 'Any -> Any -> Boolean', F\lte()], |
|
| 18 | + ['gt', 'Any -> Any -> Boolean', F\gt()], |
|
| 19 | + ['gte', 'Any -> Any -> Boolean', F\gte()], |
|
| 20 | + ['is', 'String -> Any -> Boolean', F\is()], |
|
| 21 | + ['toString', 'Any -> String', F\toString()], |
|
| 22 | + ['attributes', 'Object|Array -> Object|Array', F\attributes()], |
|
| 23 | + ['keys', 'List -> List', F\keys()], |
|
| 24 | + ['keys', 'Object|Array -> List', F\keys()], |
|
| 25 | + ['values', 'List -> List', F\values()], |
|
| 26 | + ['values', 'Object|Array -> List', F\values()], |
|
| 27 | + ['has', 'Any -> Object|Array -> Boolean', F\has()], |
|
| 28 | + ['get', 'Any -> Object|Array -> Any', F\get()], |
|
| 29 | + ['getPath', 'List -> Object|Array -> Any', F\getPath()], |
|
| 30 | + ['set', 'Any -> Any -> Object|Array -> Object|Array', F\set()], |
|
| 31 | + ['update', 'Any -> Function -> Object|Array -> Object|Array', F\update()], |
|
| 32 | + ['satisfies', 'Function -> Any -> Object|Array -> Boolean', F\satisfies()], |
|
| 33 | + ['satisfiesAll', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAll()], |
|
| 34 | + ['satisfiesAny', 'Object|Array -> Object|Array -> Boolean', F\satisfiesAny()], |
|
| 35 | + ['toPairs', 'Object|Array -> List', F\toPairs()], |
|
| 36 | + ['toPairs', 'List -> List', F\toPairs()], |
|
| 37 | + ['split', 'String -> String -> List', F\split()], |
|
| 38 | + ['join', 'String -> List -> String', F\join()], |
|
| 39 | + ['replace', 'String|List -> String|List -> String -> String', F\replace()], |
|
| 40 | + ['regReplace', 'String -> String -> String -> String', F\regReplace()], |
|
| 41 | + ['upperCase', 'String -> String', F\upperCase()], |
|
| 42 | + ['lowerCase', 'String -> String', F\lowerCase()], |
|
| 43 | + ['camelCase', 'String -> String', F\camelCase()], |
|
| 44 | + ['snakeCase', 'String -> String -> String', F\snakeCase()], |
|
| 45 | + ['startsWith', 'String -> String -> Boolean', F\startsWith()], |
|
| 46 | + ['endsWith', 'String -> String -> Boolean', F\endsWith()], |
|
| 47 | + ['test', 'String -> String -> Boolean', F\test()], |
|
| 48 | + ['match', 'String -> String -> List', F\match()], |
|
| 49 | + ['occurences', 'String -> String -> Number', F\occurences()], |
|
| 50 | + ['chunks', 'String -> String -> String -> List', F\chunks()], |
|
| 51 | + ['map', 'Function -> List -> List', F\map()], |
|
| 52 | + ['map', 'Function -> Object|Array -> Object|Array', F\map()], |
|
| 53 | + ['chain', 'Function -> List -> List', F\chain()], |
|
| 54 | + ['filter', 'Function -> List -> List', F\filter()], |
|
| 55 | + ['reduce', 'Function -> Any -> List -> Any', F\reduce()], |
|
| 56 | + ['each', 'Function -> List -> List', F\each()], |
|
| 57 | + ['head', 'List -> Any', F\head()], |
|
| 58 | + ['head', 'String -> String', F\head()], |
|
| 59 | + ['last', 'List -> Any', F\last()], |
|
| 60 | + ['last', 'String -> String', F\last()], |
|
| 61 | + ['init', 'List -> Any', F\init()], |
|
| 62 | + ['init', 'String -> String', F\init()], |
|
| 63 | + ['tail', 'List -> Any', F\tail()], |
|
| 64 | + ['tail', 'String -> String', F\tail()], |
|
| 65 | + ['reverse', 'List -> List', F\reverse()], |
|
| 66 | + ['reverse', 'String -> String', F\reverse()], |
|
| 67 | + ['length', 'List -> Number', F\length()], |
|
| 68 | + ['length', 'String -> Number', F\length()], |
|
| 69 | + ['allSatisfies', 'Function -> List -> Boolean', F\allSatisfies()], |
|
| 70 | + ['anySatisfies', 'Function -> List -> Boolean', F\anySatisfies()], |
|
| 71 | + ['concat', 'List -> List -> List', F\concat()], |
|
| 72 | + ['concat', 'String -> String -> String', F\concat()], |
|
| 73 | + ['concatAll', 'List -> List', F\concatAll()], |
|
| 74 | + ['insert', 'Number -> Any -> List -> List', F\insert()], |
|
| 75 | + ['insert', 'Number -> String -> String -> String', F\insert()], |
|
| 76 | + ['insertAll', 'Number -> List -> List -> List', F\insertAll()], |
|
| 77 | + ['insertAll', 'Number -> String -> String -> String', F\insertAll()], |
|
| 78 | + ['append', 'Any -> List -> List', F\append()], |
|
| 79 | + ['append', 'String -> String -> String', F\append()], |
|
| 80 | + ['prepend', 'Any -> List -> List', F\prepend()], |
|
| 81 | + ['prepend', 'String -> String -> String', F\prepend()], |
|
| 82 | + ['take', 'Number -> List -> List', F\take()], |
|
| 83 | + ['take', 'Number -> String -> String', F\take()], |
|
| 84 | + ['takeWhile', 'Function -> List -> List', F\takeWhile()], |
|
| 85 | + ['takeLastWhile', 'Function -> List -> List', F\takeLastWhile()], |
|
| 86 | + ['takeUntil', 'Function -> List -> List', F\takeUntil()], |
|
| 87 | + ['takeLastUntil', 'Function -> List -> List', F\takeLastUntil()], |
|
| 88 | + ['remove', 'Number -> List -> List', F\remove()], |
|
| 89 | + ['remove', 'Number -> String -> String', F\remove()], |
|
| 90 | + ['removeWhile', 'Function -> List -> List', F\removeWhile()], |
|
| 91 | + ['removeLastWhile', 'Function -> List -> List', F\removeLastWhile()], |
|
| 92 | + ['removeUntil', 'Function -> List -> List', F\removeUntil()], |
|
| 93 | + ['removeLastUntil', 'Function -> List -> List', F\removeLastUntil()], |
|
| 94 | + ['fromPairs', 'List -> Object|Array', F\fromPairs()], |
|
| 95 | + ['slices', 'Number -> List -> List', F\slices()], |
|
| 96 | + ['slices', 'Number -> String -> List', F\slices()], |
|
| 97 | + ['contains', 'Any -> List -> Boolean', F\contains()], |
|
| 98 | + ['contains', 'String -> String -> Boolean', F\contains()], |
|
| 99 | + ['findIndex', 'Function -> List -> Number|Null', F\findIndex()], |
|
| 100 | + ['findIndex', 'Function -> Object|Array -> Any', F\findIndex()], |
|
| 101 | + ['findLastIndex', 'Function -> List -> Number|Null', F\findLastIndex()], |
|
| 102 | + ['findLastIndex', 'Function -> Object|Array -> Any', F\findLastIndex()], |
|
| 103 | + ['find', 'Function -> List -> Any', F\find()], |
|
| 104 | + ['findLast', 'Function -> List -> Any', F\findLast()], |
|
| 105 | + ['indexOf', 'Any -> List -> Number', F\indexOf()], |
|
| 106 | + ['indexOf', 'Any -> Object|Array -> Any', F\indexOf()], |
|
| 107 | + ['indexOf', 'String -> String -> Number', F\indexOf()], |
|
| 108 | + ['lastIndexOf', 'Any -> List -> Number', F\lastIndexOf()], |
|
| 109 | + ['lastIndexOf', 'Any -> Object|Array -> Any', F\lastIndexOf()], |
|
| 110 | + ['lastIndexOf', 'String -> String -> Number', F\lastIndexOf()], |
|
| 111 | + ['uniqueBy', 'Function -> List -> List', F\uniqueBy()], |
|
| 112 | + ['unique', 'List -> List', F\unique()], |
|
| 113 | + ['groupBy', 'Function -> List -> Object|Array', F\groupBy()], |
|
| 114 | + ['pairsFrom', 'List -> List -> List', F\pairsFrom()], |
|
| 115 | + ['sort', 'Function -> List -> List', F\sort()], |
|
| 116 | + ['plus', 'Number -> Number -> Number', F\plus()], |
|
| 117 | + ['minus', 'Number -> Number -> Number', F\minus()], |
|
| 118 | + ['negate', 'Number -> Number', F\negate()], |
|
| 119 | + ['multiply', 'Number -> Number -> Number', F\multiply()], |
|
| 120 | + ['divide', 'Number -> Number -> Number', F\divide()], |
|
| 121 | + ['modulo', 'Number -> Number -> Number', F\modulo()], |
|
| 122 | + ['sum', 'List -> Number', F\sum()], |
|
| 123 | + ['product', 'List -> Number', F\product()], |
|
| 124 | + ['min', 'Number -> Number -> Number', F\min()], |
|
| 125 | + ['minBy', 'Function -> Any -> Any -> Any', F\minBy()], |
|
| 126 | + ['max', 'Number -> Number -> Number', F\max()], |
|
| 127 | + ['maxBy', 'Function -> Any -> Any -> Any', F\maxBy()], |
|
| 128 | 128 | |
| 129 | 129 | ]); |
@@ -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 | }; |
@@ -119,25 +119,30 @@ discard block |
||
| 119 | 119 | return function() use($fn) { |
| 120 | 120 | $args = func_get_args(); |
| 121 | 121 | $n = count($args); |
| 122 | - while ($n > 0 && _is_placeholder($args[$n - 1])) |
|
| 123 | - $n --; |
|
| 124 | - if ($n == 0) |
|
| 125 | - return _curry_two($fn); |
|
| 122 | + while ($n > 0 && _is_placeholder($args[$n - 1])) { |
|
| 123 | + $n --; |
|
| 124 | + } |
|
| 125 | + if ($n == 0) { |
|
| 126 | + return _curry_two($fn); |
|
| 127 | + } |
|
| 126 | 128 | if ($n == 1) { |
| 127 | 129 | $a = &$args[0]; |
| 128 | - if (_is_placeholder($a)) |
|
| 129 | - return _curry_two($fn); |
|
| 130 | + if (_is_placeholder($a)) { |
|
| 131 | + return _curry_two($fn); |
|
| 132 | + } |
|
| 130 | 133 | return _curry_one(function($b) use($fn, &$a) { |
| 131 | 134 | return $fn($a, $b); |
| 132 | 135 | }); |
| 133 | 136 | } |
| 134 | 137 | $a = &$args[0]; |
| 135 | 138 | $b = &$args[1]; |
| 136 | - if (_is_placeholder($a) && _is_placeholder($b)) |
|
| 137 | - return _curry_two($fn); |
|
| 138 | - if (_is_placeholder($a)) |
|
| 139 | - return _curry_one(function($_a) use($fn, &$b) { |
|
| 139 | + if (_is_placeholder($a) && _is_placeholder($b)) { |
|
| 140 | + return _curry_two($fn); |
|
| 141 | + } |
|
| 142 | + if (_is_placeholder($a)) { |
|
| 143 | + return _curry_one(function($_a) use($fn, &$b) { |
|
| 140 | 144 | return $fn($_a, $b); |
| 145 | + } |
|
| 141 | 146 | }); |
| 142 | 147 | return $fn($args[0], $args[1]); |
| 143 | 148 | }; |
@@ -168,10 +173,12 @@ discard block |
||
| 168 | 173 | return function() use($fn) { |
| 169 | 174 | $args = func_get_args(); |
| 170 | 175 | $n = count($args); |
| 171 | - while ($n > 0 && _is_placeholder($args[$n - 1])) |
|
| 172 | - $n --; |
|
| 173 | - if ($n == 0) |
|
| 174 | - return _curry_three($fn); |
|
| 176 | + while ($n > 0 && _is_placeholder($args[$n - 1])) { |
|
| 177 | + $n --; |
|
| 178 | + } |
|
| 179 | + if ($n == 0) { |
|
| 180 | + return _curry_three($fn); |
|
| 181 | + } |
|
| 175 | 182 | if ($n == 1) { |
| 176 | 183 | $a = &$args[0]; |
| 177 | 184 | return _curry_two(function($b, $c) use($fn, &$a) { |
@@ -181,9 +188,10 @@ discard block |
||
| 181 | 188 | if ($n == 2) { |
| 182 | 189 | $a = &$args[0]; $b = &$args[1]; |
| 183 | 190 | |
| 184 | - if (_is_placeholder($a)) |
|
| 185 | - return _curry_two(function($_a, $c) use($fn, &$b) { |
|
| 191 | + if (_is_placeholder($a)) { |
|
| 192 | + return _curry_two(function($_a, $c) use($fn, &$b) { |
|
| 186 | 193 | return $fn($_a, $b, $c); |
| 194 | + } |
|
| 187 | 195 | }); |
| 188 | 196 | return _curry_one(function($c) use($fn, &$a, &$b) { |
| 189 | 197 | return $fn($a, $b, $c); |
@@ -192,17 +200,20 @@ discard block |
||
| 192 | 200 | |
| 193 | 201 | $a = &$args[0]; $b = &$args[1]; $c = &$args[2]; |
| 194 | 202 | |
| 195 | - if (_is_placeholder($a) && _is_placeholder($b)) |
|
| 196 | - return _curry_two(function($_a, $_b) use($fn, &$c) { |
|
| 203 | + if (_is_placeholder($a) && _is_placeholder($b)) { |
|
| 204 | + return _curry_two(function($_a, $_b) use($fn, &$c) { |
|
| 197 | 205 | return $fn($_a, $_b, $c); |
| 206 | + } |
|
| 198 | 207 | }); |
| 199 | - if (_is_placeholder($a)) |
|
| 200 | - return _curry_one(function($_a) use($fn, &$b, &$c) { |
|
| 208 | + if (_is_placeholder($a)) { |
|
| 209 | + return _curry_one(function($_a) use($fn, &$b, &$c) { |
|
| 201 | 210 | return $fn($_a, $b, $c); |
| 211 | + } |
|
| 202 | 212 | }); |
| 203 | - if (_is_placeholder($b)) |
|
| 204 | - return _curry_one(function($_b) use($fn, &$a, &$c) { |
|
| 213 | + if (_is_placeholder($b)) { |
|
| 214 | + return _curry_one(function($_b) use($fn, &$a, &$c) { |
|
| 205 | 215 | return $fn($a, $_b, $c); |
| 216 | + } |
|
| 206 | 217 | }); |
| 207 | 218 | |
| 208 | 219 | return $fn($a, $b, $c); |
@@ -284,8 +295,9 @@ discard block |
||
| 284 | 295 | $merged->args[$mergedIndex] = $given[$givenIndex]; |
| 285 | 296 | } |
| 286 | 297 | |
| 287 | - if (_is_placeholder($merged->args[$mergedIndex])) |
|
| 288 | - $merged->placeholders ++; |
|
| 298 | + if (_is_placeholder($merged->args[$mergedIndex])) { |
|
| 299 | + $merged->placeholders ++; |
|
| 300 | + } |
|
| 289 | 301 | |
| 290 | 302 | $givenIndex ++; |
| 291 | 303 | $mergedIndex ++; |
@@ -303,8 +315,9 @@ discard block |
||
| 303 | 315 | $argsCount = count($args); |
| 304 | 316 | $fillersCount = count($fillers); |
| 305 | 317 | while ($fillersIndex < $fillersCount) { |
| 306 | - while (!_is_placeholder($args[$argsIndex])) |
|
| 307 | - $argsIndex ++; |
|
| 318 | + while (!_is_placeholder($args[$argsIndex])) { |
|
| 319 | + $argsIndex ++; |
|
| 320 | + } |
|
| 308 | 321 | $args[$argsIndex] = $fillers[$fillersIndex]; |
| 309 | 322 | $fillersIndex ++; |
| 310 | 323 | } |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | * @ignore |
| 89 | 89 | * @signature (a -> b) -> (a -> b) |
| 90 | 90 | * @param callable $fn |
| 91 | - * @return callable |
|
| 91 | + * @return \Closure |
|
| 92 | 92 | */ |
| 93 | 93 | function _curry_one($fn) { |
| 94 | 94 | return function() use($fn) { |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @signature (a,b -> c) -> (a -> b -> c) |
| 115 | 115 | * @param callable $fn |
| 116 | - * @return callable |
|
| 116 | + * @return \Closure |
|
| 117 | 117 | */ |
| 118 | 118 | function _curry_two($fn) { |
| 119 | 119 | return function() use($fn) { |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * |
| 165 | 165 | * @signature (a,b,c -> d) -> (a -> b -> c -> d) |
| 166 | 166 | * @param callable $fn |
| 167 | - * @return callable |
|
| 167 | + * @return \Closure |
|
| 168 | 168 | */ |
| 169 | 169 | function _curry_three($fn) { |
| 170 | 170 | return function() use($fn) { |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | * @param callable $fn |
| 228 | 228 | * @param int $n |
| 229 | 229 | * @param array $given |
| 230 | - * @return callable |
|
| 230 | + * @return \Closure |
|
| 231 | 231 | */ |
| 232 | 232 | function _curry_n($fn, $n, $given = []) { |
| 233 | 233 | return function() use($fn, $n, $given) { |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | -require __DIR__.'/../../vendor/autoload.php'; |
|
| 2 | +require __DIR__ . '/../../vendor/autoload.php'; |
|
| 3 | 3 | |
| 4 | 4 | use Tarsana\Functional as F; |
| 5 | 5 | use Tarsana\Functional\Stream; |
@@ -6,7 +6,7 @@ |
||
| 6 | 6 | |
| 7 | 7 | $words = []; |
| 8 | 8 | foreach ($text as $word => $occ) { |
| 9 | - if (! isset($words[$occ])) { |
|
| 9 | + if (!isset($words[$occ])) { |
|
| 10 | 10 | $words[$occ] = []; |
| 11 | 11 | } |
| 12 | 12 | $words[$occ][] = $word; |
@@ -103,8 +103,9 @@ |
||
| 103 | 103 | protected function getWordsHavingOccurrences($number) { |
| 104 | 104 | $result = []; |
| 105 | 105 | foreach ($this->list as $word) { |
| 106 | - if ($word->occurrences() == $number) |
|
| 107 | - $result[] = $word; |
|
| 106 | + if ($word->occurrences() == $number) { |
|
| 107 | + $result[] = $word; |
|
| 108 | + } |
|
| 108 | 109 | } |
| 109 | 110 | usort($result, function(Word $w1, Word $w2) { |
| 110 | 111 | return strcmp($w1->value(), $w2->value()); |
@@ -8,10 +8,10 @@ |
||
| 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 | } |
@@ -11,8 +11,9 @@ |
||
| 11 | 11 | private function __construct(){} |
| 12 | 12 | public static function get() |
| 13 | 13 | { |
| 14 | - if(static::$instance === null) |
|
| 15 | - static::$instance = new Placeholder; |
|
| 14 | + if(static::$instance === null) { |
|
| 15 | + static::$instance = new Placeholder; |
|
| 16 | + } |
|
| 16 | 17 | return static::$instance; |
| 17 | 18 | } |
| 18 | 19 | } |
@@ -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 | }); |