Completed
Pull Request — master (#6)
by
unknown
03:41 queued 01:28
created
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.
build.php 1 patch
Braces   +55 added lines, -37 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
 
@@ -676,8 +693,9 @@  discard block
 block discarded – undo
676 693
 
677 694
 // Convert Warnings to Exceptions
678 695
 set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) {
679
-    if (0 === error_reporting())
680
-        return false;
696
+    if (0 === error_reporting()) {
697
+            return false;
698
+    }
681 699
     throw new \ErrorException($errstr, 0, $errno, $errfile, $errline);
682 700
 });
683 701
 
Please login to merge, or discard this patch.
src/string.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -336,10 +336,10 @@
 block discarded – undo
336 336
         // $text = 'foo ("bar baz" alpha) beta'
337 337
         $counters = [
338 338
             'values'   => [], // each item of this array refers to the number
339
-                              // of closings needed for an opening
339
+                                // of closings needed for an opening
340 340
             'openings' => [], // an associative array where the key is an opening
341
-                              // and the value is the index of corresponding cell
342
-                              // in the 'values' field
341
+                                // and the value is the index of corresponding cell
342
+                                // in the 'values' field
343 343
             'closings' => [], // associative array for closings like the previous one
344 344
             'total'    => 0   // the total number of needed closings
345 345
         ];
Please login to merge, or discard this patch.
Braces   +8 added lines, -6 removed lines patch added patch discarded remove patch
@@ -345,10 +345,11 @@  discard block
 block discarded – undo
345 345
         ];
346 346
         foreach (str_split($surrounders) as $key => $char) {
347 347
             $counters['values'][$key / 2] = 0;
348
-            if ($key % 2 == 0)
349
-                $counters['openings'][$char] = $key / 2;
350
-            else
351
-                $counters['closings'][$char] = $key / 2;
348
+            if ($key % 2 == 0) {
349
+                            $counters['openings'][$char] = $key / 2;
350
+            } else {
351
+                            $counters['closings'][$char] = $key / 2;
352
+            }
352 353
         }
353 354
         // $counters = [
354 355
         //   'values'   => [0, 0, 0],
@@ -394,8 +395,9 @@  discard block
 block discarded – undo
394 395
                 $index ++;
395 396
             }
396 397
         }
397
-        if ($buffer != '')
398
-            $result[] = $buffer;
398
+        if ($buffer != '') {
399
+                    $result[] = $buffer;
400
+        }
399 401
 
400 402
         return $result;
401 403
     });
Please login to merge, or discard this patch.
src/object.php 1 patch
Braces   +21 added lines, -12 removed lines patch added patch discarded remove patch
@@ -80,8 +80,9 @@  discard block
 block discarded – undo
80 80
 function attributes() {
81 81
     static $attrs = false;
82 82
     $attrs = $attrs ?: curry(function($object) {
83
-        if (is_object($object))
84
-            return get_object_vars($object);
83
+        if (is_object($object)) {
84
+                    return get_object_vars($object);
85
+        }
85 86
         return $object;
86 87
     });
87 88
     return _apply($attrs, func_get_args());
@@ -174,8 +175,12 @@  discard block
 block discarded – undo
174 175
 function has() {
175 176
     static $has = false;
176 177
     $has = $has ?: curry(function($name, $object){
177
-        if (is_object($object)) return isset($object->{$name});
178
-        if (is_array($object)) return isset($object[$name]);
178
+        if (is_object($object)) {
179
+            return isset($object->{$name});
180
+        }
181
+        if (is_array($object)) {
182
+            return isset($object[$name]);
183
+        }
179 184
         return false;
180 185
     });
181 186
     return _apply($has, func_get_args());
@@ -276,8 +281,9 @@  discard block
 block discarded – undo
276 281
         if (is_object($object)) {
277 282
             $object = clone_($object);
278 283
             $object->{$name} = $value;
279
-        } else
280
-            $object[$name] = $value;
284
+        } else {
285
+                    $object[$name] = $value;
286
+        }
281 287
         return $object;
282 288
     });
283 289
     return _apply($set, func_get_args());
