@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | public function __construct(InputDefinition $definition = null) |
24 | 24 | { |
25 | - if($definition === null) { |
|
25 | + if ($definition === null) { |
|
26 | 26 | $this->definition = new InputDefinition(); |
27 | 27 | } else { |
28 | 28 | $this->bind($definition); |
@@ -55,12 +55,12 @@ discard block |
||
55 | 55 | $definition = $this->definition; |
56 | 56 | $givenArguments = $this->arguments; |
57 | 57 | |
58 | - $missingArguments = array_filter(array_keys($definition->getArguments()), function ($argument) use ($definition, $givenArguments) { |
|
58 | + $missingArguments = array_filter(array_keys($definition->getArguments()), function($argument) use ($definition, $givenArguments) { |
|
59 | 59 | return !array_key_exists($argument, $givenArguments) && $definition->getArgument($argument)->isRequired(); |
60 | 60 | }); |
61 | 61 | |
62 | - if(count($missingArguments) > 0) { |
|
63 | - throw new \RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(' ,', $missingArguments ))); |
|
62 | + if (count($missingArguments) > 0) { |
|
63 | + throw new \RuntimeException(sprintf('Not enough arguments (missing: "%s").', implode(' ,', $missingArguments))); |
|
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getArgument($name) |
95 | 95 | { |
96 | - if(!$this->definition->hasArgument($name)) |
|
96 | + if (!$this->definition->hasArgument($name)) |
|
97 | 97 | throw new \InvalidArgumentException(sprintf('The "%s" arguments does not exist.', $name)); |
98 | 98 | |
99 | - return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault(); |
|
99 | + return isset($this->arguments[ $name ]) ? $this->arguments[ $name ] : $this->definition->getArgument($name)->getDefault(); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -104,10 +104,10 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function setArgument($name, $value) |
106 | 106 | { |
107 | - if(!$this->definition->hasArgument($name)) |
|
107 | + if (!$this->definition->hasArgument($name)) |
|
108 | 108 | throw new \InvalidArgumentException(sprintf('The "%s" arguments does not exist.', $name)); |
109 | 109 | |
110 | - $this->arguments[$name] = $value; |
|
110 | + $this->arguments[ $name ] = $value; |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | if (!$this->definition->hasOption($name)) { |
135 | 135 | throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); |
136 | 136 | } |
137 | - return array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault(); |
|
137 | + return array_key_exists($name, $this->options) ? $this->options[ $name ] : $this->definition->getOption($name)->getDefault(); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | if (!$this->definition->hasOption($name)) { |
146 | 146 | throw new \InvalidArgumentException(sprintf('The "%s" option does not exist.', $name)); |
147 | 147 | } |
148 | - $this->options[$name] = $value; |
|
148 | + $this->options[ $name ] = $value; |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -93,8 +93,9 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function getArgument($name) |
95 | 95 | { |
96 | - if(!$this->definition->hasArgument($name)) |
|
97 | - throw new \InvalidArgumentException(sprintf('The "%s" arguments does not exist.', $name)); |
|
96 | + if(!$this->definition->hasArgument($name)) { |
|
97 | + throw new \InvalidArgumentException(sprintf('The "%s" arguments does not exist.', $name)); |
|
98 | + } |
|
98 | 99 | |
99 | 100 | return isset($this->arguments[$name]) ? $this->arguments[$name] : $this->definition->getArgument($name)->getDefault(); |
100 | 101 | } |
@@ -104,8 +105,9 @@ discard block |
||
104 | 105 | */ |
105 | 106 | public function setArgument($name, $value) |
106 | 107 | { |
107 | - if(!$this->definition->hasArgument($name)) |
|
108 | - throw new \InvalidArgumentException(sprintf('The "%s" arguments does not exist.', $name)); |
|
108 | + if(!$this->definition->hasArgument($name)) { |
|
109 | + throw new \InvalidArgumentException(sprintf('The "%s" arguments does not exist.', $name)); |
|
110 | + } |
|
109 | 111 | |
110 | 112 | $this->arguments[$name] = $value; |
111 | 113 | } |
@@ -63,10 +63,10 @@ |
||
63 | 63 | */ |
64 | 64 | function random_str($length, $keyspace = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') |
65 | 65 | { |
66 | - $pieces = []; |
|
66 | + $pieces = [ ]; |
|
67 | 67 | $max = mb_strlen($keyspace, '8bit') - 1; |
68 | 68 | for ($i = 0; $i < $length; ++$i) { |
69 | - $pieces []= $keyspace[random_int(0, $max)]; |
|
69 | + $pieces [ ] = $keyspace[ random_int(0, $max) ]; |
|
70 | 70 | } |
71 | 71 | return implode('', $pieces); |
72 | 72 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct(string $name = null) |
39 | 39 | { |
40 | - if(!is_null($name)) |
|
40 | + if (!is_null($name)) |
|
41 | 41 | $this->setName($name); |
42 | 42 | |
43 | 43 | $this->definition = new InputDefinition(); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | $replacements = array( |
154 | 154 | $name, |
155 | - $_SERVER['PHP_SELF'].' '.$name, |
|
155 | + $_SERVER[ 'PHP_SELF' ].' '.$name, |
|
156 | 156 | ); |
157 | 157 | |
158 | 158 | return str_replace($placeholders, $replacements, $this->getHelp() ?: $this->getDescription()); |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | */ |
171 | 171 | public function setCode(callable $code) |
172 | 172 | { |
173 | - if($code instanceof \Closure) { |
|
173 | + if ($code instanceof \Closure) { |
|
174 | 174 | $r = new \ReflectionFunction($code); |
175 | - if(null === $r->getClosureThis()) { |
|
175 | + if (null === $r->getClosureThis()) { |
|
176 | 176 | $code = \Closure::bind($code, $this); |
177 | 177 | } |
178 | 178 | } |
@@ -338,7 +338,7 @@ discard block |
||
338 | 338 | */ |
339 | 339 | private function validateName($name) |
340 | 340 | { |
341 | - if(!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) |
|
341 | + if (!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) |
|
342 | 342 | throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); |
343 | 343 | } |
344 | 344 | } |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function __construct(string $name = null) |
39 | 39 | { |
40 | - if(!is_null($name)) |
|
41 | - $this->setName($name); |
|
40 | + if(!is_null($name)) { |
|
41 | + $this->setName($name); |
|
42 | + } |
|
42 | 43 | |
43 | 44 | $this->definition = new InputDefinition(); |
44 | 45 | |
@@ -121,8 +122,9 @@ discard block |
||
121 | 122 | } |
122 | 123 | } |
123 | 124 | |
124 | - if ($input->isInteractive()) |
|
125 | - $this->interact($input); |
|
125 | + if ($input->isInteractive()) { |
|
126 | + $this->interact($input); |
|
127 | + } |
|
126 | 128 | |
127 | 129 | $input->validate(); |
128 | 130 | |
@@ -338,7 +340,8 @@ discard block |
||
338 | 340 | */ |
339 | 341 | private function validateName($name) |
340 | 342 | { |
341 | - if(!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) |
|
342 | - throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); |
|
343 | + if(!preg_match('/^[^\:]++(\:[^\:]++)*$/', $name)) { |
|
344 | + throw new \InvalidArgumentException(sprintf('Command name "%s" is invalid.', $name)); |
|
345 | + } |
|
343 | 346 | } |
344 | 347 | } |
@@ -18,8 +18,8 @@ |
||
18 | 18 | class ListCommand extends Command |
19 | 19 | { |
20 | 20 | /** |
21 | - * {@inheritdoc} |
|
22 | - */ |
|
21 | + * {@inheritdoc} |
|
22 | + */ |
|
23 | 23 | protected function configure() |
24 | 24 | { |
25 | 25 | $this |
@@ -36,14 +36,16 @@ |
||
36 | 36 | */ |
37 | 37 | public function __construct($stream, int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = null, OutputFormatterInterface $formatter = null) |
38 | 38 | { |
39 | - if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) |
|
40 | - throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); |
|
39 | + if (!is_resource($stream) || 'stream' !== get_resource_type($stream)) { |
|
40 | + throw new \InvalidArgumentException('The StreamOutput class needs a stream as its first argument.'); |
|
41 | + } |
|
41 | 42 | |
42 | 43 | |
43 | 44 | $this->stream = $stream; |
44 | 45 | |
45 | - if (null === $decorated) |
|
46 | - $decorated = $this->hasColorSupport(); |
|
46 | + if (null === $decorated) { |
|
47 | + $decorated = $this->hasColorSupport(); |
|
48 | + } |
|
47 | 49 | |
48 | 50 | |
49 | 51 | parent::__construct($verbosity, $decorated, $formatter); |
@@ -22,9 +22,9 @@ |
||
22 | 22 | private $formatter; |
23 | 23 | |
24 | 24 | /** |
25 | - * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) |
|
26 | - * @param bool $decorated Whether to decorate messages |
|
27 | - * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) |
|
25 | + * @param int $verbosity The verbosity level (one of the VERBOSITY constants in OutputInterface) |
|
26 | + * @param bool $decorated Whether to decorate messages |
|
27 | + * @param OutputFormatterInterface|null $formatter Output formatter instance (null to use default OutputFormatter) |
|
28 | 28 | */ |
29 | 29 | public function __construct(int $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, OutputFormatterInterface $formatter = null) |
30 | 30 | { |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | $default = ''; |
36 | 36 | } |
37 | 37 | |
38 | - $totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName()); |
|
38 | + $totalWidth = isset($options[ 'total_width' ]) ? $options[ 'total_width' ] : Helper::strlen($argument->getName()); |
|
39 | 39 | $spacingWidth = $totalWidth - strlen($argument->getName()); |
40 | 40 | |
41 | 41 | $this->writeText(sprintf(' <info>%s</info> %s%s%s', |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | } |
68 | 68 | } |
69 | 69 | |
70 | - $totalWidth = isset($options['total_width']) ? $options['total_width'] : $this->calculateTotalWidthForOptions(array($option)); |
|
70 | + $totalWidth = isset($options[ 'total_width' ]) ? $options[ 'total_width' ] : $this->calculateTotalWidthForOptions(array($option)); |
|
71 | 71 | |
72 | 72 | $synopsis = sprintf('%s%s', |
73 | 73 | $option->getShortcut() ? sprintf('-%s, ', $option->getShortcut()) : ' ', |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | foreach ($definition->getOptions() as $option) { |
117 | 117 | if (strlen($option->getShortcut()) > 1) { |
118 | - $laterOptions[] = $option; |
|
118 | + $laterOptions[ ] = $option; |
|
119 | 119 | continue; |
120 | 120 | } |
121 | 121 | |
@@ -178,10 +178,10 @@ discard block |
||
178 | 178 | */ |
179 | 179 | protected function describeApplication(Kernel $kernel, array $options = array()) |
180 | 180 | { |
181 | - $describedNamespace = isset($options['namespace']) ? $options['namespace'] : null; |
|
181 | + $describedNamespace = isset($options[ 'namespace' ]) ? $options[ 'namespace' ] : null; |
|
182 | 182 | $description = new ApplicationDescription($kernel, $describedNamespace); |
183 | 183 | |
184 | - if (isset($options['raw_text']) && $options['raw_text']) { |
|
184 | + if (isset($options[ 'raw_text' ]) && $options[ 'raw_text' ]) { |
|
185 | 185 | $width = $this->getColumnWidth($description->getCommands()); |
186 | 186 | |
187 | 187 | foreach ($description->getCommands() as $command) { |
@@ -205,15 +205,15 @@ discard block |
||
205 | 205 | // make sure all alias commands are included when describing a specific namespace |
206 | 206 | $describedNamespaceInfo = reset($namespaces); |
207 | 207 | |
208 | - foreach ($describedNamespaceInfo['commands'] as $name) { |
|
209 | - $commands[$name] = $description->getCommand($name); |
|
208 | + foreach ($describedNamespaceInfo[ 'commands' ] as $name) { |
|
209 | + $commands[ $name ] = $description->getCommand($name); |
|
210 | 210 | } |
211 | 211 | } |
212 | 212 | |
213 | 213 | // calculate max. width based on available commands per namespace |
214 | 214 | //TODO: somehow this does not work as intended |
215 | - $width = $this->getColumnWidth(call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) { |
|
216 | - return array_intersect($namespace['commands'], array_keys($commands)); |
|
215 | + $width = $this->getColumnWidth(call_user_func_array('array_merge', array_map(function($namespace) use ($commands) { |
|
216 | + return array_intersect($namespace[ 'commands' ], array_keys($commands)); |
|
217 | 217 | }, $namespaces))); |
218 | 218 | |
219 | 219 | if ($describedNamespace) { |
@@ -223,22 +223,22 @@ discard block |
||
223 | 223 | } |
224 | 224 | |
225 | 225 | foreach ($namespaces as $namespace) { |
226 | - $namespace['commands'] = array_filter($namespace['commands'], function ($name) use ($commands) { |
|
227 | - return isset($commands[$name]); |
|
226 | + $namespace[ 'commands' ] = array_filter($namespace[ 'commands' ], function($name) use ($commands) { |
|
227 | + return isset($commands[ $name ]); |
|
228 | 228 | }); |
229 | 229 | |
230 | - if (!$namespace['commands']) |
|
230 | + if (!$namespace[ 'commands' ]) |
|
231 | 231 | continue; |
232 | 232 | |
233 | - if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { |
|
233 | + if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace[ 'id' ]) { |
|
234 | 234 | $this->writeText("\n"); |
235 | - $this->writeText(' <comment>'.$namespace['id'].'</comment>', $options); |
|
235 | + $this->writeText(' <comment>'.$namespace[ 'id' ].'</comment>', $options); |
|
236 | 236 | } |
237 | 237 | |
238 | - foreach ($namespace['commands'] as $name) { |
|
238 | + foreach ($namespace[ 'commands' ] as $name) { |
|
239 | 239 | $this->writeText("\n"); |
240 | 240 | $spacingWidth = $width - Helper::strlen($name); |
241 | - $command = $commands[$name]; |
|
241 | + $command = $commands[ $name ]; |
|
242 | 242 | $commandAliases = $name === $command->getName() ? $this->getCommandAliasesText($command) : ''; |
243 | 243 | $this->writeText(sprintf(' <info>%s</info>%s%s', $name, str_repeat(' ', $spacingWidth), $commandAliases.$command->getDescription()), $options); |
244 | 244 | } |
@@ -254,8 +254,8 @@ discard block |
||
254 | 254 | private function writeText($content, array $options = array()) |
255 | 255 | { |
256 | 256 | $this->write( |
257 | - isset($options['raw_text']) && $options['raw_text'] ? strip_tags($content) : $content, |
|
258 | - isset($options['raw_output']) ? !$options['raw_output'] : true |
|
257 | + isset($options[ 'raw_text' ]) && $options[ 'raw_text' ] ? strip_tags($content) : $content, |
|
258 | + isset($options[ 'raw_output' ]) ? !$options[ 'raw_output' ] : true |
|
259 | 259 | ); |
260 | 260 | } |
261 | 261 | |
@@ -275,7 +275,7 @@ discard block |
||
275 | 275 | } elseif (is_array($default)) { |
276 | 276 | foreach ($default as $key => $value) { |
277 | 277 | if (is_string($value)) { |
278 | - $default[$key] = OutputFormatter::escape($value); |
|
278 | + $default[ $key ] = OutputFormatter::escape($value); |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | } |
@@ -293,13 +293,13 @@ discard block |
||
293 | 293 | |
294 | 294 | foreach ($commands as $command) { |
295 | 295 | if ($command instanceof Command) { |
296 | - $widths[] = Helper::strlen($command->getName()); |
|
296 | + $widths[ ] = Helper::strlen($command->getName()); |
|
297 | 297 | |
298 | 298 | foreach ($command->getAliases() as $alias) { |
299 | - $widths[] = Helper::strlen($alias); |
|
299 | + $widths[ ] = Helper::strlen($alias); |
|
300 | 300 | } |
301 | 301 | } else { |
302 | - $widths[] = Helper::strlen($command); |
|
302 | + $widths[ ] = Helper::strlen($command); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 |
@@ -106,8 +106,9 @@ discard block |
||
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | - if ($definition->getArguments() && $definition->getOptions()) |
|
110 | - $this->writeText("\n"); |
|
109 | + if ($definition->getArguments() && $definition->getOptions()) { |
|
110 | + $this->writeText("\n"); |
|
111 | + } |
|
111 | 112 | |
112 | 113 | if ($definition->getOptions()) { |
113 | 114 | $laterOptions = array(); |
@@ -189,8 +190,9 @@ discard block |
||
189 | 190 | $this->writeText("\n"); |
190 | 191 | } |
191 | 192 | } else { |
192 | - if ('' != $help = $kernel->getHelp()) |
|
193 | - $this->writeText("$help\n\n", $options); |
|
193 | + if ('' != $help = $kernel->getHelp()) { |
|
194 | + $this->writeText("$help\n\n", $options); |
|
195 | + } |
|
194 | 196 | |
195 | 197 | $this->writeText("<comment>Usage:</comment>\n", $options); |
196 | 198 | $this->writeText(" command [options] [arguments]\n\n", $options); |
@@ -227,8 +229,9 @@ discard block |
||
227 | 229 | return isset($commands[$name]); |
228 | 230 | }); |
229 | 231 | |
230 | - if (!$namespace['commands']) |
|
231 | - continue; |
|
232 | + if (!$namespace['commands']) { |
|
233 | + continue; |
|
234 | + } |
|
232 | 235 | |
233 | 236 | if (!$describedNamespace && ApplicationDescription::GLOBAL_NAMESPACE !== $namespace['id']) { |
234 | 237 | $this->writeText("\n"); |
@@ -267,8 +270,9 @@ discard block |
||
267 | 270 | */ |
268 | 271 | private function formatDefaultValue($default): string |
269 | 272 | { |
270 | - if (INF === $default) |
|
271 | - return 'INF'; |
|
273 | + if (INF === $default) { |
|
274 | + return 'INF'; |
|
275 | + } |
|
272 | 276 | |
273 | 277 | if (is_string($default)) { |
274 | 278 | $default = OutputFormatter::escape($default); |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | public function getNamespaces() |
49 | 49 | { |
50 | 50 | //if (null === $this->namespaces) { |
51 | - if ([] === $this->namespaces) { |
|
51 | + if ([ ] === $this->namespaces) { |
|
52 | 52 | $this->inspectApplication(); |
53 | 53 | } |
54 | 54 | |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function getCommand($name) |
78 | 78 | { |
79 | - if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) |
|
79 | + if (!isset($this->commands[ $name ]) && !isset($this->aliases[ $name ])) |
|
80 | 80 | throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); |
81 | 81 | |
82 | - return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; |
|
82 | + return isset($this->commands[ $name ]) ? $this->commands[ $name ] : $this->aliases[ $name ]; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | private function inspectApplication() |
86 | 86 | { |
87 | - $this->commands = []; |
|
88 | - $this->namespaces = []; |
|
87 | + $this->commands = [ ]; |
|
88 | + $this->namespaces = [ ]; |
|
89 | 89 | $all = $this->kernel->all($this->namespace ? $this->kernel->findNamespace($this->namespace) : null); |
90 | 90 | //dd($this->kernel->findNamespace($this->namespace)); |
91 | 91 | |
92 | 92 | foreach ($this->sortCommands($all) as $namespace => $commands) { |
93 | - $names = []; |
|
93 | + $names = [ ]; |
|
94 | 94 | |
95 | 95 | /** @var Command $command */ |
96 | 96 | foreach ($commands as $name => $command) { |
@@ -98,15 +98,15 @@ discard block |
||
98 | 98 | continue; |
99 | 99 | |
100 | 100 | if ($command->getName() === $name) { |
101 | - $this->commands[$name] = $command; |
|
101 | + $this->commands[ $name ] = $command; |
|
102 | 102 | } else { |
103 | - $this->aliases[$name] = $command; |
|
103 | + $this->aliases[ $name ] = $command; |
|
104 | 104 | } |
105 | 105 | |
106 | - $names[] = $name; |
|
106 | + $names[ ] = $name; |
|
107 | 107 | } |
108 | 108 | |
109 | - $this->namespaces[$namespace] = ['id' => $namespace, 'commands' => $names]; |
|
109 | + $this->namespaces[ $namespace ] = [ 'id' => $namespace, 'commands' => $names ]; |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | |
@@ -118,15 +118,15 @@ discard block |
||
118 | 118 | */ |
119 | 119 | private function sortCommands(array $commands): array |
120 | 120 | { |
121 | - $namespacedCommands = []; |
|
122 | - $globalCommands = []; |
|
121 | + $namespacedCommands = [ ]; |
|
122 | + $globalCommands = [ ]; |
|
123 | 123 | |
124 | 124 | foreach ($commands as $name => $command) { |
125 | 125 | $key = $this->kernel->extractNamespace($name, 1); |
126 | 126 | if (!$key) { |
127 | - $globalCommands['_global'][$name] = $command; |
|
127 | + $globalCommands[ '_global' ][ $name ] = $command; |
|
128 | 128 | } else { |
129 | - $namespacedCommands[$key][$name] = $command; |
|
129 | + $namespacedCommands[ $key ][ $name ] = $command; |
|
130 | 130 | } |
131 | 131 | } |
132 | 132 |
@@ -76,8 +76,9 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function getCommand($name) |
78 | 78 | { |
79 | - if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) |
|
80 | - throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); |
|
79 | + if (!isset($this->commands[$name]) && !isset($this->aliases[$name])) { |
|
80 | + throw new CommandNotFoundException(sprintf('Command %s does not exist.', $name)); |
|
81 | + } |
|
81 | 82 | |
82 | 83 | return isset($this->commands[$name]) ? $this->commands[$name] : $this->aliases[$name]; |
83 | 84 | } |
@@ -94,8 +95,9 @@ discard block |
||
94 | 95 | |
95 | 96 | /** @var Command $command */ |
96 | 97 | foreach ($commands as $name => $command) { |
97 | - if (!$command->getName() || (!$this->showHidden && $command->isHidden())) |
|
98 | - continue; |
|
98 | + if (!$command->getName() || (!$this->showHidden && $command->isHidden())) { |
|
99 | + continue; |
|
100 | + } |
|
99 | 101 | |
100 | 102 | if ($command->getName() === $name) { |
101 | 103 | $this->commands[$name] = $command; |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | |
78 | 78 | public function setStyle($name, OutputFormatterStyleInterface $style) |
79 | 79 | { |
80 | - $this->styles[strtolower($name)] = $style; |
|
80 | + $this->styles[ strtolower($name) ] = $style; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | public function hasStyle($name) |
84 | 84 | { |
85 | - return isset($this->styles[strtolower($name)]); |
|
85 | + return isset($this->styles[ strtolower($name) ]); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | public function getStyle($name) |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | throw new \InvalidArgumentException(sprintf('Undefined style: %s', $name)); |
92 | 92 | } |
93 | 93 | |
94 | - return $this->styles[strtolower($name)]; |
|
94 | + return $this->styles[ strtolower($name) ]; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -105,11 +105,11 @@ discard block |
||
105 | 105 | $tagRegex = '[a-z][a-z0-9,_=;-]*+'; |
106 | 106 | preg_match_all("#<(($tagRegex) | /($tagRegex)?)>#ix", $message, $matches, PREG_OFFSET_CAPTURE); |
107 | 107 | |
108 | - foreach ($matches[0] as $i => $match) { |
|
109 | - $pos = $match[1]; |
|
110 | - $text = $match[0]; |
|
108 | + foreach ($matches[ 0 ] as $i => $match) { |
|
109 | + $pos = $match[ 1 ]; |
|
110 | + $text = $match[ 0 ]; |
|
111 | 111 | |
112 | - if (0 != $pos && '\\' == $message[$pos - 1]) |
|
112 | + if (0 != $pos && '\\' == $message[ $pos - 1 ]) |
|
113 | 113 | continue; |
114 | 114 | |
115 | 115 | // add the text up to the next tag |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | $offset = $pos + strlen($text); |
118 | 118 | |
119 | 119 | // opening tag? |
120 | - if ($open = '/' != $text[1]) { |
|
121 | - $tag = $matches[1][$i][0]; |
|
120 | + if ($open = '/' != $text[ 1 ]) { |
|
121 | + $tag = $matches[ 1 ][ $i ][ 0 ]; |
|
122 | 122 | } else { |
123 | - $tag = isset($matches[3][$i][0]) ? $matches[3][$i][0] : ''; |
|
123 | + $tag = isset($matches[ 3 ][ $i ][ 0 ]) ? $matches[ 3 ][ $i ][ 0 ] : ''; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | if (!$open && !$tag) { |
@@ -150,8 +150,8 @@ discard block |
||
150 | 150 | */ |
151 | 151 | private function createStyleFromString(string $string) |
152 | 152 | { |
153 | - if (isset($this->styles[$string])) |
|
154 | - return $this->styles[$string]; |
|
153 | + if (isset($this->styles[ $string ])) |
|
154 | + return $this->styles[ $string ]; |
|
155 | 155 | |
156 | 156 | if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) |
157 | 157 | return false; |
@@ -160,12 +160,12 @@ discard block |
||
160 | 160 | |
161 | 161 | foreach ($matches as $match) { |
162 | 162 | array_shift($match); |
163 | - if ('fg' == $match[0]) { |
|
164 | - $style->setForeground($match[1]); |
|
165 | - } elseif ('bg' == $match[0]) { |
|
166 | - $style->setBackground($match[1]); |
|
167 | - } elseif ('options' === $match[0]) { |
|
168 | - preg_match_all('([^,;]+)', $match[1], $options); |
|
163 | + if ('fg' == $match[ 0 ]) { |
|
164 | + $style->setForeground($match[ 1 ]); |
|
165 | + } elseif ('bg' == $match[ 0 ]) { |
|
166 | + $style->setBackground($match[ 1 ]); |
|
167 | + } elseif ('options' === $match[ 0 ]) { |
|
168 | + preg_match_all('([^,;]+)', $match[ 1 ], $options); |
|
169 | 169 | $options = array_shift($options); |
170 | 170 | foreach ($options as $option) { |
171 | 171 | $style->setOption($option); |
@@ -109,8 +109,9 @@ discard block |
||
109 | 109 | $pos = $match[1]; |
110 | 110 | $text = $match[0]; |
111 | 111 | |
112 | - if (0 != $pos && '\\' == $message[$pos - 1]) |
|
113 | - continue; |
|
112 | + if (0 != $pos && '\\' == $message[$pos - 1]) { |
|
113 | + continue; |
|
114 | + } |
|
114 | 115 | |
115 | 116 | // add the text up to the next tag |
116 | 117 | $output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset)); |
@@ -137,8 +138,9 @@ discard block |
||
137 | 138 | |
138 | 139 | $output .= $this->applyCurrentStyle(substr($message, $offset)); |
139 | 140 | |
140 | - if (false !== strpos($output, "\0")) |
|
141 | - return strtr($output, array("\0" => '\\', '\\<' => '<')); |
|
141 | + if (false !== strpos($output, "\0")) { |
|
142 | + return strtr($output, array("\0" => '\\', '\\<' => '<')); |
|
143 | + } |
|
142 | 144 | |
143 | 145 | return str_replace('\\<', '<', $output); |
144 | 146 | } |
@@ -150,11 +152,13 @@ discard block |
||
150 | 152 | */ |
151 | 153 | private function createStyleFromString(string $string) |
152 | 154 | { |
153 | - if (isset($this->styles[$string])) |
|
154 | - return $this->styles[$string]; |
|
155 | + if (isset($this->styles[$string])) { |
|
156 | + return $this->styles[$string]; |
|
157 | + } |
|
155 | 158 | |
156 | - if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) |
|
157 | - return false; |
|
159 | + if (!preg_match_all('/([^=]+)=([^;]+)(;|$)/', $string, $matches, PREG_SET_ORDER)) { |
|
160 | + return false; |
|
161 | + } |
|
158 | 162 | |
159 | 163 | $style = new OutputFormatterStyle(); |
160 | 164 |