Completed
Push — master ( 5a66ad...309b32 )
by Amine
01:58
created
src/common.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,6 @@  discard block
 block discarded – undo
24 24
  * ```
25 25
  *
26 26
  * @signature * -> String
27
- * @param  mixed $data
28 27
  * @return string
29 28
  */
30 29
 function type() {
@@ -79,7 +78,6 @@  discard block
 block discarded – undo
79 78
  * ```
80 79
  *
81 80
  * @signature * -> String
82
- * @param  mixed $something
83 81
  * @return string
84 82
  */
85 83
 function toString () {
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
  * @param  mixed $something
83 83
  * @return string
84 84
  */
85
-function toString () {
85
+function toString() {
86 86
     $toString = function($something) {
87 87
         switch (type($something)) {
88 88
             case 'String':
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
                 return $something->__toString();
106 106
             case 'Object':
107 107
             case 'Array':
108
-                return '{' . join(', ', map(function($pair){
109
-                    return $pair[0].': '. toString($pair[1]);
108
+                return '{' . join(', ', map(function($pair) {
109
+                    return $pair[0] . ': ' . toString($pair[1]);
110 110
                 }, toPairs($something))) . '}';
111 111
             default:
112
-                return '['.type($something).']';
112
+                return '[' . type($something) . ']';
113 113
         }
114 114
     };
115 115
     return apply(curry($toString), func_get_args());
Please login to merge, or discard this patch.
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,9 +29,15 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function type() {
31 31
     $type = function($data) {
32
-        if ($data instanceof Error) return 'Error';
33
-        if ($data instanceof Stream) return "Stream({$data->type})";
34
-        if (is_callable($data)) return 'Function';
32
+        if ($data instanceof Error) {
33
+            return 'Error';
34
+        }
35
+        if ($data instanceof Stream) {
36
+            return "Stream({$data->type})";
37
+        }
38
+        if (is_callable($data)) {
39
+            return 'Function';
40
+        }
35 41
         switch (gettype($data)) {
36 42
             case 'boolean':
37 43
                 return 'Boolean';
@@ -45,8 +51,9 @@  discard block
 block discarded – undo
45 51
             case 'resource':
46 52
                 return 'Resource';
47 53
             case 'array':
48
-                if (allSatisfies('is_numeric', keys($data)))
49
-                    return 'List';
54
+                if (allSatisfies('is_numeric', keys($data))) {
55
+                                    return 'List';
56
+                }
50 57
                 return 'Array';
51 58
             case 'object':
52 59
                 return 'Object';
Please login to merge, or discard this patch.
src/functions.php 2 patches
Unused Use Statements   -2 removed lines patch added patch discarded remove patch
@@ -3,8 +3,6 @@
 block discarded – undo
3 3
  * This file contains functions dealing with functions.
4 4
  */
5 5
 
6
-use Tarsana\Functional\Exceptions\InvalidArgument;
7
-
8 6
 /**
9 7
  * Adds the `Tarsana\Functional\` namespace to a function name.
10 8
  * This is useful to pass non-curried functions as parameter.
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -59,8 +59,9 @@  discard block
 block discarded – undo
59 59
     $addArgument = function($currentBoundArgs, $arg) use($fnArgsCount) {
60 60
         $currentBoundArgsCount = count($currentBoundArgs);
61 61
         $placeholderPosition = 0;
62
-        while($placeholderPosition < $currentBoundArgsCount && !_is_placeholder($currentBoundArgs[$placeholderPosition]))
63
-            $placeholderPosition ++;
62
+        while($placeholderPosition < $currentBoundArgsCount && !_is_placeholder($currentBoundArgs[$placeholderPosition])) {
63
+                    $placeholderPosition ++;
64
+        }
64 65
         if ($currentBoundArgsCount < $fnArgsCount || $placeholderPosition == $currentBoundArgsCount) {
65 66
             $currentBoundArgs[] = $arg;
66 67
         } else { // There is a placeholder and number of bound args >= $fnArgsCount
@@ -87,8 +88,9 @@  discard block
 block discarded – undo
87 88
         $boundArgs = _merge_args($argsCount, $boundArgs, func_get_args());
88 89
         $numberOfPlaceholders = count(array_filter($boundArgs, _f('_is_placeholder')));
89 90
         $numberOfGivenArgs = count($boundArgs) - $numberOfPlaceholders;
90
-        if ($numberOfGivenArgs >= $argsCount)
91
-            return call_user_func_array($fn, $boundArgs);
91
+        if ($numberOfGivenArgs >= $argsCount) {
92
+                    return call_user_func_array($fn, $boundArgs);
93
+        }
92 94
         return _curried_function($fn, $argsCount, $boundArgs);
93 95
     };
94 96
 }
@@ -179,8 +181,9 @@  discard block
 block discarded – undo
179 181
  */
180 182
 function pipe() {
181 183
     $fns = func_get_args();
182
-    if(count($fns) < 1)
183
-        return _f('identity');
184
+    if(count($fns) < 1) {
185
+            return _f('identity');
186
+    }
184 187
     return curry(function () use ($fns) {
185 188
         $result = _apply(array_shift($fns), func_get_args());
186 189
         foreach ($fns as $fn) {
Please login to merge, or discard this patch.
src/math.php 2 patches
Doc Comments   -13 removed lines patch added patch discarded remove patch
@@ -11,8 +11,6 @@  discard block
 block discarded – undo
11 11
  * ```
12 12
  *
13 13
  * @signature Number -> Number -> Number
14
- * @param  int|float $x
15
- * @param  int|float $y
16 14
  * @return int|float
17 15
  */
18 16
 function plus() {
@@ -29,8 +27,6 @@  discard block
 block discarded – undo
29 27
  * ```
30 28
  *
31 29
  * @signature Number -> Number -> Number
32
- * @param  int|float $x
33
- * @param  int|float $y
34 30
  * @return int|float
35 31
  */
36 32
 function minus() {
@@ -48,7 +44,6 @@  discard block
 block discarded – undo
48 44
  * ```
49 45
  *
50 46
  * @signature Number -> Number
51
- * @param  int|float $x
52 47
  * @return int|float
53 48
  */
54 49
 function negate() {
@@ -65,8 +60,6 @@  discard block
 block discarded – undo
65 60
  * ```
66 61
  *
67 62
  * @signature Number -> Number -> Number
68
- * @param  int|float $x
69
- * @param  int|float $y
70 63
  * @return int|float
71 64
  */
72 65
 function multiply() {
@@ -83,8 +76,6 @@  discard block
 block discarded – undo
83 76
  * ```
84 77
  *
85 78
  * @signature Number -> Number -> Number
86
- * @param  int|float $x
87
- * @param  int|float $y
88 79
  * @return int|float
89 80
  */
90 81
 function divide() {
@@ -101,8 +92,6 @@  discard block
 block discarded – undo
101 92
  * ```
102 93
  *
103 94
  * @signature Number -> Number -> Number
104
- * @param  int|float $x
105
- * @param  int|float $y
106 95
  * @return int|float
107 96
  */
108 97
 function modulo() {
@@ -120,7 +109,6 @@  discard block
 block discarded – undo
120 109
  * ```
121 110
  *
122 111
  * @signature [Number] -> Number
123
- * @param  array $numbers
124 112
  * @return int|float
125 113
  */
126 114
 function sum() {
@@ -137,7 +125,6 @@  discard block
 block discarded – undo
137 125
  * ```
138 126
  *
139 127
  * @signature [Number] -> Number
140
- * @param  array $numbers
141 128
  * @return int|float
142 129
  */
143 130
 function product() {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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,8 +52,8 @@  discard block
 block discarded – undo
52 52
  * @return int|float
53 53
  */
54 54
 function negate() {
55
-    return apply(curry(function($x){
56
-        return -$x;
55
+    return apply(curry(function($x) {
56
+        return - $x;
57 57
     }), func_get_args());
58 58
 }
59 59
 
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
  * @return int|float
71 71
  */
72 72
 function multiply() {
73
-    $multiply = curry(function($x, $y){
73
+    $multiply = curry(function($x, $y) {
74 74
         return $y * $x;
75 75
     });
76 76
     return apply($multiply, func_get_args());
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
  * @return int|float
89 89
  */
90 90
 function divide() {
91
-    $divide = curry(function($x, $y){
91
+    $divide = curry(function($x, $y) {
92 92
         return $x / $y;
93 93
     });
94 94
     return apply($divide, func_get_args());
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
  * @return int|float
107 107
  */
108 108
 function modulo() {
109
-    $modulo = curry(function($x, $y){
109
+    $modulo = curry(function($x, $y) {
110 110
         return $x % $y;
111 111
     });
112 112
     return apply($modulo, func_get_args());
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  * @return int|float
125 125
  */
126 126
 function sum() {
127
-    return apply(curry(function($numbers){
127
+    return apply(curry(function($numbers) {
128 128
         return reduce(plus(), 0, $numbers);
129 129
     }), func_get_args());
130 130
 }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
  * @return int|float
142 142
  */
143 143
 function product() {
144
-    return apply(curry(function($numbers){
144
+    return apply(curry(function($numbers) {
145 145
         return reduce(multiply(), 1, $numbers);
146 146
     }), func_get_args());
147 147
 }
Please login to merge, or discard this patch.
src/object.php 1 patch
Doc Comments   -18 removed lines patch added patch discarded remove patch
@@ -19,7 +19,6 @@  discard block
 block discarded – undo
19 19
  * ```
20 20
  *
21 21
  * @signature a -> a
22
- * @param  mixed $value
23 22
  * @return mixed
24 23
  */
25 24
 function clone_() {
@@ -67,7 +66,6 @@  discard block
 block discarded – undo
67 66
  * ```
68 67
  *
69 68
  * @signature {k: v} -> {k: v}
70
- * @param  object $object
71 69
  * @return array
72 70
  */
73 71
 function attributes() {
@@ -143,8 +141,6 @@  discard block
 block discarded – undo
143 141
  * ```
144 142
  *
145 143
  * @signature k -> {k: v} -> Boolean
146
- * @param  string|int $name
147
- * @param  mixed $object
148 144
  * @return bool
149 145
  */
150 146
 function has() {
@@ -173,8 +169,6 @@  discard block
 block discarded – undo
173 169
  * ```
174 170
  *
175 171
  * @signature k -> {k: v} -> Maybe(v)
176
- * @param  string $name
177
- * @param  array $object
178 172
  * @return mixed
179 173
  */
180 174
 function get() {
@@ -201,8 +195,6 @@  discard block
 block discarded – undo
201 195
  * ```
202 196
  *
203 197
  * @signature [k] -> {k: v} -> v
204
- * @param  array $path
205
- * @param  mixed $object
206 198
  * @return mixed
207 199
  */
208 200
 function getPath() {
@@ -229,9 +221,6 @@  discard block
 block discarded – undo
229 221
  * ```
230 222
  *
231 223
  * @signature k -> v -> {k: v} -> {k: v}
232
- * @param  string|int $name
233
- * @param  mixed $value
234
- * @param  mixed $object
235 224
  * @return mixed
236 225
  */
237 226
 function set() {
@@ -258,9 +247,6 @@  discard block
 block discarded – undo
258 247
  * ```
259 248
  *
260 249
  * @signature (a -> Boolean) -> k -> {k : a} -> Boolean
261
- * @param  callable $predicate
262
- * @param  string|int $key
263
- * @param  mixed $object
264 250
  * @return bool
265 251
  */
266 252
 function satisfies() {
@@ -294,8 +280,6 @@  discard block
 block discarded – undo
294 280
  * ```
295 281
  *
296 282
  * @signature {String: (a -> Boolean)} -> {k : a} -> Boolean
297
- * @param  array $predicates
298
- * @param  mixed $object
299 283
  * @return bool
300 284
  */
301 285
 function satisfiesAll() {
@@ -335,8 +319,6 @@  discard block
 block discarded – undo
335 319
  * ```
336 320
  *
337 321
  * @signature {String: (a -> Boolean)} -> {k : a} -> Boolean
338
- * @param  array $predicates
339
- * @param  mixed $object
340 322
  * @return bool
341 323
  */
342 324
 function satisfiesAny() {
Please login to merge, or discard this patch.
src/string.php 1 patch
Spacing   +2 added lines, -3 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
 }
@@ -306,8 +306,7 @@  discard block
 block discarded – undo
306 306
         $updateCountAt = curry(function($item, $counts, $index) use($openings, $closings) {
307 307
             $count = occurences(__(), $item);
308 308
             return ($openings[$index] == $closings[$index]) ?
309
-                ($counts[$index] + $count($openings[$index])) % 2 :
310
-                $counts[$index] + $count($openings[$index]) - $count($closings[$index]);
309
+                ($counts[$index] + $count($openings[$index])) % 2 : $counts[$index] + $count($openings[$index]) - $count($closings[$index]);
311 310
         });
312 311
         // Updates counts for all surrenders
313 312
         $updateCounts = curry(function($item, $counts) use($indexes, $updateCountAt) {
Please login to merge, or discard this patch.