@@ -17,8 +17,7 @@ |
||
17 | 17 | * |
18 | 18 | * @author Wouter J <[email protected]> |
19 | 19 | */ |
20 | -interface InputAwareInterface |
|
21 | -{ |
|
20 | +interface InputAwareInterface { |
|
22 | 21 | /** |
23 | 22 | * Sets the Console Input. |
24 | 23 | */ |
@@ -33,8 +33,7 @@ discard block |
||
33 | 33 | protected $arguments = []; |
34 | 34 | protected $interactive = true; |
35 | 35 | |
36 | - public function __construct(InputDefinition $definition = null) |
|
37 | - { |
|
36 | + public function __construct(InputDefinition $definition = null) { |
|
38 | 37 | if (null === $definition) { |
39 | 38 | $this->definition = new InputDefinition(); |
40 | 39 | } else { |
@@ -46,8 +45,7 @@ discard block |
||
46 | 45 | /** |
47 | 46 | * {@inheritdoc} |
48 | 47 | */ |
49 | - public function bind(InputDefinition $definition) |
|
50 | - { |
|
48 | + public function bind(InputDefinition $definition) { |
|
51 | 49 | $this->arguments = []; |
52 | 50 | $this->options = []; |
53 | 51 | $this->definition = $definition; |
@@ -63,8 +61,7 @@ discard block |
||
63 | 61 | /** |
64 | 62 | * {@inheritdoc} |
65 | 63 | */ |
66 | - public function validate() |
|
67 | - { |
|
64 | + public function validate() { |
|
68 | 65 | $definition = $this->definition; |
69 | 66 | $givenArguments = $this->arguments; |
70 | 67 | |
@@ -80,32 +77,28 @@ discard block |
||
80 | 77 | /** |
81 | 78 | * {@inheritdoc} |
82 | 79 | */ |
83 | - public function isInteractive() |
|
84 | - { |
|
80 | + public function isInteractive() { |
|
85 | 81 | return $this->interactive; |
86 | 82 | } |
87 | 83 | |
88 | 84 | /** |
89 | 85 | * {@inheritdoc} |
90 | 86 | */ |
91 | - public function setInteractive(bool $interactive) |
|
92 | - { |
|
87 | + public function setInteractive(bool $interactive) { |
|
93 | 88 | $this->interactive = $interactive; |
94 | 89 | } |
95 | 90 | |
96 | 91 | /** |
97 | 92 | * {@inheritdoc} |
98 | 93 | */ |
99 | - public function getArguments() |
|
100 | - { |
|
94 | + public function getArguments() { |
|
101 | 95 | return array_merge($this->definition->getArgumentDefaults(), $this->arguments); |
102 | 96 | } |
103 | 97 | |
104 | 98 | /** |
105 | 99 | * {@inheritdoc} |
106 | 100 | */ |
107 | - public function getArgument(string $name) |
|
108 | - { |
|
101 | + public function getArgument(string $name) { |
|
109 | 102 | if (!$this->definition->hasArgument($name)) { |
110 | 103 | throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); |
111 | 104 | } |
@@ -116,8 +109,7 @@ discard block |
||
116 | 109 | /** |
117 | 110 | * {@inheritdoc} |
118 | 111 | */ |
119 | - public function setArgument(string $name, $value) |
|
120 | - { |
|
112 | + public function setArgument(string $name, $value) { |
|
121 | 113 | if (!$this->definition->hasArgument($name)) { |
122 | 114 | throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); |
123 | 115 | } |
@@ -128,24 +120,21 @@ discard block |
||
128 | 120 | /** |
129 | 121 | * {@inheritdoc} |
130 | 122 | */ |
131 | - public function hasArgument(string $name) |
|
132 | - { |
|
123 | + public function hasArgument(string $name) { |
|
133 | 124 | return $this->definition->hasArgument($name); |
134 | 125 | } |
135 | 126 | |
136 | 127 | /** |
137 | 128 | * {@inheritdoc} |
138 | 129 | */ |
139 | - public function getOptions() |
|
140 | - { |
|
130 | + public function getOptions() { |
|
141 | 131 | return array_merge($this->definition->getOptionDefaults(), $this->options); |
142 | 132 | } |
143 | 133 | |
144 | 134 | /** |
145 | 135 | * {@inheritdoc} |
146 | 136 | */ |
147 | - public function getOption(string $name) |
|
148 | - { |
|
137 | + public function getOption(string $name) { |
|
149 | 138 | if ($this->definition->hasNegation($name)) { |
150 | 139 | if (null === $value = $this->getOption($this->definition->negationToName($name))) { |
151 | 140 | return $value; |
@@ -164,8 +153,7 @@ discard block |
||
164 | 153 | /** |
165 | 154 | * {@inheritdoc} |
166 | 155 | */ |
167 | - public function setOption(string $name, $value) |
|
168 | - { |
|
156 | + public function setOption(string $name, $value) { |
|
169 | 157 | if ($this->definition->hasNegation($name)) { |
170 | 158 | $this->options[$this->definition->negationToName($name)] = !$value; |
171 | 159 | |
@@ -180,8 +168,7 @@ discard block |
||
180 | 168 | /** |
181 | 169 | * {@inheritdoc} |
182 | 170 | */ |
183 | - public function hasOption(string $name) |
|
184 | - { |
|
171 | + public function hasOption(string $name) { |
|
185 | 172 | return $this->definition->hasOption($name) || $this->definition->hasNegation($name); |
186 | 173 | } |
187 | 174 | |
@@ -190,24 +177,21 @@ discard block |
||
190 | 177 | * |
191 | 178 | * @return string |
192 | 179 | */ |
193 | - public function escapeToken(string $token) |
|
194 | - { |
|
180 | + public function escapeToken(string $token) { |
|
195 | 181 | return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token); |
196 | 182 | } |
197 | 183 | |
198 | 184 | /** |
199 | 185 | * {@inheritdoc} |
200 | 186 | */ |
201 | - public function setStream($stream) |
|
202 | - { |
|
187 | + public function setStream($stream) { |
|
203 | 188 | $this->stream = $stream; |
204 | 189 | } |
205 | 190 | |
206 | 191 | /** |
207 | 192 | * {@inheritdoc} |
208 | 193 | */ |
209 | - public function getStream() |
|
210 | - { |
|
194 | + public function getStream() { |
|
211 | 195 | return $this->stream; |
212 | 196 | } |
213 | 197 | } |
@@ -23,12 +23,10 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @author Fabien Potencier <[email protected]> |
25 | 25 | */ |
26 | -class ArrayInput extends Input |
|
27 | -{ |
|
26 | +class ArrayInput extends Input { |
|
28 | 27 | private $parameters; |
29 | 28 | |
30 | - public function __construct(array $parameters, InputDefinition $definition = null) |
|
31 | - { |
|
29 | + public function __construct(array $parameters, InputDefinition $definition = null) { |
|
32 | 30 | $this->parameters = $parameters; |
33 | 31 | |
34 | 32 | parent::__construct($definition); |
@@ -37,8 +35,7 @@ discard block |
||
37 | 35 | /** |
38 | 36 | * {@inheritdoc} |
39 | 37 | */ |
40 | - public function getFirstArgument() |
|
41 | - { |
|
38 | + public function getFirstArgument() { |
|
42 | 39 | foreach ($this->parameters as $param => $value) { |
43 | 40 | if ($param && \is_string($param) && '-' === $param[0]) { |
44 | 41 | continue; |
@@ -53,8 +50,7 @@ discard block |
||
53 | 50 | /** |
54 | 51 | * {@inheritdoc} |
55 | 52 | */ |
56 | - public function hasParameterOption($values, bool $onlyParams = false) |
|
57 | - { |
|
53 | + public function hasParameterOption($values, bool $onlyParams = false) { |
|
58 | 54 | $values = (array) $values; |
59 | 55 | |
60 | 56 | foreach ($this->parameters as $k => $v) { |
@@ -77,8 +73,7 @@ discard block |
||
77 | 73 | /** |
78 | 74 | * {@inheritdoc} |
79 | 75 | */ |
80 | - public function getParameterOption($values, $default = false, bool $onlyParams = false) |
|
81 | - { |
|
76 | + public function getParameterOption($values, $default = false, bool $onlyParams = false) { |
|
82 | 77 | $values = (array) $values; |
83 | 78 | |
84 | 79 | foreach ($this->parameters as $k => $v) { |
@@ -103,8 +98,7 @@ discard block |
||
103 | 98 | * |
104 | 99 | * @return string |
105 | 100 | */ |
106 | - public function __toString() |
|
107 | - { |
|
101 | + public function __toString() { |
|
108 | 102 | $params = []; |
109 | 103 | foreach ($this->parameters as $param => $val) { |
110 | 104 | if ($param && \is_string($param) && '-' === $param[0]) { |
@@ -127,8 +121,7 @@ discard block |
||
127 | 121 | /** |
128 | 122 | * {@inheritdoc} |
129 | 123 | */ |
130 | - protected function parse() |
|
131 | - { |
|
124 | + protected function parse() { |
|
132 | 125 | foreach ($this->parameters as $key => $value) { |
133 | 126 | if ('--' === $key) { |
134 | 127 | return; |
@@ -148,8 +141,7 @@ discard block |
||
148 | 141 | * |
149 | 142 | * @throws InvalidOptionException When option given doesn't exist |
150 | 143 | */ |
151 | - private function addShortOption(string $shortcut, $value) |
|
152 | - { |
|
144 | + private function addShortOption(string $shortcut, $value) { |
|
153 | 145 | if (!$this->definition->hasShortcut($shortcut)) { |
154 | 146 | throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut)); |
155 | 147 | } |
@@ -163,8 +155,7 @@ discard block |
||
163 | 155 | * @throws InvalidOptionException When option given doesn't exist |
164 | 156 | * @throws InvalidOptionException When a required value is missing |
165 | 157 | */ |
166 | - private function addLongOption(string $name, $value) |
|
167 | - { |
|
158 | + private function addLongOption(string $name, $value) { |
|
168 | 159 | if (!$this->definition->hasOption($name)) { |
169 | 160 | if (!$this->definition->hasNegation($name)) { |
170 | 161 | throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name)); |
@@ -199,8 +190,7 @@ discard block |
||
199 | 190 | * |
200 | 191 | * @throws InvalidArgumentException When argument given doesn't exist |
201 | 192 | */ |
202 | - private function addArgument($name, $value) |
|
203 | - { |
|
193 | + private function addArgument($name, $value) { |
|
204 | 194 | if (!$this->definition->hasArgument($name)) { |
205 | 195 | throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); |
206 | 196 | } |
@@ -11,12 +11,10 @@ |
||
11 | 11 | |
12 | 12 | namespace Symfony\Component\Console\SignalRegistry; |
13 | 13 | |
14 | -final class SignalRegistry |
|
15 | -{ |
|
14 | +final class SignalRegistry { |
|
16 | 15 | private $signalHandlers = []; |
17 | 16 | |
18 | - public function __construct() |
|
19 | - { |
|
17 | + public function __construct() { |
|
20 | 18 | if (\function_exists('pcntl_async_signals')) { |
21 | 19 | pcntl_async_signals(true); |
22 | 20 | } |
@@ -18,31 +18,27 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Maxime Steinhausser <[email protected]> |
20 | 20 | */ |
21 | -class FactoryCommandLoader implements CommandLoaderInterface |
|
22 | -{ |
|
21 | +class FactoryCommandLoader implements CommandLoaderInterface { |
|
23 | 22 | private $factories; |
24 | 23 | |
25 | 24 | /** |
26 | 25 | * @param callable[] $factories Indexed by command names |
27 | 26 | */ |
28 | - public function __construct(array $factories) |
|
29 | - { |
|
27 | + public function __construct(array $factories) { |
|
30 | 28 | $this->factories = $factories; |
31 | 29 | } |
32 | 30 | |
33 | 31 | /** |
34 | 32 | * {@inheritdoc} |
35 | 33 | */ |
36 | - public function has(string $name) |
|
37 | - { |
|
34 | + public function has(string $name) { |
|
38 | 35 | return isset($this->factories[$name]); |
39 | 36 | } |
40 | 37 | |
41 | 38 | /** |
42 | 39 | * {@inheritdoc} |
43 | 40 | */ |
44 | - public function get(string $name) |
|
45 | - { |
|
41 | + public function get(string $name) { |
|
46 | 42 | if (!isset($this->factories[$name])) { |
47 | 43 | throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); |
48 | 44 | } |
@@ -55,8 +51,7 @@ discard block |
||
55 | 51 | /** |
56 | 52 | * {@inheritdoc} |
57 | 53 | */ |
58 | - public function getNames() |
|
59 | - { |
|
54 | + public function getNames() { |
|
60 | 55 | return array_keys($this->factories); |
61 | 56 | } |
62 | 57 | } |
@@ -17,8 +17,7 @@ |
||
17 | 17 | /** |
18 | 18 | * @author Robin Chalas <[email protected]> |
19 | 19 | */ |
20 | -interface CommandLoaderInterface |
|
21 | -{ |
|
20 | +interface CommandLoaderInterface { |
|
22 | 21 | /** |
23 | 22 | * Loads a command. |
24 | 23 | * |
@@ -19,16 +19,14 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @author Robin Chalas <[email protected]> |
21 | 21 | */ |
22 | -class ContainerCommandLoader implements CommandLoaderInterface |
|
23 | -{ |
|
22 | +class ContainerCommandLoader implements CommandLoaderInterface { |
|
24 | 23 | private $container; |
25 | 24 | private $commandMap; |
26 | 25 | |
27 | 26 | /** |
28 | 27 | * @param array $commandMap An array with command names as keys and service ids as values |
29 | 28 | */ |
30 | - public function __construct(ContainerInterface $container, array $commandMap) |
|
31 | - { |
|
29 | + public function __construct(ContainerInterface $container, array $commandMap) { |
|
32 | 30 | $this->container = $container; |
33 | 31 | $this->commandMap = $commandMap; |
34 | 32 | } |
@@ -36,8 +34,7 @@ discard block |
||
36 | 34 | /** |
37 | 35 | * {@inheritdoc} |
38 | 36 | */ |
39 | - public function get(string $name) |
|
40 | - { |
|
37 | + public function get(string $name) { |
|
41 | 38 | if (!$this->has($name)) { |
42 | 39 | throw new CommandNotFoundException(sprintf('Command "%s" does not exist.', $name)); |
43 | 40 | } |
@@ -48,16 +45,14 @@ discard block |
||
48 | 45 | /** |
49 | 46 | * {@inheritdoc} |
50 | 47 | */ |
51 | - public function has(string $name) |
|
52 | - { |
|
48 | + public function has(string $name) { |
|
53 | 49 | return isset($this->commandMap[$name]) && $this->container->has($this->commandMap[$name]); |
54 | 50 | } |
55 | 51 | |
56 | 52 | /** |
57 | 53 | * {@inheritdoc} |
58 | 54 | */ |
59 | - public function getNames() |
|
60 | - { |
|
55 | + public function getNames() { |
|
61 | 56 | return array_keys($this->commandMap); |
62 | 57 | } |
63 | 58 | } |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -final class Color |
|
20 | -{ |
|
19 | +final class Color { |
|
21 | 20 | private const COLORS = [ |
22 | 21 | 'black' => 0, |
23 | 22 | 'red' => 1, |
@@ -53,8 +52,7 @@ discard block |
||
53 | 52 | private $background; |
54 | 53 | private $options = []; |
55 | 54 | |
56 | - public function __construct(string $foreground = '', string $background = '', array $options = []) |
|
57 | - { |
|
55 | + public function __construct(string $foreground = '', string $background = '', array $options = []) { |
|
58 | 56 | $this->foreground = $this->parseColor($foreground); |
59 | 57 | $this->background = $this->parseColor($background, true); |
60 | 58 |
@@ -64,8 +64,7 @@ discard block |
||
64 | 64 | * |
65 | 65 | * @author Fabien Potencier <[email protected]> |
66 | 66 | */ |
67 | -class Application implements ResetInterface |
|
68 | -{ |
|
67 | +class Application implements ResetInterface { |
|
69 | 68 | private $commands = []; |
70 | 69 | private $wantHelps = false; |
71 | 70 | private $runningCommand; |
@@ -84,8 +83,7 @@ discard block |
||
84 | 83 | private $signalRegistry; |
85 | 84 | private $signalsToDispatchEvent = []; |
86 | 85 | |
87 | - public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') |
|
88 | - { |
|
86 | + public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN') { |
|
89 | 87 | $this->name = $name; |
90 | 88 | $this->version = $version; |
91 | 89 | $this->terminal = new Terminal(); |
@@ -99,13 +97,11 @@ discard block |
||
99 | 97 | /** |
100 | 98 | * @final |
101 | 99 | */ |
102 | - public function setDispatcher(EventDispatcherInterface $dispatcher) |
|
103 | - { |
|
100 | + public function setDispatcher(EventDispatcherInterface $dispatcher) { |
|
104 | 101 | $this->dispatcher = $dispatcher; |
105 | 102 | } |
106 | 103 | |
107 | - public function setCommandLoader(CommandLoaderInterface $commandLoader) |
|
108 | - { |
|
104 | + public function setCommandLoader(CommandLoaderInterface $commandLoader) { |
|
109 | 105 | $this->commandLoader = $commandLoader; |
110 | 106 | } |
111 | 107 | |
@@ -118,8 +114,7 @@ discard block |
||
118 | 114 | return $this->signalRegistry; |
119 | 115 | } |
120 | 116 | |
121 | - public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent) |
|
122 | - { |
|
117 | + public function setSignalsToDispatchEvent(int ...$signalsToDispatchEvent) { |
|
123 | 118 | $this->signalsToDispatchEvent = $signalsToDispatchEvent; |
124 | 119 | } |
125 | 120 | |
@@ -130,8 +125,7 @@ discard block |
||
130 | 125 | * |
131 | 126 | * @throws \Exception When running fails. Bypass this when {@link setCatchExceptions()}. |
132 | 127 | */ |
133 | - public function run(InputInterface $input = null, OutputInterface $output = null) |
|
134 | - { |
|
128 | + public function run(InputInterface $input = null, OutputInterface $output = null) { |
|
135 | 129 | if (\function_exists('putenv')) { |
136 | 130 | @putenv('LINES='.$this->terminal->getHeight()); |
137 | 131 | @putenv('COLUMNS='.$this->terminal->getWidth()); |
@@ -213,8 +207,7 @@ discard block |
||
213 | 207 | * |
214 | 208 | * @return int 0 if everything went fine, or an error code |
215 | 209 | */ |
216 | - public function doRun(InputInterface $input, OutputInterface $output) |
|
217 | - { |
|
210 | + public function doRun(InputInterface $input, OutputInterface $output) { |
|
218 | 211 | if (true === $input->hasParameterOption(['--version', '-V'], true)) { |
219 | 212 | $output->writeln($this->getLongVersion()); |
220 | 213 | |
@@ -301,12 +294,10 @@ discard block |
||
301 | 294 | /** |
302 | 295 | * {@inheritdoc} |
303 | 296 | */ |
304 | - public function reset() |
|
305 | - { |
|
297 | + public function reset() { |
|
306 | 298 | } |
307 | 299 | |
308 | - public function setHelperSet(HelperSet $helperSet) |
|
309 | - { |
|
300 | + public function setHelperSet(HelperSet $helperSet) { |
|
310 | 301 | $this->helperSet = $helperSet; |
311 | 302 | } |
312 | 303 | |
@@ -315,8 +306,7 @@ discard block |
||
315 | 306 | * |
316 | 307 | * @return HelperSet The HelperSet instance associated with this command |
317 | 308 | */ |
318 | - public function getHelperSet() |
|
319 | - { |
|
309 | + public function getHelperSet() { |
|
320 | 310 | if (!$this->helperSet) { |
321 | 311 | $this->helperSet = $this->getDefaultHelperSet(); |
322 | 312 | } |
@@ -324,8 +314,7 @@ discard block |
||
324 | 314 | return $this->helperSet; |
325 | 315 | } |
326 | 316 | |
327 | - public function setDefinition(InputDefinition $definition) |
|
328 | - { |
|
317 | + public function setDefinition(InputDefinition $definition) { |
|
329 | 318 | $this->definition = $definition; |
330 | 319 | } |
331 | 320 | |
@@ -334,8 +323,7 @@ discard block |
||
334 | 323 | * |
335 | 324 | * @return InputDefinition The InputDefinition instance |
336 | 325 | */ |
337 | - public function getDefinition() |
|
338 | - { |
|
326 | + public function getDefinition() { |
|
339 | 327 | if (!$this->definition) { |
340 | 328 | $this->definition = $this->getDefaultInputDefinition(); |
341 | 329 | } |
@@ -355,8 +343,7 @@ discard block |
||
355 | 343 | * |
356 | 344 | * @return string A help message |
357 | 345 | */ |
358 | - public function getHelp() |
|
359 | - { |
|
346 | + public function getHelp() { |
|
360 | 347 | return $this->getLongVersion(); |
361 | 348 | } |
362 | 349 | |
@@ -365,16 +352,14 @@ discard block |
||
365 | 352 | * |
366 | 353 | * @return bool Whether to catch exceptions or not during commands execution |
367 | 354 | */ |
368 | - public function areExceptionsCaught() |
|
369 | - { |
|
355 | + public function areExceptionsCaught() { |
|
370 | 356 | return $this->catchExceptions; |
371 | 357 | } |
372 | 358 | |
373 | 359 | /** |
374 | 360 | * Sets whether to catch exceptions or not during commands execution. |
375 | 361 | */ |
376 | - public function setCatchExceptions(bool $boolean) |
|
377 | - { |
|
362 | + public function setCatchExceptions(bool $boolean) { |
|
378 | 363 | $this->catchExceptions = $boolean; |
379 | 364 | } |
380 | 365 | |
@@ -383,16 +368,14 @@ discard block |
||
383 | 368 | * |
384 | 369 | * @return bool Whether to automatically exit after a command execution or not |
385 | 370 | */ |
386 | - public function isAutoExitEnabled() |
|
387 | - { |
|
371 | + public function isAutoExitEnabled() { |
|
388 | 372 | return $this->autoExit; |
389 | 373 | } |
390 | 374 | |
391 | 375 | /** |
392 | 376 | * Sets whether to automatically exit after a command execution or not. |
393 | 377 | */ |
394 | - public function setAutoExit(bool $boolean) |
|
395 | - { |
|
378 | + public function setAutoExit(bool $boolean) { |
|
396 | 379 | $this->autoExit = $boolean; |
397 | 380 | } |
398 | 381 | |
@@ -401,16 +384,14 @@ discard block |
||
401 | 384 | * |
402 | 385 | * @return string The application name |
403 | 386 | */ |
404 | - public function getName() |
|
405 | - { |
|
387 | + public function getName() { |
|
406 | 388 | return $this->name; |
407 | 389 | } |
408 | 390 | |
409 | 391 | /** |
410 | 392 | * Sets the application name. |
411 | 393 | **/ |
412 | - public function setName(string $name) |
|
413 | - { |
|
394 | + public function setName(string $name) { |
|
414 | 395 | $this->name = $name; |
415 | 396 | } |
416 | 397 | |
@@ -419,16 +400,14 @@ discard block |
||
419 | 400 | * |
420 | 401 | * @return string The application version |
421 | 402 | */ |
422 | - public function getVersion() |
|
423 | - { |
|
403 | + public function getVersion() { |
|
424 | 404 | return $this->version; |
425 | 405 | } |
426 | 406 | |
427 | 407 | /** |
428 | 408 | * Sets the application version. |
429 | 409 | */ |
430 | - public function setVersion(string $version) |
|
431 | - { |
|
410 | + public function setVersion(string $version) { |
|
432 | 411 | $this->version = $version; |
433 | 412 | } |
434 | 413 | |
@@ -437,8 +416,7 @@ discard block |
||
437 | 416 | * |
438 | 417 | * @return string The long application version |
439 | 418 | */ |
440 | - public function getLongVersion() |
|
441 | - { |
|
419 | + public function getLongVersion() { |
|
442 | 420 | if ('UNKNOWN' !== $this->getName()) { |
443 | 421 | if ('UNKNOWN' !== $this->getVersion()) { |
444 | 422 | return sprintf('%s <info>%s</info>', $this->getName(), $this->getVersion()); |
@@ -455,8 +433,7 @@ discard block |
||
455 | 433 | * |
456 | 434 | * @return Command The newly created command |
457 | 435 | */ |
458 | - public function register(string $name) |
|
459 | - { |
|
436 | + public function register(string $name) { |
|
460 | 437 | return $this->add(new Command($name)); |
461 | 438 | } |
462 | 439 | |
@@ -467,8 +444,7 @@ discard block |
||
467 | 444 | * |
468 | 445 | * @param Command[] $commands An array of commands |
469 | 446 | */ |
470 | - public function addCommands(array $commands) |
|
471 | - { |
|
447 | + public function addCommands(array $commands) { |
|
472 | 448 | foreach ($commands as $command) { |
473 | 449 | $this->add($command); |
474 | 450 | } |
@@ -482,8 +458,7 @@ discard block |
||
482 | 458 | * |
483 | 459 | * @return Command|null The registered command if enabled or null |
484 | 460 | */ |
485 | - public function add(Command $command) |
|
486 | - { |
|
461 | + public function add(Command $command) { |
|
487 | 462 | $this->init(); |
488 | 463 | |
489 | 464 | $command->setApplication($this); |
@@ -519,8 +494,7 @@ discard block |
||
519 | 494 | * |
520 | 495 | * @throws CommandNotFoundException When given command name does not exist |
521 | 496 | */ |
522 | - public function get(string $name) |
|
523 | - { |
|
497 | + public function get(string $name) { |
|
524 | 498 | $this->init(); |
525 | 499 | |
526 | 500 | if (!$this->has($name)) { |
@@ -551,8 +525,7 @@ discard block |
||
551 | 525 | * |
552 | 526 | * @return bool true if the command exists, false otherwise |
553 | 527 | */ |
554 | - public function has(string $name) |
|
555 | - { |
|
528 | + public function has(string $name) { |
|
556 | 529 | $this->init(); |
557 | 530 | |
558 | 531 | return isset($this->commands[$name]) || ($this->commandLoader && $this->commandLoader->has($name) && $this->add($this->commandLoader->get($name))); |
@@ -565,8 +538,7 @@ discard block |
||
565 | 538 | * |
566 | 539 | * @return string[] An array of namespaces |
567 | 540 | */ |
568 | - public function getNamespaces() |
|
569 | - { |
|
541 | + public function getNamespaces() { |
|
570 | 542 | $namespaces = []; |
571 | 543 | foreach ($this->all() as $command) { |
572 | 544 | if ($command->isHidden()) { |
@@ -590,8 +562,7 @@ discard block |
||
590 | 562 | * |
591 | 563 | * @throws NamespaceNotFoundException When namespace is incorrect or ambiguous |
592 | 564 | */ |
593 | - public function findNamespace(string $namespace) |
|
594 | - { |
|
565 | + public function findNamespace(string $namespace) { |
|
595 | 566 | $allNamespaces = $this->getNamespaces(); |
596 | 567 | $expr = implode('[^:]*:', array_map('preg_quote', explode(':', $namespace))).'[^:]*'; |
597 | 568 | $namespaces = preg_grep('{^'.$expr.'}', $allNamespaces); |
@@ -630,8 +601,7 @@ discard block |
||
630 | 601 | * |
631 | 602 | * @throws CommandNotFoundException When command name is incorrect or ambiguous |
632 | 603 | */ |
633 | - public function find(string $name) |
|
634 | - { |
|
604 | + public function find(string $name) { |
|
635 | 605 | $this->init(); |
636 | 606 | |
637 | 607 | $aliases = []; |
@@ -740,8 +710,7 @@ discard block |
||
740 | 710 | * |
741 | 711 | * @return Command[] An array of Command instances |
742 | 712 | */ |
743 | - public function all(string $namespace = null) |
|
744 | - { |
|
713 | + public function all(string $namespace = null) { |
|
745 | 714 | $this->init(); |
746 | 715 | |
747 | 716 | if (null === $namespace) { |
@@ -782,8 +751,7 @@ discard block |
||
782 | 751 | * |
783 | 752 | * @return string[][] An array of abbreviations |
784 | 753 | */ |
785 | - public static function getAbbreviations(array $names) |
|
786 | - { |
|
754 | + public static function getAbbreviations(array $names) { |
|
787 | 755 | $abbrevs = []; |
788 | 756 | foreach ($names as $name) { |
789 | 757 | for ($len = \strlen($name); $len > 0; --$len) { |
@@ -884,8 +852,7 @@ discard block |
||
884 | 852 | /** |
885 | 853 | * Configures the input and output instances based on the user arguments and options. |
886 | 854 | */ |
887 | - protected function configureIO(InputInterface $input, OutputInterface $output) |
|
888 | - { |
|
855 | + protected function configureIO(InputInterface $input, OutputInterface $output) { |
|
889 | 856 | if (true === $input->hasParameterOption(['--ansi'], true)) { |
890 | 857 | $output->setDecorated(true); |
891 | 858 | } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) { |
@@ -939,8 +906,7 @@ discard block |
||
939 | 906 | * |
940 | 907 | * @return int 0 if everything went fine, or an error code |
941 | 908 | */ |
942 | - protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) |
|
943 | - { |
|
909 | + protected function doRunCommand(Command $command, InputInterface $input, OutputInterface $output) { |
|
944 | 910 | foreach ($command->getHelperSet() as $helper) { |
945 | 911 | if ($helper instanceof InputAwareInterface) { |
946 | 912 | $helper->setInput($input); |
@@ -1022,8 +988,7 @@ discard block |
||
1022 | 988 | * |
1023 | 989 | * @return string|null |
1024 | 990 | */ |
1025 | - protected function getCommandName(InputInterface $input) |
|
1026 | - { |
|
991 | + protected function getCommandName(InputInterface $input) { |
|
1027 | 992 | return $this->singleCommand ? $this->defaultCommand : $input->getFirstArgument(); |
1028 | 993 | } |
1029 | 994 | |
@@ -1032,8 +997,7 @@ discard block |
||
1032 | 997 | * |
1033 | 998 | * @return InputDefinition An InputDefinition instance |
1034 | 999 | */ |
1035 | - protected function getDefaultInputDefinition() |
|
1036 | - { |
|
1000 | + protected function getDefaultInputDefinition() { |
|
1037 | 1001 | return new InputDefinition([ |
1038 | 1002 | new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'), |
1039 | 1003 | new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display help for the given command. When no command is given display help for the <info>'.$this->defaultCommand.'</info> command'), |
@@ -1050,8 +1014,7 @@ discard block |
||
1050 | 1014 | * |
1051 | 1015 | * @return Command[] An array of default Command instances |
1052 | 1016 | */ |
1053 | - protected function getDefaultCommands() |
|
1054 | - { |
|
1017 | + protected function getDefaultCommands() { |
|
1055 | 1018 | return [new HelpCommand(), new ListCommand()]; |
1056 | 1019 | } |
1057 | 1020 | |
@@ -1060,8 +1023,7 @@ discard block |
||
1060 | 1023 | * |
1061 | 1024 | * @return HelperSet A HelperSet instance |
1062 | 1025 | */ |
1063 | - protected function getDefaultHelperSet() |
|
1064 | - { |
|
1026 | + protected function getDefaultHelperSet() { |
|
1065 | 1027 | return new HelperSet([ |
1066 | 1028 | new FormatterHelper(), |
1067 | 1029 | new DebugFormatterHelper(), |
@@ -1085,8 +1047,7 @@ discard block |
||
1085 | 1047 | * |
1086 | 1048 | * @return string The namespace of the command |
1087 | 1049 | */ |
1088 | - public function extractNamespace(string $name, int $limit = null) |
|
1089 | - { |
|
1050 | + public function extractNamespace(string $name, int $limit = null) { |
|
1090 | 1051 | $parts = explode(':', $name, -1); |
1091 | 1052 | |
1092 | 1053 | return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit)); |
@@ -1145,8 +1106,7 @@ discard block |
||
1145 | 1106 | * |
1146 | 1107 | * @return self |
1147 | 1108 | */ |
1148 | - public function setDefaultCommand(string $commandName, bool $isSingleCommand = false) |
|
1149 | - { |
|
1109 | + public function setDefaultCommand(string $commandName, bool $isSingleCommand = false) { |
|
1150 | 1110 | $this->defaultCommand = explode('|', ltrim($commandName, '|'))[0]; |
1151 | 1111 | |
1152 | 1112 | if ($isSingleCommand) { |
@@ -1225,8 +1185,7 @@ discard block |
||
1225 | 1185 | return $namespaces; |
1226 | 1186 | } |
1227 | 1187 | |
1228 | - private function init() |
|
1229 | - { |
|
1188 | + private function init() { |
|
1230 | 1189 | if ($this->initialized) { |
1231 | 1190 | return; |
1232 | 1191 | } |