@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class RuntimeException |
| 39 | 39 | * @package Platine\Console\Exception |
| 40 | 40 | */ |
| 41 | -class RuntimeException extends ConsoleException |
|
| 42 | -{ |
|
| 41 | +class RuntimeException extends ConsoleException { |
|
| 43 | 42 | } |
@@ -40,6 +40,5 @@ |
||
| 40 | 40 | * Class ConsoleException |
| 41 | 41 | * @package Platine\Console\Exception |
| 42 | 42 | */ |
| 43 | -class ConsoleException extends Exception |
|
| 44 | -{ |
|
| 43 | +class ConsoleException extends Exception { |
|
| 45 | 44 | } |
@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class InvalidParameterException |
| 39 | 39 | * @package Platine\Console\Exception |
| 40 | 40 | */ |
| 41 | -class InvalidParameterException extends ConsoleException |
|
| 42 | -{ |
|
| 41 | +class InvalidParameterException extends ConsoleException { |
|
| 43 | 42 | } |
@@ -38,6 +38,5 @@ |
||
| 38 | 38 | * Class InvalidArgumentException |
| 39 | 39 | * @package Platine\Console\Exception |
| 40 | 40 | */ |
| 41 | -class InvalidArgumentException extends ConsoleException |
|
| 42 | -{ |
|
| 41 | +class InvalidArgumentException extends ConsoleException { |
|
| 43 | 42 | } |
@@ -360,9 +360,9 @@ |
||
| 360 | 360 | : ['pipe', 'w']; |
| 361 | 361 | |
| 362 | 362 | return [ |
| 363 | - self::STDIN_DESCRIPTOR => ['pipe', 'r'], |
|
| 364 | - self::STDOUT_DESCRIPTOR => $out, |
|
| 365 | - self::STDERR_DESCRIPTOR => $out, |
|
| 363 | + self::STDIN_DESCRIPTOR => ['pipe', 'r'], |
|
| 364 | + self::STDOUT_DESCRIPTOR => $out, |
|
| 365 | + self::STDERR_DESCRIPTOR => $out, |
|
| 366 | 366 | ]; |
| 367 | 367 | } |
| 368 | 368 | |
@@ -54,8 +54,7 @@ discard block |
||
| 54 | 54 | * Class Shell |
| 55 | 55 | * @package Platine\Console\Command |
| 56 | 56 | */ |
| 57 | -class Shell |
|
| 58 | -{ |
|
| 57 | +class Shell { |
|
| 59 | 58 | public const STDIN_DESCRIPTOR = 0; |
| 60 | 59 | public const STDOUT_DESCRIPTOR = 1; |
| 61 | 60 | public const STDERR_DESCRIPTOR = 2; |
@@ -152,8 +151,7 @@ discard block |
||
| 152 | 151 | /** |
| 153 | 152 | * Create new instance |
| 154 | 153 | */ |
| 155 | - public function __construct() |
|
| 156 | - { |
|
| 154 | + public function __construct() { |
|
| 157 | 155 | if (!function_exists('proc_open')) { |
| 158 | 156 | throw new RuntimeException( |
| 159 | 157 | 'The "proc_open" could not be found in your PHP setup' |
@@ -129,7 +129,7 @@ |
||
| 129 | 129 | }; |
| 130 | 130 | |
| 131 | 131 | $this->command('__default__', 'Default command', '', true, true) |
| 132 | - ->on([$this, 'showHelp'], 'help'); |
|
| 132 | + ->on([$this, 'showHelp'], 'help'); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | * Class Application |
| 60 | 60 | * @package Platine\Console |
| 61 | 61 | */ |
| 62 | -class Application |
|
| 63 | -{ |
|
| 62 | +class Application { |
|
| 64 | 63 | /** |
| 65 | 64 | * List of commands |
| 66 | 65 | * @var array<Command> |
@@ -339,8 +338,7 @@ discard block |
||
| 339 | 338 | * @param array<int, string> $argv |
| 340 | 339 | * @return mixed |
| 341 | 340 | */ |
| 342 | - public function handle(array $argv) |
|
| 343 | - { |
|
| 341 | + public function handle(array $argv) { |
|
| 344 | 342 | if (count($argv) < 2) { |
| 345 | 343 | return $this->showHelp(); |
| 346 | 344 | } |
@@ -367,8 +365,7 @@ discard block |
||
| 367 | 365 | * Show help of all commands. |
| 368 | 366 | * @return mixed |
| 369 | 367 | */ |
| 370 | - public function showHelp() |
|
| 371 | - { |
|
| 368 | + public function showHelp() { |
|
| 372 | 369 | $writer = $this->io()->writer(); |
| 373 | 370 | |
| 374 | 371 | $header = sprintf( |
@@ -418,8 +415,7 @@ discard block |
||
| 418 | 415 | * @param Command $command |
| 419 | 416 | * @return mixed |
| 420 | 417 | */ |
| 421 | - protected function executeCommand(Command $command) |
|
| 422 | - { |
|
| 418 | + protected function executeCommand(Command $command) { |
|
| 423 | 419 | if ($command->getName() === '__default__') { |
| 424 | 420 | return $this->showCommandNotFound(); |
| 425 | 421 | } |
@@ -446,8 +442,7 @@ discard block |
||
| 446 | 442 | * Command not found handler. |
| 447 | 443 | * @return mixed |
| 448 | 444 | */ |
| 449 | - protected function showCommandNotFound() |
|
| 450 | - { |
|
| 445 | + protected function showCommandNotFound() { |
|
| 451 | 446 | $available = array_keys($this->getCommands() + $this->aliases); |
| 452 | 447 | |
| 453 | 448 | $this->outputHelper() |
@@ -61,10 +61,10 @@ |
||
| 61 | 61 | */ |
| 62 | 62 | protected string $short = ''; |
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * The long option name |
|
| 66 | - * @var string |
|
| 67 | - */ |
|
| 64 | + /** |
|
| 65 | + * The long option name |
|
| 66 | + * @var string |
|
| 67 | + */ |
|
| 68 | 68 | protected string $long = ''; |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -52,8 +52,7 @@ |
||
| 52 | 52 | * Class Option |
| 53 | 53 | * @package Platine\Console\Input |
| 54 | 54 | */ |
| 55 | -class Option extends Parameter |
|
| 56 | -{ |
|
| 55 | +class Option extends Parameter { |
|
| 57 | 56 | /** |
| 58 | 57 | * The short option name |
| 59 | 58 | * @var string |
@@ -248,9 +248,9 @@ |
||
| 248 | 248 | |
| 249 | 249 | foreach ($choices as $choice => $desc) { |
| 250 | 250 | $this->writer->eol() |
| 251 | - ->cyan( |
|
| 252 | - str_pad(' [' . $choice . ']', $maxLength + 6) |
|
| 253 | - ); |
|
| 251 | + ->cyan( |
|
| 252 | + str_pad(' [' . $choice . ']', $maxLength + 6) |
|
| 253 | + ); |
|
| 254 | 254 | |
| 255 | 255 | $this->writer->dim($desc); |
| 256 | 256 | } |
@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * Class Interactor |
| 58 | 58 | * @package Platine\Console\IO |
| 59 | 59 | */ |
| 60 | -class Interactor |
|
| 61 | -{ |
|
| 60 | +class Interactor { |
|
| 62 | 61 | /** |
| 63 | 62 | * Stream reader instance |
| 64 | 63 | * @var Reader |
@@ -76,8 +75,7 @@ discard block |
||
| 76 | 75 | * @param string|null $input |
| 77 | 76 | * @param string|null $output |
| 78 | 77 | */ |
| 79 | - public function __construct(?string $input = null, ?string $output = null) |
|
| 80 | - { |
|
| 78 | + public function __construct(?string $input = null, ?string $output = null) { |
|
| 81 | 79 | $this->reader = new Reader($input); |
| 82 | 80 | $this->writer = new Writer($output); |
| 83 | 81 | } |
@@ -122,8 +120,7 @@ discard block |
||
| 122 | 120 | * |
| 123 | 121 | * @return mixed |
| 124 | 122 | */ |
| 125 | - public function choice(string $text, array $choices, $default = null, bool $case = false) |
|
| 126 | - { |
|
| 123 | + public function choice(string $text, array $choices, $default = null, bool $case = false) { |
|
| 127 | 124 | $this->writer->yellow($text); |
| 128 | 125 | |
| 129 | 126 | $this->listOptions($choices, $default, false); |
@@ -144,8 +141,7 @@ discard block |
||
| 144 | 141 | * |
| 145 | 142 | * @return mixed |
| 146 | 143 | */ |
| 147 | - public function choices(string $text, array $choices, $default = null, bool $case = false) |
|
| 148 | - { |
|
| 144 | + public function choices(string $text, array $choices, $default = null, bool $case = false) { |
|
| 149 | 145 | $this->writer->yellow($text); |
| 150 | 146 | |
| 151 | 147 | $this->listOptions($choices, $default, true); |
@@ -110,19 +110,19 @@ discard block |
||
| 110 | 110 | $traceStr = '</eol></eol><info>Stack Trace:</end></eol></eol>'; |
| 111 | 111 | foreach ($error->getTrace() as $i => $trace) { |
| 112 | 112 | $trace += [ |
| 113 | - 'class' => '', |
|
| 114 | - 'type' => '', |
|
| 115 | - 'function' => '', |
|
| 116 | - 'file' => '', |
|
| 117 | - 'line' => '', |
|
| 118 | - 'args' => [] |
|
| 119 | - ]; |
|
| 113 | + 'class' => '', |
|
| 114 | + 'type' => '', |
|
| 115 | + 'function' => '', |
|
| 116 | + 'file' => '', |
|
| 117 | + 'line' => '', |
|
| 118 | + 'args' => [] |
|
| 119 | + ]; |
|
| 120 | 120 | |
| 121 | 121 | $symbol = $trace['class'] . $trace['type'] . $trace['function']; |
| 122 | 122 | $arguments = $this->stringifyArgs($trace['args']); |
| 123 | 123 | |
| 124 | 124 | $traceStr .= ' <comment>' . $i . ')</end> <error>' |
| 125 | - . $symbol . '</end><comment>(' . $arguments . ')</end>'; |
|
| 125 | + . $symbol . '</end><comment>(' . $arguments . ')</end>'; |
|
| 126 | 126 | |
| 127 | 127 | if ($trace['file'] !== '') { |
| 128 | 128 | $file = realpath($trace['file']); |
@@ -151,13 +151,13 @@ discard block |
||
| 151 | 151 | return $this; |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | - /** |
|
| 155 | - * Show options help |
|
| 156 | - * @param array<Option> $items |
|
| 157 | - * @param string $header |
|
| 158 | - * @param string $footer |
|
| 159 | - * @return $this |
|
| 160 | - */ |
|
| 154 | + /** |
|
| 155 | + * Show options help |
|
| 156 | + * @param array<Option> $items |
|
| 157 | + * @param string $header |
|
| 158 | + * @param string $footer |
|
| 159 | + * @return $this |
|
| 160 | + */ |
|
| 161 | 161 | public function showOptionsHelp( |
| 162 | 162 | array $items, |
| 163 | 163 | string $header = '', |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | |
| 204 | 204 | if (strpos($usage, ' ## ') === false) { |
| 205 | 205 | $this->writer->eol()->boldGreen('Usage Examples: ', true) |
| 206 | - ->colors($usage)->eol(); |
|
| 206 | + ->colors($usage)->eol(); |
|
| 207 | 207 | |
| 208 | 208 | return $this; |
| 209 | 209 | } |
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | ); |
| 243 | 243 | |
| 244 | 244 | $this->writer->eol() |
| 245 | - ->boldGreen('Usage Examples: ', true) |
|
| 246 | - ->colors($formatedUsage)->eol(); |
|
| 245 | + ->boldGreen('Usage Examples: ', true) |
|
| 246 | + ->colors($formatedUsage)->eol(); |
|
| 247 | 247 | |
| 248 | 248 | return $this; |
| 249 | 249 | } |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | * Class OutputHelper |
| 61 | 61 | * @package Platine\Console\Util |
| 62 | 62 | */ |
| 63 | -class OutputHelper |
|
| 64 | -{ |
|
| 63 | +class OutputHelper { |
|
| 65 | 64 | /** |
| 66 | 65 | * The writer stream instance |
| 67 | 66 | * @var Writer |
@@ -78,8 +77,7 @@ discard block |
||
| 78 | 77 | * Create new instance |
| 79 | 78 | * @param Writer|null $writer |
| 80 | 79 | */ |
| 81 | - public function __construct(?Writer $writer = null) |
|
| 82 | - { |
|
| 80 | + public function __construct(?Writer $writer = null) { |
|
| 83 | 81 | $this->writer = $writer ? $writer : new Writer(); |
| 84 | 82 | } |
| 85 | 83 | |