@@ -370,8 +376,9 @@  discard block
 block discarded – undo
370 376
     static $satisfiesAll = false;
371 377
     $satisfiesAll = $satisfiesAll ?: curry(function($predicates, $object) {
372 378
         foreach ($predicates as $key => $predicate) {
373
-            if (!satisfies($predicate, $key, $object))
374
-                return false;
379
+            if (!satisfies($predicate, $key, $object)) {
380
+                            return false;
381
+            }
375 382
         }
376 383
         return true;
377 384
     });
@@ -408,8 +415,9 @@  discard block
 block discarded – undo
408 415
     static $satisfiesAny = false;
409 416
     $satisfiesAny = $satisfiesAny ?: curry(function($predicates, $object) {
410 417
         foreach ($predicates as $key => $predicate) {
411
-            if (satisfies($predicate, $key, $object))
412
-                return true;
418
+            if (satisfies($predicate, $key, $object)) {
419
+                            return true;
420
+            }
413 421
         }
414 422
         return false;
415 423
     });
@@ -433,8 +441,9 @@  discard block
 block discarded – undo
433 441
 function toPairs() {
434 442
     static $toPairs = false;
435 443
     $toPairs = $toPairs ?: curry(function($object) {
436
-        if (is_object($object))
437
-            $object = get_object_vars($object);
444
+        if (is_object($object)) {
445
+                    $object = get_object_vars($object);
446
+        }
438 447
         $result = [];
439 448
         foreach ($object as $key => $value) {
440 449
             $result[] = [$key, $value];
Please login to merge, or discard this patch.
src/operators.php 1 patch
Braces   +18 added lines, -12 removed lines patch added patch discarded remove patch
@@ -184,17 +184,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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;
Please login to merge, or discard this patch.
src/Internal/_stream_operations.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -3,127 +3,127 @@
 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
-	['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
 ]);
Please login to merge, or discard this patch.
performance/scripts/object-oriented.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -103,8 +103,9 @@
 block discarded – undo
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());
Please login to merge, or discard this patch.
src/Internal/_functions.php 2 patches
Braces   +39 added lines, -26 removed lines patch added patch discarded remove patch
@@ -119,25 +119,30 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -314,11 +314,11 @@
 block discarded – undo
314 314
 }
315 315
 
316 316
 function _iterable_reduce(callable $reducer, $acc, \Iterator $iterator) {
317
-	$iterator->rewind();
318
-	while ($iterator->valid()) {
319
-		$acc = $reducer($acc, $iterator->current(), $iterator->key());
320
-		$iterator->next();
321
-	}
322
-	return $acc;
317
+    $iterator->rewind();
318
+    while ($iterator->valid()) {
319
+        $acc = $reducer($acc, $iterator->current(), $iterator->key());
320
+        $iterator->next();
321
+    }
322
+    return $acc;
323 323
 }
324 324
 
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
@@ -33,9 +33,15 @@  discard block
 block discarded – undo
33 33
 function type() {
34 34
     static $type = false;
35 35
     $type = $type ?: _curry_one(function($data) {
36
-        if ($data instanceof Error) return 'Error';
37
-        if ($data instanceof Stream) return 'Stream';
38
-        if (is_callable($data)) return 'Function';
36
+        if ($data instanceof Error) {
37
+            return 'Error';
38
+        }
39
+        if ($data instanceof Stream) {
40
+            return 'Stream';
41
+        }
42
+        if (is_callable($data)) {
43
+            return 'Function';
44
+        }
39 45
         switch (gettype($data)) {
40 46
             case 'boolean':
41 47
                 return 'Boolean';
@@ -49,8 +55,9 @@  discard block
 block discarded – undo
49 55
             case 'resource':
50 56
                 return 'Resource';
51 57
             case 'array':
52
-                if (allSatisfies('is_numeric', keys($data)))
53
-                    return 'List';
58
+                if (allSatisfies('is_numeric', keys($data))) {
59
+                                    return 'List';
60
+                }
54 61
                 return 'Array';
55 62
             case 'object':
56 63
                 return 'Object';
Please login to merge, or discard this patch.