@@ -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 Reader |
55 | 55 | * @package Platine\Console\Input |
56 | 56 | */ |
57 | -class Reader |
|
58 | -{ |
|
57 | +class Reader { |
|
59 | 58 | /** |
60 | 59 | * The input stream |
61 | 60 | * @var resource |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | * Create new instance |
67 | 66 | * @param string|null $path the input read path |
68 | 67 | */ |
69 | - public function __construct(?string $path = null) |
|
70 | - { |
|
68 | + public function __construct(?string $path = null) { |
|
71 | 69 | $stream = STDIN; |
72 | 70 | if ($path !== null) { |
73 | 71 | $stream = fopen($path, 'r'); |
@@ -88,8 +86,7 @@ discard block |
||
88 | 86 | * @param resource $stream |
89 | 87 | * @return $this |
90 | 88 | */ |
91 | - public function setStream($stream) |
|
92 | - { |
|
89 | + public function setStream($stream) { |
|
93 | 90 | $this->stream = $stream; |
94 | 91 | return $this; |
95 | 92 | } |
@@ -101,8 +98,7 @@ discard block |
||
101 | 98 | * @param callable|null $callback The validator/sanitizer callback. |
102 | 99 | * @return mixed |
103 | 100 | */ |
104 | - public function read($default = null, ?callable $callback = null) |
|
105 | - { |
|
101 | + public function read($default = null, ?callable $callback = null) { |
|
106 | 102 | $input = ''; |
107 | 103 | $read = fgets($this->stream); |
108 | 104 | |
@@ -124,8 +120,7 @@ discard block |
||
124 | 120 | * @param callable|null $callback The validator/sanitizer callback. |
125 | 121 | * @return mixed |
126 | 122 | */ |
127 | - public function readAll(?callable $callback = null) |
|
128 | - { |
|
123 | + public function readAll(?callable $callback = null) { |
|
129 | 124 | $input = stream_get_contents($this->stream); |
130 | 125 | |
131 | 126 | return $callback !== null |
@@ -138,8 +133,7 @@ discard block |
||
138 | 133 | * @param callable|null $callback The validator/sanitizer callback. |
139 | 134 | * @return mixed |
140 | 135 | */ |
141 | - public function readPipe(?callable $callback = null) |
|
142 | - { |
|
136 | + public function readPipe(?callable $callback = null) { |
|
143 | 137 | $stdin = ''; |
144 | 138 | $read = [$this->stream]; |
145 | 139 | $write = []; |
@@ -165,8 +159,7 @@ discard block |
||
165 | 159 | * @param callable|null $callback The validator/sanitizer callback. |
166 | 160 | * @return mixed |
167 | 161 | */ |
168 | - public function readHidden($default = null, ?callable $callback = null) |
|
169 | - { |
|
162 | + public function readHidden($default = null, ?callable $callback = null) { |
|
170 | 163 | if (substr(strtoupper(PHP_OS), 0, 3) === 'WIN') { |
171 | 164 | return $this->readHiddenWindows($default, $callback); |
172 | 165 | } |
@@ -187,8 +180,7 @@ discard block |
||
187 | 180 | * @param callable|null $callback The validation/sanitizer callback. |
188 | 181 | * @return mixed |
189 | 182 | */ |
190 | - protected function readHiddenWindows($default = null, ?callable $callback = null) |
|
191 | - { |
|
183 | + protected function readHiddenWindows($default = null, ?callable $callback = null) { |
|
192 | 184 | $cmd = 'powershell -Command ' . implode('; ', [ |
193 | 185 | '$pword = Read-Host -AsSecureString', |
194 | 186 | '$pword = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($pword)', |
@@ -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 |
@@ -164,8 +163,7 @@ discard block |
||
164 | 163 | * Return the parameter default value |
165 | 164 | * @return mixed |
166 | 165 | */ |
167 | - public function getDefault() |
|
168 | - { |
|
166 | + public function getDefault() { |
|
169 | 167 | if ($this->isVariadic()) { |
170 | 168 | return (array) $this->default; |
171 | 169 | } |
@@ -206,8 +204,7 @@ discard block |
||
206 | 204 | * @param mixed $raw |
207 | 205 | * @return mixed |
208 | 206 | */ |
209 | - public function filter($raw) |
|
210 | - { |
|
207 | + public function filter($raw) { |
|
211 | 208 | if ($this->filter !== null) { |
212 | 209 | $callback = $this->filter; |
213 | 210 |
@@ -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 | } |
@@ -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 RuntimeException |
39 | 39 | * @package Platine\Console\Exception |
40 | 40 | */ |
41 | -class RuntimeException extends ConsoleException |
|
42 | -{ |
|
41 | +class RuntimeException extends ConsoleException { |
|
43 | 42 | } |
@@ -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 | } |
@@ -55,8 +55,7 @@ |
||
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 |
@@ -109,19 +109,19 @@ discard block |
||
109 | 109 | $traceStr = '</eol></eol><info>Stack Trace:</end></eol></eol>'; |
110 | 110 | foreach ($error->getTrace() as $i => $trace) { |
111 | 111 | $trace += [ |
112 | - 'class' => '', |
|
113 | - 'type' => '', |
|
114 | - 'function' => '', |
|
115 | - 'file' => '', |
|
116 | - 'line' => '', |
|
117 | - 'args' => [] |
|
118 | - ]; |
|
112 | + 'class' => '', |
|
113 | + 'type' => '', |
|
114 | + 'function' => '', |
|
115 | + 'file' => '', |
|
116 | + 'line' => '', |
|
117 | + 'args' => [] |
|
118 | + ]; |
|
119 | 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 |
||
150 | 150 | return $this; |
151 | 151 | } |
152 | 152 | |
153 | - /** |
|
154 | - * Show options help |
|
155 | - * @param Option[] $items |
|
156 | - * @param string $header |
|
157 | - * @param string $footer |
|
158 | - * @return $this |
|
159 | - */ |
|
153 | + /** |
|
154 | + * Show options help |
|
155 | + * @param 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,7 +202,7 @@ discard block |
||
202 | 202 | |
203 | 203 | if (strpos($usage, ' ## ') === false) { |
204 | 204 | $this->writer->eol()->boldGreen('Usage Examples: ', true) |
205 | - ->colors($usage)->eol(); |
|
205 | + ->colors($usage)->eol(); |
|
206 | 206 | |
207 | 207 | return $this; |
208 | 208 | } |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | ); |
246 | 246 | |
247 | 247 | $this->writer->eol() |
248 | - ->boldGreen('Usage Examples: ', true) |
|
249 | - ->colors($formatedUsage)->eol(); |
|
248 | + ->boldGreen('Usage Examples: ', true) |
|
249 | + ->colors($formatedUsage)->eol(); |
|
250 | 250 | |
251 | 251 | return $this; |
252 | 252 | } |
@@ -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 | |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | |
234 | 234 | $formatedUsage = (string) preg_replace_callback( |
235 | 235 | '~ ## ~', |
236 | - function () use (&$lines, $maxLength) { |
|
236 | + function() use (&$lines, $maxLength) { |
|
237 | 237 | $sizeOfLine = 0; |
238 | 238 | $currentLine = array_shift($lines); |
239 | 239 | if ($currentLine !== null) { |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | */ |
388 | 388 | protected function sortItems(array $items, int &$max = 0): array |
389 | 389 | { |
390 | - $results = array_map(function ($item) { |
|
390 | + $results = array_map(function($item) { |
|
391 | 391 | return strlen($this->getName($item)); |
392 | 392 | }, $items); |
393 | 393 | |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | $max = max($results); |
397 | 397 | } |
398 | 398 | |
399 | - uasort($items, function (Parameter|Command $a, Parameter|Command $b) { |
|
399 | + uasort($items, function(Parameter | Command $a, Parameter | Command $b) { |
|
400 | 400 | return $a->getName() <=> $b->getName(); |
401 | 401 | }); |
402 | 402 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | * @param Parameter|Command $item |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - protected function getName(Parameter|Command $item): string |
|
411 | + protected function getName(Parameter | Command $item): string |
|
412 | 412 | { |
413 | 413 | $name = $item->getName(); |
414 | 414 | if ($item instanceof Command) { |
@@ -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 ?? new Writer(); |
84 | 82 | } |
85 | 83 |