@@ -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 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | public function push(OutputFormatterStyleInterface $style) |
38 | 38 | { |
39 | - $this->styles[] = $style; |
|
39 | + $this->styles[ ] = $style; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if (empty($this->styles)) { |
74 | 74 | return $this->emptyStyle; |
75 | 75 | } |
76 | - return $this->styles[count($this->styles) - 1]; |
|
76 | + return $this->styles[ count($this->styles) - 1 ]; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -16,40 +16,40 @@ discard block |
||
16 | 16 | class OutputFormatterStyle implements OutputFormatterStyleInterface |
17 | 17 | { |
18 | 18 | private static $availableForegroundColors = [ |
19 | - 'black' => ['set' => 30, 'unset' => 39], |
|
20 | - 'red' => ['set' => 31, 'unset' => 39], |
|
21 | - 'green' => ['set' => 32, 'unset' => 39], |
|
22 | - 'yellow' => ['set' => 33, 'unset' => 39], |
|
23 | - 'blue' => ['set' => 34, 'unset' => 39], |
|
24 | - 'magenta' => ['set' => 35, 'unset' => 39], |
|
25 | - 'cyan' => ['set' => 36, 'unset' => 39], |
|
26 | - 'white' => ['set' => 37, 'unset' => 39], |
|
27 | - 'default' => ['set' => 39, 'unset' => 39] |
|
19 | + 'black' => [ 'set' => 30, 'unset' => 39 ], |
|
20 | + 'red' => [ 'set' => 31, 'unset' => 39 ], |
|
21 | + 'green' => [ 'set' => 32, 'unset' => 39 ], |
|
22 | + 'yellow' => [ 'set' => 33, 'unset' => 39 ], |
|
23 | + 'blue' => [ 'set' => 34, 'unset' => 39 ], |
|
24 | + 'magenta' => [ 'set' => 35, 'unset' => 39 ], |
|
25 | + 'cyan' => [ 'set' => 36, 'unset' => 39 ], |
|
26 | + 'white' => [ 'set' => 37, 'unset' => 39 ], |
|
27 | + 'default' => [ 'set' => 39, 'unset' => 39 ] |
|
28 | 28 | ]; |
29 | 29 | |
30 | 30 | private static $availableBackgroundColors = [ |
31 | - 'black' => ['set' => 40, 'unset' => 49], |
|
32 | - 'red' => ['set' => 41, 'unset' => 49], |
|
33 | - 'green' => ['set' => 42, 'unset' => 49], |
|
34 | - 'yellow' => ['set' => 43, 'unset' => 49], |
|
35 | - 'blue' => ['set' => 44, 'unset' => 49], |
|
36 | - 'magenta' => ['set' => 45, 'unset' => 49], |
|
37 | - 'cyan' => ['set' => 46, 'unset' => 49], |
|
38 | - 'white' => ['set' => 47, 'unset' => 49], |
|
39 | - 'default' => ['set' => 49, 'unset' => 49] |
|
31 | + 'black' => [ 'set' => 40, 'unset' => 49 ], |
|
32 | + 'red' => [ 'set' => 41, 'unset' => 49 ], |
|
33 | + 'green' => [ 'set' => 42, 'unset' => 49 ], |
|
34 | + 'yellow' => [ 'set' => 43, 'unset' => 49 ], |
|
35 | + 'blue' => [ 'set' => 44, 'unset' => 49 ], |
|
36 | + 'magenta' => [ 'set' => 45, 'unset' => 49 ], |
|
37 | + 'cyan' => [ 'set' => 46, 'unset' => 49 ], |
|
38 | + 'white' => [ 'set' => 47, 'unset' => 49 ], |
|
39 | + 'default' => [ 'set' => 49, 'unset' => 49 ] |
|
40 | 40 | ]; |
41 | 41 | |
42 | 42 | private static $availableOptions = [ |
43 | - 'bold' => ['set' => 1, 'unset' => 22], |
|
44 | - 'underscore' => ['set' => 4, 'unset' => 24], |
|
45 | - 'blink' => ['set' => 5, 'unset' => 25], |
|
46 | - 'reverse' => ['set' => 7, 'unset' => 27], |
|
47 | - 'conceal' => ['set' => 8, 'unset' => 28] |
|
43 | + 'bold' => [ 'set' => 1, 'unset' => 22 ], |
|
44 | + 'underscore' => [ 'set' => 4, 'unset' => 24 ], |
|
45 | + 'blink' => [ 'set' => 5, 'unset' => 25 ], |
|
46 | + 'reverse' => [ 'set' => 7, 'unset' => 27 ], |
|
47 | + 'conceal' => [ 'set' => 8, 'unset' => 28 ] |
|
48 | 48 | ]; |
49 | 49 | |
50 | 50 | private $foreground; |
51 | 51 | private $background; |
52 | - private $options = []; |
|
52 | + private $options = [ ]; |
|
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Initializes output formatter style. |
@@ -83,14 +83,14 @@ discard block |
||
83 | 83 | $this->foreground = null; |
84 | 84 | return; |
85 | 85 | } |
86 | - if (!isset(static::$availableForegroundColors[$color])) { |
|
86 | + if (!isset(static::$availableForegroundColors[ $color ])) { |
|
87 | 87 | throw new \InvalidArgumentException(sprintf( |
88 | 88 | 'Invalid foreground color specified: "%s". Expected one of (%s)', |
89 | 89 | $color, |
90 | 90 | implode(', ', array_keys(static::$availableForegroundColors)) |
91 | 91 | )); |
92 | 92 | } |
93 | - $this->foreground = static::$availableForegroundColors[$color]; |
|
93 | + $this->foreground = static::$availableForegroundColors[ $color ]; |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -106,14 +106,14 @@ discard block |
||
106 | 106 | $this->background = null; |
107 | 107 | return; |
108 | 108 | } |
109 | - if (!isset(static::$availableBackgroundColors[$color])) { |
|
109 | + if (!isset(static::$availableBackgroundColors[ $color ])) { |
|
110 | 110 | throw new \InvalidArgumentException(sprintf( |
111 | 111 | 'Invalid background color specified: "%s". Expected one of (%s)', |
112 | 112 | $color, |
113 | 113 | implode(', ', array_keys(static::$availableBackgroundColors)) |
114 | 114 | )); |
115 | 115 | } |
116 | - $this->background = static::$availableBackgroundColors[$color]; |
|
116 | + $this->background = static::$availableBackgroundColors[ $color ]; |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function setOption($option) |
127 | 127 | { |
128 | - if (!isset(static::$availableOptions[$option])) { |
|
128 | + if (!isset(static::$availableOptions[ $option ])) { |
|
129 | 129 | throw new \InvalidArgumentException(sprintf( |
130 | 130 | 'Invalid option specified: "%s". Expected one of (%s)', |
131 | 131 | $option, |
132 | 132 | implode(', ', array_keys(static::$availableOptions)) |
133 | 133 | )); |
134 | 134 | } |
135 | - if (!in_array(static::$availableOptions[$option], $this->options)) { |
|
136 | - $this->options[] = static::$availableOptions[$option]; |
|
135 | + if (!in_array(static::$availableOptions[ $option ], $this->options)) { |
|
136 | + $this->options[ ] = static::$availableOptions[ $option ]; |
|
137 | 137 | } |
138 | 138 | } |
139 | 139 | |
@@ -146,16 +146,16 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function unsetOption($option) |
148 | 148 | { |
149 | - if (!isset(static::$availableOptions[$option])) { |
|
149 | + if (!isset(static::$availableOptions[ $option ])) { |
|
150 | 150 | throw new \InvalidArgumentException(sprintf( |
151 | 151 | 'Invalid option specified: "%s". Expected one of (%s)', |
152 | 152 | $option, |
153 | 153 | implode(', ', array_keys(static::$availableOptions)) |
154 | 154 | )); |
155 | 155 | } |
156 | - $pos = array_search(static::$availableOptions[$option], $this->options); |
|
156 | + $pos = array_search(static::$availableOptions[ $option ], $this->options); |
|
157 | 157 | if (false !== $pos) { |
158 | - unset($this->options[$pos]); |
|
158 | + unset($this->options[ $pos ]); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
@@ -183,19 +183,19 @@ discard block |
||
183 | 183 | $unsetCodes = array(); |
184 | 184 | |
185 | 185 | if (null !== $this->foreground) { |
186 | - $setCodes[] = $this->foreground['set']; |
|
187 | - $unsetCodes[] = $this->foreground['unset']; |
|
186 | + $setCodes[ ] = $this->foreground[ 'set' ]; |
|
187 | + $unsetCodes[ ] = $this->foreground[ 'unset' ]; |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | if (null !== $this->background) { |
191 | - $setCodes[] = $this->background['set']; |
|
192 | - $unsetCodes[] = $this->background['unset']; |
|
191 | + $setCodes[ ] = $this->background[ 'set' ]; |
|
192 | + $unsetCodes[ ] = $this->background[ 'unset' ]; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | if (count($this->options)) { |
196 | 196 | foreach ($this->options as $option) { |
197 | - $setCodes[] = $option['set']; |
|
198 | - $unsetCodes[] = $option['unset']; |
|
197 | + $setCodes[ ] = $option[ 'set' ]; |
|
198 | + $unsetCodes[ ] = $option[ 'unset' ]; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 |
@@ -60,14 +60,17 @@ discard block |
||
60 | 60 | */ |
61 | 61 | public function __construct(string $foreground = null, string $background = null, array $options = array()) |
62 | 62 | { |
63 | - if (null !== $foreground) |
|
64 | - $this->setForeground($foreground); |
|
63 | + if (null !== $foreground) { |
|
64 | + $this->setForeground($foreground); |
|
65 | + } |
|
65 | 66 | |
66 | - if (null !== $background) |
|
67 | - $this->setBackground($background); |
|
67 | + if (null !== $background) { |
|
68 | + $this->setBackground($background); |
|
69 | + } |
|
68 | 70 | |
69 | - if (count($options)) |
|
70 | - $this->setOptions($options); |
|
71 | + if (count($options)) { |
|
72 | + $this->setOptions($options); |
|
73 | + } |
|
71 | 74 | } |
72 | 75 | |
73 | 76 | /** |
@@ -199,8 +202,9 @@ discard block |
||
199 | 202 | } |
200 | 203 | } |
201 | 204 | |
202 | - if (0 === count($setCodes)) |
|
203 | - return $text; |
|
205 | + if (0 === count($setCodes)) { |
|
206 | + return $text; |
|
207 | + } |
|
204 | 208 | |
205 | 209 | return sprintf("\033[%sm%s\033[%sm", implode(';', $setCodes), $text, implode(';', $unsetCodes)); |
206 | 210 | } |
@@ -41,8 +41,9 @@ |
||
41 | 41 | $actualDecorated = $this->isDecorated(); |
42 | 42 | $this->stderr = new StreamOutput($this->openErrorStream(), $verbosity, $decorated, $this->getFormatter()); |
43 | 43 | |
44 | - if ($decorated === null) |
|
45 | - $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); |
|
44 | + if ($decorated === null) { |
|
45 | + $this->setDecorated($actualDecorated && $this->stderr->isDecorated()); |
|
46 | + } |
|
46 | 47 | } |
47 | 48 | |
48 | 49 | /** |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | |
80 | 80 | foreach (explode(PHP_EOL, $message) as $lineContent) { |
81 | 81 | $this->lines += ceil($this->getDisplayLength($lineContent) / $this->terminal->getWidth()) ?: 1; |
82 | - $this->content[] = $lineContent; |
|
83 | - $this->content[] = PHP_EOL; |
|
82 | + $this->content[ ] = $lineContent; |
|
83 | + $this->content[ ] = PHP_EOL; |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | parent::doWrite($message, true); |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | break; |
102 | 102 | |
103 | 103 | $numberOfLinesToClear += $section->lines; |
104 | - $erasedContent[] = $section->getContent(); |
|
104 | + $erasedContent[ ] = $section->getContent(); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | if ($numberOfLinesToClear > 0) { |
@@ -37,8 +37,9 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function clear(int $lines = null) |
39 | 39 | { |
40 | - if (empty($this->content) || !$this->isDecorated()) |
|
41 | - return; |
|
40 | + if (empty($this->content) || !$this->isDecorated()) { |
|
41 | + return; |
|
42 | + } |
|
42 | 43 | |
43 | 44 | if ($lines) { |
44 | 45 | \array_splice($this->content, -($lines * 2)); // Multiply lines by 2 to cater for each new line added between content |
@@ -72,8 +73,9 @@ discard block |
||
72 | 73 | */ |
73 | 74 | protected function doWrite($message, $newline) |
74 | 75 | { |
75 | - if (!$this->isDecorated()) |
|
76 | - return parent::doWrite($message, $newline); |
|
76 | + if (!$this->isDecorated()) { |
|
77 | + return parent::doWrite($message, $newline); |
|
78 | + } |
|
77 | 79 | |
78 | 80 | $erasedContent = $this->popStreamContentUntilCurrentSection(); |
79 | 81 | |
@@ -97,8 +99,9 @@ discard block |
||
97 | 99 | $erasedContent = array(); |
98 | 100 | |
99 | 101 | foreach ($this->sections as $section) { |
100 | - if ($section === $this) |
|
101 | - break; |
|
102 | + if ($section === $this) { |
|
103 | + break; |
|
104 | + } |
|
102 | 105 | |
103 | 106 | $numberOfLinesToClear += $section->lines; |
104 | 107 | $erasedContent[] = $section->getContent(); |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | 'format' => 'txt', |
45 | 45 | ), $options); |
46 | 46 | |
47 | - if (!isset($this->descriptors[$options['format']])) |
|
48 | - throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); |
|
47 | + if (!isset($this->descriptors[ $options[ 'format' ] ])) |
|
48 | + throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options[ 'format' ])); |
|
49 | 49 | |
50 | - $descriptor = $this->descriptors[$options['format']]; |
|
50 | + $descriptor = $this->descriptors[ $options[ 'format' ] ]; |
|
51 | 51 | $descriptor->describe($output, $object, $options); |
52 | 52 | } |
53 | 53 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function register($format, DescriptorInterface $descriptor) |
63 | 63 | { |
64 | - $this->descriptors[$format] = $descriptor; |
|
64 | + $this->descriptors[ $format ] = $descriptor; |
|
65 | 65 | |
66 | 66 | return $this; |
67 | 67 | } |
@@ -44,8 +44,9 @@ |
||
44 | 44 | 'format' => 'txt', |
45 | 45 | ), $options); |
46 | 46 | |
47 | - if (!isset($this->descriptors[$options['format']])) |
|
48 | - throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); |
|
47 | + if (!isset($this->descriptors[$options['format']])) { |
|
48 | + throw new \InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); |
|
49 | + } |
|
49 | 50 | |
50 | 51 | $descriptor = $this->descriptors[$options['format']]; |
51 | 52 | $descriptor->describe($output, $object, $options); |
@@ -60,14 +60,14 @@ |
||
60 | 60 | ]; |
61 | 61 | |
62 | 62 | foreach ($timeFormats as $index => $format) { |
63 | - if ($secs >= $format[0]) { |
|
64 | - if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0]) |
|
63 | + if ($secs >= $format[ 0 ]) { |
|
64 | + if ((isset($timeFormats[ $index + 1 ]) && $secs < $timeFormats[ $index + 1 ][ 0 ]) |
|
65 | 65 | || $index == count($timeFormats) - 1 |
66 | 66 | ) { |
67 | 67 | if (2 == count($format)) |
68 | - return $format[1]; |
|
68 | + return $format[ 1 ]; |
|
69 | 69 | |
70 | - return floor($secs / $format[2]).' '.$format[1]; |
|
70 | + return floor($secs / $format[ 2 ]).' '.$format[ 1 ]; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
@@ -22,8 +22,9 @@ discard block |
||
22 | 22 | public static function strlen($string) |
23 | 23 | { |
24 | 24 | |
25 | - if (false === $encoding = mb_detect_encoding($string, null, true)) |
|
26 | - return strlen($string); |
|
25 | + if (false === $encoding = mb_detect_encoding($string, null, true)) { |
|
26 | + return strlen($string); |
|
27 | + } |
|
27 | 28 | |
28 | 29 | return mb_strwidth($string, $encoding); |
29 | 30 | } |
@@ -39,8 +40,9 @@ discard block |
||
39 | 40 | */ |
40 | 41 | public static function substr($string, $from, $length = null) |
41 | 42 | { |
42 | - if ($encoding = mb_detect_encoding($string, null, true) === false) |
|
43 | - return substr($string, $from, $length); |
|
43 | + if ($encoding = mb_detect_encoding($string, null, true) === false) { |
|
44 | + return substr($string, $from, $length); |
|
45 | + } |
|
44 | 46 | |
45 | 47 | return mb_substr($string, $from, $length, $encoding); |
46 | 48 | } |
@@ -64,8 +66,9 @@ discard block |
||
64 | 66 | if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0]) |
65 | 67 | || $index == count($timeFormats) - 1 |
66 | 68 | ) { |
67 | - if (2 == count($format)) |
|
68 | - return $format[1]; |
|
69 | + if (2 == count($format)) { |
|
70 | + return $format[1]; |
|
71 | + } |
|
69 | 72 | |
70 | 73 | return floor($secs / $format[2]).' '.$format[1]; |
71 | 74 | } |
@@ -75,14 +78,17 @@ discard block |
||
75 | 78 | |
76 | 79 | public static function formatMemory($memory) |
77 | 80 | { |
78 | - if ($memory >= 1024 * 1024 * 1024) |
|
79 | - return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024); |
|
81 | + if ($memory >= 1024 * 1024 * 1024) { |
|
82 | + return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024); |
|
83 | + } |
|
80 | 84 | |
81 | - if ($memory >= 1024 * 1024) |
|
82 | - return sprintf('%.1f MiB', $memory / 1024 / 1024); |
|
85 | + if ($memory >= 1024 * 1024) { |
|
86 | + return sprintf('%.1f MiB', $memory / 1024 / 1024); |
|
87 | + } |
|
83 | 88 | |
84 | - if ($memory >= 1024) |
|
85 | - return sprintf('%d KiB', $memory / 1024); |
|
89 | + if ($memory >= 1024) { |
|
90 | + return sprintf('%d KiB', $memory / 1024); |
|
91 | + } |
|
86 | 92 | |
87 | 93 | return sprintf('%d B', $memory); |
88 | 94 | } |