Passed
Push — develop ( add880...26f5dd )
by nguereza
02:36
created
src/Command/Command.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -579,17 +579,17 @@
 block discarded – undo
579 579
     protected function defaults(): self
580 580
     {
581 581
         $this->addOption('-h|--help', 'Show help')
582
-              ->on([$this, 'showHelp']);
582
+                ->on([$this, 'showHelp']);
583 583
 
584 584
         $this->addOption('-v|--version', 'Show version')
585
-             ->on([$this, 'showVersion']);
585
+                ->on([$this, 'showVersion']);
586 586
 
587 587
         $this->addOption('-V|--verbosity', 'Verbosity level', 0)
588
-             ->on(function () {
588
+                ->on(function () {
589 589
                 $this->set('verbosity', $this->verbosity++);
590 590
 
591 591
                 return false;
592
-             });
592
+                });
593 593
 
594 594
         $this->onExit(function (int $exitCode = 0) {
595 595
             exit($exitCode);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -585,13 +585,13 @@
 block discarded – undo
585 585
              ->on([$this, 'showVersion']);
586 586
 
587 587
         $this->addOption('-V|--verbosity', 'Verbosity level', 0)
588
-             ->on(function () {
588
+             ->on(function() {
589 589
                 $this->set('verbosity', $this->verbosity++);
590 590
 
591 591
                 return false;
592 592
              });
593 593
 
594
-        $this->onExit(function (int $exitCode = 0) {
594
+        $this->onExit(function(int $exitCode = 0) {
595 595
             exit($exitCode);
596 596
         });
597 597
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -63,8 +63,7 @@  discard block
 block discarded – undo
63 63
  * Class Command
64 64
  * @package Platine\Console\Command
65 65
  */
66
-class Command extends Parser
67
-{
66
+class Command extends Parser {
68 67
 
69 68
     /**
70 69
      * The command version
@@ -397,8 +396,7 @@  discard block
 block discarded – undo
397 396
      * Show this command help and abort
398 397
      * @return mixed
399 398
      */
400
-    public function showHelp()
401
-    {
399
+    public function showHelp() {
402 400
         $io = $this->io();
403 401
         $helper = new OutputHelper($io->writer());
404 402
 
@@ -444,8 +442,7 @@  discard block
 block discarded – undo
444 442
      * Show this command version and abort
445 443
      * @return mixed
446 444
      */
447
-    public function showVersion()
448
-    {
445
+    public function showVersion() {
449 446
         $this->writer()->bold(
450 447
             sprintf(
451 448
                 '%s, %s',
@@ -462,8 +459,7 @@  discard block
 block discarded – undo
462 459
      * Execute the command
463 460
      * @return mixed
464 461
      */
465
-    public function execute()
466
-    {
462
+    public function execute() {
467 463
     }
468 464
 
469 465
 
@@ -482,16 +478,14 @@  discard block
 block discarded – undo
482 478
      * @param mixed $object
483 479
      * @return mixed
484 480
      */
485
-    public function tap($object)
486
-    {
481
+    public function tap($object) {
487 482
         return $object ? $object : $this->app;
488 483
     }
489 484
 
490 485
     /**
491 486
      * {@inheritdoc}
492 487
      */
493
-    public function emit(string $event, $value = null)
494
-    {
488
+    public function emit(string $event, $value = null) {
495 489
         if (empty($this->events[$event])) {
496 490
             return null;
497 491
         }
@@ -504,8 +498,7 @@  discard block
 block discarded – undo
504 498
      * @param string $longName
505 499
      * @return mixed|null
506 500
      */
507
-    public function getOptionValue(string $longName)
508
-    {
501
+    public function getOptionValue(string $longName) {
509 502
         $values = $this->values();
510 503
 
511 504
         return array_key_exists($longName, $values)
@@ -518,8 +511,7 @@  discard block
 block discarded – undo
518 511
      * @param string $name
519 512
      * @return mixed|null
520 513
      */
521
-    public function getArgumentValue(string $name)
522
-    {
514
+    public function getArgumentValue(string $name) {
523 515
         $values = $this->values();
524 516
 
525 517
         return array_key_exists($name, $values)
@@ -552,8 +544,7 @@  discard block
 block discarded – undo
552 544
     /**
553 545
      * {@inheritdoc}
554 546
      */
555
-    protected function handleUnknown(string $arg, $value = null)
556
-    {
547
+    protected function handleUnknown(string $arg, $value = null) {
557 548
         if ($this->allowUnknown) {
558 549
             return $this->set(Helper::toCamelCase($arg), $value);
559 550
         }
Please login to merge, or discard this patch.
src/Command/Shell.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -360,9 +360,9 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
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;
@@ -154,8 +153,7 @@  discard block
 block discarded – undo
154 153
      * @param string $command
155 154
      * @param string|null $input
156 155
      */
157
-    public function __construct(string $command, ?string $input = null)
158
-    {
156
+    public function __construct(string $command, ?string $input = null) {
159 157
         if (!function_exists('proc_open')) {
160 158
             throw new RuntimeException(
161 159
                 'The "proc_open" could not be found in your PHP setup'
Please login to merge, or discard this patch.
src/Application.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -129,7 +129,7 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@
 block discarded – undo
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
             exit($exitCode);
129 129
         };
130 130
 
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,8 +59,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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()
Please login to merge, or discard this patch.
src/Util/OutputHelper.php 3 patches
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -110,18 +110,18 @@  discard block
 block discarded – undo
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
             $symbol = $trace['class'] . $trace['type'] . $trace['function'];
121 121
             $arguments = $this->stringifyArgs($trace['args']);
122 122
 
123 123
             $traceStr .= ' <comment>' . $i . ')</end> <error>'
124
-                   . $symbol . '</end><comment>(' . $arguments . ')</end>';
124
+                    . $symbol . '</end><comment>(' . $arguments . ')</end>';
125 125
 
126 126
             if ($trace['file'] !== '') {
127 127
                 $file = realpath($trace['file']);
@@ -150,13 +150,13 @@  discard block
 block discarded – undo
150 150
         return $this;
151 151
     }
152 152
 
153
-     /**
154
-     * Show options help
155
-     * @param array<Option> $items
156
-     * @param string $header
157
-     * @param string $footer
158
-     * @return $this
159
-     */
153
+        /**
154
+         * Show options help
155
+         * @param array<Option> $items
156
+         * @param string $header
157
+         * @param string $footer
158
+         * @return $this
159
+         */
160 160
     public function showOptionsHelp(
161 161
         array $items,
162 162
         string $header = '',
@@ -202,8 +202,8 @@  discard block
 block discarded – undo
202 202
 
203 203
         if (strpos($usage, ' ## ') === false) {
204 204
             $this->writer->eol()
205
-                 ->green('Usage Examples: ', true, null, Color::BOLD)
206
-                 ->colors($usage)->eol();
205
+                    ->green('Usage Examples: ', true, null, Color::BOLD)
206
+                    ->colors($usage)->eol();
207 207
 
208 208
             return $this;
209 209
         }
@@ -243,8 +243,8 @@  discard block
 block discarded – undo
243 243
         );
244 244
 
245 245
         $this->writer->eol()
246
-                 ->green('Usage Examples: ', true, null, Color::BOLD)
247
-                 ->colors($formatedUsage)->eol();
246
+                    ->green('Usage Examples: ', true, null, Color::BOLD)
247
+                    ->colors($formatedUsage)->eol();
248 248
 
249 249
         return $this;
250 250
     }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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();
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,8 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
src/Util/Helper.php 1 patch
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -55,8 +55,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Input/Parser.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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()],
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -56,8 +56,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/Input/Reader.php 1 patch
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
  * Class Reader
53 53
  * @package Platine\Console\Input
54 54
  */
55
-class Reader
56
-{
55
+class Reader {
57 56
 
58 57
     /**
59 58
      * The input stream
@@ -65,8 +64,7 @@  discard block
 block discarded – undo
65 64
      * Create new instance
66 65
      * @param string|null $path the input read path
67 66
      */
68
-    public function __construct(?string $path = null)
69
-    {
67
+    public function __construct(?string $path = null) {
70 68
         $stream = STDIN;
71 69
         if ($path !== null) {
72 70
             $stream = fopen($path, 'r');
@@ -81,8 +79,7 @@  discard block
 block discarded – undo
81 79
      * @param callable|null $callback The validator/sanitizer callback.
82 80
      * @return mixed
83 81
      */
84
-    public function read($default = null, ?callable $callback = null)
85
-    {
82
+    public function read($default = null, ?callable $callback = null) {
86 83
         $in = '';
87 84
         $read = fgets($this->stream);
88 85
 
@@ -104,8 +101,7 @@  discard block
 block discarded – undo
104 101
      * @param callable|null $callback The validator/sanitizer callback.
105 102
      * @return mixed
106 103
      */
107
-    public function readAll(?callable $callback = null)
108
-    {
104
+    public function readAll(?callable $callback = null) {
109 105
         $in = stream_get_contents($this->stream);
110 106
 
111 107
         return $callback !== null
@@ -118,8 +114,7 @@  discard block
 block discarded – undo
118 114
      * @param callable|null $callback The validator/sanitizer callback.
119 115
      * @return mixed
120 116
      */
121
-    public function readPipe(?callable $callback = null)
122
-    {
117
+    public function readPipe(?callable $callback = null) {
123 118
         $stdin = '';
124 119
         $read = [$this->stream];
125 120
         $write = [];
@@ -145,8 +140,7 @@  discard block
 block discarded – undo
145 140
      * @param callable|null $callback The validator/sanitizer callback.
146 141
      * @return mixed
147 142
      */
148
-    public function readHidden($default = null, ?callable $callback = null)
149
-    {
143
+    public function readHidden($default = null, ?callable $callback = null) {
150 144
         if (substr(strtoupper(PHP_OS), 0, 3) === 'WIN') {
151 145
             return $this->readHiddenWindows($default, $callback);
152 146
         }
@@ -167,8 +161,7 @@  discard block
 block discarded – undo
167 161
      * @param callable|null $callback The validator/sanitizer callback.
168 162
      * @return mixed
169 163
      */
170
-    protected function readHiddenWindows($default = null, ?callable $callback = null)
171
-    {
164
+    protected function readHiddenWindows($default = null, ?callable $callback = null) {
172 165
         $cmd = 'powershell -Command ' . implode('; ', array_filter([
173 166
                     '$pword = Read-Host -AsSecureString',
174 167
                     '$pword = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword)',
Please login to merge, or discard this patch.
src/Input/Option.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -61,10 +61,10 @@
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@
 block discarded – undo
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
     /**
59 58
      * The short option name
Please login to merge, or discard this patch.
src/Input/Parameter.php 1 patch
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -54,8 +54,7 @@  discard block
 block discarded – undo
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
     /**
61 60
      * The name of the parameter
@@ -183,8 +182,7 @@  discard block
 block discarded – undo
183 182
      * Return the parameter default value
184 183
      * @return mixed
185 184
      */
186
-    public function getDefault()
187
-    {
185
+    public function getDefault() {
188 186
         if ($this->isVariadic()) {
189 187
             return (array) $this->default;
190 188
         }
@@ -234,8 +232,7 @@  discard block
 block discarded – undo
234 232
      * @param mixed $raw
235 233
      * @return mixed
236 234
      */
237
-    public function filter($raw)
238
-    {
235
+    public function filter($raw) {
239 236
         if ($this->filter !== null) {
240 237
             $callback = $this->filter;
241 238
 
Please login to merge, or discard this patch.