Passed
Pull Request — master (#853)
by butschster
06:40
created
src/Exceptions/src/Renderer/PlainRenderer.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
     ): string {
23 23
         $verbosity ??= $this->defaultVerbosity;
24 24
         $exceptions = [$exception];
25
-        while ($exception = $exception->getPrevious()) {
25
+        while ($exception = $exception->getPrevious()){
26 26
             $exceptions[] = $exception;
27 27
         }
28 28
 
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
         $result = [];
32 32
         $rootDir = \getcwd();
33 33
 
34
-        foreach ($exceptions as $exception) {
34
+        foreach ($exceptions as $exception){
35 35
             $file = \str_starts_with($exception->getFile(), $rootDir)
36 36
                 ? \substr($exception->getFile(), \strlen($rootDir) + 1)
37 37
                 : $exception->getFile();
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
                 $exception->getLine(),
45 45
             );
46 46
 
47
-            if ($verbosity->value >= Verbosity::DEBUG->value) {
47
+            if ($verbosity->value >= Verbosity::DEBUG->value){
48 48
                 $row .= $this->renderTrace($exception, new Highlighter(new PlainStyle()));
49
-            } elseif ($verbosity->value >= Verbosity::VERBOSE->value) {
49
+            } elseif ($verbosity->value >= Verbosity::VERBOSE->value){
50 50
                 $row .= $this->renderTrace($exception);
51 51
             }
52 52
 
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
     private function renderTrace(\Throwable $e, Highlighter $h = null): string
65 65
     {
66 66
         $stacktrace = $this->getStacktrace($e);
67
-        if ($stacktrace === []) {
67
+        if ($stacktrace === []){
68 68
             return '';
69 69
         }
70 70
 
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
 
74 74
         $pad = \strlen((string)\count($stacktrace));
75 75
 
76
-        foreach ($stacktrace as $i => $trace) {
77
-            if (isset($trace['type'], $trace['class'])) {
76
+        foreach ($stacktrace as $i => $trace){
77
+            if (isset($trace['type'], $trace['class'])){
78 78
                 $line = \sprintf(
79 79
                     '%s. %s%s%s()',
80
-                    \str_pad((string)((int) $i + 1), $pad, ' ', \STR_PAD_LEFT),
80
+                    \str_pad((string)((int)$i + 1), $pad, ' ', \STR_PAD_LEFT),
81 81
                     $trace['class'],
82 82
                     $trace['type'],
83 83
                     $trace['function']
84 84
                 );
85
-            } else {
85
+            }else{
86 86
                 $line = $trace['function'];
87 87
             }
88 88
 
89
-            if (isset($trace['file'])) {
89
+            if (isset($trace['file'])){
90 90
                 $file = \str_starts_with($trace['file'], $rootDir)
91 91
                     ? \substr($trace['file'], \strlen($rootDir) + 1)
92 92
                     : $trace['file'];
@@ -94,23 +94,23 @@  discard block
 block discarded – undo
94 94
                 $line .= \sprintf(' at %s:%s', $file, $trace['line']);
95 95
             }
96 96
 
97
-            if (\in_array($line, $this->lines, true)) {
97
+            if (\in_array($line, $this->lines, true)){
98 98
                 continue;
99 99
             }
100 100
 
101 101
             $this->lines[] = $line;
102 102
 
103
-            $result .= $line . "\n";
103
+            $result .= $line."\n";
104 104
 
105
-            if ($h !== null && !empty($trace['file'])) {
105
+            if ($h !== null && !empty($trace['file'])){
106 106
                 $result .= $h->highlightLines(
107 107
                     \file_get_contents($trace['file']),
108 108
                     $trace['line'],
109 109
                     self::SHOW_LINES
110
-                ) . "\n";
110
+                )."\n";
111 111
             }
112 112
         }
113 113
 
114
-        return $result . "\n";
114
+        return $result."\n";
115 115
     }
116 116
 }
Please login to merge, or discard this patch.
Braces   +24 added lines, -11 removed lines patch added patch discarded remove patch
@@ -22,7 +22,8 @@  discard block
 block discarded – undo
22 22
     ): string {
23 23
         $verbosity ??= $this->defaultVerbosity;
24 24
         $exceptions = [$exception];
25
-        while ($exception = $exception->getPrevious()) {
25
+        while ($exception = $exception->getPrevious())
26
+        {
26 27
             $exceptions[] = $exception;
27 28
         }
28 29
 
@@ -31,7 +32,8 @@  discard block
 block discarded – undo
31 32
         $result = [];
32 33
         $rootDir = \getcwd();
33 34
 
34
-        foreach ($exceptions as $exception) {
35
+        foreach ($exceptions as $exception)
36
+        {
35 37
             $file = \str_starts_with($exception->getFile(), $rootDir)
36 38
                 ? \substr($exception->getFile(), \strlen($rootDir) + 1)
37 39
                 : $exception->getFile();
@@ -44,9 +46,12 @@  discard block
 block discarded – undo
44 46
                 $exception->getLine(),
45 47
             );
46 48
 
47
-            if ($verbosity->value >= Verbosity::DEBUG->value) {
49
+            if ($verbosity->value >= Verbosity::DEBUG->value)
50
+            {
48 51
                 $row .= $this->renderTrace($exception, new Highlighter(new PlainStyle()));
49
-            } elseif ($verbosity->value >= Verbosity::VERBOSE->value) {
52
+            }
53
+            elseif ($verbosity->value >= Verbosity::VERBOSE->value)
54
+            {
50 55
                 $row .= $this->renderTrace($exception);
51 56
             }
52 57
 
@@ -64,7 +69,8 @@  discard block
 block discarded – undo
64 69
     private function renderTrace(\Throwable $e, Highlighter $h = null): string
65 70
     {
66 71
         $stacktrace = $this->getStacktrace($e);
67
-        if ($stacktrace === []) {
72
+        if ($stacktrace === [])
73
+        {
68 74
             return '';
69 75
         }
70 76
 
@@ -73,8 +79,10 @@  discard block
 block discarded – undo
73 79
 
74 80
         $pad = \strlen((string)\count($stacktrace));
75 81
 
76
-        foreach ($stacktrace as $i => $trace) {
77
-            if (isset($trace['type'], $trace['class'])) {
82
+        foreach ($stacktrace as $i => $trace)
83
+        {
84
+            if (isset($trace['type'], $trace['class']))
85
+            {
78 86
                 $line = \sprintf(
79 87
                     '%s. %s%s%s()',
80 88
                     \str_pad((string)((int) $i + 1), $pad, ' ', \STR_PAD_LEFT),
@@ -82,11 +90,14 @@  discard block
 block discarded – undo
82 90
                     $trace['type'],
83 91
                     $trace['function']
84 92
                 );
85
-            } else {
93
+            }
94
+            else
95
+            {
86 96
                 $line = $trace['function'];
87 97
             }
88 98
 
89
-            if (isset($trace['file'])) {
99
+            if (isset($trace['file']))
100
+            {
90 101
                 $file = \str_starts_with($trace['file'], $rootDir)
91 102
                     ? \substr($trace['file'], \strlen($rootDir) + 1)
92 103
                     : $trace['file'];
@@ -94,7 +105,8 @@  discard block
 block discarded – undo
94 105
                 $line .= \sprintf(' at %s:%s', $file, $trace['line']);
95 106
             }
96 107
 
97
-            if (\in_array($line, $this->lines, true)) {
108
+            if (\in_array($line, $this->lines, true))
109
+            {
98 110
                 continue;
99 111
             }
100 112
 
@@ -102,7 +114,8 @@  discard block
 block discarded – undo
102 114
 
103 115
             $result .= $line . "\n";
104 116
 
105
-            if ($h !== null && !empty($trace['file'])) {
117
+            if ($h !== null && !empty($trace['file']))
118
+            {
106 119
                 $result .= $h->highlightLines(
107 120
                     \file_get_contents($trace['file']),
108 121
                     $trace['line'],
Please login to merge, or discard this patch.
src/Exceptions/src/Renderer/ConsoleRenderer.php 2 patches
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
         $exceptions = [$exception];
69 69
         $currentE = $exception;
70 70
 
71
-        while ($exception = $exception->getPrevious()) {
71
+        while ($exception = $exception->getPrevious()){
72 72
             $exceptions[] = $exception;
73 73
         }
74 74
 
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
                 $exception->getLine()
96 96
             );
97 97
 
98
-            if ($verbosity->value >= Verbosity::DEBUG->value) {
98
+            if ($verbosity->value >= Verbosity::DEBUG->value){
99 99
                 $row .= $this->renderTrace(
100 100
                     $exception,
101 101
                     new Highlighter(
102 102
                         $this->colorsSupport ? new ConsoleStyle() : new PlainStyle()
103 103
                     )
104 104
                 );
105
-            } elseif ($verbosity->value >= Verbosity::VERBOSE->value) {
105
+            } elseif ($verbosity->value >= Verbosity::VERBOSE->value){
106 106
                 $row .= $this->renderTrace($exception);
107 107
             }
108 108
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
         $length += $padding;
135 135
 
136
-        foreach ($lines as $line) {
136
+        foreach ($lines as $line){
137 137
             $result .= $this->format(
138 138
                 "<{$style}>%s%s%s</reset>\n",
139 139
                 \str_repeat('', $padding + 1),
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
     private function renderTrace(\Throwable $e, Highlighter $h = null): string
152 152
     {
153 153
         $stacktrace = $this->getStacktrace($e);
154
-        if (empty($stacktrace)) {
154
+        if (empty($stacktrace)){
155 155
             return '';
156 156
         }
157 157
 
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 
161 161
         $pad = \strlen((string)\count($stacktrace));
162 162
 
163
-        foreach ($stacktrace as $i => $trace) {
163
+        foreach ($stacktrace as $i => $trace){
164 164
             $file = null;
165 165
             $classColor = 'while';
166 166
 
167
-            if (isset($trace['file'])) {
167
+            if (isset($trace['file'])){
168 168
                 $file = \str_starts_with($trace['file'], $rootDir)
169 169
                     ? \substr($trace['file'], \strlen($rootDir) + 1)
170 170
                     : $trace['file'];
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                 $classColor = \str_starts_with($file, 'vendor/') ? 'gray' : 'white';
173 173
             }
174 174
 
175
-            if (isset($trace['type'], $trace['class'])) {
175
+            if (isset($trace['type'], $trace['class'])){
176 176
                 $line = $this->format(
177 177
                     "<$classColor>%s.</reset> <white>%s%s%s()</reset>",
178 178
                     \str_pad((string)($i + 1), $pad, ' ', \STR_PAD_LEFT),
@@ -180,13 +180,13 @@  discard block
 block discarded – undo
180 180
                     $trace['type'],
181 181
                     $trace['function']
182 182
                 );
183
-            } else {
183
+            }else{
184 184
                 $line = $this->format(
185 185
                     ' <white>%s()</reset>',
186 186
                     $trace['function']
187 187
                 );
188 188
             }
189
-            if ($file !== null) {
189
+            if ($file !== null){
190 190
                 $line .= $this->format(
191 191
                     " <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>",
192 192
                     $file,
@@ -194,20 +194,20 @@  discard block
 block discarded – undo
194 194
                 );
195 195
             }
196 196
 
197
-            if (\in_array($line, $this->lines, true)) {
197
+            if (\in_array($line, $this->lines, true)){
198 198
                 continue;
199 199
             }
200 200
 
201 201
             $this->lines[] = $line;
202 202
 
203
-            $result .= $line . "\n";
203
+            $result .= $line."\n";
204 204
 
205
-            if ($h !== null && !empty($trace['file'])) {
205
+            if ($h !== null && !empty($trace['file'])){
206 206
                 $result .= $h->highlightLines(
207 207
                         \file_get_contents($trace['file']),
208 208
                         $trace['line'],
209 209
                         static::SHOW_LINES
210
-                    ) . "\n";
210
+                    )."\n";
211 211
             }
212 212
         }
213 213
 
@@ -219,13 +219,13 @@  discard block
 block discarded – undo
219 219
      */
220 220
     private function format(string $format, mixed ...$args): string
221 221
     {
222
-        if (!$this->colorsSupport) {
222
+        if (!$this->colorsSupport){
223 223
             $format = \preg_replace('/<[^>]+>/', '', $format);
224
-        } else {
225
-            $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) {
224
+        }else{
225
+            $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial){
226 226
                 $style = '';
227
-                foreach (\explode(',', \trim($partial[2], '/')) as $color) {
228
-                    if (isset(self::COLORS[$color])) {
227
+                foreach (\explode(',', \trim($partial[2], '/')) as $color){
228
+                    if (isset(self::COLORS[$color])){
229 229
                         $style .= self::COLORS[$color];
230 230
                     }
231 231
                 }
@@ -244,12 +244,12 @@  discard block
 block discarded – undo
244 244
      */
245 245
     private function isColorsSupported(mixed $stream = STDOUT): bool
246 246
     {
247
-        if ('Hyper' === \getenv('TERM_PROGRAM')) {
247
+        if ('Hyper' === \getenv('TERM_PROGRAM')){
248 248
             return true;
249 249
         }
250 250
 
251
-        try {
252
-            if (\DIRECTORY_SEPARATOR === '\\') {
251
+        try{
252
+            if (\DIRECTORY_SEPARATOR === '\\'){
253 253
                 return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream))
254 254
                     || \getenv('ANSICON') !== false
255 255
                     || \getenv('ConEmuANSI') === 'ON'
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
             }
258 258
 
259 259
             return @\stream_isatty($stream);
260
-        } catch (\Throwable) {
260
+        }catch (\Throwable){
261 261
             return false;
262 262
         }
263 263
     }
Please login to merge, or discard this patch.
Braces   +46 added lines, -21 removed lines patch added patch discarded remove patch
@@ -68,7 +68,8 @@  discard block
 block discarded – undo
68 68
         $exceptions = [$exception];
69 69
         $currentE = $exception;
70 70
 
71
-        while ($exception = $exception->getPrevious()) {
71
+        while ($exception = $exception->getPrevious())
72
+        {
72 73
             $exceptions[] = $exception;
73 74
         }
74 75
 
@@ -95,14 +96,17 @@  discard block
 block discarded – undo
95 96
                 $exception->getLine()
96 97
             );
97 98
 
98
-            if ($verbosity->value >= Verbosity::DEBUG->value) {
99
+            if ($verbosity->value >= Verbosity::DEBUG->value)
100
+            {
99 101
                 $row .= $this->renderTrace(
100 102
                     $exception,
101 103
                     new Highlighter(
102 104
                         $this->colorsSupport ? new ConsoleStyle() : new PlainStyle()
103 105
                     )
104 106
                 );
105
-            } elseif ($verbosity->value >= Verbosity::VERBOSE->value) {
107
+            }
108
+            elseif ($verbosity->value >= Verbosity::VERBOSE->value)
109
+            {
106 110
                 $row .= $this->renderTrace($exception);
107 111
             }
108 112
 
@@ -133,7 +137,8 @@  discard block
 block discarded – undo
133 137
 
134 138
         $length += $padding;
135 139
 
136
-        foreach ($lines as $line) {
140
+        foreach ($lines as $line)
141
+        {
137 142
             $result .= $this->format(
138 143
                 "<{$style}>%s%s%s</reset>\n",
139 144
                 \str_repeat('', $padding + 1),
@@ -151,7 +156,8 @@  discard block
 block discarded – undo
151 156
     private function renderTrace(\Throwable $e, Highlighter $h = null): string
152 157
     {
153 158
         $stacktrace = $this->getStacktrace($e);
154
-        if (empty($stacktrace)) {
159
+        if (empty($stacktrace))
160
+        {
155 161
             return '';
156 162
         }
157 163
 
@@ -160,11 +166,13 @@  discard block
 block discarded – undo
160 166
 
161 167
         $pad = \strlen((string)\count($stacktrace));
162 168
 
163
-        foreach ($stacktrace as $i => $trace) {
169
+        foreach ($stacktrace as $i => $trace)
170
+        {
164 171
             $file = null;
165 172
             $classColor = 'while';
166 173
 
167
-            if (isset($trace['file'])) {
174
+            if (isset($trace['file']))
175
+            {
168 176
                 $file = \str_starts_with($trace['file'], $rootDir)
169 177
                     ? \substr($trace['file'], \strlen($rootDir) + 1)
170 178
                     : $trace['file'];
@@ -172,7 +180,8 @@  discard block
 block discarded – undo
172 180
                 $classColor = \str_starts_with($file, 'vendor/') ? 'gray' : 'white';
173 181
             }
174 182
 
175
-            if (isset($trace['type'], $trace['class'])) {
183
+            if (isset($trace['type'], $trace['class']))
184
+            {
176 185
                 $line = $this->format(
177 186
                     "<$classColor>%s.</reset> <white>%s%s%s()</reset>",
178 187
                     \str_pad((string)($i + 1), $pad, ' ', \STR_PAD_LEFT),
@@ -180,13 +189,16 @@  discard block
 block discarded – undo
180 189
                     $trace['type'],
181 190
                     $trace['function']
182 191
                 );
183
-            } else {
192
+            }
193
+            else
194
+            {
184 195
                 $line = $this->format(
185 196
                     ' <white>%s()</reset>',
186 197
                     $trace['function']
187 198
                 );
188 199
             }
189
-            if ($file !== null) {
200
+            if ($file !== null)
201
+            {
190 202
                 $line .= $this->format(
191 203
                     " <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>",
192 204
                     $file,
@@ -194,7 +206,8 @@  discard block
 block discarded – undo
194 206
                 );
195 207
             }
196 208
 
197
-            if (\in_array($line, $this->lines, true)) {
209
+            if (\in_array($line, $this->lines, true))
210
+            {
198 211
                 continue;
199 212
             }
200 213
 
@@ -202,7 +215,8 @@  discard block
 block discarded – undo
202 215
 
203 216
             $result .= $line . "\n";
204 217
 
205
-            if ($h !== null && !empty($trace['file'])) {
218
+            if ($h !== null && !empty($trace['file']))
219
+            {
206 220
                 $result .= $h->highlightLines(
207 221
                         \file_get_contents($trace['file']),
208 222
                         $trace['line'],
@@ -219,13 +233,19 @@  discard block
 block discarded – undo
219 233
      */
220 234
     private function format(string $format, mixed ...$args): string
221 235
     {
222
-        if (!$this->colorsSupport) {
236
+        if (!$this->colorsSupport)
237
+        {
223 238
             $format = \preg_replace('/<[^>]+>/', '', $format);
224
-        } else {
225
-            $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) {
239
+        }
240
+        else
241
+        {
242
+            $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial)
243
+            {
226 244
                 $style = '';
227
-                foreach (\explode(',', \trim($partial[2], '/')) as $color) {
228
-                    if (isset(self::COLORS[$color])) {
245
+                foreach (\explode(',', \trim($partial[2], '/')) as $color)
246
+                {
247
+                    if (isset(self::COLORS[$color]))
248
+                    {
229 249
                         $style .= self::COLORS[$color];
230 250
                     }
231 251
                 }
@@ -244,12 +264,15 @@  discard block
 block discarded – undo
244 264
      */
245 265
     private function isColorsSupported(mixed $stream = STDOUT): bool
246 266
     {
247
-        if ('Hyper' === \getenv('TERM_PROGRAM')) {
267
+        if ('Hyper' === \getenv('TERM_PROGRAM'))
268
+        {
248 269
             return true;
249 270
         }
250 271
 
251
-        try {
252
-            if (\DIRECTORY_SEPARATOR === '\\') {
272
+        try
273
+        {
274
+            if (\DIRECTORY_SEPARATOR === '\\')
275
+            {
253 276
                 return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream))
254 277
                     || \getenv('ANSICON') !== false
255 278
                     || \getenv('ConEmuANSI') === 'ON'
@@ -257,7 +280,9 @@  discard block
 block discarded – undo
257 280
             }
258 281
 
259 282
             return @\stream_isatty($stream);
260
-        } catch (\Throwable) {
283
+        }
284
+        catch (\Throwable)
285
+        {
261 286
             return false;
262 287
         }
263 288
     }
Please login to merge, or discard this patch.