@@ -634,8 +634,6 @@ discard block |
||
| 634 | 634 | * Gets an element of the stream methods list. |
| 635 | 635 | * |
| 636 | 636 | * @signature String -> Block -> String |
| 637 | - * @param string $moduleName |
|
| 638 | - * @param object $block |
|
| 639 | 637 | * @return string |
| 640 | 638 | */ |
| 641 | 639 | function stream_method_link() { |
@@ -661,7 +659,6 @@ discard block |
||
| 661 | 659 | * Dump a variable and returns it. |
| 662 | 660 | * |
| 663 | 661 | * @signature a -> a |
| 664 | - * @param mixed $something |
|
| 665 | 662 | * @return mixed |
| 666 | 663 | */ |
| 667 | 664 | function log() { |
@@ -148,14 +148,16 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |
@@ -26,7 +26,6 @@ discard block |
||
| 26 | 26 | * ``` |
| 27 | 27 | * |
| 28 | 28 | * @signature * -> String |
| 29 | - * @param mixed $data |
|
| 30 | 29 | * @return string |
| 31 | 30 | */ |
| 32 | 31 | function type() { |
@@ -73,8 +72,6 @@ discard block |
||
| 73 | 72 | * |
| 74 | 73 | * @stream |
| 75 | 74 | * @signature String -> * -> Boolean |
| 76 | - * @param string $type |
|
| 77 | - * @param mixed $data |
|
| 78 | 75 | * @return boolean |
| 79 | 76 | */ |
| 80 | 77 | function is() { |
@@ -109,7 +106,6 @@ discard block |
||
| 109 | 106 | * |
| 110 | 107 | * @stream |
| 111 | 108 | * @signature * -> String |
| 112 | - * @param mixed $something |
|
| 113 | 109 | * @return string |
| 114 | 110 | */ |
| 115 | 111 | function toString () { |
@@ -33,9 +33,15 @@ discard block |
||
| 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 |
||
| 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'; |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * Returns supported types in signatures. |
| 41 | 41 | * |
| 42 | 42 | * @signature List |
| 43 | - * @return array |
|
| 43 | + * @return string[] |
|
| 44 | 44 | */ |
| 45 | 45 | function _stream_types() { |
| 46 | 46 | return [ |
@@ -126,7 +126,6 @@ discard block |
||
| 126 | 126 | * @signature String -> String -> Maybe(Function) -> Operation |
| 127 | 127 | * @param string $name |
| 128 | 128 | * @param string $signature |
| 129 | - * @param callable $fn |
|
| 130 | 129 | * @return array |
| 131 | 130 | */ |
| 132 | 131 | function _stream_operation($name, $signature, $callable = null) { |
@@ -190,8 +189,6 @@ discard block |
||
| 190 | 189 | * F\_stream_ensure_type('List -> Bar', 'Bar'); // throws "Stream: invalid signature 'List -> Bar' it should follow the syntax 'TypeArg1 -> TypeArg2 -> ... -> ReturnType' and types to use are Boolean, Number, String, Resource, Function, List, Array, Object, Any" |
| 191 | 190 | * ``` |
| 192 | 191 | * @signature String -> String -> String |
| 193 | - * @param string $signature |
|
| 194 | - * @param string $type |
|
| 195 | 192 | * @return string |
| 196 | 193 | */ |
| 197 | 194 | function _stream_ensure_type() { |
@@ -491,8 +488,6 @@ discard block |
||
| 491 | 488 | * ``` |
| 492 | 489 | * |
| 493 | 490 | * @signature [String] -> Operation -> Boolean |
| 494 | - * @param array $argsTypes |
|
| 495 | - * @param array $operation |
|
| 496 | 491 | * @return bool |
| 497 | 492 | */ |
| 498 | 493 | function _stream_operation_is_applicable() { |
@@ -131,8 +131,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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) { |
@@ -14,8 +14,6 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @stream |
| 16 | 16 | * @signature Number -> Number -> Number |
| 17 | - * @param int|float $x |
|
| 18 | - * @param int|float $y |
|
| 19 | 17 | * @return int|float |
| 20 | 18 | */ |
| 21 | 19 | function plus() { |
@@ -35,8 +33,6 @@ discard block |
||
| 35 | 33 | * |
| 36 | 34 | * @stream |
| 37 | 35 | * @signature Number -> Number -> Number |
| 38 | - * @param int|float $x |
|
| 39 | - * @param int|float $y |
|
| 40 | 36 | * @return int|float |
| 41 | 37 | */ |
| 42 | 38 | function minus() { |
@@ -57,7 +53,6 @@ discard block |
||
| 57 | 53 | * |
| 58 | 54 | * @stream |
| 59 | 55 | * @signature Number -> Number |
| 60 | - * @param int|float $x |
|
| 61 | 56 | * @return int|float |
| 62 | 57 | */ |
| 63 | 58 | function negate() { |
@@ -78,8 +73,6 @@ discard block |
||
| 78 | 73 | * |
| 79 | 74 | * @stream |
| 80 | 75 | * @signature Number -> Number -> Number |
| 81 | - * @param int|float $x |
|
| 82 | - * @param int|float $y |
|
| 83 | 76 | * @return int|float |
| 84 | 77 | */ |
| 85 | 78 | function multiply() { |
@@ -99,8 +92,6 @@ discard block |
||
| 99 | 92 | * |
| 100 | 93 | * @stream |
| 101 | 94 | * @signature Number -> Number -> Number |
| 102 | - * @param int|float $x |
|
| 103 | - * @param int|float $y |
|
| 104 | 95 | * @return int|float |
| 105 | 96 | */ |
| 106 | 97 | function divide() { |
@@ -120,8 +111,6 @@ discard block |
||
| 120 | 111 | * |
| 121 | 112 | * @stream |
| 122 | 113 | * @signature Number -> Number -> Number |
| 123 | - * @param int|float $x |
|
| 124 | - * @param int|float $y |
|
| 125 | 114 | * @return int|float |
| 126 | 115 | */ |
| 127 | 116 | function modulo() { |
@@ -142,7 +131,6 @@ discard block |
||
| 142 | 131 | * |
| 143 | 132 | * @stream |
| 144 | 133 | * @signature [Number] -> Number |
| 145 | - * @param array $numbers |
|
| 146 | 134 | * @return int|float |
| 147 | 135 | */ |
| 148 | 136 | function sum() { |
@@ -163,7 +151,6 @@ discard block |
||
| 163 | 151 | * |
| 164 | 152 | * @stream |
| 165 | 153 | * @signature [Number] -> Number |
| 166 | - * @param array $numbers |
|
| 167 | 154 | * @return int|float |
| 168 | 155 | */ |
| 169 | 156 | function product() { |
@@ -184,8 +171,6 @@ discard block |
||
| 184 | 171 | * |
| 185 | 172 | * @stream |
| 186 | 173 | * @signature Number -> Number -> Number |
| 187 | - * @param number $a |
|
| 188 | - * @param number $b |
|
| 189 | 174 | * @return number |
| 190 | 175 | */ |
| 191 | 176 | function min() { |
@@ -206,9 +191,6 @@ discard block |
||
| 206 | 191 | * |
| 207 | 192 | * @stream |
| 208 | 193 | * @signature (a -> Number) -> a -> a -> a |
| 209 | - * @param callable $fn |
|
| 210 | - * @param mixed $a |
|
| 211 | - * @param mixed $b |
|
| 212 | 194 | * @return mixed |
| 213 | 195 | */ |
| 214 | 196 | function minBy() { |
@@ -229,8 +211,6 @@ discard block |
||
| 229 | 211 | * |
| 230 | 212 | * @stream |
| 231 | 213 | * @signature Number -> Number -> Number |
| 232 | - * @param number $a |
|
| 233 | - * @param number $b |
|
| 234 | 214 | * @return number |
| 235 | 215 | */ |
| 236 | 216 | function max() { |
@@ -251,9 +231,6 @@ discard block |
||
| 251 | 231 | * |
| 252 | 232 | * @stream |
| 253 | 233 | * @signature (a -> Number) -> a -> a -> a |
| 254 | - * @param callable $fn |
|
| 255 | - * @param mixed $a |
|
| 256 | - * @param mixed $b |
|
| 257 | 234 | * @return mixed |
| 258 | 235 | */ |
| 259 | 236 | function maxBy() { |
@@ -14,8 +14,6 @@ discard block |
||
| 14 | 14 | * |
| 15 | 15 | * @stream |
| 16 | 16 | * @signature String -> String -> [String] |
| 17 | - * @param string $delimiter |
|
| 18 | - * @param string $string |
|
| 19 | 17 | * @return array |
| 20 | 18 | */ |
| 21 | 19 | function split() { |
@@ -34,8 +32,6 @@ discard block |
||
| 34 | 32 | * |
| 35 | 33 | * @stream |
| 36 | 34 | * @signature String -> [String] -> String |
| 37 | - * @param string $glue |
|
| 38 | - * @param array $pieces |
|
| 39 | 35 | * @return string |
| 40 | 36 | */ |
| 41 | 37 | function join() { |
@@ -59,9 +55,6 @@ discard block |
||
| 59 | 55 | * |
| 60 | 56 | * @stream |
| 61 | 57 | * @signature String|[String] -> String|[String] -> String -> String |
| 62 | - * @param string $search |
|
| 63 | - * @param string $replacement |
|
| 64 | - * @param string $string |
|
| 65 | 58 | * @return string |
| 66 | 59 | */ |
| 67 | 60 | function replace() { |
@@ -81,9 +74,6 @@ discard block |
||
| 81 | 74 | * |
| 82 | 75 | * @stream |
| 83 | 76 | * @signature String -> String -> String -> String |
| 84 | - * @param string $pattern |
|
| 85 | - * @param string $replacement |
|
| 86 | - * @param string $string |
|
| 87 | 77 | * @return string |
| 88 | 78 | */ |
| 89 | 79 | function regReplace() { |
@@ -101,7 +91,6 @@ discard block |
||
| 101 | 91 | * |
| 102 | 92 | * @stream |
| 103 | 93 | * @signature String -> String |
| 104 | - * @param string $string |
|
| 105 | 94 | * @return string |
| 106 | 95 | */ |
| 107 | 96 | function upperCase() { |
@@ -119,7 +108,6 @@ discard block |
||
| 119 | 108 | * |
| 120 | 109 | * @stream |
| 121 | 110 | * @signature String -> String |
| 122 | - * @param string $string |
|
| 123 | 111 | * @return string |
| 124 | 112 | */ |
| 125 | 113 | function lowerCase() { |
@@ -137,7 +125,6 @@ discard block |
||
| 137 | 125 | * |
| 138 | 126 | * @stream |
| 139 | 127 | * @signature String -> String |
| 140 | - * @param string $string |
|
| 141 | 128 | * @return string |
| 142 | 129 | */ |
| 143 | 130 | function camelCase() { |
@@ -164,8 +151,6 @@ discard block |
||
| 164 | 151 | * |
| 165 | 152 | * @stream |
| 166 | 153 | * @signature String -> String -> String |
| 167 | - * @param string $delimiter |
|
| 168 | - * @param string $string |
|
| 169 | 154 | * @return string |
| 170 | 155 | */ |
| 171 | 156 | function snakeCase() { |
@@ -194,8 +179,6 @@ discard block |
||
| 194 | 179 | * |
| 195 | 180 | * @stream |
| 196 | 181 | * @signature String -> String -> Boolean |
| 197 | - * @param string $token |
|
| 198 | - * @param string $string |
|
| 199 | 182 | * @return bool |
| 200 | 183 | */ |
| 201 | 184 | function startsWith() { |
@@ -220,8 +203,6 @@ discard block |
||
| 220 | 203 | * |
| 221 | 204 | * @stream |
| 222 | 205 | * @signature String -> String -> Boolean |
| 223 | - * @param string $token |
|
| 224 | - * @param string $string |
|
| 225 | 206 | * @return bool |
| 226 | 207 | */ |
| 227 | 208 | function endsWith() { |
@@ -246,8 +227,6 @@ discard block |
||
| 246 | 227 | * |
| 247 | 228 | * @stream |
| 248 | 229 | * @signature String -> String -> Boolean |
| 249 | - * @param string $pattern |
|
| 250 | - * @param string $string |
|
| 251 | 230 | * @return bool |
| 252 | 231 | */ |
| 253 | 232 | function test() { |
@@ -270,8 +249,6 @@ discard block |
||
| 270 | 249 | * |
| 271 | 250 | * @stream |
| 272 | 251 | * @signature String -> String -> [String] |
| 273 | - * @param string $pattern |
|
| 274 | - * @param string $string |
|
| 275 | 252 | * @return array |
| 276 | 253 | */ |
| 277 | 254 | function match() { |
@@ -295,8 +272,6 @@ discard block |
||
| 295 | 272 | * |
| 296 | 273 | * @stream |
| 297 | 274 | * @signature String -> String -> Number |
| 298 | - * @param string $token |
|
| 299 | - * @param string $text |
|
| 300 | 275 | * @return int |
| 301 | 276 | */ |
| 302 | 277 | function occurences() { |
@@ -322,9 +297,6 @@ discard block |
||
| 322 | 297 | * |
| 323 | 298 | * @stream |
| 324 | 299 | * @signature String -> String -> String -> [String] |
| 325 | - * @param string $surrounders |
|
| 326 | - * @param string $separator |
|
| 327 | - * @param sring $text |
|
| 328 | 300 | * @return array |
| 329 | 301 | */ |
| 330 | 302 | function chunks() { |
@@ -345,10 +345,11 @@ discard block |
||
| 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 |
||
| 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 | }); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | /** |
| 4 | 4 | * Returns the list of scripts to compare. |
| 5 | 5 | * |
| 6 | - * @return array |
|
| 6 | + * @return string[] |
|
| 7 | 7 | */ |
| 8 | 8 | function scripts() { |
| 9 | 9 | return [ |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * and returns its running time in miliseconds. |
| 102 | 102 | * |
| 103 | 103 | * @param string $path |
| 104 | - * @return array |
|
| 104 | + * @return double |
|
| 105 | 105 | */ |
| 106 | 106 | function execute($path, $input) { |
| 107 | 107 | $start = microtime(true); |
@@ -80,8 +80,9 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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]; |
@@ -22,7 +22,6 @@ discard block |
||
| 22 | 22 | * ``` |
| 23 | 23 | * |
| 24 | 24 | * @signature a -> a |
| 25 | - * @param mixed $value |
|
| 26 | 25 | * @return mixed |
| 27 | 26 | */ |
| 28 | 27 | function clone_() { |
@@ -74,7 +73,6 @@ discard block |
||
| 74 | 73 | * |
| 75 | 74 | * @stream |
| 76 | 75 | * @signature {k: v} -> {k: v} |
| 77 | - * @param object|array $object |
|
| 78 | 76 | * @return array |
| 79 | 77 | */ |
| 80 | 78 | function attributes() { |
@@ -99,7 +97,6 @@ discard block |
||
| 99 | 97 | * @stream |
| 100 | 98 | * @signature [*] -> [Number] |
| 101 | 99 | * @signature {k: v} -> [k] |
| 102 | - * @param object|array $object |
|
| 103 | 100 | * @return array |
| 104 | 101 | */ |
| 105 | 102 | function keys() { |
@@ -124,7 +121,6 @@ discard block |
||
| 124 | 121 | * @stream |
| 125 | 122 | * @signature [a] -> [a] |
| 126 | 123 | * @signature {k: v} -> [v] |
| 127 | - * @param object|array $object |
|
| 128 | 124 | * @return array |
| 129 | 125 | */ |
| 130 | 126 | function values() { |
@@ -167,8 +163,6 @@ discard block |
||
| 167 | 163 | * |
| 168 | 164 | * @stream |
| 169 | 165 | * @signature k -> {k: v} -> Boolean |
| 170 | - * @param string|int $name |
|
| 171 | - * @param mixed $object |
|
| 172 | 166 | * @return bool |
| 173 | 167 | */ |
| 174 | 168 | function has() { |
@@ -202,8 +196,6 @@ discard block |
||
| 202 | 196 | * |
| 203 | 197 | * @stream |
| 204 | 198 | * @signature k -> {k: v} -> Maybe(v) |
| 205 | - * @param string $name |
|
| 206 | - * @param array $object |
|
| 207 | 199 | * @return mixed |
| 208 | 200 | */ |
| 209 | 201 | function get() { |
@@ -233,8 +225,6 @@ discard block |
||
| 233 | 225 | * |
| 234 | 226 | * @stream |
| 235 | 227 | * @signature [k] -> {k: v} -> v |
| 236 | - * @param array $path |
|
| 237 | - * @param mixed $object |
|
| 238 | 228 | * @return mixed |
| 239 | 229 | */ |
| 240 | 230 | function getPath() { |
@@ -265,9 +255,6 @@ discard block |
||
| 265 | 255 | * |
| 266 | 256 | * @stream |
| 267 | 257 | * @signature k -> v -> {k: v} -> {k: v} |
| 268 | - * @param string|int $name |
|
| 269 | - * @param mixed $value |
|
| 270 | - * @param mixed $object |
|
| 271 | 258 | * @return mixed |
| 272 | 259 | */ |
| 273 | 260 | function set() { |
@@ -299,9 +286,6 @@ discard block |
||
| 299 | 286 | * |
| 300 | 287 | * @stream |
| 301 | 288 | * @signature k -> (v -> v) -> {k: v} -> {k: v} |
| 302 | - * @param string|int $name |
|
| 303 | - * @param callable $fn |
|
| 304 | - * @param mixed $object |
|
| 305 | 289 | * @return mixed |
| 306 | 290 | */ |
| 307 | 291 | function update() { |
@@ -327,9 +311,6 @@ discard block |
||
| 327 | 311 | * |
| 328 | 312 | * @stream |
| 329 | 313 | * @signature (a -> Boolean) -> k -> {k : a} -> Boolean |
| 330 | - * @param callable $predicate |
|
| 331 | - * @param string|int $key |
|
| 332 | - * @param mixed $object |
|
| 333 | 314 | * @return bool |
| 334 | 315 | */ |
| 335 | 316 | function satisfies() { |
@@ -362,8 +343,6 @@ discard block |
||
| 362 | 343 | * |
| 363 | 344 | * @stream |
| 364 | 345 | * @signature {String: (a -> Boolean)} -> {k : a} -> Boolean |
| 365 | - * @param array $predicates |
|
| 366 | - * @param mixed $object |
|
| 367 | 346 | * @return bool |
| 368 | 347 | */ |
| 369 | 348 | function satisfiesAll() { |
@@ -400,8 +379,6 @@ discard block |
||
| 400 | 379 | * |
| 401 | 380 | * @stream |
| 402 | 381 | * @signature {String: (a -> Boolean)} -> {k : a} -> Boolean |
| 403 | - * @param array $predicates |
|
| 404 | - * @param mixed $object |
|
| 405 | 382 | * @return bool |
| 406 | 383 | */ |
| 407 | 384 | function satisfiesAny() { |
@@ -427,7 +404,6 @@ discard block |
||
| 427 | 404 | * @stream |
| 428 | 405 | * @signature {k: v} -> [(k,v)] |
| 429 | 406 | * @signature [v] -> [(Number,v)] |
| 430 | - * @param array $object |
|
| 431 | 407 | * @return array |
| 432 | 408 | */ |
| 433 | 409 | function toPairs() { |
@@ -184,17 +184,20 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | function _equals($a, $b) { |
| 186 | 186 | $type = type($a); |
| 187 | - if ($type != type($b)) |
|
| 188 | - return false; |
|
| 187 | + if ($type != type($b)) { |
|
| 188 | + return false; |
|
| 189 | + } |
|
| 189 | 190 | switch ($type) { |
| 190 | 191 | case 'List': |
| 191 | 192 | $length = count($a); |
| 192 | - if (count($b) != $length) |
|
| 193 | - return false; |
|
| 193 | + if (count($b) != $length) { |
|
| 194 | + return false; |
|
| 195 | + } |
|
| 194 | 196 | $index = 0; |
| 195 | 197 | while ($index < $length) { |
| 196 | - if (!_equals($a[$index], $b[$index])) |
|
| 197 | - return false; |
|
| 198 | + if (!_equals($a[$index], $b[$index])) { |
|
| 199 | + return false; |
|
| 200 | + } |
|
| 198 | 201 | $index ++; |
| 199 | 202 | } |
| 200 | 203 | return true; |
@@ -204,14 +207,17 @@ discard block |
||
| 204 | 207 | $keysA = keys($a); |
| 205 | 208 | $keysB = keys($b); |
| 206 | 209 | $length = count($keysA); |
| 207 | - if (count($keysB) != $length) |
|
| 208 | - return false; |
|
| 210 | + if (count($keysB) != $length) { |
|
| 211 | + return false; |
|
| 212 | + } |
|
| 209 | 213 | $index = 0; |
| 210 | 214 | while ($index < $length) { |
| 211 | - if (!_equals($keysA[$index], $keysB[$index])) |
|
| 212 | - return false; |
|
| 213 | - if (!_equals(get($keysA[$index], $a), get($keysB[$index], $b))) |
|
| 214 | - return false; |
|
| 215 | + if (!_equals($keysA[$index], $keysB[$index])) { |
|
| 216 | + return false; |
|
| 217 | + } |
|
| 218 | + if (!_equals(get($keysA[$index], $a), get($keysB[$index], $b))) { |
|
| 219 | + return false; |
|
| 220 | + } |
|
| 215 | 221 | $index ++; |
| 216 | 222 | } |
| 217 | 223 | return true; |
@@ -16,8 +16,6 @@ discard block |
||
| 16 | 16 | * |
| 17 | 17 | * @stream |
| 18 | 18 | * @signature Boolean -> Boolean -> Boolean |
| 19 | - * @param bool $a |
|
| 20 | - * @param bool $b |
|
| 21 | 19 | * @return bool |
| 22 | 20 | */ |
| 23 | 21 | function and_() { |
@@ -39,8 +37,6 @@ discard block |
||
| 39 | 37 | * |
| 40 | 38 | * @stream |
| 41 | 39 | * @signature Boolean -> Boolean -> Boolean |
| 42 | - * @param bool $a |
|
| 43 | - * @param bool $b |
|
| 44 | 40 | * @return bool |
| 45 | 41 | */ |
| 46 | 42 | function or_() { |
@@ -60,7 +56,6 @@ discard block |
||
| 60 | 56 | * |
| 61 | 57 | * @stream |
| 62 | 58 | * @signature Boolean -> Boolean |
| 63 | - * @param bool $x |
|
| 64 | 59 | * @return bool |
| 65 | 60 | */ |
| 66 | 61 | function not() { |
@@ -80,8 +75,6 @@ discard block |
||
| 80 | 75 | * |
| 81 | 76 | * @stream |
| 82 | 77 | * @signature * -> * -> Boolean |
| 83 | - * @param mixed $a |
|
| 84 | - * @param mixed $b |
|
| 85 | 78 | * @return bool |
| 86 | 79 | */ |
| 87 | 80 | function eq() { |
@@ -100,8 +93,6 @@ discard block |
||
| 100 | 93 | * |
| 101 | 94 | * @stream |
| 102 | 95 | * @signature * -> * -> Boolean |
| 103 | - * @param mixed $a |
|
| 104 | - * @param mixed $b |
|
| 105 | 96 | * @return bool |
| 106 | 97 | */ |
| 107 | 98 | function notEq() { |
@@ -120,8 +111,6 @@ discard block |
||
| 120 | 111 | * ``` |
| 121 | 112 | * @stream |
| 122 | 113 | * @signature * -> * -> Boolean |
| 123 | - * @param mixed $a |
|
| 124 | - * @param mixed $b |
|
| 125 | 114 | * @return bool |
| 126 | 115 | */ |
| 127 | 116 | function eqq() { |
@@ -141,8 +130,6 @@ discard block |
||
| 141 | 130 | * |
| 142 | 131 | * @stream |
| 143 | 132 | * @signature * -> * -> Boolean |
| 144 | - * @param mixed $a |
|
| 145 | - * @param mixed $b |
|
| 146 | 133 | * @return bool |
| 147 | 134 | */ |
| 148 | 135 | function notEqq() { |
@@ -173,8 +160,6 @@ discard block |
||
| 173 | 160 | * |
| 174 | 161 | * @stream |
| 175 | 162 | * @signature * -> * -> Boolean |
| 176 | - * @param mixed $a |
|
| 177 | - * @param mixed $b |
|
| 178 | 163 | * @return bool |
| 179 | 164 | */ |
| 180 | 165 | function equals() { |
@@ -258,8 +243,6 @@ discard block |
||
| 258 | 243 | * |
| 259 | 244 | * @stream |
| 260 | 245 | * @signature * -> * -> Boolean |
| 261 | - * @param mixed $a |
|
| 262 | - * @param mixed $b |
|
| 263 | 246 | * @return bool |
| 264 | 247 | */ |
| 265 | 248 | function lt() { |
@@ -280,8 +263,6 @@ discard block |
||
| 280 | 263 | * |
| 281 | 264 | * @stream |
| 282 | 265 | * @signature * -> * -> Boolean |
| 283 | - * @param mixed $a |
|
| 284 | - * @param mixed $b |
|
| 285 | 266 | * @return bool |
| 286 | 267 | */ |
| 287 | 268 | function lte() { |
@@ -302,8 +283,6 @@ discard block |
||
| 302 | 283 | * |
| 303 | 284 | * @stream |
| 304 | 285 | * @signature * -> * -> Boolean |
| 305 | - * @param mixed $a |
|
| 306 | - * @param mixed $b |
|
| 307 | 286 | * @return bool |
| 308 | 287 | */ |
| 309 | 288 | function gt() { |
@@ -324,8 +303,6 @@ discard block |
||
| 324 | 303 | * |
| 325 | 304 | * @stream |
| 326 | 305 | * @signature * -> * -> Boolean |
| 327 | - * @param mixed $a |
|
| 328 | - * @param mixed $b |
|
| 329 | 306 | * @return bool |
| 330 | 307 | */ |
| 331 | 308 | function gte() { |
@@ -103,8 +103,9 @@ |
||
| 103 | 103 | protected function getWordsHavingOccurrences($number) { |
| 104 | 104 | $result = []; |
| 105 | 105 | foreach ($this->list as $word) { |
| 106 | - if ($word->occurrences() == $number) |
|
| 107 | - $result[] = $word; |
|
| 106 | + if ($word->occurrences() == $number) { |
|
| 107 | + $result[] = $word; |
|
| 108 | + } |
|
| 108 | 109 | } |
| 109 | 110 | usort($result, function(Word $w1, Word $w2) { |
| 110 | 111 | return strcmp($w1->value(), $w2->value()); |