Passed
Push — master ( 1bc8f5...82abcf )
by Aleksei
31:40 queued 16:32
created
src/Console/src/Console.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
             ? $this->application->addCommand(...)
131 131
             : $this->application->add(...);
132 132
 
133
-        foreach ($commands as $command) {
134
-            if ($command instanceof Command) {
133
+        foreach ($commands as $command){
134
+            if ($command instanceof Command){
135 135
                 $command->setContainer($this->container);
136 136
                 $command->setInterceptors($interceptors);
137 137
             }
138 138
 
139
-            if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) {
139
+            if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface){
140 140
                 $command->setEventDispatcher($this->dispatcher);
141 141
             }
142 142
 
@@ -151,27 +151,27 @@  discard block
 block discarded – undo
151 151
      */
152 152
     private function configureIO(InputInterface $input, OutputInterface $output): void
153 153
     {
154
-        if ($input->hasParameterOption(['--ansi'], true)) {
154
+        if ($input->hasParameterOption(['--ansi'], true)){
155 155
             $output->setDecorated(true);
156
-        } elseif ($input->hasParameterOption(['--no-ansi'], true)) {
156
+        } elseif ($input->hasParameterOption(['--no-ansi'], true)){
157 157
             $output->setDecorated(false);
158 158
         }
159 159
 
160
-        if ($input->hasParameterOption(['--no-interaction', '-n'], true)) {
160
+        if ($input->hasParameterOption(['--no-interaction', '-n'], true)){
161 161
             $input->setInteractive(false);
162
-        } elseif (\function_exists('posix_isatty')) {
162
+        } elseif (\function_exists('posix_isatty')){
163 163
             $inputStream = null;
164 164
 
165
-            if ($input instanceof StreamableInputInterface) {
165
+            if ($input instanceof StreamableInputInterface){
166 166
                 $inputStream = $input->getStream();
167 167
             }
168 168
 
169
-            if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false) {
169
+            if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false){
170 170
                 $input->setInteractive(false);
171 171
             }
172 172
         }
173 173
 
174
-        match ($shellVerbosity = (int) \getenv('SHELL_VERBOSITY')) {
174
+        match ($shellVerbosity = (int)\getenv('SHELL_VERBOSITY')) {
175 175
             -1 => $output->setVerbosity(OutputInterface::VERBOSITY_QUIET),
176 176
             1 => $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE),
177 177
             2 => $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE),
@@ -179,22 +179,22 @@  discard block
 block discarded – undo
179 179
             default => $shellVerbosity = 0,
180 180
         };
181 181
 
182
-        if ($input->hasParameterOption(['--quiet', '-q'], true)) {
182
+        if ($input->hasParameterOption(['--quiet', '-q'], true)){
183 183
             $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
184 184
             $shellVerbosity = -1;
185
-        } else {
185
+        }else{
186 186
             if (
187 187
                 $input->hasParameterOption('-vvv', true)
188 188
                 || $input->hasParameterOption('--verbose=3', true)
189 189
                 || $input->getParameterOption('--verbose', false, true) === 3
190
-            ) {
190
+            ){
191 191
                 $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
192 192
                 $shellVerbosity = 3;
193 193
             } elseif (
194 194
                 $input->hasParameterOption('-vv', true)
195 195
                 || $input->hasParameterOption('--verbose=2', true)
196 196
                 || $input->getParameterOption('--verbose', false, true) === 2
197
-            ) {
197
+            ){
198 198
                 $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
199 199
                 $shellVerbosity = 2;
200 200
             } elseif (
@@ -202,17 +202,17 @@  discard block
 block discarded – undo
202 202
                 || $input->hasParameterOption('--verbose=1', true)
203 203
                 || $input->hasParameterOption('--verbose', true)
204 204
                 || $input->getParameterOption('--verbose', false, true)
205
-            ) {
205
+            ){
206 206
                 $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
207 207
                 $shellVerbosity = 1;
208 208
             }
209 209
         }
210 210
 
211
-        if ($shellVerbosity === -1) {
211
+        if ($shellVerbosity === -1){
212 212
             $input->setInteractive(false);
213 213
         }
214 214
 
215
-        \putenv('SHELL_VERBOSITY=' . $shellVerbosity);
215
+        \putenv('SHELL_VERBOSITY='.$shellVerbosity);
216 216
         $_ENV['SHELL_VERBOSITY'] = $shellVerbosity;
217 217
         $_SERVER['SHELL_VERBOSITY'] = $shellVerbosity;
218 218
     }
Please login to merge, or discard this patch.
Braces   +41 added lines, -19 removed lines patch added patch discarded remove patch
@@ -38,7 +38,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -130,13 +135,16 @@  discard block
 block discarded – undo
130 135
             ? $this->application->addCommand(...)
131 136
             : $this->application->add(...);
132 137
 
133
-        foreach ($commands as $command) {
134
-            if ($command instanceof Command) {
138
+        foreach ($commands as $command)
139
+        {
140
+            if ($command instanceof Command)
141
+            {
135 142
                 $command->setContainer($this->container);
136 143
                 $command->setInterceptors($interceptors);
137 144
             }
138 145
 
139
-            if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface) {
146
+            if ($this->dispatcher !== null && $command instanceof EventDispatcherAwareInterface)
147
+            {
140 148
                 $command->setEventDispatcher($this->dispatcher);
141 149
             }
142 150
 
@@ -151,22 +159,30 @@  discard block
 block discarded – undo
151 159
      */
152 160
     private function configureIO(InputInterface $input, OutputInterface $output): void
153 161
     {
154
-        if ($input->hasParameterOption(['--ansi'], true)) {
162
+        if ($input->hasParameterOption(['--ansi'], true))
163
+        {
155 164
             $output->setDecorated(true);
156
-        } elseif ($input->hasParameterOption(['--no-ansi'], true)) {
165
+        }
166
+        elseif ($input->hasParameterOption(['--no-ansi'], true))
167
+        {
157 168
             $output->setDecorated(false);
158 169
         }
159 170
 
160
-        if ($input->hasParameterOption(['--no-interaction', '-n'], true)) {
171
+        if ($input->hasParameterOption(['--no-interaction', '-n'], true))
172
+        {
161 173
             $input->setInteractive(false);
162
-        } elseif (\function_exists('posix_isatty')) {
174
+        }
175
+        elseif (\function_exists('posix_isatty'))
176
+        {
163 177
             $inputStream = null;
164 178
 
165
-            if ($input instanceof StreamableInputInterface) {
179
+            if ($input instanceof StreamableInputInterface)
180
+            {
166 181
                 $inputStream = $input->getStream();
167 182
             }
168 183
 
169
-            if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false) {
184
+            if ($inputStream !== null && !@\posix_isatty($inputStream) && \getenv('SHELL_INTERACTIVE') === false)
185
+            {
170 186
                 $input->setInteractive(false);
171 187
             }
172 188
         }
@@ -179,10 +195,13 @@  discard block
 block discarded – undo
179 195
             default => $shellVerbosity = 0,
180 196
         };
181 197
 
182
-        if ($input->hasParameterOption(['--quiet', '-q'], true)) {
198
+        if ($input->hasParameterOption(['--quiet', '-q'], true))
199
+        {
183 200
             $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
184 201
             $shellVerbosity = -1;
185
-        } else {
202
+        }
203
+        else
204
+        {
186 205
             if (
187 206
                 $input->hasParameterOption('-vvv', true)
188 207
                 || $input->hasParameterOption('--verbose=3', true)
@@ -190,14 +209,16 @@  discard block
 block discarded – undo
190 209
             ) {
191 210
                 $output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
192 211
                 $shellVerbosity = 3;
193
-            } elseif (
212
+            }
213
+            elseif (
194 214
                 $input->hasParameterOption('-vv', true)
195 215
                 || $input->hasParameterOption('--verbose=2', true)
196 216
                 || $input->getParameterOption('--verbose', false, true) === 2
197 217
             ) {
198 218
                 $output->setVerbosity(OutputInterface::VERBOSITY_VERY_VERBOSE);
199 219
                 $shellVerbosity = 2;
200
-            } elseif (
220
+            }
221
+            elseif (
201 222
                 $input->hasParameterOption('-v', true)
202 223
                 || $input->hasParameterOption('--verbose=1', true)
203 224
                 || $input->hasParameterOption('--verbose', true)
@@ -208,7 +229,8 @@  discard block
 block discarded – undo
208 229
             }
209 230
         }
210 231
 
211
-        if ($shellVerbosity === -1) {
232
+        if ($shellVerbosity === -1)
233
+        {
212 234
             $input->setInteractive(false);
213 235
         }
214 236
 
Please login to merge, or discard this patch.