@@ -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 | /** |
| 66 | 65 | * List of commands |
@@ -338,8 +337,7 @@ discard block |
||
| 338 | 337 | * @param array<int, string> $argv |
| 339 | 338 | * @return mixed |
| 340 | 339 | */ |
| 341 | - public function handle(array $argv) |
|
| 342 | - { |
|
| 340 | + public function handle(array $argv) { |
|
| 343 | 341 | if (count($argv) < 2) { |
| 344 | 342 | return $this->showHelp(); |
| 345 | 343 | } |
@@ -366,8 +364,7 @@ discard block |
||
| 366 | 364 | * Show help of all commands. |
| 367 | 365 | * @return mixed |
| 368 | 366 | */ |
| 369 | - public function showHelp() |
|
| 370 | - { |
|
| 367 | + public function showHelp() { |
|
| 371 | 368 | $writer = $this->io()->writer(); |
| 372 | 369 | |
| 373 | 370 | $header = sprintf( |
@@ -417,8 +414,7 @@ discard block |
||
| 417 | 414 | * @param Command $command |
| 418 | 415 | * @return mixed |
| 419 | 416 | */ |
| 420 | - protected function executeCommand(Command $command) |
|
| 421 | - { |
|
| 417 | + protected function executeCommand(Command $command) { |
|
| 422 | 418 | if ($command->getName() === '__default__') { |
| 423 | 419 | return $this->showCommandNotFound(); |
| 424 | 420 | } |
@@ -445,8 +441,7 @@ discard block |
||
| 445 | 441 | * Command not found handler. |
| 446 | 442 | * @return mixed |
| 447 | 443 | */ |
| 448 | - protected function showCommandNotFound() |
|
| 449 | - { |
|
| 444 | + protected function showCommandNotFound() { |
|
| 450 | 445 | $available = array_keys($this->getCommands() + $this->aliases); |
| 451 | 446 | |
| 452 | 447 | $this->outputHelper() |
@@ -124,7 +124,7 @@ |
||
| 124 | 124 | $this->name = $name; |
| 125 | 125 | $this->version = $version; |
| 126 | 126 | |
| 127 | - $this->onExit = $onExit ? $onExit : function (int $exitCode = 0) { |
|
| 127 | + $this->onExit = $onExit ? $onExit : function(int $exitCode = 0) { |
|
| 128 | 128 | //@codeCoverageIgnoreStart |
| 129 | 129 | exit($exitCode); |
| 130 | 130 | //@codeCoverageIgnoreEnd |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | string $header = '', |
| 180 | 180 | string $footer = '' |
| 181 | 181 | ): self { |
| 182 | - $this->maxCommandWidth = !empty($items) ? max(array_map(function (Command $item) { |
|
| 182 | + $this->maxCommandWidth = !empty($items) ? max(array_map(function(Command $item) { |
|
| 183 | 183 | return strlen($item->getName()); |
| 184 | 184 | }, $items)) : 0; |
| 185 | 185 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | $maxLength = (int) max($lines) + 4; |
| 232 | 232 | $formatedUsage = (string) preg_replace_callback( |
| 233 | 233 | '~ ## ~', |
| 234 | - function () use (&$lines, $maxLength) { |
|
| 234 | + function() use (&$lines, $maxLength) { |
|
| 235 | 235 | $sizeOfLine = 0; |
| 236 | 236 | $currentLine = array_shift($lines); |
| 237 | 237 | if ($currentLine !== null) { |
@@ -387,11 +387,11 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | protected function sortItems(array $items, int &$max = 0): array |
| 389 | 389 | { |
| 390 | - $max = max(array_map(function ($item) { |
|
| 390 | + $max = max(array_map(function($item) { |
|
| 391 | 391 | return strlen($this->getName($item)); |
| 392 | 392 | }, $items)); |
| 393 | 393 | |
| 394 | - uasort($items, function ($a, $b) { |
|
| 394 | + uasort($items, function($a, $b) { |
|
| 395 | 395 | /* @var Parameter $b */ |
| 396 | 396 | /* @var Parameter $a */ |
| 397 | 397 | return $a->getName() <=> $b->getName(); |
@@ -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 | /** |
| 67 | 66 | * The writer stream instance |
@@ -79,8 +78,7 @@ discard block |
||
| 79 | 78 | * Create new instance |
| 80 | 79 | * @param Writer|null $writer |
| 81 | 80 | */ |
| 82 | - public function __construct(?Writer $writer = null) |
|
| 83 | - { |
|
| 81 | + public function __construct(?Writer $writer = null) { |
|
| 84 | 82 | $this->writer = $writer ? $writer : new Writer(); |
| 85 | 83 | } |
| 86 | 84 | |
@@ -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 | } |
@@ -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 | /** |
| 62 | 61 | * Convert the given string to camel case |
@@ -123,8 +122,7 @@ discard block |
||
| 123 | 122 | * @param string|null $value |
| 124 | 123 | * @return mixed |
| 125 | 124 | */ |
| 126 | - public static function normalizeValue(Parameter $parameter, ?string $value = null) |
|
| 127 | - { |
|
| 125 | + public static function normalizeValue(Parameter $parameter, ?string $value = null) { |
|
| 128 | 126 | if ($parameter instanceof Option && $parameter->isBool()) { |
| 129 | 127 | return !$parameter->getDefault(); |
| 130 | 128 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | $value = null; |
| 222 | 222 | if ($nextArg !== null && substr($nextArg, 0, 1) !== '-') { |
| 223 | - $value = $nextArg; |
|
| 223 | + $value = $nextArg; |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | $option = $this->getOptionForArgument($arg); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | /** @var array<Parameter> $missingItems */ |
| 297 | 297 | $missingItems = array_filter( |
| 298 | 298 | $this->options + $this->arguments, |
| 299 | - function ($item) { |
|
| 299 | + function($item) { |
|
| 300 | 300 | /** @var Parameter $item */ |
| 301 | 301 | return $item->isRequired() && in_array( |
| 302 | 302 | $this->values[$item->getAttributeName()], |
@@ -56,8 +56,7 @@ discard block |
||
| 56 | 56 | * Class Parser |
| 57 | 57 | * @package Platine\Console\Input |
| 58 | 58 | */ |
| 59 | -abstract class Parser |
|
| 60 | -{ |
|
| 59 | +abstract class Parser { |
|
| 61 | 60 | |
| 62 | 61 | /** |
| 63 | 62 | * The last seen variadic option name |
@@ -190,8 +189,7 @@ discard block |
||
| 190 | 189 | * @param string $arg |
| 191 | 190 | * @return mixed |
| 192 | 191 | */ |
| 193 | - protected function parseArgument(string $arg) |
|
| 194 | - { |
|
| 192 | + protected function parseArgument(string $arg) { |
|
| 195 | 193 | if ($this->lastVariadic) { |
| 196 | 194 | return $this->set($this->lastVariadic, $arg, true); |
| 197 | 195 | } |
@@ -216,8 +214,7 @@ discard block |
||
| 216 | 214 | * @param string|null $nextArg |
| 217 | 215 | * @return mixed|bool |
| 218 | 216 | */ |
| 219 | - protected function parseOptions(string $arg, ?string $nextArg = null) |
|
| 220 | - { |
|
| 217 | + protected function parseOptions(string $arg, ?string $nextArg = null) { |
|
| 221 | 218 | $value = null; |
| 222 | 219 | if ($nextArg !== null && substr($nextArg, 0, 1) !== '-') { |
| 223 | 220 | $value = $nextArg; |