@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $exceptions = [$exception]; |
| 67 | 67 | $currentE = $exception; |
| 68 | 68 | |
| 69 | - while ($exception = $exception->getPrevious()) { |
|
| 69 | + while ($exception = $exception->getPrevious()){ |
|
| 70 | 70 | $exceptions[] = $exception; |
| 71 | 71 | } |
| 72 | 72 | |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $result = []; |
| 76 | 76 | $rootDir = \getcwd(); |
| 77 | 77 | |
| 78 | - foreach ($exceptions as $exception) { |
|
| 78 | + foreach ($exceptions as $exception){ |
|
| 79 | 79 | $prefix = $currentE === $exception ? '' : 'Previous: '; |
| 80 | 80 | $row = $this->renderHeader( |
| 81 | 81 | \sprintf("%s[%s]\n%s", $prefix, $exception::class, $exception->getMessage()), |
@@ -92,14 +92,14 @@ discard block |
||
| 92 | 92 | $exception->getLine(), |
| 93 | 93 | ); |
| 94 | 94 | |
| 95 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
| 95 | + if ($verbosity->value >= Verbosity::DEBUG->value){ |
|
| 96 | 96 | $row .= $this->renderTrace( |
| 97 | 97 | $exception, |
| 98 | 98 | new Highlighter( |
| 99 | 99 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle(), |
| 100 | 100 | ), |
| 101 | 101 | ); |
| 102 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
| 102 | + } elseif ($verbosity->value >= Verbosity::VERBOSE->value){ |
|
| 103 | 103 | $row .= $this->renderTrace($exception); |
| 104 | 104 | } |
| 105 | 105 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | |
| 131 | 131 | $length += $padding; |
| 132 | 132 | |
| 133 | - foreach ($lines as $line) { |
|
| 133 | + foreach ($lines as $line){ |
|
| 134 | 134 | $result .= $this->format( |
| 135 | 135 | "<{$style}>%s%s%s</reset>\n", |
| 136 | 136 | \str_repeat('', $padding + 1), |
@@ -148,39 +148,39 @@ discard block |
||
| 148 | 148 | private function renderTrace(\Throwable $e, ?Highlighter $h = null): string |
| 149 | 149 | { |
| 150 | 150 | $stacktrace = $this->getStacktrace($e); |
| 151 | - if (empty($stacktrace)) { |
|
| 151 | + if (empty($stacktrace)){ |
|
| 152 | 152 | return ''; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | $result = "\n"; |
| 156 | 156 | $rootDir = \getcwd(); |
| 157 | 157 | |
| 158 | - $pad = \strlen((string) \count($stacktrace)); |
|
| 158 | + $pad = \strlen((string)\count($stacktrace)); |
|
| 159 | 159 | |
| 160 | - foreach ($stacktrace as $i => $trace) { |
|
| 161 | - $file = isset($trace['file']) ? (string) $trace['file'] : null; |
|
| 160 | + foreach ($stacktrace as $i => $trace){ |
|
| 161 | + $file = isset($trace['file']) ? (string)$trace['file'] : null; |
|
| 162 | 162 | $classColor = 'while'; |
| 163 | 163 | |
| 164 | - if ($file !== null) { |
|
| 164 | + if ($file !== null){ |
|
| 165 | 165 | \str_starts_with($file, $rootDir) and $file = \substr($file, \strlen($rootDir) + 1); |
| 166 | 166 | $classColor = \str_starts_with($file, 'vendor/') ? 'gray' : 'white'; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - if (isset($trace['type'], $trace['class'])) { |
|
| 169 | + if (isset($trace['type'], $trace['class'])){ |
|
| 170 | 170 | $line = $this->format( |
| 171 | 171 | "<$classColor>%s.</reset> <white>%s%s%s()</reset>", |
| 172 | - \str_pad((string) ((int) $i + 1), $pad, ' ', \STR_PAD_LEFT), |
|
| 172 | + \str_pad((string)((int)$i + 1), $pad, ' ', \STR_PAD_LEFT), |
|
| 173 | 173 | $trace['class'], |
| 174 | 174 | $trace['type'], |
| 175 | 175 | $trace['function'], |
| 176 | 176 | ); |
| 177 | - } else { |
|
| 177 | + }else{ |
|
| 178 | 178 | $line = $this->format( |
| 179 | 179 | ' <white>%s()</reset>', |
| 180 | 180 | $trace['function'], |
| 181 | 181 | ); |
| 182 | 182 | } |
| 183 | - if ($file !== null) { |
|
| 183 | + if ($file !== null){ |
|
| 184 | 184 | $line .= $this->format( |
| 185 | 185 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
| 186 | 186 | $file, |
@@ -188,21 +188,21 @@ discard block |
||
| 188 | 188 | ); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - if (\in_array($line, $this->lines, true)) { |
|
| 191 | + if (\in_array($line, $this->lines, true)){ |
|
| 192 | 192 | continue; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | $this->lines[] = $line; |
| 196 | 196 | |
| 197 | - $result .= $line . "\n"; |
|
| 197 | + $result .= $line."\n"; |
|
| 198 | 198 | |
| 199 | - if ($h !== null && !empty($trace['file'])) { |
|
| 199 | + if ($h !== null && !empty($trace['file'])){ |
|
| 200 | 200 | $str = @\file_get_contents($trace['file']); |
| 201 | 201 | $result .= $h->highlightLines( |
| 202 | 202 | $str, |
| 203 | 203 | $trace['line'], |
| 204 | 204 | static::SHOW_LINES, |
| 205 | - ) . "\n"; |
|
| 205 | + )."\n"; |
|
| 206 | 206 | unset($str); |
| 207 | 207 | } |
| 208 | 208 | } |
@@ -215,13 +215,13 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | private function format(string $format, mixed ...$args): string |
| 217 | 217 | { |
| 218 | - if (!$this->colorsSupport) { |
|
| 218 | + if (!$this->colorsSupport){ |
|
| 219 | 219 | $format = \preg_replace('/<[^>]+>/', '', $format); |
| 220 | - } else { |
|
| 221 | - $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) { |
|
| 220 | + }else{ |
|
| 221 | + $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial){ |
|
| 222 | 222 | $style = ''; |
| 223 | - foreach (\explode(',', \trim($partial[2], '/')) as $color) { |
|
| 224 | - if (isset(self::COLORS[$color])) { |
|
| 223 | + foreach (\explode(',', \trim($partial[2], '/')) as $color){ |
|
| 224 | + if (isset(self::COLORS[$color])){ |
|
| 225 | 225 | $style .= self::COLORS[$color]; |
| 226 | 226 | } |
| 227 | 227 | } |
@@ -240,12 +240,12 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | private function isColorsSupported(mixed $stream = STDOUT): bool |
| 242 | 242 | { |
| 243 | - if (\getenv('TERM_PROGRAM') === 'Hyper') { |
|
| 243 | + if (\getenv('TERM_PROGRAM') === 'Hyper'){ |
|
| 244 | 244 | return true; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - try { |
|
| 248 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
| 247 | + try{ |
|
| 248 | + if (\DIRECTORY_SEPARATOR === '\\'){ |
|
| 249 | 249 | return (\function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($stream)) |
| 250 | 250 | || \getenv('ANSICON') !== false |
| 251 | 251 | || \getenv('ConEmuANSI') === 'ON' |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | } |
| 254 | 254 | |
| 255 | 255 | return @\stream_isatty($stream); |
| 256 | - } catch (\Throwable) { |
|
| 256 | + }catch (\Throwable){ |
|
| 257 | 257 | return false; |
| 258 | 258 | } |
| 259 | 259 | } |
@@ -66,7 +66,8 @@ discard block |
||
| 66 | 66 | $exceptions = [$exception]; |
| 67 | 67 | $currentE = $exception; |
| 68 | 68 | |
| 69 | - while ($exception = $exception->getPrevious()) { |
|
| 69 | + while ($exception = $exception->getPrevious()) |
|
| 70 | + { |
|
| 70 | 71 | $exceptions[] = $exception; |
| 71 | 72 | } |
| 72 | 73 | |
@@ -75,7 +76,8 @@ discard block |
||
| 75 | 76 | $result = []; |
| 76 | 77 | $rootDir = \getcwd(); |
| 77 | 78 | |
| 78 | - foreach ($exceptions as $exception) { |
|
| 79 | + foreach ($exceptions as $exception) |
|
| 80 | + { |
|
| 79 | 81 | $prefix = $currentE === $exception ? '' : 'Previous: '; |
| 80 | 82 | $row = $this->renderHeader( |
| 81 | 83 | \sprintf("%s[%s]\n%s", $prefix, $exception::class, $exception->getMessage()), |
@@ -92,14 +94,17 @@ discard block |
||
| 92 | 94 | $exception->getLine(), |
| 93 | 95 | ); |
| 94 | 96 | |
| 95 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
| 97 | + if ($verbosity->value >= Verbosity::DEBUG->value) |
|
| 98 | + { |
|
| 96 | 99 | $row .= $this->renderTrace( |
| 97 | 100 | $exception, |
| 98 | 101 | new Highlighter( |
| 99 | 102 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle(), |
| 100 | 103 | ), |
| 101 | 104 | ); |
| 102 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
| 105 | + } |
|
| 106 | + elseif ($verbosity->value >= Verbosity::VERBOSE->value) |
|
| 107 | + { |
|
| 103 | 108 | $row .= $this->renderTrace($exception); |
| 104 | 109 | } |
| 105 | 110 | |
@@ -130,7 +135,8 @@ discard block |
||
| 130 | 135 | |
| 131 | 136 | $length += $padding; |
| 132 | 137 | |
| 133 | - foreach ($lines as $line) { |
|
| 138 | + foreach ($lines as $line) |
|
| 139 | + { |
|
| 134 | 140 | $result .= $this->format( |
| 135 | 141 | "<{$style}>%s%s%s</reset>\n", |
| 136 | 142 | \str_repeat('', $padding + 1), |
@@ -148,7 +154,8 @@ discard block |
||
| 148 | 154 | private function renderTrace(\Throwable $e, ?Highlighter $h = null): string |
| 149 | 155 | { |
| 150 | 156 | $stacktrace = $this->getStacktrace($e); |
| 151 | - if (empty($stacktrace)) { |
|
| 157 | + if (empty($stacktrace)) |
|
| 158 | + { |
|
| 152 | 159 | return ''; |
| 153 | 160 | } |
| 154 | 161 | |
@@ -157,16 +164,19 @@ discard block |
||
| 157 | 164 | |
| 158 | 165 | $pad = \strlen((string) \count($stacktrace)); |
| 159 | 166 | |
| 160 | - foreach ($stacktrace as $i => $trace) { |
|
| 167 | + foreach ($stacktrace as $i => $trace) |
|
| 168 | + { |
|
| 161 | 169 | $file = isset($trace['file']) ? (string) $trace['file'] : null; |
| 162 | 170 | $classColor = 'while'; |
| 163 | 171 | |
| 164 | - if ($file !== null) { |
|
| 172 | + if ($file !== null) |
|
| 173 | + { |
|
| 165 | 174 | \str_starts_with($file, $rootDir) and $file = \substr($file, \strlen($rootDir) + 1); |
| 166 | 175 | $classColor = \str_starts_with($file, 'vendor/') ? 'gray' : 'white'; |
| 167 | 176 | } |
| 168 | 177 | |
| 169 | - if (isset($trace['type'], $trace['class'])) { |
|
| 178 | + if (isset($trace['type'], $trace['class'])) |
|
| 179 | + { |
|
| 170 | 180 | $line = $this->format( |
| 171 | 181 | "<$classColor>%s.</reset> <white>%s%s%s()</reset>", |
| 172 | 182 | \str_pad((string) ((int) $i + 1), $pad, ' ', \STR_PAD_LEFT), |
@@ -174,13 +184,16 @@ discard block |
||
| 174 | 184 | $trace['type'], |
| 175 | 185 | $trace['function'], |
| 176 | 186 | ); |
| 177 | - } else { |
|
| 187 | + } |
|
| 188 | + else |
|
| 189 | + { |
|
| 178 | 190 | $line = $this->format( |
| 179 | 191 | ' <white>%s()</reset>', |
| 180 | 192 | $trace['function'], |
| 181 | 193 | ); |
| 182 | 194 | } |
| 183 | - if ($file !== null) { |
|
| 195 | + if ($file !== null) |
|
| 196 | + { |
|
| 184 | 197 | $line .= $this->format( |
| 185 | 198 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
| 186 | 199 | $file, |
@@ -188,7 +201,8 @@ discard block |
||
| 188 | 201 | ); |
| 189 | 202 | } |
| 190 | 203 | |
| 191 | - if (\in_array($line, $this->lines, true)) { |
|
| 204 | + if (\in_array($line, $this->lines, true)) |
|
| 205 | + { |
|
| 192 | 206 | continue; |
| 193 | 207 | } |
| 194 | 208 | |
@@ -196,7 +210,8 @@ discard block |
||
| 196 | 210 | |
| 197 | 211 | $result .= $line . "\n"; |
| 198 | 212 | |
| 199 | - if ($h !== null && !empty($trace['file'])) { |
|
| 213 | + if ($h !== null && !empty($trace['file'])) |
|
| 214 | + { |
|
| 200 | 215 | $str = @\file_get_contents($trace['file']); |
| 201 | 216 | $result .= $h->highlightLines( |
| 202 | 217 | $str, |
@@ -215,13 +230,19 @@ discard block |
||
| 215 | 230 | */ |
| 216 | 231 | private function format(string $format, mixed ...$args): string |
| 217 | 232 | { |
| 218 | - if (!$this->colorsSupport) { |
|
| 233 | + if (!$this->colorsSupport) |
|
| 234 | + { |
|
| 219 | 235 | $format = \preg_replace('/<[^>]+>/', '', $format); |
| 220 | - } else { |
|
| 221 | - $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) { |
|
| 236 | + } |
|
| 237 | + else |
|
| 238 | + { |
|
| 239 | + $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) |
|
| 240 | + { |
|
| 222 | 241 | $style = ''; |
| 223 | - foreach (\explode(',', \trim($partial[2], '/')) as $color) { |
|
| 224 | - if (isset(self::COLORS[$color])) { |
|
| 242 | + foreach (\explode(',', \trim($partial[2], '/')) as $color) |
|
| 243 | + { |
|
| 244 | + if (isset(self::COLORS[$color])) |
|
| 245 | + { |
|
| 225 | 246 | $style .= self::COLORS[$color]; |
| 226 | 247 | } |
| 227 | 248 | } |
@@ -240,12 +261,15 @@ discard block |
||
| 240 | 261 | */ |
| 241 | 262 | private function isColorsSupported(mixed $stream = STDOUT): bool |
| 242 | 263 | { |
| 243 | - if (\getenv('TERM_PROGRAM') === 'Hyper') { |
|
| 264 | + if (\getenv('TERM_PROGRAM') === 'Hyper') |
|
| 265 | + { |
|
| 244 | 266 | return true; |
| 245 | 267 | } |
| 246 | 268 | |
| 247 | - try { |
|
| 248 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
| 269 | + try |
|
| 270 | + { |
|
| 271 | + if (\DIRECTORY_SEPARATOR === '\\') |
|
| 272 | + { |
|
| 249 | 273 | return (\function_exists('sapi_windows_vt100_support') && @sapi_windows_vt100_support($stream)) |
| 250 | 274 | || \getenv('ANSICON') !== false |
| 251 | 275 | || \getenv('ConEmuANSI') === 'ON' |
@@ -253,7 +277,9 @@ discard block |
||
| 253 | 277 | } |
| 254 | 278 | |
| 255 | 279 | return @\stream_isatty($stream); |
| 256 | - } catch (\Throwable) { |
|
| 280 | + } |
|
| 281 | + catch (\Throwable) |
|
| 282 | + { |
|
| 257 | 283 | return false; |
| 258 | 284 | } |
| 259 | 285 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | #[Proxy] private readonly ContainerInterface $container = new Container(), |
| 39 | 39 | private readonly ScopeInterface $scope = new Container(), |
| 40 | 40 | private readonly ?EventDispatcherInterface $dispatcher = null, |
| 41 | - ) {} |
|
| 41 | + ){} |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Run console application. |
@@ -62,14 +62,14 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function run( |
| 64 | 64 | ?string $command, |
| 65 | - array|InputInterface $input = [], |
|
| 65 | + array | InputInterface $input = [], |
|
| 66 | 66 | OutputInterface $output = new BufferedOutput(), |
| 67 | 67 | ): CommandOutput { |
| 68 | 68 | $input = \is_array($input) ? new ArrayInput($input) : $input; |
| 69 | 69 | |
| 70 | 70 | $this->configureIO($input, $output); |
| 71 | 71 | |
| 72 | - if ($command !== null) { |
|
| 72 | + if ($command !== null){ |
|
| 73 | 73 | $input = new InputProxy($input, ['firstArgument' => $command]); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -96,18 +96,18 @@ discard block |
||
| 96 | 96 | */ |
| 97 | 97 | public function getApplication(): Application |
| 98 | 98 | { |
| 99 | - if ($this->application !== null) { |
|
| 99 | + if ($this->application !== null){ |
|
| 100 | 100 | return $this->application; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | $this->application = new Application($this->config->getName(), $this->config->getVersion()); |
| 104 | 104 | $this->application->setCatchExceptions(false); |
| 105 | 105 | $this->application->setAutoExit(false); |
| 106 | - if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) { |
|
| 106 | + if ($this->dispatcher instanceof SymfonyEventDispatcherInterface){ |
|
| 107 | 107 | $this->application->setDispatcher($this->dispatcher); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - if ($this->locator !== null) { |
|
| 110 | + if ($this->locator !== null){ |
|
| 111 | 111 | $this->addCommands($this->locator->locateCommands()); |
| 112 | 112 | } |
| 113 | 113 | |
@@ -127,13 +127,13 @@ discard block |
||
| 127 | 127 | { |
| 128 | 128 | $interceptors = $this->config->getInterceptors(); |
| 129 | 129 | |
| 130 | - foreach ($commands as $command) { |
|
| 131 | - if ($command instanceof Command) { |
|
| 130 | + foreach ($commands as $command){ |
|
| 131 | + if ($command instanceof Command){ |
|
| 132 | 132 | $command->setContainer($this->container); |
| 133 | 133 | $command->setInterceptors($interceptors); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
| 136 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface){ |
|
| 137 | 137 | $command->setEventDispatcher($this->dispatcher); |
| 138 | 138 | } |
| 139 | 139 | |
@@ -148,27 +148,27 @@ discard block |
||
| 148 | 148 | */ |
| 149 | 149 | private function configureIO(InputInterface $input, OutputInterface $output): void |
| 150 | 150 | { |
| 151 | - if ($input->hasParameterOption(['--ansi'], true)) { |
|
| 151 | + if ($input->hasParameterOption(['--ansi'], true)){ |
|
| 152 | 152 | $output->setDecorated(true); |
| 153 | - } elseif ($input->hasParameterOption(['--no-ansi'], true)) { |
|
| 153 | + } elseif ($input->hasParameterOption(['--no-ansi'], true)){ |
|
| 154 | 154 | $output->setDecorated(false); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - if ($input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
| 157 | + if ($input->hasParameterOption(['--no-interaction', '-n'], true)){ |
|
| 158 | 158 | $input->setInteractive(false); |
| 159 | - } elseif (\function_exists('posix_isatty')) { |
|
| 159 | + } elseif (\function_exists('posix_isatty')){ |
|
| 160 | 160 | $inputStream = null; |
| 161 | 161 | |
| 162 | - if ($input instanceof StreamableInputInterface) { |
|
| 162 | + if ($input instanceof StreamableInputInterface){ |
|
| 163 | 163 | $inputStream = $input->getStream(); |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false) { |
|
| 166 | + if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false){ |
|
| 167 | 167 | $input->setInteractive(false); |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - match ($shellVerbosity = (int) \getenv('SHELL_VERBOSITY')) { |
|
| 171 | + match ($shellVerbosity = (int)\getenv('SHELL_VERBOSITY')) { |
|
| 172 | 172 | -1 => $output->setVerbosity(OutputInterface::VERBOSITY_QUIET), |
| 173 | 173 | 1 => $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE), |
| 174 | 174 | 2 => $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE), |
@@ -176,22 +176,22 @@ discard block |
||
| 176 | 176 | default => $shellVerbosity = 0, |
| 177 | 177 | }; |
| 178 | 178 | |
| 179 | - if ($input->hasParameterOption(['--quiet', '-q'], true)) { |
|
| 179 | + if ($input->hasParameterOption(['--quiet', '-q'], true)){ |
|
| 180 | 180 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
| 181 | 181 | $shellVerbosity = -1; |
| 182 | - } else { |
|
| 182 | + }else{ |
|
| 183 | 183 | if ( |
| 184 | 184 | $input->hasParameterOption('-vvv', true) |
| 185 | 185 | || $input->hasParameterOption('--verbose=3', true) |
| 186 | 186 | || $input->getParameterOption('--verbose', false, true) === 3 |
| 187 | - ) { |
|
| 187 | + ){ |
|
| 188 | 188 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
| 189 | 189 | $shellVerbosity = 3; |
| 190 | 190 | } elseif ( |
| 191 | 191 | $input->hasParameterOption('-vv', true) |
| 192 | 192 | || $input->hasParameterOption('--verbose=2', true) |
| 193 | 193 | || $input->getParameterOption('--verbose', false, true) === 2 |
| 194 | - ) { |
|
| 194 | + ){ |
|
| 195 | 195 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
| 196 | 196 | $shellVerbosity = 2; |
| 197 | 197 | } elseif ( |
@@ -199,17 +199,17 @@ discard block |
||
| 199 | 199 | || $input->hasParameterOption('--verbose=1', true) |
| 200 | 200 | || $input->hasParameterOption('--verbose', true) |
| 201 | 201 | || $input->getParameterOption('--verbose', false, true) |
| 202 | - ) { |
|
| 202 | + ){ |
|
| 203 | 203 | $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); |
| 204 | 204 | $shellVerbosity = 1; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - if ($shellVerbosity === -1) { |
|
| 208 | + if ($shellVerbosity === -1){ |
|
| 209 | 209 | $input->setInteractive(false); |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - \putenv('SHELL_VERBOSITY=' . $shellVerbosity); |
|
| 212 | + \putenv('SHELL_VERBOSITY='.$shellVerbosity); |
|
| 213 | 213 | $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; |
| 214 | 214 | $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; |
| 215 | 215 | } |
@@ -38,7 +38,8 @@ discard block |
||
| 38 | 38 | #[Proxy] private readonly ContainerInterface $container = new Container(), |
| 39 | 39 | private readonly ScopeInterface $scope = new Container(), |
| 40 | 40 | private readonly ?EventDispatcherInterface $dispatcher = null, |
| 41 | - ) {} |
|
| 41 | + ) { |
|
| 42 | +} |
|
| 42 | 43 | |
| 43 | 44 | /** |
| 44 | 45 | * Run console application. |
@@ -69,7 +70,8 @@ discard block |
||
| 69 | 70 | |
| 70 | 71 | $this->configureIO($input, $output); |
| 71 | 72 | |
| 72 | - if ($command !== null) { |
|
| 73 | + if ($command !== null) |
|
| 74 | + { |
|
| 73 | 75 | $input = new InputProxy($input, ['firstArgument' => $command]); |
| 74 | 76 | } |
| 75 | 77 | |
@@ -96,18 +98,21 @@ discard block |
||
| 96 | 98 | */ |
| 97 | 99 | public function getApplication(): Application |
| 98 | 100 | { |
| 99 | - if ($this->application !== null) { |
|
| 101 | + if ($this->application !== null) |
|
| 102 | + { |
|
| 100 | 103 | return $this->application; |
| 101 | 104 | } |
| 102 | 105 | |
| 103 | 106 | $this->application = new Application($this->config->getName(), $this->config->getVersion()); |
| 104 | 107 | $this->application->setCatchExceptions(false); |
| 105 | 108 | $this->application->setAutoExit(false); |
| 106 | - if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) { |
|
| 109 | + if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) |
|
| 110 | + { |
|
| 107 | 111 | $this->application->setDispatcher($this->dispatcher); |
| 108 | 112 | } |
| 109 | 113 | |
| 110 | - if ($this->locator !== null) { |
|
| 114 | + if ($this->locator !== null) |
|
| 115 | + { |
|
| 111 | 116 | $this->addCommands($this->locator->locateCommands()); |
| 112 | 117 | } |
| 113 | 118 | |
@@ -127,13 +132,16 @@ discard block |
||
| 127 | 132 | { |
| 128 | 133 | $interceptors = $this->config->getInterceptors(); |
| 129 | 134 | |
| 130 | - foreach ($commands as $command) { |
|
| 131 | - if ($command instanceof Command) { |
|
| 135 | + foreach ($commands as $command) |
|
| 136 | + { |
|
| 137 | + if ($command instanceof Command) |
|
| 138 | + { |
|
| 132 | 139 | $command->setContainer($this->container); |
| 133 | 140 | $command->setInterceptors($interceptors); |
| 134 | 141 | } |
| 135 | 142 | |
| 136 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
| 143 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) |
|
| 144 | + { |
|
| 137 | 145 | $command->setEventDispatcher($this->dispatcher); |
| 138 | 146 | } |
| 139 | 147 | |
@@ -148,22 +156,30 @@ discard block |
||
| 148 | 156 | */ |
| 149 | 157 | private function configureIO(InputInterface $input, OutputInterface $output): void |
| 150 | 158 | { |
| 151 | - if ($input->hasParameterOption(['--ansi'], true)) { |
|
| 159 | + if ($input->hasParameterOption(['--ansi'], true)) |
|
| 160 | + { |
|
| 152 | 161 | $output->setDecorated(true); |
| 153 | - } elseif ($input->hasParameterOption(['--no-ansi'], true)) { |
|
| 162 | + } |
|
| 163 | + elseif ($input->hasParameterOption(['--no-ansi'], true)) |
|
| 164 | + { |
|
| 154 | 165 | $output->setDecorated(false); |
| 155 | 166 | } |
| 156 | 167 | |
| 157 | - if ($input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
| 168 | + if ($input->hasParameterOption(['--no-interaction', '-n'], true)) |
|
| 169 | + { |
|
| 158 | 170 | $input->setInteractive(false); |
| 159 | - } elseif (\function_exists('posix_isatty')) { |
|
| 171 | + } |
|
| 172 | + elseif (\function_exists('posix_isatty')) |
|
| 173 | + { |
|
| 160 | 174 | $inputStream = null; |
| 161 | 175 | |
| 162 | - if ($input instanceof StreamableInputInterface) { |
|
| 176 | + if ($input instanceof StreamableInputInterface) |
|
| 177 | + { |
|
| 163 | 178 | $inputStream = $input->getStream(); |
| 164 | 179 | } |
| 165 | 180 | |
| 166 | - if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false) { |
|
| 181 | + if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false) |
|
| 182 | + { |
|
| 167 | 183 | $input->setInteractive(false); |
| 168 | 184 | } |
| 169 | 185 | } |
@@ -176,10 +192,13 @@ discard block |
||
| 176 | 192 | default => $shellVerbosity = 0, |
| 177 | 193 | }; |
| 178 | 194 | |
| 179 | - if ($input->hasParameterOption(['--quiet', '-q'], true)) { |
|
| 195 | + if ($input->hasParameterOption(['--quiet', '-q'], true)) |
|
| 196 | + { |
|
| 180 | 197 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
| 181 | 198 | $shellVerbosity = -1; |
| 182 | - } else { |
|
| 199 | + } |
|
| 200 | + else |
|
| 201 | + { |
|
| 183 | 202 | if ( |
| 184 | 203 | $input->hasParameterOption('-vvv', true) |
| 185 | 204 | || $input->hasParameterOption('--verbose=3', true) |
@@ -187,14 +206,16 @@ discard block |
||
| 187 | 206 | ) { |
| 188 | 207 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
| 189 | 208 | $shellVerbosity = 3; |
| 190 | - } elseif ( |
|
| 209 | + } |
|
| 210 | + elseif ( |
|
| 191 | 211 | $input->hasParameterOption('-vv', true) |
| 192 | 212 | || $input->hasParameterOption('--verbose=2', true) |
| 193 | 213 | || $input->getParameterOption('--verbose', false, true) === 2 |
| 194 | 214 | ) { |
| 195 | 215 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
| 196 | 216 | $shellVerbosity = 2; |
| 197 | - } elseif ( |
|
| 217 | + } |
|
| 218 | + elseif ( |
|
| 198 | 219 | $input->hasParameterOption('-v', true) |
| 199 | 220 | || $input->hasParameterOption('--verbose=1', true) |
| 200 | 221 | || $input->hasParameterOption('--verbose', true) |
@@ -205,7 +226,8 @@ discard block |
||
| 205 | 226 | } |
| 206 | 227 | } |
| 207 | 228 | |
| 208 | - if ($shellVerbosity === -1) { |
|
| 229 | + if ($shellVerbosity === -1) |
|
| 230 | + { |
|
| 209 | 231 | $input->setInteractive(false); |
| 210 | 232 | } |
| 211 | 233 | |