Passed
Push — master ( 477224...3259b8 )
by Aleksei
06:12 queued 18s
created
src/Exceptions/src/Renderer/ConsoleRenderer.php 1 patch
Braces   +48 added lines, -22 removed lines patch added patch discarded remove patch
@@ -66,7 +66,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Console/src/Console.php 1 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
 
@@ -127,13 +132,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
205 226
             }
206 227
         }
207 228
 
208
-        if ($shellVerbosity === -1) {
229
+        if ($shellVerbosity === -1)
230
+        {
209 231
             $input->setInteractive(false);
210 232
         }
211 233
 
Please login to merge, or discard this patch.