@@ -578,17 +578,17 @@ |
||
578 | 578 | protected function defaults(): self |
579 | 579 | { |
580 | 580 | $this->addOption('-h|--help', 'Show help') |
581 | - ->on([$this, 'showHelp']); |
|
581 | + ->on([$this, 'showHelp']); |
|
582 | 582 | |
583 | 583 | $this->addOption('-v|--version', 'Show version') |
584 | - ->on([$this, 'showVersion']); |
|
584 | + ->on([$this, 'showVersion']); |
|
585 | 585 | |
586 | 586 | $this->addOption('-V|--verbosity', 'Verbosity level', 0) |
587 | - ->on(function () { |
|
587 | + ->on(function () { |
|
588 | 588 | $this->set('verbosity', ++$this->verbosity); |
589 | 589 | |
590 | 590 | return false; |
591 | - }); |
|
591 | + }); |
|
592 | 592 | |
593 | 593 | $this->onExit(function (int $exitCode = 0) { |
594 | 594 | $this->terminate($exitCode); |
@@ -584,13 +584,13 @@ |
||
584 | 584 | ->on([$this, 'showVersion']); |
585 | 585 | |
586 | 586 | $this->addOption('-V|--verbosity', 'Verbosity level', 0) |
587 | - ->on(function () { |
|
587 | + ->on(function() { |
|
588 | 588 | $this->set('verbosity', ++$this->verbosity); |
589 | 589 | |
590 | 590 | return false; |
591 | 591 | }); |
592 | 592 | |
593 | - $this->onExit(function (int $exitCode = 0) { |
|
593 | + $this->onExit(function(int $exitCode = 0) { |
|
594 | 594 | $this->terminate($exitCode); |
595 | 595 | }); |
596 | 596 |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | * Class Command |
65 | 65 | * @package Platine\Console\Command |
66 | 66 | */ |
67 | -class Command extends Parser |
|
68 | -{ |
|
67 | +class Command extends Parser { |
|
69 | 68 | /** |
70 | 69 | * The command version |
71 | 70 | * @var string |
@@ -395,8 +394,7 @@ discard block |
||
395 | 394 | * Show this command help and abort |
396 | 395 | * @return mixed |
397 | 396 | */ |
398 | - public function showHelp() |
|
399 | - { |
|
397 | + public function showHelp() { |
|
400 | 398 | $io = $this->io(); |
401 | 399 | $helper = new OutputHelper($io->writer()); |
402 | 400 | |
@@ -442,8 +440,7 @@ discard block |
||
442 | 440 | * Show this command version and abort |
443 | 441 | * @return mixed |
444 | 442 | */ |
445 | - public function showVersion() |
|
446 | - { |
|
443 | + public function showVersion() { |
|
447 | 444 | $this->writer()->bold( |
448 | 445 | sprintf( |
449 | 446 | '%s, %s', |
@@ -460,8 +457,7 @@ discard block |
||
460 | 457 | * Execute the command |
461 | 458 | * @return mixed |
462 | 459 | */ |
463 | - public function execute() |
|
464 | - { |
|
460 | + public function execute() { |
|
465 | 461 | } |
466 | 462 | |
467 | 463 | /** |
@@ -480,16 +476,14 @@ discard block |
||
480 | 476 | * @param mixed $object |
481 | 477 | * @return mixed |
482 | 478 | */ |
483 | - public function tap($object = null) |
|
484 | - { |
|
479 | + public function tap($object = null) { |
|
485 | 480 | return $object ?? $this->app; |
486 | 481 | } |
487 | 482 | |
488 | 483 | /** |
489 | 484 | * {@inheritdoc} |
490 | 485 | */ |
491 | - public function emit(string $event, $value = null) |
|
492 | - { |
|
486 | + public function emit(string $event, $value = null) { |
|
493 | 487 | if (empty($this->events[$event])) { |
494 | 488 | return null; |
495 | 489 | } |
@@ -502,8 +496,7 @@ discard block |
||
502 | 496 | * @param string $longName |
503 | 497 | * @return mixed|null |
504 | 498 | */ |
505 | - public function getOptionValue(string $longName) |
|
506 | - { |
|
499 | + public function getOptionValue(string $longName) { |
|
507 | 500 | $values = $this->values(); |
508 | 501 | |
509 | 502 | return array_key_exists($longName, $values) |
@@ -516,8 +509,7 @@ discard block |
||
516 | 509 | * @param string $name |
517 | 510 | * @return mixed|null |
518 | 511 | */ |
519 | - public function getArgumentValue(string $name) |
|
520 | - { |
|
512 | + public function getArgumentValue(string $name) { |
|
521 | 513 | $values = $this->values(); |
522 | 514 | |
523 | 515 | return array_key_exists($name, $values) |
@@ -550,8 +542,7 @@ discard block |
||
550 | 542 | /** |
551 | 543 | * {@inheritdoc} |
552 | 544 | */ |
553 | - protected function handleUnknown(string $arg, $value = null) |
|
554 | - { |
|
545 | + protected function handleUnknown(string $arg, $value = null) { |
|
555 | 546 | if ($this->allowUnknown) { |
556 | 547 | return $this->set(Helper::toCamelCase($arg), $value); |
557 | 548 | } |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class Argument |
53 | 53 | * @package Platine\Console\Input |
54 | 54 | */ |
55 | -class Argument extends Parameter |
|
56 | -{ |
|
55 | +class Argument extends Parameter { |
|
57 | 56 | /** |
58 | 57 | * {@inheritdoc} |
59 | 58 | */ |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * Class Parameter |
55 | 55 | * @package Platine\Console\Input |
56 | 56 | */ |
57 | -abstract class Parameter |
|
58 | -{ |
|
57 | +abstract class Parameter { |
|
59 | 58 | /** |
60 | 59 | * The name of the parameter |
61 | 60 | * @var string |
@@ -182,8 +181,7 @@ discard block |
||
182 | 181 | * Return the parameter default value |
183 | 182 | * @return mixed |
184 | 183 | */ |
185 | - public function getDefault() |
|
186 | - { |
|
184 | + public function getDefault() { |
|
187 | 185 | if ($this->isVariadic()) { |
188 | 186 | return (array) $this->default; |
189 | 187 | } |
@@ -233,8 +231,7 @@ discard block |
||
233 | 231 | * @param mixed $raw |
234 | 232 | * @return mixed |
235 | 233 | */ |
236 | - public function filter($raw) |
|
237 | - { |
|
234 | + public function filter($raw) { |
|
238 | 235 | if ($this->filter !== null) { |
239 | 236 | $callback = $this->filter; |
240 | 237 |
@@ -52,8 +52,7 @@ |
||
52 | 52 | * Class Cursor |
53 | 53 | * @package Platine\Console\Output |
54 | 54 | */ |
55 | -class Cursor |
|
56 | -{ |
|
55 | +class Cursor { |
|
57 | 56 | /** |
58 | 57 | * Returns signal to move cursor up "count" times. |
59 | 58 | * @param int $count |
@@ -609,8 +609,7 @@ discard block |
||
609 | 609 | * @method string darkgrayBgWhite(string $text) |
610 | 610 | * @method string darkgrayBgGray(string $text) |
611 | 611 | */ |
612 | -class Color |
|
613 | -{ |
|
612 | +class Color { |
|
614 | 613 | /** |
615 | 614 | * The color constants |
616 | 615 | */ |
@@ -765,8 +764,7 @@ discard block |
||
765 | 764 | * @return mixed |
766 | 765 | * @throws Error |
767 | 766 | */ |
768 | - public function __call(string $method, array $args = []) |
|
769 | - { |
|
767 | + public function __call(string $method, array $args = []) { |
|
770 | 768 | $colors = [ |
771 | 769 | 'black' => self::BLACK, |
772 | 770 | 'red' => self::RED, |
@@ -55,8 +55,7 @@ |
||
55 | 55 | * Class Table |
56 | 56 | * @package Platine\Console\Output |
57 | 57 | */ |
58 | -class Table |
|
59 | -{ |
|
58 | +class Table { |
|
60 | 59 | /** |
61 | 60 | * Render table data |
62 | 61 | * @param array<int, array<int, array<string, string>>> $rows |
@@ -607,8 +607,7 @@ discard block |
||
607 | 607 | * @method Writer darkgrayBgWhite(string $text, bool $eol = false) |
608 | 608 | * @method Writer darkgrayBgGray(string $text, bool $eol = false) |
609 | 609 | */ |
610 | -class Writer |
|
611 | -{ |
|
610 | +class Writer { |
|
612 | 611 | /** |
613 | 612 | * The output stream |
614 | 613 | * @var resource |
@@ -644,8 +643,7 @@ discard block |
||
644 | 643 | * @param string|null $path the output write path |
645 | 644 | * @param Color|null $color the color instance |
646 | 645 | */ |
647 | - public function __construct(?string $path = null, ?Color $color = null) |
|
648 | - { |
|
646 | + public function __construct(?string $path = null, ?Color $color = null) { |
|
649 | 647 | $stream = null; |
650 | 648 | if ($path !== null) { |
651 | 649 | $stream = fopen($path, 'w'); |
@@ -772,8 +770,7 @@ discard block |
||
772 | 770 | * @param array<int, mixed> $args |
773 | 771 | * @return $this |
774 | 772 | */ |
775 | - public function __call(string $method, array $args = []) |
|
776 | - { |
|
773 | + public function __call(string $method, array $args = []) { |
|
777 | 774 | if (method_exists($this->cursor, $method)) { |
778 | 775 | return $this->cursor->{$method}(...$args); |
779 | 776 | } |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * Class Helper |
56 | 56 | * @package Platine\Console\Util |
57 | 57 | */ |
58 | -class Helper |
|
59 | -{ |
|
58 | +class Helper { |
|
60 | 59 | /** |
61 | 60 | * Convert the given string to camel case |
62 | 61 | * @param string $str |
@@ -122,8 +121,7 @@ discard block |
||
122 | 121 | * @param string|null $value |
123 | 122 | * @return mixed |
124 | 123 | */ |
125 | - public static function normalizeValue(Parameter $parameter, ?string $value = null) |
|
126 | - { |
|
124 | + public static function normalizeValue(Parameter $parameter, ?string $value = null) { |
|
127 | 125 | if ($parameter instanceof Option && $parameter->isBool()) { |
128 | 126 | return !$parameter->getDefault(); |
129 | 127 | } |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | * Class Reader |
53 | 53 | * @package Platine\Console\Input |
54 | 54 | */ |
55 | -class Reader |
|
56 | -{ |
|
55 | +class Reader { |
|
57 | 56 | /** |
58 | 57 | * The input stream |
59 | 58 | * @var resource |
@@ -64,8 +63,7 @@ discard block |
||
64 | 63 | * Create new instance |
65 | 64 | * @param string|null $path the input read path |
66 | 65 | */ |
67 | - public function __construct(?string $path = null) |
|
68 | - { |
|
66 | + public function __construct(?string $path = null) { |
|
69 | 67 | $stream = STDIN; |
70 | 68 | if ($path !== null) { |
71 | 69 | $stream = fopen($path, 'r'); |
@@ -80,8 +78,7 @@ discard block |
||
80 | 78 | * @param callable|null $callback The validator/sanitizer callback. |
81 | 79 | * @return mixed |
82 | 80 | */ |
83 | - public function read($default = null, ?callable $callback = null) |
|
84 | - { |
|
81 | + public function read($default = null, ?callable $callback = null) { |
|
85 | 82 | // see https://www.php.net/manual/en/filesystem.configuration.php#ini.auto-detect-line-endings |
86 | 83 | ini_set('auto_detect_line_endings', 'true'); |
87 | 84 | $input = ''; |
@@ -105,8 +102,7 @@ discard block |
||
105 | 102 | * @param callable|null $callback The validator/sanitizer callback. |
106 | 103 | * @return mixed |
107 | 104 | */ |
108 | - public function readAll(?callable $callback = null) |
|
109 | - { |
|
105 | + public function readAll(?callable $callback = null) { |
|
110 | 106 | $input = stream_get_contents($this->stream); |
111 | 107 | |
112 | 108 | return $callback !== null |
@@ -119,8 +115,7 @@ discard block |
||
119 | 115 | * @param callable|null $callback The validator/sanitizer callback. |
120 | 116 | * @return mixed |
121 | 117 | */ |
122 | - public function readPipe(?callable $callback = null) |
|
123 | - { |
|
118 | + public function readPipe(?callable $callback = null) { |
|
124 | 119 | $stdin = ''; |
125 | 120 | $read = [$this->stream]; |
126 | 121 | $write = []; |
@@ -146,8 +141,7 @@ discard block |
||
146 | 141 | * @param callable|null $callback The validator/sanitizer callback. |
147 | 142 | * @return mixed |
148 | 143 | */ |
149 | - public function readHidden($default = null, ?callable $callback = null) |
|
150 | - { |
|
144 | + public function readHidden($default = null, ?callable $callback = null) { |
|
151 | 145 | if (substr(strtoupper(PHP_OS), 0, 3) === 'WIN') { |
152 | 146 | return $this->readHiddenWindows($default, $callback); |
153 | 147 | } |
@@ -168,8 +162,7 @@ discard block |
||
168 | 162 | * @param callable|null $callback The validator/sanitizer callback. |
169 | 163 | * @return mixed |
170 | 164 | */ |
171 | - protected function readHiddenWindows($default = null, ?callable $callback = null) |
|
172 | - { |
|
165 | + protected function readHiddenWindows($default = null, ?callable $callback = null) { |
|
173 | 166 | $cmd = 'powershell -Command ' . implode('; ', array_filter([ |
174 | 167 | '$pword = Read-Host -AsSecureString', |
175 | 168 | '$pword = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword)', |