@@ -70,7 +70,8 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | $this->configureIO($input, $output); |
| 72 | 72 | |
| 73 | - if ($command !== null) { |
|
| 73 | + if ($command !== null) |
|
| 74 | + { |
|
| 74 | 75 | $input = new InputProxy($input, ['firstArgument' => $command]); |
| 75 | 76 | } |
| 76 | 77 | |
@@ -89,18 +90,21 @@ discard block |
||
| 89 | 90 | */ |
| 90 | 91 | public function getApplication(): Application |
| 91 | 92 | { |
| 92 | - if ($this->application !== null) { |
|
| 93 | + if ($this->application !== null) |
|
| 94 | + { |
|
| 93 | 95 | return $this->application; |
| 94 | 96 | } |
| 95 | 97 | |
| 96 | 98 | $this->application = new Application($this->config->getName(), $this->config->getVersion()); |
| 97 | 99 | $this->application->setCatchExceptions(false); |
| 98 | 100 | $this->application->setAutoExit(false); |
| 99 | - if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) { |
|
| 101 | + if ($this->dispatcher instanceof SymfonyEventDispatcherInterface) |
|
| 102 | + { |
|
| 100 | 103 | $this->application->setDispatcher($this->dispatcher); |
| 101 | 104 | } |
| 102 | 105 | |
| 103 | - if ($this->locator !== null) { |
|
| 106 | + if ($this->locator !== null) |
|
| 107 | + { |
|
| 104 | 108 | $this->addCommands($this->locator->locateCommands()); |
| 105 | 109 | } |
| 106 | 110 | |
@@ -120,13 +124,16 @@ discard block |
||
| 120 | 124 | { |
| 121 | 125 | $interceptors = $this->config->getInterceptors(); |
| 122 | 126 | |
| 123 | - foreach ($commands as $command) { |
|
| 124 | - if ($command instanceof Command) { |
|
| 127 | + foreach ($commands as $command) |
|
| 128 | + { |
|
| 129 | + if ($command instanceof Command) |
|
| 130 | + { |
|
| 125 | 131 | $command->setContainer($this->container); |
| 126 | 132 | $command->setInterceptors($interceptors); |
| 127 | 133 | } |
| 128 | 134 | |
| 129 | - if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) { |
|
| 135 | + if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) |
|
| 136 | + { |
|
| 130 | 137 | $command->setEventDispatcher($this->dispatcher); |
| 131 | 138 | } |
| 132 | 139 | |
@@ -141,22 +148,30 @@ discard block |
||
| 141 | 148 | */ |
| 142 | 149 | private function configureIO(InputInterface $input, OutputInterface $output): void |
| 143 | 150 | { |
| 144 | - if ($input->hasParameterOption(['--ansi'], true)) { |
|
| 151 | + if ($input->hasParameterOption(['--ansi'], true)) |
|
| 152 | + { |
|
| 145 | 153 | $output->setDecorated(true); |
| 146 | - } elseif ($input->hasParameterOption(['--no-ansi'], true)) { |
|
| 154 | + } |
|
| 155 | + elseif ($input->hasParameterOption(['--no-ansi'], true)) |
|
| 156 | + { |
|
| 147 | 157 | $output->setDecorated(false); |
| 148 | 158 | } |
| 149 | 159 | |
| 150 | - if ($input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
| 160 | + if ($input->hasParameterOption(['--no-interaction', '-n'], true)) |
|
| 161 | + { |
|
| 151 | 162 | $input->setInteractive(false); |
| 152 | - } elseif (\function_exists('posix_isatty')) { |
|
| 163 | + } |
|
| 164 | + elseif (\function_exists('posix_isatty')) |
|
| 165 | + { |
|
| 153 | 166 | $inputStream = null; |
| 154 | 167 | |
| 155 | - if ($input instanceof StreamableInputInterface) { |
|
| 168 | + if ($input instanceof StreamableInputInterface) |
|
| 169 | + { |
|
| 156 | 170 | $inputStream = $input->getStream(); |
| 157 | 171 | } |
| 158 | 172 | |
| 159 | - if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { |
|
| 173 | + if ($inputStream !== null && !@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) |
|
| 174 | + { |
|
| 160 | 175 | $input->setInteractive(false); |
| 161 | 176 | } |
| 162 | 177 | } |
@@ -169,10 +184,13 @@ discard block |
||
| 169 | 184 | default => $shellVerbosity = 0 |
| 170 | 185 | }; |
| 171 | 186 | |
| 172 | - if ($input->hasParameterOption(['--quiet', '-q'], true)) { |
|
| 187 | + if ($input->hasParameterOption(['--quiet', '-q'], true)) |
|
| 188 | + { |
|
| 173 | 189 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
| 174 | 190 | $shellVerbosity = -1; |
| 175 | - } else { |
|
| 191 | + } |
|
| 192 | + else |
|
| 193 | + { |
|
| 176 | 194 | if ( |
| 177 | 195 | $input->hasParameterOption('-vvv', true) |
| 178 | 196 | || $input->hasParameterOption('--verbose=3', true) |
@@ -180,14 +198,16 @@ discard block |
||
| 180 | 198 | ) { |
| 181 | 199 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
| 182 | 200 | $shellVerbosity = 3; |
| 183 | - } elseif ( |
|
| 201 | + } |
|
| 202 | + elseif ( |
|
| 184 | 203 | $input->hasParameterOption('-vv', true) |
| 185 | 204 | || $input->hasParameterOption('--verbose=2', true) |
| 186 | 205 | || 2 === $input->getParameterOption('--verbose', false, true) |
| 187 | 206 | ) { |
| 188 | 207 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
| 189 | 208 | $shellVerbosity = 2; |
| 190 | - } elseif ( |
|
| 209 | + } |
|
| 210 | + elseif ( |
|
| 191 | 211 | $input->hasParameterOption('-v', true) |
| 192 | 212 | || $input->hasParameterOption('--verbose=1', true) |
| 193 | 213 | || $input->hasParameterOption('--verbose', true) |
@@ -198,7 +218,8 @@ discard block |
||
| 198 | 218 | } |
| 199 | 219 | } |
| 200 | 220 | |
| 201 | - if (-1 === $shellVerbosity) { |
|
| 221 | + if (-1 === $shellVerbosity) |
|
| 222 | + { |
|
| 202 | 223 | $input->setInteractive(false); |
| 203 | 224 | } |
| 204 | 225 | |