@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | ConsoleConfig $config, |
53 | 53 | LocatorInterface $locator = null, |
54 | 54 | ContainerInterface $container = null |
55 | - ) { |
|
55 | + ){ |
|
56 | 56 | $this->config = $config; |
57 | 57 | $this->locator = $locator; |
58 | 58 | $this->container = $container ?? new Container(); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | |
103 | 103 | $this->configureIO($input, $output); |
104 | 104 | |
105 | - if ($command !== null) { |
|
105 | + if ($command !== null){ |
|
106 | 106 | $input = new InputProxy($input, ['firstArgument' => $command]); |
107 | 107 | } |
108 | 108 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function getApplication(): Application |
124 | 124 | { |
125 | - if ($this->application !== null) { |
|
125 | + if ($this->application !== null){ |
|
126 | 126 | return $this->application; |
127 | 127 | } |
128 | 128 | |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $this->application->setCatchExceptions(false); |
131 | 131 | $this->application->setAutoExit(false); |
132 | 132 | |
133 | - if ($this->locator !== null) { |
|
133 | + if ($this->locator !== null){ |
|
134 | 134 | $this->addCommands($this->locator->locateCommands()); |
135 | 135 | } |
136 | 136 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | */ |
147 | 147 | private function addCommands(iterable $commands): void |
148 | 148 | { |
149 | - foreach ($commands as $command) { |
|
150 | - if ($command instanceof Command) { |
|
149 | + foreach ($commands as $command){ |
|
150 | + if ($command instanceof Command){ |
|
151 | 151 | $command->setContainer($this->container); |
152 | 152 | } |
153 | 153 | |
@@ -164,27 +164,27 @@ discard block |
||
164 | 164 | */ |
165 | 165 | private function configureIO(InputInterface $input, OutputInterface $output): void |
166 | 166 | { |
167 | - if (true === $input->hasParameterOption(['--ansi'], true)) { |
|
167 | + if (true === $input->hasParameterOption(['--ansi'], true)){ |
|
168 | 168 | $output->setDecorated(true); |
169 | - } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) { |
|
169 | + } elseif (true === $input->hasParameterOption(['--no-ansi'], true)){ |
|
170 | 170 | $output->setDecorated(false); |
171 | 171 | } |
172 | 172 | |
173 | - if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
173 | + if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)){ |
|
174 | 174 | $input->setInteractive(false); |
175 | - } elseif (\function_exists('posix_isatty')) { |
|
175 | + } elseif (\function_exists('posix_isatty')){ |
|
176 | 176 | $inputStream = null; |
177 | 177 | |
178 | - if ($input instanceof StreamableInputInterface) { |
|
178 | + if ($input instanceof StreamableInputInterface){ |
|
179 | 179 | $inputStream = $input->getStream(); |
180 | 180 | } |
181 | 181 | |
182 | - if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { |
|
182 | + if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')){ |
|
183 | 183 | $input->setInteractive(false); |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - switch ($shellVerbosity = (int)getenv('SHELL_VERBOSITY')) { |
|
187 | + switch ($shellVerbosity = (int)getenv('SHELL_VERBOSITY')){ |
|
188 | 188 | case -1: |
189 | 189 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
190 | 190 | break; |
@@ -204,22 +204,22 @@ discard block |
||
204 | 204 | |
205 | 205 | if ( |
206 | 206 | true === $input->hasParameterOption(['--quiet', '-q'], true) |
207 | - ) { |
|
207 | + ){ |
|
208 | 208 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
209 | 209 | $shellVerbosity = -1; |
210 | - } else { |
|
210 | + }else{ |
|
211 | 211 | if ( |
212 | 212 | $input->hasParameterOption('-vvv', true) |
213 | 213 | || $input->hasParameterOption('--verbose=3', true) |
214 | 214 | || 3 === $input->getParameterOption('--verbose', false, true) |
215 | - ) { |
|
215 | + ){ |
|
216 | 216 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
217 | 217 | $shellVerbosity = 3; |
218 | 218 | } elseif ( |
219 | 219 | $input->hasParameterOption('-vv', true) |
220 | 220 | || $input->hasParameterOption('--verbose=2', true) |
221 | 221 | || 2 === $input->getParameterOption('--verbose', false, true) |
222 | - ) { |
|
222 | + ){ |
|
223 | 223 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
224 | 224 | $shellVerbosity = 2; |
225 | 225 | } elseif ( |
@@ -227,17 +227,17 @@ discard block |
||
227 | 227 | || $input->hasParameterOption('--verbose=1', true) |
228 | 228 | || $input->hasParameterOption('--verbose', true) |
229 | 229 | || $input->getParameterOption('--verbose', false, true) |
230 | - ) { |
|
230 | + ){ |
|
231 | 231 | $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE); |
232 | 232 | $shellVerbosity = 1; |
233 | 233 | } |
234 | 234 | } |
235 | 235 | |
236 | - if (-1 === $shellVerbosity) { |
|
236 | + if (-1 === $shellVerbosity){ |
|
237 | 237 | $input->setInteractive(false); |
238 | 238 | } |
239 | 239 | |
240 | - putenv('SHELL_VERBOSITY=' . $shellVerbosity); |
|
240 | + putenv('SHELL_VERBOSITY='.$shellVerbosity); |
|
241 | 241 | $_ENV['SHELL_VERBOSITY'] = $shellVerbosity; |
242 | 242 | $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity; |
243 | 243 | } |
@@ -72,7 +72,8 @@ discard block |
||
72 | 72 | $input = $input ?? new ArgvInput(); |
73 | 73 | $output = $output ?? new ConsoleOutput(); |
74 | 74 | |
75 | - return ContainerScope::runScope($this->container, function () use ($input, $output) { |
|
75 | + return ContainerScope::runScope($this->container, function () use ($input, $output) |
|
76 | + { |
|
76 | 77 | return $this->run( |
77 | 78 | $input->getFirstArgument() ?? 'list', |
78 | 79 | $input, |
@@ -102,11 +103,13 @@ discard block |
||
102 | 103 | |
103 | 104 | $this->configureIO($input, $output); |
104 | 105 | |
105 | - if ($command !== null) { |
|
106 | + if ($command !== null) |
|
107 | + { |
|
106 | 108 | $input = new InputProxy($input, ['firstArgument' => $command]); |
107 | 109 | } |
108 | 110 | |
109 | - $code = ContainerScope::runScope($this->container, function () use ($input, $output) { |
|
111 | + $code = ContainerScope::runScope($this->container, function () use ($input, $output) |
|
112 | + { |
|
110 | 113 | return $this->getApplication()->doRun($input, $output); |
111 | 114 | }); |
112 | 115 | |
@@ -122,7 +125,8 @@ discard block |
||
122 | 125 | */ |
123 | 126 | public function getApplication(): Application |
124 | 127 | { |
125 | - if ($this->application !== null) { |
|
128 | + if ($this->application !== null) |
|
129 | + { |
|
126 | 130 | return $this->application; |
127 | 131 | } |
128 | 132 | |
@@ -130,7 +134,8 @@ discard block |
||
130 | 134 | $this->application->setCatchExceptions(false); |
131 | 135 | $this->application->setAutoExit(false); |
132 | 136 | |
133 | - if ($this->locator !== null) { |
|
137 | + if ($this->locator !== null) |
|
138 | + { |
|
134 | 139 | $this->addCommands($this->locator->locateCommands()); |
135 | 140 | } |
136 | 141 | |
@@ -146,8 +151,10 @@ discard block |
||
146 | 151 | */ |
147 | 152 | private function addCommands(iterable $commands): void |
148 | 153 | { |
149 | - foreach ($commands as $command) { |
|
150 | - if ($command instanceof Command) { |
|
154 | + foreach ($commands as $command) |
|
155 | + { |
|
156 | + if ($command instanceof Command) |
|
157 | + { |
|
151 | 158 | $command->setContainer($this->container); |
152 | 159 | } |
153 | 160 | |
@@ -164,27 +171,36 @@ discard block |
||
164 | 171 | */ |
165 | 172 | private function configureIO(InputInterface $input, OutputInterface $output): void |
166 | 173 | { |
167 | - if (true === $input->hasParameterOption(['--ansi'], true)) { |
|
174 | + if (true === $input->hasParameterOption(['--ansi'], true)) |
|
175 | + { |
|
168 | 176 | $output->setDecorated(true); |
169 | - } elseif (true === $input->hasParameterOption(['--no-ansi'], true)) { |
|
177 | + } |
|
178 | + elseif (true === $input->hasParameterOption(['--no-ansi'], true)) |
|
179 | + { |
|
170 | 180 | $output->setDecorated(false); |
171 | 181 | } |
172 | 182 | |
173 | - if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) { |
|
183 | + if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) |
|
184 | + { |
|
174 | 185 | $input->setInteractive(false); |
175 | - } elseif (\function_exists('posix_isatty')) { |
|
186 | + } |
|
187 | + elseif (\function_exists('posix_isatty')) |
|
188 | + { |
|
176 | 189 | $inputStream = null; |
177 | 190 | |
178 | - if ($input instanceof StreamableInputInterface) { |
|
191 | + if ($input instanceof StreamableInputInterface) |
|
192 | + { |
|
179 | 193 | $inputStream = $input->getStream(); |
180 | 194 | } |
181 | 195 | |
182 | - if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) { |
|
196 | + if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) |
|
197 | + { |
|
183 | 198 | $input->setInteractive(false); |
184 | 199 | } |
185 | 200 | } |
186 | 201 | |
187 | - switch ($shellVerbosity = (int)getenv('SHELL_VERBOSITY')) { |
|
202 | + switch ($shellVerbosity = (int)getenv('SHELL_VERBOSITY')) |
|
203 | + { |
|
188 | 204 | case -1: |
189 | 205 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
190 | 206 | break; |
@@ -207,7 +223,9 @@ discard block |
||
207 | 223 | ) { |
208 | 224 | $output->setVerbosity(OutputInterface::VERBOSITY_QUIET); |
209 | 225 | $shellVerbosity = -1; |
210 | - } else { |
|
226 | + } |
|
227 | + else |
|
228 | + { |
|
211 | 229 | if ( |
212 | 230 | $input->hasParameterOption('-vvv', true) |
213 | 231 | || $input->hasParameterOption('--verbose=3', true) |
@@ -215,14 +233,16 @@ discard block |
||
215 | 233 | ) { |
216 | 234 | $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG); |
217 | 235 | $shellVerbosity = 3; |
218 | - } elseif ( |
|
236 | + } |
|
237 | + elseif ( |
|
219 | 238 | $input->hasParameterOption('-vv', true) |
220 | 239 | || $input->hasParameterOption('--verbose=2', true) |
221 | 240 | || 2 === $input->getParameterOption('--verbose', false, true) |
222 | 241 | ) { |
223 | 242 | $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE); |
224 | 243 | $shellVerbosity = 2; |
225 | - } elseif ( |
|
244 | + } |
|
245 | + elseif ( |
|
226 | 246 | $input->hasParameterOption('-v', true) |
227 | 247 | || $input->hasParameterOption('--verbose=1', true) |
228 | 248 | || $input->hasParameterOption('--verbose', true) |
@@ -233,7 +253,8 @@ discard block |
||
233 | 253 | } |
234 | 254 | } |
235 | 255 | |
236 | - if (-1 === $shellVerbosity) { |
|
256 | + if (-1 === $shellVerbosity) |
|
257 | + { |
|
237 | 258 | $input->setInteractive(false); |
238 | 259 | } |
239 | 260 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | class ConfigureTest extends BaseTest |
25 | 25 | { |
26 | 26 | public const TOKENIZER_CONFIG = [ |
27 | - 'directories' => [__DIR__ . '/../src/Command', __DIR__ . '/Fixtures/'], |
|
27 | + 'directories' => [__DIR__.'/../src/Command', __DIR__.'/Fixtures/'], |
|
28 | 28 | 'exclude' => [] |
29 | 29 | ]; |
30 | 30 | |
@@ -34,9 +34,9 @@ discard block |
||
34 | 34 | ['command' => 'test', 'header' => 'Test Command'], |
35 | 35 | ['command' => 'helper', 'options' => ['helper' => 'writeln'], 'footer' => 'Good!'], |
36 | 36 | ['invoke' => [self::class, 'do']], |
37 | - ['invoke' => self::class . '::do'], |
|
37 | + ['invoke' => self::class.'::do'], |
|
38 | 38 | 'Spiral\Tests\Console\ok', |
39 | - ['invoke' => self::class . '::err'], |
|
39 | + ['invoke' => self::class.'::err'], |
|
40 | 40 | ] |
41 | 41 | ]; |
42 | 42 |
@@ -126,10 +126,12 @@ |
||
126 | 126 | $this->assertEquals(1, $output->getCode()); |
127 | 127 | } |
128 | 128 | |
129 | - public function do(OutputInterface $output): void |
|
129 | + public function do{ |
|
130 | + (OutputInterface $output): void |
|
130 | 131 | { |
131 | 132 | $output->write('OK'); |
132 | 133 | } |
134 | + } |
|
133 | 135 | |
134 | 136 | public function err(OutputInterface $output): void |
135 | 137 | { |
@@ -21,7 +21,7 @@ |
||
21 | 21 | abstract class BaseTest extends TestCase |
22 | 22 | { |
23 | 23 | public const TOKENIZER_CONFIG = [ |
24 | - 'directories' => [__DIR__ . '/Fixtures/'], |
|
24 | + 'directories' => [__DIR__.'/Fixtures/'], |
|
25 | 25 | 'exclude' => ['User'], |
26 | 26 | ]; |
27 | 27 |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | class UpdateTest extends BaseTest |
25 | 25 | { |
26 | 26 | public const TOKENIZER_CONFIG = [ |
27 | - 'directories' => [__DIR__ . '/../src/Command', __DIR__ . '/Fixtures/'], |
|
27 | + 'directories' => [__DIR__.'/../src/Command', __DIR__.'/Fixtures/'], |
|
28 | 28 | 'exclude' => [] |
29 | 29 | ]; |
30 | 30 | |
@@ -35,9 +35,9 @@ discard block |
||
35 | 35 | ['command' => 'test', 'header' => 'Test Command'], |
36 | 36 | ['command' => 'helper', 'options' => ['helper' => 'writeln'], 'footer' => 'Good!'], |
37 | 37 | ['invoke' => [self::class, 'do']], |
38 | - ['invoke' => self::class . '::do'], |
|
38 | + ['invoke' => self::class.'::do'], |
|
39 | 39 | 'Spiral\Tests\Console\ok', |
40 | - ['invoke' => self::class . '::err'], |
|
40 | + ['invoke' => self::class.'::err'], |
|
41 | 41 | ] |
42 | 42 | ]; |
43 | 43 |
@@ -126,10 +126,12 @@ |
||
126 | 126 | $this->assertEquals(1, $output->getCode()); |
127 | 127 | } |
128 | 128 | |
129 | - public function do(OutputInterface $output): void |
|
129 | + public function do{ |
|
130 | + (OutputInterface $output): void |
|
130 | 131 | { |
131 | 132 | $output->write('OK'); |
132 | 133 | } |
134 | + } |
|
133 | 135 | |
134 | 136 | public function err(OutputInterface $output): void |
135 | 137 | { |
@@ -22,6 +22,6 @@ |
||
22 | 22 | */ |
23 | 23 | public function perform(): void |
24 | 24 | { |
25 | - throw new Exception('Unhandled another failed command error at ' . __METHOD__ . ' (line ' . __LINE__ . ')'); |
|
25 | + throw new Exception('Unhandled another failed command error at '.__METHOD__.' (line '.__LINE__.')'); |
|
26 | 26 | } |
27 | 27 | } |
@@ -22,6 +22,6 @@ |
||
22 | 22 | */ |
23 | 23 | public function perform(): void |
24 | 24 | { |
25 | - throw new Exception('Unhandled failed command error at ' . __METHOD__ . ' (line ' . __LINE__ . ')'); |
|
25 | + throw new Exception('Unhandled failed command error at '.__METHOD__.' (line '.__LINE__.')'); |
|
26 | 26 | } |
27 | 27 | } |
@@ -22,6 +22,6 @@ |
||
22 | 22 | |
23 | 23 | public function perform(): void |
24 | 24 | { |
25 | - $this->write('Hello World - ' . ($this->count++)); |
|
25 | + $this->write('Hello World - '.($this->count++)); |
|
26 | 26 | } |
27 | 27 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | |
27 | 27 | public function perform(): void |
28 | 28 | { |
29 | - switch ($this->argument('helper')) { |
|
29 | + switch ($this->argument('helper')){ |
|
30 | 30 | case 'verbose': |
31 | 31 | $this->write($this->isVerbose() ? 'true' : 'false'); |
32 | 32 | break; |
@@ -26,7 +26,8 @@ |
||
26 | 26 | |
27 | 27 | public function perform(): void |
28 | 28 | { |
29 | - switch ($this->argument('helper')) { |
|
29 | + switch ($this->argument('helper')) |
|
30 | + { |
|
30 | 31 | case 'verbose': |
31 | 32 | $this->write($this->isVerbose() ? 'true' : 'false'); |
32 | 33 | break; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | $headers = $acceptHeader->getAll(); |
119 | 119 | $this->assertCount(count($expected), $headers); |
120 | 120 | |
121 | - foreach ($expected as $i => $value) { |
|
121 | + foreach ($expected as $i => $value){ |
|
122 | 122 | $this->assertSame($value, $headers[$i]->getValue()); |
123 | 123 | } |
124 | 124 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | $headers = $acceptHeader->getAll(); |
165 | 165 | $this->assertCount(count($expected), $headers); |
166 | 166 | |
167 | - foreach ($expected as $i => $value) { |
|
167 | + foreach ($expected as $i => $value){ |
|
168 | 168 | $this->assertSame($value, (string)$headers[$i]); |
169 | 169 | } |
170 | 170 | } |
@@ -118,7 +118,8 @@ discard block |
||
118 | 118 | $headers = $acceptHeader->getAll(); |
119 | 119 | $this->assertCount(count($expected), $headers); |
120 | 120 | |
121 | - foreach ($expected as $i => $value) { |
|
121 | + foreach ($expected as $i => $value) |
|
122 | + { |
|
122 | 123 | $this->assertSame($value, $headers[$i]->getValue()); |
123 | 124 | } |
124 | 125 | } |
@@ -164,7 +165,8 @@ discard block |
||
164 | 165 | $headers = $acceptHeader->getAll(); |
165 | 166 | $this->assertCount(count($expected), $headers); |
166 | 167 | |
167 | - foreach ($expected as $i => $value) { |
|
168 | + foreach ($expected as $i => $value) |
|
169 | + { |
|
168 | 170 | $this->assertSame($value, (string)$headers[$i]); |
169 | 171 | } |
170 | 172 | } |