@@ -18,7 +18,6 @@ |
||
18 | 18 | * |
19 | 19 | * @author Jean-François Simon <[email protected]> |
20 | 20 | */ |
21 | -interface DescriptorInterface |
|
22 | -{ |
|
21 | +interface DescriptorInterface { |
|
23 | 22 | public function describe(OutputInterface $output, object $object, array $options = []); |
24 | 23 | } |
@@ -24,21 +24,18 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @internal |
26 | 26 | */ |
27 | -class JsonDescriptor extends Descriptor |
|
28 | -{ |
|
27 | +class JsonDescriptor extends Descriptor { |
|
29 | 28 | /** |
30 | 29 | * {@inheritdoc} |
31 | 30 | */ |
32 | - protected function describeInputArgument(InputArgument $argument, array $options = []) |
|
33 | - { |
|
31 | + protected function describeInputArgument(InputArgument $argument, array $options = []) { |
|
34 | 32 | $this->writeData($this->getInputArgumentData($argument), $options); |
35 | 33 | } |
36 | 34 | |
37 | 35 | /** |
38 | 36 | * {@inheritdoc} |
39 | 37 | */ |
40 | - protected function describeInputOption(InputOption $option, array $options = []) |
|
41 | - { |
|
38 | + protected function describeInputOption(InputOption $option, array $options = []) { |
|
42 | 39 | $this->writeData($this->getInputOptionData($option), $options); |
43 | 40 | if ($option->isNegatable()) { |
44 | 41 | $this->writeData($this->getInputOptionData($option, true), $options); |
@@ -48,24 +45,21 @@ discard block |
||
48 | 45 | /** |
49 | 46 | * {@inheritdoc} |
50 | 47 | */ |
51 | - protected function describeInputDefinition(InputDefinition $definition, array $options = []) |
|
52 | - { |
|
48 | + protected function describeInputDefinition(InputDefinition $definition, array $options = []) { |
|
53 | 49 | $this->writeData($this->getInputDefinitionData($definition), $options); |
54 | 50 | } |
55 | 51 | |
56 | 52 | /** |
57 | 53 | * {@inheritdoc} |
58 | 54 | */ |
59 | - protected function describeCommand(Command $command, array $options = []) |
|
60 | - { |
|
55 | + protected function describeCommand(Command $command, array $options = []) { |
|
61 | 56 | $this->writeData($this->getCommandData($command, $options['short'] ?? false), $options); |
62 | 57 | } |
63 | 58 | |
64 | 59 | /** |
65 | 60 | * {@inheritdoc} |
66 | 61 | */ |
67 | - protected function describeApplication(Application $application, array $options = []) |
|
68 | - { |
|
62 | + protected function describeApplication(Application $application, array $options = []) { |
|
69 | 63 | $describedNamespace = $options['namespace'] ?? null; |
70 | 64 | $description = new ApplicationDescription($application, $describedNamespace, true); |
71 | 65 | $commands = []; |
@@ -96,8 +90,7 @@ discard block |
||
96 | 90 | /** |
97 | 91 | * Writes data as json. |
98 | 92 | */ |
99 | - private function writeData(array $data, array $options) |
|
100 | - { |
|
93 | + private function writeData(array $data, array $options) { |
|
101 | 94 | $flags = $options['json_encoding'] ?? 0; |
102 | 95 | |
103 | 96 | $this->write(json_encode($data, $flags)); |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @internal |
22 | 22 | */ |
23 | -class ApplicationDescription |
|
24 | -{ |
|
23 | +class ApplicationDescription { |
|
25 | 24 | public const GLOBAL_NAMESPACE = '_global'; |
26 | 25 | |
27 | 26 | private $application; |
@@ -43,8 +42,7 @@ discard block |
||
43 | 42 | */ |
44 | 43 | private $aliases; |
45 | 44 | |
46 | - public function __construct(Application $application, string $namespace = null, bool $showHidden = false) |
|
47 | - { |
|
45 | + public function __construct(Application $application, string $namespace = null, bool $showHidden = false) { |
|
48 | 46 | $this->application = $application; |
49 | 47 | $this->namespace = $namespace; |
50 | 48 | $this->showHidden = $showHidden; |
@@ -83,8 +81,7 @@ discard block |
||
83 | 81 | return $this->commands[$name] ?? $this->aliases[$name]; |
84 | 82 | } |
85 | 83 | |
86 | - private function inspectApplication() |
|
87 | - { |
|
84 | + private function inspectApplication() { |
|
88 | 85 | $this->commands = []; |
89 | 86 | $this->namespaces = []; |
90 | 87 |
@@ -18,8 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Maxime Steinhausser <[email protected]> |
20 | 20 | */ |
21 | -class GithubActionReporter |
|
22 | -{ |
|
21 | +class GithubActionReporter { |
|
23 | 22 | private $output; |
24 | 23 | |
25 | 24 | /** |
@@ -42,8 +41,7 @@ discard block |
||
42 | 41 | ',' => '%2C', |
43 | 42 | ]; |
44 | 43 | |
45 | - public function __construct(OutputInterface $output) |
|
46 | - { |
|
44 | + public function __construct(OutputInterface $output) { |
|
47 | 45 | $this->output = $output; |
48 | 46 | } |
49 | 47 |
@@ -24,8 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @see https://www.php-fig.org/psr/psr-3/ |
26 | 26 | */ |
27 | -class ConsoleLogger extends AbstractLogger |
|
28 | -{ |
|
27 | +class ConsoleLogger extends AbstractLogger { |
|
29 | 28 | public const INFO = 'info'; |
30 | 29 | public const ERROR = 'error'; |
31 | 30 | |
@@ -52,8 +51,7 @@ discard block |
||
52 | 51 | ]; |
53 | 52 | private $errored = false; |
54 | 53 | |
55 | - public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = []) |
|
56 | - { |
|
54 | + public function __construct(OutputInterface $output, array $verbosityLevelMap = [], array $formatLevelMap = []) { |
|
57 | 55 | $this->output = $output; |
58 | 56 | $this->verbosityLevelMap = $verbosityLevelMap + $this->verbosityLevelMap; |
59 | 57 | $this->formatLevelMap = $formatLevelMap + $this->formatLevelMap; |
@@ -64,8 +62,7 @@ discard block |
||
64 | 62 | * |
65 | 63 | * @return void |
66 | 64 | */ |
67 | - public function log($level, $message, array $context = []) |
|
68 | - { |
|
65 | + public function log($level, $message, array $context = []) { |
|
69 | 66 | if (!isset($this->verbosityLevelMap[$level])) { |
70 | 67 | throw new InvalidArgumentException(sprintf('The log level "%s" does not exist.', $level)); |
71 | 68 | } |
@@ -92,8 +89,7 @@ discard block |
||
92 | 89 | * |
93 | 90 | * @return bool |
94 | 91 | */ |
95 | - public function hasErrored() |
|
96 | - { |
|
92 | + public function hasErrored() { |
|
97 | 93 | return $this->errored; |
98 | 94 | } |
99 | 95 |
@@ -22,17 +22,14 @@ discard block |
||
22 | 22 | * @author James Halsall <[email protected]> |
23 | 23 | * @author Robin Chalas <[email protected]> |
24 | 24 | */ |
25 | -class ErrorListener implements EventSubscriberInterface |
|
26 | -{ |
|
25 | +class ErrorListener implements EventSubscriberInterface { |
|
27 | 26 | private $logger; |
28 | 27 | |
29 | - public function __construct(LoggerInterface $logger = null) |
|
30 | - { |
|
28 | + public function __construct(LoggerInterface $logger = null) { |
|
31 | 29 | $this->logger = $logger; |
32 | 30 | } |
33 | 31 | |
34 | - public function onConsoleError(ConsoleErrorEvent $event) |
|
35 | - { |
|
32 | + public function onConsoleError(ConsoleErrorEvent $event) { |
|
36 | 33 | if (null === $this->logger) { |
37 | 34 | return; |
38 | 35 | } |
@@ -48,8 +45,7 @@ discard block |
||
48 | 45 | $this->logger->critical('Error thrown while running command "{command}". Message: "{message}"', ['exception' => $error, 'command' => $inputString, 'message' => $error->getMessage()]); |
49 | 46 | } |
50 | 47 | |
51 | - public function onConsoleTerminate(ConsoleTerminateEvent $event) |
|
52 | - { |
|
48 | + public function onConsoleTerminate(ConsoleTerminateEvent $event) { |
|
53 | 49 | if (null === $this->logger) { |
54 | 50 | return; |
55 | 51 | } |
@@ -69,8 +65,7 @@ discard block |
||
69 | 65 | $this->logger->debug('Command "{command}" exited with code "{code}"', ['command' => $inputString, 'code' => $exitCode]); |
70 | 66 | } |
71 | 67 | |
72 | - public static function getSubscribedEvents() |
|
73 | - { |
|
68 | + public static function getSubscribedEvents() { |
|
74 | 69 | return [ |
75 | 70 | ConsoleEvents::ERROR => ['onConsoleError', -128], |
76 | 71 | ConsoleEvents::TERMINATE => ['onConsoleTerminate', -128], |
@@ -18,8 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @author Fabien Potencier <[email protected]> |
20 | 20 | */ |
21 | -class ChoiceQuestion extends Question |
|
22 | -{ |
|
21 | +class ChoiceQuestion extends Question { |
|
23 | 22 | private $choices; |
24 | 23 | private $multiselect = false; |
25 | 24 | private $prompt = ' > '; |
@@ -30,8 +29,7 @@ discard block |
||
30 | 29 | * @param array $choices The list of available choices |
31 | 30 | * @param mixed $default The default answer to return |
32 | 31 | */ |
33 | - public function __construct(string $question, array $choices, $default = null) |
|
34 | - { |
|
32 | + public function __construct(string $question, array $choices, $default = null) { |
|
35 | 33 | if (!$choices) { |
36 | 34 | throw new \LogicException('Choice question must have at least 1 choice available.'); |
37 | 35 | } |
@@ -48,8 +46,7 @@ discard block |
||
48 | 46 | * |
49 | 47 | * @return array |
50 | 48 | */ |
51 | - public function getChoices() |
|
52 | - { |
|
49 | + public function getChoices() { |
|
53 | 50 | return $this->choices; |
54 | 51 | } |
55 | 52 | |
@@ -60,8 +57,7 @@ discard block |
||
60 | 57 | * |
61 | 58 | * @return $this |
62 | 59 | */ |
63 | - public function setMultiselect(bool $multiselect) |
|
64 | - { |
|
60 | + public function setMultiselect(bool $multiselect) { |
|
65 | 61 | $this->multiselect = $multiselect; |
66 | 62 | $this->setValidator($this->getDefaultValidator()); |
67 | 63 | |
@@ -73,8 +69,7 @@ discard block |
||
73 | 69 | * |
74 | 70 | * @return bool |
75 | 71 | */ |
76 | - public function isMultiselect() |
|
77 | - { |
|
72 | + public function isMultiselect() { |
|
78 | 73 | return $this->multiselect; |
79 | 74 | } |
80 | 75 | |
@@ -83,8 +78,7 @@ discard block |
||
83 | 78 | * |
84 | 79 | * @return string |
85 | 80 | */ |
86 | - public function getPrompt() |
|
87 | - { |
|
81 | + public function getPrompt() { |
|
88 | 82 | return $this->prompt; |
89 | 83 | } |
90 | 84 | |
@@ -93,8 +87,7 @@ discard block |
||
93 | 87 | * |
94 | 88 | * @return $this |
95 | 89 | */ |
96 | - public function setPrompt(string $prompt) |
|
97 | - { |
|
90 | + public function setPrompt(string $prompt) { |
|
98 | 91 | $this->prompt = $prompt; |
99 | 92 | |
100 | 93 | return $this; |
@@ -107,8 +100,7 @@ discard block |
||
107 | 100 | * |
108 | 101 | * @return $this |
109 | 102 | */ |
110 | - public function setErrorMessage(string $errorMessage) |
|
111 | - { |
|
103 | + public function setErrorMessage(string $errorMessage) { |
|
112 | 104 | $this->errorMessage = $errorMessage; |
113 | 105 | $this->setValidator($this->getDefaultValidator()); |
114 | 106 |
@@ -19,8 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | * @author Fabien Potencier <[email protected]> |
21 | 21 | */ |
22 | -class Question |
|
23 | -{ |
|
22 | +class Question { |
|
24 | 23 | private $question; |
25 | 24 | private $attempts; |
26 | 25 | private $hidden = false; |
@@ -36,8 +35,7 @@ discard block |
||
36 | 35 | * @param string $question The question to ask to the user |
37 | 36 | * @param string|bool|int|float|null $default The default answer to return if the user enters nothing |
38 | 37 | */ |
39 | - public function __construct(string $question, $default = null) |
|
40 | - { |
|
38 | + public function __construct(string $question, $default = null) { |
|
41 | 39 | $this->question = $question; |
42 | 40 | $this->default = $default; |
43 | 41 | } |
@@ -47,8 +45,7 @@ discard block |
||
47 | 45 | * |
48 | 46 | * @return string |
49 | 47 | */ |
50 | - public function getQuestion() |
|
51 | - { |
|
48 | + public function getQuestion() { |
|
52 | 49 | return $this->question; |
53 | 50 | } |
54 | 51 | |
@@ -57,8 +54,7 @@ discard block |
||
57 | 54 | * |
58 | 55 | * @return string|bool|int|float|null |
59 | 56 | */ |
60 | - public function getDefault() |
|
61 | - { |
|
57 | + public function getDefault() { |
|
62 | 58 | return $this->default; |
63 | 59 | } |
64 | 60 | |
@@ -87,8 +83,7 @@ discard block |
||
87 | 83 | * |
88 | 84 | * @return bool |
89 | 85 | */ |
90 | - public function isHidden() |
|
91 | - { |
|
86 | + public function isHidden() { |
|
92 | 87 | return $this->hidden; |
93 | 88 | } |
94 | 89 | |
@@ -99,8 +94,7 @@ discard block |
||
99 | 94 | * |
100 | 95 | * @throws LogicException In case the autocompleter is also used |
101 | 96 | */ |
102 | - public function setHidden(bool $hidden) |
|
103 | - { |
|
97 | + public function setHidden(bool $hidden) { |
|
104 | 98 | if ($this->autocompleterCallback) { |
105 | 99 | throw new LogicException('A hidden question cannot use the autocompleter.'); |
106 | 100 | } |
@@ -115,8 +109,7 @@ discard block |
||
115 | 109 | * |
116 | 110 | * @return bool |
117 | 111 | */ |
118 | - public function isHiddenFallback() |
|
119 | - { |
|
112 | + public function isHiddenFallback() { |
|
120 | 113 | return $this->hiddenFallback; |
121 | 114 | } |
122 | 115 | |
@@ -125,8 +118,7 @@ discard block |
||
125 | 118 | * |
126 | 119 | * @return $this |
127 | 120 | */ |
128 | - public function setHiddenFallback(bool $fallback) |
|
129 | - { |
|
121 | + public function setHiddenFallback(bool $fallback) { |
|
130 | 122 | $this->hiddenFallback = (bool) $fallback; |
131 | 123 | |
132 | 124 | return $this; |
@@ -137,8 +129,7 @@ discard block |
||
137 | 129 | * |
138 | 130 | * @return iterable|null |
139 | 131 | */ |
140 | - public function getAutocompleterValues() |
|
141 | - { |
|
132 | + public function getAutocompleterValues() { |
|
142 | 133 | $callback = $this->getAutocompleterCallback(); |
143 | 134 | |
144 | 135 | return $callback ? $callback('') : null; |
@@ -151,8 +142,7 @@ discard block |
||
151 | 142 | * |
152 | 143 | * @throws LogicException |
153 | 144 | */ |
154 | - public function setAutocompleterValues(?iterable $values) |
|
155 | - { |
|
145 | + public function setAutocompleterValues(?iterable $values) { |
|
156 | 146 | if (\is_array($values)) { |
157 | 147 | $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values); |
158 | 148 | |
@@ -202,8 +192,7 @@ discard block |
||
202 | 192 | * |
203 | 193 | * @return $this |
204 | 194 | */ |
205 | - public function setValidator(callable $validator = null) |
|
206 | - { |
|
195 | + public function setValidator(callable $validator = null) { |
|
207 | 196 | $this->validator = $validator; |
208 | 197 | |
209 | 198 | return $this; |
@@ -214,8 +203,7 @@ discard block |
||
214 | 203 | * |
215 | 204 | * @return callable|null |
216 | 205 | */ |
217 | - public function getValidator() |
|
218 | - { |
|
206 | + public function getValidator() { |
|
219 | 207 | return $this->validator; |
220 | 208 | } |
221 | 209 | |
@@ -228,8 +216,7 @@ discard block |
||
228 | 216 | * |
229 | 217 | * @throws InvalidArgumentException in case the number of attempts is invalid |
230 | 218 | */ |
231 | - public function setMaxAttempts(?int $attempts) |
|
232 | - { |
|
219 | + public function setMaxAttempts(?int $attempts) { |
|
233 | 220 | if (null !== $attempts) { |
234 | 221 | $attempts = (int) $attempts; |
235 | 222 | if ($attempts < 1) { |
@@ -249,8 +236,7 @@ discard block |
||
249 | 236 | * |
250 | 237 | * @return int|null |
251 | 238 | */ |
252 | - public function getMaxAttempts() |
|
253 | - { |
|
239 | + public function getMaxAttempts() { |
|
254 | 240 | return $this->attempts; |
255 | 241 | } |
256 | 242 | |
@@ -261,8 +247,7 @@ discard block |
||
261 | 247 | * |
262 | 248 | * @return $this |
263 | 249 | */ |
264 | - public function setNormalizer(callable $normalizer) |
|
265 | - { |
|
250 | + public function setNormalizer(callable $normalizer) { |
|
266 | 251 | $this->normalizer = $normalizer; |
267 | 252 | |
268 | 253 | return $this; |
@@ -275,13 +260,11 @@ discard block |
||
275 | 260 | * |
276 | 261 | * @return callable|null |
277 | 262 | */ |
278 | - public function getNormalizer() |
|
279 | - { |
|
263 | + public function getNormalizer() { |
|
280 | 264 | return $this->normalizer; |
281 | 265 | } |
282 | 266 | |
283 | - protected function isAssoc(array $array) |
|
284 | - { |
|
267 | + protected function isAssoc(array $array) { |
|
285 | 268 | return (bool) \count(array_filter(array_keys($array), 'is_string')); |
286 | 269 | } |
287 | 270 |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class ConfirmationQuestion extends Question |
|
20 | -{ |
|
19 | +class ConfirmationQuestion extends Question { |
|
21 | 20 | private $trueAnswerRegex; |
22 | 21 | |
23 | 22 | /** |
@@ -25,8 +24,7 @@ discard block |
||
25 | 24 | * @param bool $default The default answer to return, true or false |
26 | 25 | * @param string $trueAnswerRegex A regex to match the "yes" answer |
27 | 26 | */ |
28 | - public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i') |
|
29 | - { |
|
27 | + public function __construct(string $question, bool $default = true, string $trueAnswerRegex = '/^y/i') { |
|
30 | 28 | parent::__construct($question, $default); |
31 | 29 | |
32 | 30 | $this->trueAnswerRegex = $trueAnswerRegex; |