Passed
Push — master ( 477224...3259b8 )
by Aleksei
06:12 queued 18s
created
src/Exceptions/src/Renderer/ConsoleRenderer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  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
             $exceptions[] = $exception;
71 71
         }
72 72
 
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
253 253
             }
254 254
 
255 255
             return @\stream_isatty($stream);
256
-        } catch (\Throwable) {
256
+        }catch (\Throwable){
257 257
             return false;
258 258
         }
259 259
     }
Please login to merge, or discard this patch.
src/Console/src/Console.php 1 patch
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
 
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.