@@ -22,7 +22,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 | } |
@@ -22,7 +22,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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'], |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | $verbosity ??= $this->defaultVerbosity; |
66 | 66 | |
67 | 67 | $exceptions = [$exception]; |
68 | - while ($exception = $exception->getPrevious()) { |
|
68 | + while ($exception = $exception->getPrevious()){ |
|
69 | 69 | $exceptions[] = $exception; |
70 | 70 | } |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | $result = []; |
75 | 75 | $rootDir = \getcwd(); |
76 | 76 | |
77 | - foreach ($exceptions as $exception) { |
|
77 | + foreach ($exceptions as $exception){ |
|
78 | 78 | $row = $this->renderHeader( |
79 | 79 | \sprintf("[%s]\n%s", $exception::class, $exception->getMessage()), |
80 | 80 | $exception instanceof \Error ? 'bg:magenta,white' : 'bg:red,white' |
@@ -90,11 +90,11 @@ discard block |
||
90 | 90 | $exception->getLine() |
91 | 91 | ); |
92 | 92 | |
93 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
93 | + if ($verbosity->value >= Verbosity::DEBUG->value){ |
|
94 | 94 | $row .= $this->renderTrace($exception, new Highlighter( |
95 | 95 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle() |
96 | 96 | )); |
97 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
97 | + } elseif ($verbosity->value >= Verbosity::VERBOSE->value){ |
|
98 | 98 | $row .= $this->renderTrace($exception); |
99 | 99 | } |
100 | 100 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | |
126 | 126 | $length += $padding; |
127 | 127 | |
128 | - foreach ($lines as $line) { |
|
128 | + foreach ($lines as $line){ |
|
129 | 129 | $result .= $this->format( |
130 | 130 | "<{$style}>%s%s%s</reset>\n", |
131 | 131 | \str_repeat('', $padding + 1), |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
144 | 144 | { |
145 | 145 | $stacktrace = $this->getStacktrace($e); |
146 | - if (empty($stacktrace)) { |
|
146 | + if (empty($stacktrace)){ |
|
147 | 147 | return ''; |
148 | 148 | } |
149 | 149 | |
@@ -152,23 +152,23 @@ discard block |
||
152 | 152 | |
153 | 153 | $pad = \strlen((string)\count($stacktrace)); |
154 | 154 | |
155 | - foreach ($stacktrace as $i => $trace) { |
|
156 | - if (isset($trace['type'], $trace['class'])) { |
|
155 | + foreach ($stacktrace as $i => $trace){ |
|
156 | + if (isset($trace['type'], $trace['class'])){ |
|
157 | 157 | $line = $this->format( |
158 | 158 | ' <white>%s. %s%s%s()</reset>', |
159 | - \str_pad((string)((int) $i + 1), $pad, ' ', \STR_PAD_LEFT), |
|
159 | + \str_pad((string)((int)$i + 1), $pad, ' ', \STR_PAD_LEFT), |
|
160 | 160 | $trace['class'], |
161 | 161 | $trace['type'], |
162 | 162 | $trace['function'] |
163 | 163 | ); |
164 | - } else { |
|
164 | + }else{ |
|
165 | 165 | $line = $this->format( |
166 | 166 | ' <white>%s()</reset>', |
167 | 167 | $trace['function'] |
168 | 168 | ); |
169 | 169 | } |
170 | 170 | |
171 | - if (isset($trace['file'])) { |
|
171 | + if (isset($trace['file'])){ |
|
172 | 172 | $file = \str_starts_with($trace['file'], $rootDir) |
173 | 173 | ? \substr($trace['file'], \strlen($rootDir) + 1) |
174 | 174 | : $trace['file']; |
@@ -180,18 +180,18 @@ discard block |
||
180 | 180 | ); |
181 | 181 | } |
182 | 182 | |
183 | - if (\in_array($line, $this->lines, true)) { |
|
183 | + if (\in_array($line, $this->lines, true)){ |
|
184 | 184 | continue; |
185 | 185 | } |
186 | 186 | |
187 | - $result .= $line . "\n"; |
|
187 | + $result .= $line."\n"; |
|
188 | 188 | |
189 | - if ($h !== null && !empty($trace['file'])) { |
|
189 | + if ($h !== null && !empty($trace['file'])){ |
|
190 | 190 | $result .= $h->highlightLines( |
191 | 191 | \file_get_contents($trace['file']), |
192 | 192 | $trace['line'], |
193 | 193 | static::SHOW_LINES |
194 | - ) . "\n"; |
|
194 | + )."\n"; |
|
195 | 195 | } |
196 | 196 | } |
197 | 197 | |
@@ -203,13 +203,13 @@ discard block |
||
203 | 203 | */ |
204 | 204 | private function format(string $format, mixed ...$args): string |
205 | 205 | { |
206 | - if (!$this->colorsSupport) { |
|
206 | + if (!$this->colorsSupport){ |
|
207 | 207 | $format = \preg_replace('/<[^>]+>/', '', $format); |
208 | - } else { |
|
209 | - $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) { |
|
208 | + }else{ |
|
209 | + $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial){ |
|
210 | 210 | $style = ''; |
211 | - foreach (\explode(',', \trim($partial[2], '/')) as $color) { |
|
212 | - if (isset(self::COLORS[$color])) { |
|
211 | + foreach (\explode(',', \trim($partial[2], '/')) as $color){ |
|
212 | + if (isset(self::COLORS[$color])){ |
|
213 | 213 | $style .= self::COLORS[$color]; |
214 | 214 | } |
215 | 215 | } |
@@ -228,12 +228,12 @@ discard block |
||
228 | 228 | */ |
229 | 229 | private function isColorsSupported(mixed $stream = STDOUT): bool |
230 | 230 | { |
231 | - if ('Hyper' === \getenv('TERM_PROGRAM')) { |
|
231 | + if ('Hyper' === \getenv('TERM_PROGRAM')){ |
|
232 | 232 | return true; |
233 | 233 | } |
234 | 234 | |
235 | - try { |
|
236 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
235 | + try{ |
|
236 | + if (\DIRECTORY_SEPARATOR === '\\'){ |
|
237 | 237 | return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream)) |
238 | 238 | || \getenv('ANSICON') !== false |
239 | 239 | || \getenv('ConEmuANSI') === 'ON' |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | } |
242 | 242 | |
243 | 243 | return @\stream_isatty($stream); |
244 | - } catch (\Throwable) { |
|
244 | + }catch (\Throwable){ |
|
245 | 245 | return false; |
246 | 246 | } |
247 | 247 | } |
@@ -65,7 +65,8 @@ discard block |
||
65 | 65 | $verbosity ??= $this->defaultVerbosity; |
66 | 66 | |
67 | 67 | $exceptions = [$exception]; |
68 | - while ($exception = $exception->getPrevious()) { |
|
68 | + while ($exception = $exception->getPrevious()) |
|
69 | + { |
|
69 | 70 | $exceptions[] = $exception; |
70 | 71 | } |
71 | 72 | |
@@ -74,7 +75,8 @@ discard block |
||
74 | 75 | $result = []; |
75 | 76 | $rootDir = \getcwd(); |
76 | 77 | |
77 | - foreach ($exceptions as $exception) { |
|
78 | + foreach ($exceptions as $exception) |
|
79 | + { |
|
78 | 80 | $row = $this->renderHeader( |
79 | 81 | \sprintf("[%s]\n%s", $exception::class, $exception->getMessage()), |
80 | 82 | $exception instanceof \Error ? 'bg:magenta,white' : 'bg:red,white' |
@@ -90,11 +92,14 @@ discard block |
||
90 | 92 | $exception->getLine() |
91 | 93 | ); |
92 | 94 | |
93 | - if ($verbosity->value >= Verbosity::DEBUG->value) { |
|
95 | + if ($verbosity->value >= Verbosity::DEBUG->value) |
|
96 | + { |
|
94 | 97 | $row .= $this->renderTrace($exception, new Highlighter( |
95 | 98 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle() |
96 | 99 | )); |
97 | - } elseif ($verbosity->value >= Verbosity::VERBOSE->value) { |
|
100 | + } |
|
101 | + elseif ($verbosity->value >= Verbosity::VERBOSE->value) |
|
102 | + { |
|
98 | 103 | $row .= $this->renderTrace($exception); |
99 | 104 | } |
100 | 105 | |
@@ -125,7 +130,8 @@ discard block |
||
125 | 130 | |
126 | 131 | $length += $padding; |
127 | 132 | |
128 | - foreach ($lines as $line) { |
|
133 | + foreach ($lines as $line) |
|
134 | + { |
|
129 | 135 | $result .= $this->format( |
130 | 136 | "<{$style}>%s%s%s</reset>\n", |
131 | 137 | \str_repeat('', $padding + 1), |
@@ -143,7 +149,8 @@ discard block |
||
143 | 149 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
144 | 150 | { |
145 | 151 | $stacktrace = $this->getStacktrace($e); |
146 | - if (empty($stacktrace)) { |
|
152 | + if (empty($stacktrace)) |
|
153 | + { |
|
147 | 154 | return ''; |
148 | 155 | } |
149 | 156 | |
@@ -152,8 +159,10 @@ discard block |
||
152 | 159 | |
153 | 160 | $pad = \strlen((string)\count($stacktrace)); |
154 | 161 | |
155 | - foreach ($stacktrace as $i => $trace) { |
|
156 | - if (isset($trace['type'], $trace['class'])) { |
|
162 | + foreach ($stacktrace as $i => $trace) |
|
163 | + { |
|
164 | + if (isset($trace['type'], $trace['class'])) |
|
165 | + { |
|
157 | 166 | $line = $this->format( |
158 | 167 | ' <white>%s. %s%s%s()</reset>', |
159 | 168 | \str_pad((string)((int) $i + 1), $pad, ' ', \STR_PAD_LEFT), |
@@ -161,14 +170,17 @@ discard block |
||
161 | 170 | $trace['type'], |
162 | 171 | $trace['function'] |
163 | 172 | ); |
164 | - } else { |
|
173 | + } |
|
174 | + else |
|
175 | + { |
|
165 | 176 | $line = $this->format( |
166 | 177 | ' <white>%s()</reset>', |
167 | 178 | $trace['function'] |
168 | 179 | ); |
169 | 180 | } |
170 | 181 | |
171 | - if (isset($trace['file'])) { |
|
182 | + if (isset($trace['file'])) |
|
183 | + { |
|
172 | 184 | $file = \str_starts_with($trace['file'], $rootDir) |
173 | 185 | ? \substr($trace['file'], \strlen($rootDir) + 1) |
174 | 186 | : $trace['file']; |
@@ -180,13 +192,15 @@ discard block |
||
180 | 192 | ); |
181 | 193 | } |
182 | 194 | |
183 | - if (\in_array($line, $this->lines, true)) { |
|
195 | + if (\in_array($line, $this->lines, true)) |
|
196 | + { |
|
184 | 197 | continue; |
185 | 198 | } |
186 | 199 | |
187 | 200 | $result .= $line . "\n"; |
188 | 201 | |
189 | - if ($h !== null && !empty($trace['file'])) { |
|
202 | + if ($h !== null && !empty($trace['file'])) |
|
203 | + { |
|
190 | 204 | $result .= $h->highlightLines( |
191 | 205 | \file_get_contents($trace['file']), |
192 | 206 | $trace['line'], |
@@ -203,13 +217,19 @@ discard block |
||
203 | 217 | */ |
204 | 218 | private function format(string $format, mixed ...$args): string |
205 | 219 | { |
206 | - if (!$this->colorsSupport) { |
|
220 | + if (!$this->colorsSupport) |
|
221 | + { |
|
207 | 222 | $format = \preg_replace('/<[^>]+>/', '', $format); |
208 | - } else { |
|
209 | - $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) { |
|
223 | + } |
|
224 | + else |
|
225 | + { |
|
226 | + $format = \preg_replace_callback('/(<([^>]+)>)/', static function ($partial) |
|
227 | + { |
|
210 | 228 | $style = ''; |
211 | - foreach (\explode(',', \trim($partial[2], '/')) as $color) { |
|
212 | - if (isset(self::COLORS[$color])) { |
|
229 | + foreach (\explode(',', \trim($partial[2], '/')) as $color) |
|
230 | + { |
|
231 | + if (isset(self::COLORS[$color])) |
|
232 | + { |
|
213 | 233 | $style .= self::COLORS[$color]; |
214 | 234 | } |
215 | 235 | } |
@@ -228,12 +248,15 @@ discard block |
||
228 | 248 | */ |
229 | 249 | private function isColorsSupported(mixed $stream = STDOUT): bool |
230 | 250 | { |
231 | - if ('Hyper' === \getenv('TERM_PROGRAM')) { |
|
251 | + if ('Hyper' === \getenv('TERM_PROGRAM')) |
|
252 | + { |
|
232 | 253 | return true; |
233 | 254 | } |
234 | 255 | |
235 | - try { |
|
236 | - if (\DIRECTORY_SEPARATOR === '\\') { |
|
256 | + try |
|
257 | + { |
|
258 | + if (\DIRECTORY_SEPARATOR === '\\') |
|
259 | + { |
|
237 | 260 | return (\function_exists('sapi_windows_vt100_support') && @\sapi_windows_vt100_support($stream)) |
238 | 261 | || \getenv('ANSICON') !== false |
239 | 262 | || \getenv('ConEmuANSI') === 'ON' |
@@ -241,7 +264,9 @@ discard block |
||
241 | 264 | } |
242 | 265 | |
243 | 266 | return @\stream_isatty($stream); |
244 | - } catch (\Throwable) { |
|
267 | + } |
|
268 | + catch (\Throwable) |
|
269 | + { |
|
245 | 270 | return false; |
246 | 271 | } |
247 | 272 | } |