Completed
Pull Request — master (#1)
by Amine
02:30
created
src/operators.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,8 +97,9 @@
 block discarded – undo
97 97
 function equals() {
98 98
     $equals = function($a, $b) {
99 99
             $type = type($a);
100
-            if ($type != type($b))
101
-                return false;
100
+            if ($type != type($b)) {
101
+                            return false;
102
+            }
102 103
             switch ($type) {
103 104
                 case 'Null':
104 105
                 case 'Boolean':
Please login to merge, or discard this patch.
src/object.php 1 patch
Braces   +11 added lines, -8 removed lines patch added patch discarded remove patch
@@ -72,8 +72,9 @@  discard block
 block discarded – undo
72 72
  */
73 73
 function attributes() {
74 74
     $attrs = function($object) {
75
-        if (is_object($object))
76
-            return get_object_vars($object);
75
+        if (is_object($object)) {
76
+                    return get_object_vars($object);
77
+        }
77 78
         return $object;
78 79
     };
79 80
     return apply(curry($attrs), func_get_args());
@@ -208,8 +209,9 @@  discard block
 block discarded – undo
208 209
 function getPath() {
209 210
     $getPath = function($path, $object){
210 211
         return reduce(function($result, $name) {
211
-            if ($result !== null)
212
-                $result = get($name, $result);
212
+            if ($result !== null) {
213
+                            $result = get($name, $result);
214
+            }
213 215
             return $result;
214 216
         }, $object, $path);
215 217
     };
@@ -237,10 +239,11 @@  discard block
 block discarded – undo
237 239
 function set() {
238 240
     $set = function($name, $value, $object) {
239 241
         $object = clone_($object);
240
-        if (is_object($object))
241
-            $object->{$name} = $value;
242
-        else
243
-            $object[$name] = $value;
242
+        if (is_object($object)) {
243
+                    $object->{$name} = $value;
244
+        } else {
245
+                    $object[$name] = $value;
246
+        }
244 247
         return $object;
245 248
     };
246 249
     return apply(curry($set), func_get_args());
Please login to merge, or discard this patch.
build.php 1 patch
Braces   +52 added lines, -35 removed lines patch added patch discarded remove patch
@@ -148,14 +148,16 @@  discard block
 block discarded – undo
148 148
 function write_module($module) {
149 149
     if ($module->docs) {
150 150
         $docsDir  = dirname($module->docsPath);
151
-        if (!is_dir($docsDir))
152
-            mkdir($docsDir, 0777, true);
151
+        if (!is_dir($docsDir)) {
152
+                    mkdir($docsDir, 0777, true);
153
+        }
153 154
         file_put_contents($module->docsPath,  $module->docs);
154 155
     }
155 156
     if ($module->tests) {
156 157
         $testsDir = dirname($module->testsPath);
157
-        if (!is_dir($testsDir))
158
-            mkdir($testsDir, 0777, true);
158
+        if (!is_dir($testsDir)) {
159
+                    mkdir($testsDir, 0777, true);
160
+        }
159 161
         file_put_contents($module->testsPath, $module->tests);
160 162
     }
161 163
     if ($module->streamOperations) {
@@ -252,9 +254,15 @@  discard block
 block discarded – undo
252 254
     $tags = groupBy(get('name'), tags_of($doxBlock));
253 255
 
254 256
     $type = 'function';
255
-    if (has('file', $tags)) $type = 'file';
256
-    if (has('class', $tags)) $type = 'class';
257
-    if (has('method', $tags)) $type = 'method';
257
+    if (has('file', $tags)) {
258
+        $type = 'file';
259
+    }
260
+    if (has('class', $tags)) {
261
+        $type = 'class';
262
+    }
263
+    if (has('method', $tags)) {
264
+        $type = 'method';
265
+    }
258 266
 
259 267
     $params = map(function($tag){
260 268
         $parts = split(' ', get('value', $tag));
@@ -266,8 +274,9 @@  discard block
 block discarded – undo
266 274
 
267 275
     $return = getPath(['return', 0, 'value'], $tags);
268 276
     $signatures = get('signature', $tags);
269
-    if ($signatures)
270
-        $signatures = map(get('value'), $signatures);
277
+    if ($signatures) {
278
+            $signatures = map(get('value'), $signatures);
279
+    }
271 280
     return (object) [
272 281
         'type' => $type,
273 282
         'name' => getPath(['ctx', 'name'], $doxBlock),
@@ -291,12 +300,13 @@  discard block
 block discarded – undo
291 300
  * @return array
292 301
  */
293 302
 function tags_of($doxBlock) {
294
-    if ($doxBlock->tags)
295
-        return map(function($tag){
303
+    if ($doxBlock->tags) {
304
+            return map(function($tag){
296 305
             return (object) [
297 306
                 'name'  => $tag->type,
298 307
                 'value' => $tag->string
299 308
             ];
309
+    }
300 310
         }, $doxBlock->tags);
301 311
     return [];
302 312
 }
@@ -310,8 +320,9 @@  discard block
 block discarded – undo
310 320
  */
311 321
 function generate_docs($module) {
312 322
     $module->docs = '';
313
-    if (startsWith('_', $module->name))
314
-        return $module;
323
+    if (startsWith('_', $module->name)) {
324
+            return $module;
325
+    }
315 326
     return apply(process_of([
316 327
         'generate_docs_header',
317 328
         'generate_docs_sommaire',
@@ -388,15 +399,17 @@  discard block
 block discarded – undo
388 399
  * @return string
389 400
  */
390 401
 function generate_docs_contents_item($block) {
391
-    if ($block->type != 'function')
392
-        return '';
402
+    if ($block->type != 'function') {
403
+            return '';
404
+    }
393 405
     $params = join(', ', map(pipe(values(), join(' ')), get('params', $block)));
394 406
     $return = get('return', $block);
395 407
     $prototype = "```php\n{$block->name}({$params}) : {$return}\n```\n\n";
396 408
     $signature = '';
397 409
     $blockSignature = join("\n", $block->signatures);
398
-    if ($blockSignature)
399
-        $signature = "```\n{$blockSignature}\n```\n\n";
410
+    if ($blockSignature) {
411
+            $signature = "```\n{$blockSignature}\n```\n\n";
412
+    }
400 413
     return "# {$block->name}\n\n{$prototype}{$signature}{$block->description}\n\n";
401 414
 }
402 415
 
@@ -427,8 +440,9 @@  discard block
 block discarded – undo
427 440
 function generate_tests_header($module) {
428 441
     $namespace = "Tarsana\UnitTests\Functional";
429 442
     $additionalNamespace = replace("/", "\\", remove(6, dirname($module->testsPath)));
430
-    if ($additionalNamespace)
431
-        $namespace .= "\\" . $additionalNamespace;
443
+    if ($additionalNamespace) {
444
+            $namespace .= "\\" . $additionalNamespace;
445
+    }
432 446
     $name = remove(-4, last(split("/", $module->testsPath)));
433 447
     $module->tests .= "<?php namespace {$namespace};\n\nuse Tarsana\Functional as F;\n\nclass {$name} extends \Tarsana\UnitTests\Functional\UnitTest {\n";
434 448
     return $module;
@@ -449,10 +463,11 @@  discard block
 block discarded – undo
449 463
     $contents = join("\n", map(function($block) use($module) {
450 464
         return generate_tests_contents_item($block, $module);
451 465
     }, $blocks));
452
-    if (trim($contents) != '')
453
-        $module->tests .= $contents;
454
-    else
455
-        $module->tests = '';
466
+    if (trim($contents) != '') {
467
+            $module->tests .= $contents;
468
+    } else {
469
+            $module->tests = '';
470
+    }
456 471
     return $module;
457 472
 }
458 473
 
@@ -465,8 +480,9 @@  discard block
 block discarded – undo
465 480
  * @return string
466 481
  */
467 482
 function generate_tests_contents_item($block, $module) {
468
-    if ($block->type != 'function')
469
-        return '';
483
+    if ($block->type != 'function') {
484
+            return '';
485
+    }
470 486
 
471 487
     $code = apply(pipe(
472 488
         _f('code_from_description'),
@@ -480,8 +496,9 @@  discard block
 block discarded – undo
480 496
         join("\n")
481 497
     ), [$block]);
482 498
 
483
-    if ('' == trim($code))
484
-        return '';
499
+    if ('' == trim($code)) {
500
+            return '';
501
+    }
485 502
     return prepend("\tpublic function test_{$block->name}() {\n",
486 503
         append("\n\t}\n", $code)
487 504
     );
@@ -496,8 +513,9 @@  discard block
 block discarded – undo
496 513
  */
497 514
 function code_from_description($block) {
498 515
     $description = get('description', $block);
499
-    if (!contains('```php', $description))
500
-        return '';
516
+    if (!contains('```php', $description)) {
517
+            return '';
518
+    }
501 519
     $code = remove(7 + indexOf('```php', $description), $description);
502 520
     return remove(-4, trim($code));
503 521
 }
@@ -513,8 +531,7 @@  discard block
 block discarded – undo
513 531
     if (contains('; //=> ', $part)) {
514 532
         $pieces = split('; //=> ', $part);
515 533
         $part = "\$this->assertEquals({$pieces[1]}, {$pieces[0]});";
516
-    }
517
-    elseif (contains('; // throws ', $part)) {
534
+    } elseif (contains('; // throws ', $part)) {
518 535
         $pieces = split('; // throws ', $part);
519 536
         $variables = match('/ \$[0-9a-zA-Z_]+/', $pieces[0]);
520 537
         $use = '';
@@ -523,8 +540,7 @@  discard block
 block discarded – undo
523 540
             $use = "use({$variables}) ";
524 541
         }
525 542
         return "\$this->assertErrorThrown(function() {$use}{\n\t$pieces[0]; \n},\n{$pieces[1]});";
526
-    }
527
-    elseif (startsWith('class ', $part) || startsWith('function ', $part)) {
543
+    } elseif (startsWith('class ', $part) || startsWith('function ', $part)) {
528 544
         $module->testsFooter .= $part . "\n\n";
529 545
         $part = '';
530 546
     }
@@ -539,8 +555,9 @@  discard block
 block discarded – undo
539 555
  * @return object
540 556
  */
541 557
 function generate_tests_footer($module) {
542
-    if ($module->tests)
543
-        $module->tests .= "}\n\n{$module->testsFooter}";
558
+    if ($module->tests) {
559
+            $module->tests .= "}\n\n{$module->testsFooter}";
560
+    }
544 561
     return $module;
545 562
 }
546 563
 
Please login to merge, or discard this patch.
src/list.php 1 patch
Braces   +45 added lines, -30 removed lines patch added patch discarded remove patch
@@ -146,8 +146,9 @@  discard block
 block discarded – undo
146 146
 function head() {
147 147
     static $head = false;
148 148
     $head = $head ?: curry(function($list) {
149
-        if(is_string($list))
150
-            return substr($list, 0, 1);
149
+        if(is_string($list)) {
150
+                    return substr($list, 0, 1);
151
+        }
151 152
         return (count($list) > 0)
152 153
             ? $list[0]
153 154
             : null;
@@ -174,8 +175,9 @@  discard block
 block discarded – undo
174 175
 function last () {
175 176
     static $last = false;
176 177
     $last = $last ?: curry(function($list) {
177
-        if(is_string($list))
178
-            return substr($list, -1);
178
+        if(is_string($list)) {
179
+                    return substr($list, -1);
180
+        }
179 181
         return (count($list) > 0)
180 182
             ? $list[count($list) - 1]
181 183
             : null;
@@ -203,10 +205,11 @@  discard block
 block discarded – undo
203 205
 function init () {
204 206
     static $init = false;
205 207
     $init = $init ?: curry(function($list) {
206
-        if(is_string($list))
207
-            return (strlen($list) > 1)
208
+        if(is_string($list)) {
209
+                    return (strlen($list) > 1)
208 210
                 ? substr($list, 0, strlen($list) - 1)
209 211
                 : '';
212
+        }
210 213
         return (count($list) > 1)
211 214
             ? array_slice($list, 0, count($list) - 1)
212 215
             : [];
@@ -234,10 +237,11 @@  discard block
 block discarded – undo
234 237
 function tail () {
235 238
     static $tail = false;
236 239
     $tail = $tail ?: curry(function($list) {
237
-        if(is_string($list))
238
-            return (strlen($list) > 1)
240
+        if(is_string($list)) {
241
+                    return (strlen($list) > 1)
239 242
                 ? substr($list, 1)
240 243
                 : '';
244
+        }
241 245
         return (count($list) > 1)
242 246
             ? array_slice($list, 1)
243 247
             : [];
@@ -359,8 +363,9 @@  discard block
 block discarded – undo
359 363
     $concat = $concat ?: curry(function($list1, $list2) {
360 364
         $t1 = toString($list1);
361 365
         $t2 = toString($list2);
362
-        if (is_string($list1) && is_string($list2))
363
-            return $list1 . $list2;
366
+        if (is_string($list1) && is_string($list2)) {
367
+                    return $list1 . $list2;
368
+        }
364 369
         return array_merge($list1, $list2);
365 370
     });
366 371
     return _apply($concat, func_get_args());
@@ -443,10 +448,12 @@  discard block
 block discarded – undo
443 448
     static $insertAll = false;
444 449
     $insertAll = $insertAll ?: curry(function($position, $items, $list) {
445 450
         $length = length($list);
446
-        if ($position < 0)
447
-            $position = $length + $position;
448
-        if ($position < 0)
449
-            $position = 0;
451
+        if ($position < 0) {
452
+                    $position = $length + $position;
453
+        }
454
+        if ($position < 0) {
455
+                    $position = 0;
456
+        }
450 457
         return ($position >= $length)
451 458
             ? concat($list, $items)
452 459
             : concatAll([take($position, $list), $items, remove($position, $list)]);
@@ -521,8 +528,9 @@  discard block
 block discarded – undo
521 528
     static $take = false;
522 529
     $take = $take ?: curry(function($count, $list) {
523 530
         $length = length($list);
524
-        if ($count > $length || $count < -$length)
525
-            return [];
531
+        if ($count > $length || $count < -$length) {
532
+                    return [];
533
+        }
526 534
         if(is_string($list)) {
527 535
             return ($count >= 0)
528 536
                 ? substr($list, 0, $count)
@@ -662,8 +670,9 @@  discard block
 block discarded – undo
662 670
     static $remove = false;
663 671
     $remove = $remove ?: curry(function($count, $list) {
664 672
         $length = length($list);
665
-        if ($count > $length || $count < -$length)
666
-            return [];
673
+        if ($count > $length || $count < -$length) {
674
+                    return [];
675
+        }
667 676
         return ($count > 0)
668 677
             ? take($count - $length, $list)
669 678
             : take($count + $length, $list);
@@ -812,10 +821,12 @@  discard block
 block discarded – undo
812 821
 function slices() {
813 822
     static $slices = false;
814 823
     $slices = $slices ?: curry(function($size, $list) {
815
-        if(empty($list))
816
-            return is_string($list) ? '' : [];
817
-        if(length($list) <= $size)
818
-            return [$list];
824
+        if(empty($list)) {
825
+                    return is_string($list) ? '' : [];
826
+        }
827
+        if(length($list) <= $size) {
828
+                    return [$list];
829
+        }
819 830
         return prepend(take($size, $list), slices($size, remove($size, $list)));
820 831
     });
821 832
     return _apply($slices, func_get_args());
@@ -867,8 +878,9 @@  discard block
 block discarded – undo
867 878
     static $findIndex = false;
868 879
     $findIndex = $findIndex ?: curry(function($predicate, $list) {
869 880
         foreach ($list as $key => $value) {
870
-            if ($predicate($value))
871
-                return $key;
881
+            if ($predicate($value)) {
882
+                            return $key;
883
+            }
872 884
         }
873 885
         return null;
874 886
     });
@@ -896,8 +908,9 @@  discard block
 block discarded – undo
896 908
     static $findLastIndex = false;
897 909
     $findLastIndex = $findLastIndex ?: curry(function($predicate, $list) {
898 910
         foreach (reverse(toPairs($list)) as $pair) {
899
-            if($predicate($pair[1]))
900
-                return $pair[0];
911
+            if($predicate($pair[1])) {
912
+                            return $pair[0];
913
+            }
901 914
         }
902 915
         return null;
903 916
     });
@@ -1107,8 +1120,9 @@  discard block
 block discarded – undo
1107 1120
     $groupBy = $groupBy ?: curry(function($fn, $list) {
1108 1121
         return reduce(function($result, $item) use($fn) {
1109 1122
             $index = $fn($item);
1110
-            if (! isset($result[$index]))
1111
-                $result[$index] = [];
1123
+            if (! isset($result[$index])) {
1124
+                            $result[$index] = [];
1125
+            }
1112 1126
             $result[$index][] = $item;
1113 1127
             return $result;
1114 1128
         }, [], $list);
@@ -1137,8 +1151,9 @@  discard block
 block discarded – undo
1137 1151
     $pairsFrom = $pairsFrom ?: curry(function($list1, $list2) {
1138 1152
         $length1 = length($list1);
1139 1153
         $length2 = length($list2);
1140
-        if (0 == $length1 || 0 == $length2)
1141
-            return [];
1154
+        if (0 == $length1 || 0 == $length2) {
1155
+                    return [];
1156
+        }
1142 1157
         $list1 = values($list1);
1143 1158
         $list2 = values($list2);
1144 1159
         return map(function($index) use($list1, $list2) {
Please login to merge, or discard this patch.
src/Internal/_functions.php 1 patch
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -65,8 +65,9 @@  discard block
 block discarded – undo
65 65
     $addArgument = function($currentBoundArgs, $arg) use($fnArgsCount) {
66 66
         $currentBoundArgsCount = count($currentBoundArgs);
67 67
         $placeholderPosition = 0;
68
-        while($placeholderPosition < $currentBoundArgsCount && !_is_placeholder($currentBoundArgs[$placeholderPosition]))
69
-            $placeholderPosition ++;
68
+        while($placeholderPosition < $currentBoundArgsCount && !_is_placeholder($currentBoundArgs[$placeholderPosition])) {
69
+                    $placeholderPosition ++;
70
+        }
70 71
         if ($currentBoundArgsCount < $fnArgsCount || $placeholderPosition == $currentBoundArgsCount) {
71 72
             $currentBoundArgs[] = $arg;
72 73
         } else { // There is a placeholder and number of bound args >= $fnArgsCount
@@ -92,8 +93,9 @@  discard block
 block discarded – undo
92 93
         $boundArgs = _merge_args($argsCount, $boundArgs, func_get_args());
93 94
         $numberOfPlaceholders = count(array_filter($boundArgs, _f('_is_placeholder')));
94 95
         $numberOfGivenArgs = count($boundArgs) - $numberOfPlaceholders;
95
-        if ($numberOfGivenArgs >= $argsCount)
96
-            return call_user_func_array($fn, $boundArgs);
96
+        if ($numberOfGivenArgs >= $argsCount) {
97
+                    return call_user_func_array($fn, $boundArgs);
98
+        }
97 99
         return _curried_function($fn, $argsCount, $boundArgs);
98 100
     };
99 101
 }
Please login to merge, or discard this patch.
src/Internal/_stream.php 1 patch
Braces   +12 added lines, -8 removed lines patch added patch discarded remove patch
@@ -131,8 +131,9 @@  discard block
 block discarded – undo
131 131
  */
132 132
 function _stream_operation($name, $signature, $callable = null) {
133 133
     $callable = $callable ?: $name;
134
-    if (!is_callable($callable))
135
-        _stream_throw_error('unknown-callable', $callable);
134
+    if (!is_callable($callable)) {
135
+            _stream_throw_error('unknown-callable', $callable);
136
+    }
136 137
 
137 138
     return [
138 139
         'name' => $name,
@@ -163,8 +164,9 @@  discard block
 block discarded – undo
163 164
     // Assuming $text  = 'Number|List -> Number -> String|Array -> Number'
164 165
     $parts = map(pipe(split('|'), map(pipe('trim', _stream_ensure_type($text)))), split('->', $text));
165 166
     // $parts = [['Number', 'List'], ['Number'], ['String', 'Array'], ['Number']]
166
-    if (length($parts) < 2)
167
-        _stream_throw_error('invalid-signature', $text);
167
+    if (length($parts) < 2) {
168
+            _stream_throw_error('invalid-signature', $text);
169
+    }
168 170
 
169 171
     return reduce(function($result, $part){
170 172
         return chain(function($item) use($result){
@@ -196,8 +198,9 @@  discard block
 block discarded – undo
196 198
  */
197 199
 function _stream_ensure_type() {
198 200
     $ensureType = function($signature, $type) {
199
-        if (! contains($type, _stream_types()))
200
-            _stream_throw_error('invalid-signature', $signature);
201
+        if (! contains($type, _stream_types())) {
202
+                    _stream_throw_error('invalid-signature', $signature);
203
+        }
201 204
         return $type;
202 205
     };
203 206
     return apply(curry($ensureType), func_get_args());
@@ -553,8 +556,9 @@  discard block
 block discarded – undo
553 556
  * @return array
554 557
  */
555 558
 function _stream_resolve($stream) {
556
-    if (get('resolved', $stream))
557
-        return $stream;
559
+    if (get('resolved', $stream)) {
560
+            return $stream;
561
+    }
558 562
     $transformations = get('transformations', $stream);
559 563
     $transformation = head($transformations);
560 564
     if (null === $transformation) {
Please login to merge, or discard this patch.
src/Internal/_stream_operations.php 1 patch
Indentation   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -3,123 +3,123 @@
 block discarded – undo
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
-	['split', 'String -> String -> List', F\split()],
37
-	['join', 'String -> List -> String', F\join()],
38
-	['replace', 'String|List -> String|List -> String -> String', F\replace()],
39
-	['regReplace', 'String -> String -> String -> String', F\regReplace()],
40
-	['upperCase', 'String -> String', F\upperCase()],
41
-	['lowerCase', 'String -> String', F\lowerCase()],
42
-	['camelCase', 'String -> String', F\camelCase()],
43
-	['snakeCase', 'String -> String -> String', F\snakeCase()],
44
-	['startsWith', 'String -> String -> Boolean', F\startsWith()],
45
-	['endsWith', 'String -> String -> Boolean', F\endsWith()],
46
-	['test', 'String -> String -> Boolean', F\test()],
47
-	['match', 'String -> String -> List', F\match()],
48
-	['occurences', 'String -> String -> Number', F\occurences()],
49
-	['chunks', 'String -> String -> String -> List', F\chunks()],
50
-	['map', 'Function -> List -> List', F\map()],
51
-	['chain', 'Function -> List -> List', F\chain()],
52
-	['filter', 'Function -> List -> List', F\filter()],
53
-	['reduce', 'Function -> Any -> List -> Any', F\reduce()],
54
-	['each', 'Function -> List -> List', F\each()],
55
-	['head', 'List -> Any', F\head()],
56
-	['head', 'String -> String', F\head()],
57
-	['last', 'List -> Any', F\last()],
58
-	['last', 'String -> String', F\last()],
59
-	['init', 'List -> Any', F\init()],
60
-	['init', 'String -> String', F\init()],
61
-	['tail', 'List -> Any', F\tail()],
62
-	['tail', 'String -> String', F\tail()],
63
-	['reverse', 'List -> List', F\reverse()],
64
-	['reverse', 'String -> String', F\reverse()],
65
-	['length', 'List -> Number', F\length()],
66
-	['length', 'String -> Number', F\length()],
67
-	['allSatisfies', 'Function -> List -> Boolean', F\allSatisfies()],
68
-	['anySatisfies', 'Function -> List -> Boolean', F\anySatisfies()],
69
-	['concat', 'List -> List -> List', F\concat()],
70
-	['concat', 'String -> String -> String', F\concat()],
71
-	['concatAll', 'List -> List', F\concatAll()],
72
-	['insert', 'Number -> Any -> List -> List', F\insert()],
73
-	['insert', 'Number -> String -> String -> String', F\insert()],
74
-	['insertAll', 'Number -> List -> List -> List', F\insertAll()],
75
-	['insertAll', 'Number -> String -> String -> String', F\insertAll()],
76
-	['append', 'Any -> List -> List', F\append()],
77
-	['append', 'String -> String -> String', F\append()],
78
-	['prepend', 'Any -> List -> List', F\prepend()],
79
-	['prepend', 'String -> String -> String', F\prepend()],
80
-	['take', 'Number -> List -> List', F\take()],
81
-	['take', 'Number -> String -> String', F\take()],
82
-	['takeWhile', 'Function -> List -> List', F\takeWhile()],
83
-	['takeLastWhile', 'Function -> List -> List', F\takeLastWhile()],
84
-	['takeUntil', 'Function -> List -> List', F\takeUntil()],
85
-	['takeLastUntil', 'Function -> List -> List', F\takeLastUntil()],
86
-	['remove', 'Number -> List -> List', F\remove()],
87
-	['remove', 'Number -> String -> String', F\remove()],
88
-	['removeWhile', 'Function -> List -> List', F\removeWhile()],
89
-	['removeLastWhile', 'Function -> List -> List', F\removeLastWhile()],
90
-	['removeUntil', 'Function -> List -> List', F\removeUntil()],
91
-	['removeLastUntil', 'Function -> List -> List', F\removeLastUntil()],
92
-	['fromPairs', 'List -> Object|Array', F\fromPairs()],
93
-	['slices', 'Number -> List -> List', F\slices()],
94
-	['slices', 'Number -> String -> List', F\slices()],
95
-	['contains', 'Any -> List -> Boolean', F\contains()],
96
-	['contains', 'String -> String -> Boolean', F\contains()],
97
-	['findIndex', 'Function -> List -> Number|Null', F\findIndex()],
98
-	['findIndex', 'Function -> Object|Array -> Any', F\findIndex()],
99
-	['findLastIndex', 'Function -> List -> Number|Null', F\findLastIndex()],
100
-	['findLastIndex', 'Function -> Object|Array -> Any', F\findLastIndex()],
101
-	['find', 'Function -> List -> Any', F\find()],
102
-	['findLast', 'Function -> List -> Any', F\findLast()],
103
-	['indexOf', 'Any -> List -> Number', F\indexOf()],
104
-	['indexOf', 'Any -> Object|Array -> Any', F\indexOf()],
105
-	['indexOf', 'String -> String -> Number', F\indexOf()],
106
-	['lastIndexOf', 'Any -> List -> Number', F\lastIndexOf()],
107
-	['lastIndexOf', 'String -> String -> Number', F\lastIndexOf()],
108
-	['uniqueBy', 'Function -> List -> List', F\uniqueBy()],
109
-	['unique', 'List -> List', F\unique()],
110
-	['groupBy', 'Function -> List -> Object|Array', F\groupBy()],
111
-	['pairsFrom', 'List -> List -> List', F\pairsFrom()],
112
-	['plus', 'Number -> Number -> Number', F\plus()],
113
-	['minus', 'Number -> Number -> Number', F\minus()],
114
-	['negate', 'Number -> Number', F\negate()],
115
-	['multiply', 'Number -> Number -> Number', F\multiply()],
116
-	['divide', 'Number -> Number -> Number', F\divide()],
117
-	['modulo', 'Number -> Number -> Number', F\modulo()],
118
-	['sum', 'List -> Number', F\sum()],
119
-	['product', 'List -> Number', F\product()],
120
-	['min', 'Number -> Number -> Number', F\min()],
121
-	['minBy', 'Function -> Any -> Any -> Any', F\minBy()],
122
-	['max', 'Number -> Number -> Number', F\max()],
123
-	['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
+    ['split', 'String -> String -> List', F\split()],
37
+    ['join', 'String -> List -> String', F\join()],
38
+    ['replace', 'String|List -> String|List -> String -> String', F\replace()],
39
+    ['regReplace', 'String -> String -> String -> String', F\regReplace()],
40
+    ['upperCase', 'String -> String', F\upperCase()],
41
+    ['lowerCase', 'String -> String', F\lowerCase()],
42
+    ['camelCase', 'String -> String', F\camelCase()],
43
+    ['snakeCase', 'String -> String -> String', F\snakeCase()],
44
+    ['startsWith', 'String -> String -> Boolean', F\startsWith()],
45
+    ['endsWith', 'String -> String -> Boolean', F\endsWith()],
46
+    ['test', 'String -> String -> Boolean', F\test()],
47
+    ['match', 'String -> String -> List', F\match()],
48
+    ['occurences', 'String -> String -> Number', F\occurences()],
49
+    ['chunks', 'String -> String -> String -> List', F\chunks()],
50
+    ['map', 'Function -> List -> List', F\map()],
51
+    ['chain', 'Function -> List -> List', F\chain()],
52
+    ['filter', 'Function -> List -> List', F\filter()],
53
+    ['reduce', 'Function -> Any -> List -> Any', F\reduce()],
54
+    ['each', 'Function -> List -> List', F\each()],
55
+    ['head', 'List -> Any', F\head()],
56
+    ['head', 'String -> String', F\head()],
57
+    ['last', 'List -> Any', F\last()],
58
+    ['last', 'String -> String', F\last()],
59
+    ['init', 'List -> Any', F\init()],
60
+    ['init', 'String -> String', F\init()],
61
+    ['tail', 'List -> Any', F\tail()],
62
+    ['tail', 'String -> String', F\tail()],
63
+    ['reverse', 'List -> List', F\reverse()],
64
+    ['reverse', 'String -> String', F\reverse()],
65
+    ['length', 'List -> Number', F\length()],
66
+    ['length', 'String -> Number', F\length()],
67
+    ['allSatisfies', 'Function -> List -> Boolean', F\allSatisfies()],
68
+    ['anySatisfies', 'Function -> List -> Boolean', F\anySatisfies()],
69
+    ['concat', 'List -> List -> List', F\concat()],
70
+    ['concat', 'String -> String -> String', F\concat()],
71
+    ['concatAll', 'List -> List', F\concatAll()],
72
+    ['insert', 'Number -> Any -> List -> List', F\insert()],
73
+    ['insert', 'Number -> String -> String -> String', F\insert()],
74
+    ['insertAll', 'Number -> List -> List -> List', F\insertAll()],
75
+    ['insertAll', 'Number -> String -> String -> String', F\insertAll()],
76
+    ['append', 'Any -> List -> List', F\append()],
77
+    ['append', 'String -> String -> String', F\append()],
78
+    ['prepend', 'Any -> List -> List', F\prepend()],
79
+    ['prepend', 'String -> String -> String', F\prepend()],
80
+    ['take', 'Number -> List -> List', F\take()],
81
+    ['take', 'Number -> String -> String', F\take()],
82
+    ['takeWhile', 'Function -> List -> List', F\takeWhile()],
83
+    ['takeLastWhile', 'Function -> List -> List', F\takeLastWhile()],
84
+    ['takeUntil', 'Function -> List -> List', F\takeUntil()],
85
+    ['takeLastUntil', 'Function -> List -> List', F\takeLastUntil()],
86
+    ['remove', 'Number -> List -> List', F\remove()],
87
+    ['remove', 'Number -> String -> String', F\remove()],
88
+    ['removeWhile', 'Function -> List -> List', F\removeWhile()],
89
+    ['removeLastWhile', 'Function -> List -> List', F\removeLastWhile()],
90
+    ['removeUntil', 'Function -> List -> List', F\removeUntil()],
91
+    ['removeLastUntil', 'Function -> List -> List', F\removeLastUntil()],
92
+    ['fromPairs', 'List -> Object|Array', F\fromPairs()],
93
+    ['slices', 'Number -> List -> List', F\slices()],
94
+    ['slices', 'Number -> String -> List', F\slices()],
95
+    ['contains', 'Any -> List -> Boolean', F\contains()],
96
+    ['contains', 'String -> String -> Boolean', F\contains()],
97
+    ['findIndex', 'Function -> List -> Number|Null', F\findIndex()],
98
+    ['findIndex', 'Function -> Object|Array -> Any', F\findIndex()],
99
+    ['findLastIndex', 'Function -> List -> Number|Null', F\findLastIndex()],
100
+    ['findLastIndex', 'Function -> Object|Array -> Any', F\findLastIndex()],
101
+    ['find', 'Function -> List -> Any', F\find()],
102
+    ['findLast', 'Function -> List -> Any', F\findLast()],
103
+    ['indexOf', 'Any -> List -> Number', F\indexOf()],
104
+    ['indexOf', 'Any -> Object|Array -> Any', F\indexOf()],
105
+    ['indexOf', 'String -> String -> Number', F\indexOf()],
106
+    ['lastIndexOf', 'Any -> List -> Number', F\lastIndexOf()],
107
+    ['lastIndexOf', 'String -> String -> Number', F\lastIndexOf()],
108
+    ['uniqueBy', 'Function -> List -> List', F\uniqueBy()],
109
+    ['unique', 'List -> List', F\unique()],
110
+    ['groupBy', 'Function -> List -> Object|Array', F\groupBy()],
111
+    ['pairsFrom', 'List -> List -> List', F\pairsFrom()],
112
+    ['plus', 'Number -> Number -> Number', F\plus()],
113
+    ['minus', 'Number -> Number -> Number', F\minus()],
114
+    ['negate', 'Number -> Number', F\negate()],
115
+    ['multiply', 'Number -> Number -> Number', F\multiply()],
116
+    ['divide', 'Number -> Number -> Number', F\divide()],
117
+    ['modulo', 'Number -> Number -> Number', F\modulo()],
118
+    ['sum', 'List -> Number', F\sum()],
119
+    ['product', 'List -> Number', F\product()],
120
+    ['min', 'Number -> Number -> Number', F\min()],
121
+    ['minBy', 'Function -> Any -> Any -> Any', F\minBy()],
122
+    ['max', 'Number -> Number -> Number', F\max()],
123
+    ['maxBy', 'Function -> Any -> Any -> Any', F\maxBy()],
124 124
 
125 125
 ]);
Please login to merge, or discard this patch.
src/common.php 1 patch
Braces   +12 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,9 +32,15 @@  discard block
 block discarded – undo
32 32
 function type() {
33 33
     static $type = false;
34 34
     $type = $type ?: curry(function($data) {
35
-        if ($data instanceof Error) return 'Error';
36
-        if ($data instanceof Stream) return "Stream";
37
-        if (is_callable($data)) return 'Function';
35
+        if ($data instanceof Error) {
36
+            return 'Error';
37
+        }
38
+        if ($data instanceof Stream) {
39
+            return "Stream";
40
+        }
41
+        if (is_callable($data)) {
42
+            return 'Function';
43
+        }
38 44
         switch (gettype($data)) {
39 45
             case 'boolean':
40 46
                 return 'Boolean';
@@ -48,8 +54,9 @@  discard block
 block discarded – undo
48 54
             case 'resource':
49 55
                 return 'Resource';
50 56
             case 'array':
51
-                if (allSatisfies('is_numeric', keys($data)))
52
-                    return 'List';
57
+                if (allSatisfies('is_numeric', keys($data))) {
58
+                                    return 'List';
59
+                }
53 60
                 return 'Array';
54 61
             case 'object':
55 62
                 return 'Object';
Please login to merge, or discard this patch.