@@ -47,7 +47,7 @@ |
||
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | <?php |
50 | - foreach ($valueWrapper->getValues() as $id => $content) { |
|
50 | + foreach ($valueWrapper->getValues() as $id => $content){ |
|
51 | 51 | echo "<div id=\"argument-{$id}\" style=\"display: none\">{$content}</div>"; |
52 | 52 | } |
53 | 53 | ?> |
@@ -47,7 +47,8 @@ |
||
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | <?php |
50 | - foreach ($valueWrapper->getValues() as $id => $content) { |
|
50 | + foreach ($valueWrapper->getValues() as $id => $content) |
|
51 | + { |
|
51 | 52 | echo "<div id=\"argument-{$id}\" style=\"display: none\">{$content}</div>"; |
52 | 53 | } |
53 | 54 | ?> |
@@ -1,7 +1,7 @@ |
||
1 | 1 | <div class="tags"> |
2 | 2 | <div class="container"> |
3 | 3 | <?php |
4 | - foreach ($tags as $tag => $value) { |
|
4 | + foreach ($tags as $tag => $value){ |
|
5 | 5 | echo sprintf( |
6 | 6 | '<div class="tag"><div class="name">%s</div><div class="value">%s</div></div>', |
7 | 7 | $tag, |
@@ -1,7 +1,8 @@ |
||
1 | 1 | <div class="tags"> |
2 | 2 | <div class="container"> |
3 | 3 | <?php |
4 | - foreach ($tags as $tag => $value) { |
|
4 | + foreach ($tags as $tag => $value) |
|
5 | + { |
|
5 | 6 | echo sprintf( |
6 | 7 | '<div class="tag"><div class="name">%s</div><div class="value">%s</div></div>', |
7 | 8 | $tag, |
@@ -5,7 +5,7 @@ |
||
5 | 5 | <table> |
6 | 6 | <?php |
7 | 7 | /** @var \Spiral\Logger\Event\LogEvent $log */ |
8 | - foreach ($logEvents as $log) { |
|
8 | + foreach ($logEvents as $log){ |
|
9 | 9 | echo sprintf( |
10 | 10 | '<tr><td class="channel">%s</td><td class="message">%s</td></tr>', |
11 | 11 | $log->getChannel(), |
@@ -5,7 +5,8 @@ |
||
5 | 5 | <table> |
6 | 6 | <?php |
7 | 7 | /** @var \Spiral\Logger\Event\LogEvent $log */ |
8 | - foreach ($logEvents as $log) { |
|
8 | + foreach ($logEvents as $log) |
|
9 | + { |
|
9 | 10 | echo sprintf( |
10 | 11 | '<tr><td class="channel">%s</td><td class="message">%s</td></tr>', |
11 | 12 | $log->getChannel(), |
@@ -6,12 +6,12 @@ |
||
6 | 6 | </div> |
7 | 7 | <div class="dump" id="<?= md5($name) ?>-variables" style="display: none;"> |
8 | 8 | <?php |
9 | - if (!is_array($content)) { |
|
9 | + if (!is_array($content)){ |
|
10 | 10 | echo is_scalar($value) ? htmlspecialchars($value) : json_encode($value, JSON_PRETTY_PRINT); |
11 | - } else { ?> |
|
11 | + }else{ ?> |
|
12 | 12 | <table> |
13 | 13 | <?php |
14 | - foreach ($content as $key => $value) { |
|
14 | + foreach ($content as $key => $value){ |
|
15 | 15 | // todo: values |
16 | 16 | echo sprintf( |
17 | 17 | '<tr><td class="name">%s</td><td>%s</td></tr>', |
@@ -6,12 +6,17 @@ |
||
6 | 6 | </div> |
7 | 7 | <div class="dump" id="<?= md5($name) ?>-variables" style="display: none;"> |
8 | 8 | <?php |
9 | - if (!is_array($content)) { |
|
9 | + if (!is_array($content)) |
|
10 | + { |
|
10 | 11 | echo is_scalar($value) ? htmlspecialchars($value) : json_encode($value, JSON_PRETTY_PRINT); |
11 | - } else { ?> |
|
12 | + } |
|
13 | + else |
|
14 | + { |
|
15 | +?> |
|
12 | 16 | <table> |
13 | 17 | <?php |
14 | - foreach ($content as $key => $value) { |
|
18 | + foreach ($content as $key => $value) |
|
19 | + { |
|
15 | 20 | // todo: values |
16 | 21 | echo sprintf( |
17 | 22 | '<tr><td class="name">%s</td><td>%s</td></tr>', |
@@ -4,23 +4,23 @@ discard block |
||
4 | 4 | * @var Throwable $exception |
5 | 5 | * @var \Spiral\Exceptions\ValueWrapper $valueWrapper |
6 | 6 | */ |
7 | -foreach ($stacktrace as $index => $trace) { |
|
8 | - if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])) { |
|
7 | +foreach ($stacktrace as $index => $trace){ |
|
8 | + if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])){ |
|
9 | 9 | $trace['file'] = $stacktrace[$index - 1]['file']; |
10 | 10 | $trace['line'] = $stacktrace[$index - 1]['line']; |
11 | 11 | } |
12 | 12 | |
13 | - if (!isset($stacktrace[$index + 1])) { |
|
13 | + if (!isset($stacktrace[$index + 1])){ |
|
14 | 14 | $trace['file'] = $exception->getFile(); |
15 | 15 | $trace['line'] = $exception->getLine(); |
16 | 16 | } |
17 | 17 | |
18 | - if (!isset($trace['function']) || !isset($trace['file'])) { |
|
18 | + if (!isset($trace['function']) || !isset($trace['file'])){ |
|
19 | 19 | continue; |
20 | 20 | } |
21 | 21 | |
22 | - $function = '<strong>' . $trace['function'] . '</strong>'; |
|
23 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
22 | + $function = '<strong>'.$trace['function'].'</strong>'; |
|
23 | + if (isset($trace['type']) && isset($trace['class'])){ |
|
24 | 24 | $reflection = new ReflectionClass($trace['class']); |
25 | 25 | $function = sprintf( |
26 | 26 | '<span title="%s">%s</span>%s%s', |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | } |
33 | 33 | |
34 | 34 | $args = []; |
35 | - if (isset($trace['args'])) { |
|
35 | + if (isset($trace['args'])){ |
|
36 | 36 | $args = $valueWrapper->wrap($trace['args']); |
37 | 37 | } ?> |
38 | 38 | <div class="call"> |
@@ -4,23 +4,28 @@ discard block |
||
4 | 4 | * @var Throwable $exception |
5 | 5 | * @var \Spiral\Exceptions\ValueWrapper $valueWrapper |
6 | 6 | */ |
7 | -foreach ($stacktrace as $index => $trace) { |
|
8 | - if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])) { |
|
7 | +foreach ($stacktrace as $index => $trace) |
|
8 | +{ |
|
9 | + if (empty($trace['file']) && isset($stacktrace[$index - 1]['file'])) |
|
10 | + { |
|
9 | 11 | $trace['file'] = $stacktrace[$index - 1]['file']; |
10 | 12 | $trace['line'] = $stacktrace[$index - 1]['line']; |
11 | 13 | } |
12 | 14 | |
13 | - if (!isset($stacktrace[$index + 1])) { |
|
15 | + if (!isset($stacktrace[$index + 1])) |
|
16 | + { |
|
14 | 17 | $trace['file'] = $exception->getFile(); |
15 | 18 | $trace['line'] = $exception->getLine(); |
16 | 19 | } |
17 | 20 | |
18 | - if (!isset($trace['function']) || !isset($trace['file'])) { |
|
21 | + if (!isset($trace['function']) || !isset($trace['file'])) |
|
22 | + { |
|
19 | 23 | continue; |
20 | 24 | } |
21 | 25 | |
22 | 26 | $function = '<strong>' . $trace['function'] . '</strong>'; |
23 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
27 | + if (isset($trace['type']) && isset($trace['class'])) |
|
28 | + { |
|
24 | 29 | $reflection = new ReflectionClass($trace['class']); |
25 | 30 | $function = sprintf( |
26 | 31 | '<span title="%s">%s</span>%s%s', |
@@ -32,7 +37,8 @@ discard block |
||
32 | 37 | } |
33 | 38 | |
34 | 39 | $args = []; |
35 | - if (isset($trace['args'])) { |
|
40 | + if (isset($trace['args'])) |
|
41 | + { |
|
36 | 42 | $args = $valueWrapper->wrap($trace['args']); |
37 | 43 | } ?> |
38 | 44 | <div class="call"> |
@@ -99,12 +99,14 @@ discard block |
||
99 | 99 | { |
100 | 100 | $style = $this->getStyle($token, $previous); |
101 | 101 | |
102 | - if (strpos($token[1], "\n") === false) { |
|
102 | + if (strpos($token[1], "\n") === false) |
|
103 | + { |
|
103 | 104 | return sprintf($this->templates['token'], $style, $token[1]); |
104 | 105 | } |
105 | 106 | |
106 | 107 | $lines = []; |
107 | - foreach (explode("\n", $token[1]) as $line) { |
|
108 | + foreach (explode("\n", $token[1]) as $line) |
|
109 | + { |
|
108 | 110 | $lines[] = sprintf($this->templates['token'], $style, $line); |
109 | 111 | } |
110 | 112 | |
@@ -132,16 +134,21 @@ discard block |
||
132 | 134 | */ |
133 | 135 | private function getStyle(array $token, array $previous): string |
134 | 136 | { |
135 | - if (!empty($previous)) { |
|
136 | - foreach ($this->style as $style => $tokens) { |
|
137 | - if (in_array($previous[1] . $token[0], $tokens)) { |
|
137 | + if (!empty($previous)) |
|
138 | + { |
|
139 | + foreach ($this->style as $style => $tokens) |
|
140 | + { |
|
141 | + if (in_array($previous[1] . $token[0], $tokens)) |
|
142 | + { |
|
138 | 143 | return $style; |
139 | 144 | } |
140 | 145 | } |
141 | 146 | } |
142 | 147 | |
143 | - foreach ($this->style as $style => $tokens) { |
|
144 | - if (in_array($token[0], $tokens)) { |
|
148 | + foreach ($this->style as $style => $tokens) |
|
149 | + { |
|
150 | + if (in_array($token[0], $tokens)) |
|
151 | + { |
|
145 | 152 | return $style; |
146 | 153 | } |
147 | 154 | } |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | { |
22 | 22 | /** @var array */ |
23 | 23 | protected $templates = [ |
24 | - 'token' => '%s%s' . Color::RESET, |
|
25 | - 'line' => Color::LIGHT_CYAN . ' %s ' . Color::RESET . " %s\n", |
|
26 | - 'active' => Color::BG_RED . ' ' . Color::LIGHT_WHITE . '%s ' . Color::RESET . " %s\n", |
|
24 | + 'token' => '%s%s'.Color::RESET, |
|
25 | + 'line' => Color::LIGHT_CYAN.' %s '.Color::RESET." %s\n", |
|
26 | + 'active' => Color::BG_RED.' '.Color::LIGHT_WHITE.'%s '.Color::RESET." %s\n", |
|
27 | 27 | ]; |
28 | 28 | |
29 | 29 | /** @var array */ |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | T_VARIABLE, |
88 | 88 | ], |
89 | 89 | Color::LIGHT_YELLOW => [ |
90 | - '->' . T_STRING, |
|
91 | - '::' . T_STRING, |
|
90 | + '->'.T_STRING, |
|
91 | + '::'.T_STRING, |
|
92 | 92 | ], |
93 | 93 | ]; |
94 | 94 | |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | { |
100 | 100 | $style = $this->getStyle($token, $previous); |
101 | 101 | |
102 | - if (strpos($token[1], "\n") === false) { |
|
102 | + if (strpos($token[1], "\n") === false){ |
|
103 | 103 | return sprintf($this->templates['token'], $style, $token[1]); |
104 | 104 | } |
105 | 105 | |
106 | 106 | $lines = []; |
107 | - foreach (explode("\n", $token[1]) as $line) { |
|
107 | + foreach (explode("\n", $token[1]) as $line){ |
|
108 | 108 | $lines[] = sprintf($this->templates['token'], $style, $line); |
109 | 109 | } |
110 | 110 | |
@@ -132,16 +132,16 @@ discard block |
||
132 | 132 | */ |
133 | 133 | private function getStyle(array $token, array $previous): string |
134 | 134 | { |
135 | - if (!empty($previous)) { |
|
136 | - foreach ($this->style as $style => $tokens) { |
|
137 | - if (in_array($previous[1] . $token[0], $tokens)) { |
|
135 | + if (!empty($previous)){ |
|
136 | + foreach ($this->style as $style => $tokens){ |
|
137 | + if (in_array($previous[1].$token[0], $tokens)){ |
|
138 | 138 | return $style; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | } |
142 | 142 | |
143 | - foreach ($this->style as $style => $tokens) { |
|
144 | - if (in_array($token[0], $tokens)) { |
|
143 | + foreach ($this->style as $style => $tokens){ |
|
144 | + if (in_array($token[0], $tokens)){ |
|
145 | 145 | return $style; |
146 | 146 | } |
147 | 147 | } |
@@ -186,12 +186,14 @@ discard block |
||
186 | 186 | { |
187 | 187 | $style = $this->getStyle($token, $previous); |
188 | 188 | |
189 | - if (strpos($token[1], "\n") === false) { |
|
189 | + if (strpos($token[1], "\n") === false) |
|
190 | + { |
|
190 | 191 | return sprintf($this->templates['token'], $style, htmlspecialchars($token[1])); |
191 | 192 | } |
192 | 193 | |
193 | 194 | $lines = []; |
194 | - foreach (explode("\n", $token[1]) as $line) { |
|
195 | + foreach (explode("\n", $token[1]) as $line) |
|
196 | + { |
|
195 | 197 | $lines[] = sprintf($this->templates['token'], $style, htmlspecialchars($line)); |
196 | 198 | } |
197 | 199 | |
@@ -215,16 +217,21 @@ discard block |
||
215 | 217 | */ |
216 | 218 | private function getStyle(array $token, array $previous): string |
217 | 219 | { |
218 | - if (!empty($previous)) { |
|
219 | - foreach ($this->style as $style => $tokens) { |
|
220 | - if (in_array($previous[1] . $token[0], $tokens)) { |
|
220 | + if (!empty($previous)) |
|
221 | + { |
|
222 | + foreach ($this->style as $style => $tokens) |
|
223 | + { |
|
224 | + if (in_array($previous[1] . $token[0], $tokens)) |
|
225 | + { |
|
221 | 226 | return $style; |
222 | 227 | } |
223 | 228 | } |
224 | 229 | } |
225 | 230 | |
226 | - foreach ($this->style as $style => $tokens) { |
|
227 | - if (in_array($token[0], $tokens)) { |
|
231 | + foreach ($this->style as $style => $tokens) |
|
232 | + { |
|
233 | + if (in_array($token[0], $tokens)) |
|
234 | + { |
|
228 | 235 | return $style; |
229 | 236 | } |
230 | 237 | } |
@@ -148,8 +148,8 @@ discard block |
||
148 | 148 | T_VARIABLE, |
149 | 149 | ], |
150 | 150 | 'color: #E6D100;' => [ |
151 | - '->' . T_STRING, |
|
152 | - '::' . T_STRING, |
|
151 | + '->'.T_STRING, |
|
152 | + '::'.T_STRING, |
|
153 | 153 | ], |
154 | 154 | ]; |
155 | 155 | |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | { |
187 | 187 | $style = $this->getStyle($token, $previous); |
188 | 188 | |
189 | - if (strpos($token[1], "\n") === false) { |
|
189 | + if (strpos($token[1], "\n") === false){ |
|
190 | 190 | return sprintf($this->templates['token'], $style, htmlspecialchars($token[1])); |
191 | 191 | } |
192 | 192 | |
193 | 193 | $lines = []; |
194 | - foreach (explode("\n", $token[1]) as $line) { |
|
194 | + foreach (explode("\n", $token[1]) as $line){ |
|
195 | 195 | $lines[] = sprintf($this->templates['token'], $style, htmlspecialchars($line)); |
196 | 196 | } |
197 | 197 | |
@@ -215,16 +215,16 @@ discard block |
||
215 | 215 | */ |
216 | 216 | private function getStyle(array $token, array $previous): string |
217 | 217 | { |
218 | - if (!empty($previous)) { |
|
219 | - foreach ($this->style as $style => $tokens) { |
|
220 | - if (in_array($previous[1] . $token[0], $tokens)) { |
|
218 | + if (!empty($previous)){ |
|
219 | + foreach ($this->style as $style => $tokens){ |
|
220 | + if (in_array($previous[1].$token[0], $tokens)){ |
|
221 | 221 | return $style; |
222 | 222 | } |
223 | 223 | } |
224 | 224 | } |
225 | 225 | |
226 | - foreach ($this->style as $style => $tokens) { |
|
227 | - if (in_array($token[0], $tokens)) { |
|
226 | + foreach ($this->style as $style => $tokens){ |
|
227 | + if (in_array($token[0], $tokens)){ |
|
228 | 228 | return $style; |
229 | 229 | } |
230 | 230 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * Default code styles. |
24 | 24 | */ |
25 | - public const DEFAULT = [ |
|
25 | + public const default = [ |
|
26 | 26 | 'color: blue; font-weight: bold;' => [ |
27 | 27 | T_STATIC, |
28 | 28 | T_PUBLIC, |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @var array |
171 | 171 | */ |
172 | - protected $style = self::DEFAULT; |
|
172 | + protected $style = self::default; |
|
173 | 173 | |
174 | - public function __construct(array $style = self::DEFAULT) |
|
174 | + public function __construct(array $style = self::default) |
|
175 | 175 | { |
176 | 176 | $this->style = $style; |
177 | 177 | } |
@@ -31,7 +31,7 @@ |
||
31 | 31 | */ |
32 | 32 | public function line(int $number, string $code, bool $target = false): string |
33 | 33 | { |
34 | - if ($target) { |
|
34 | + if ($target){ |
|
35 | 35 | return sprintf( |
36 | 36 | ">%s %s\n", |
37 | 37 | str_pad((string)$number, 4, ' ', STR_PAD_LEFT), |
@@ -31,7 +31,8 @@ |
||
31 | 31 | */ |
32 | 32 | public function line(int $number, string $code, bool $target = false): string |
33 | 33 | { |
34 | - if ($target) { |
|
34 | + if ($target) |
|
35 | + { |
|
35 | 36 | return sprintf( |
36 | 37 | ">%s %s\n", |
37 | 38 | str_pad((string)$number, 4, ' ', STR_PAD_LEFT), |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | { |
70 | 70 | $result = ''; |
71 | 71 | |
72 | - if ($e instanceof \Error) { |
|
73 | - $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:magenta,white'); |
|
74 | - } else { |
|
75 | - $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:red,white'); |
|
72 | + if ($e instanceof \Error){ |
|
73 | + $result .= $this->renderHeader('['.get_class($e)."]\n".$e->getMessage(), 'bg:magenta,white'); |
|
74 | + }else{ |
|
75 | + $result .= $this->renderHeader('['.get_class($e)."]\n".$e->getMessage(), 'bg:red,white'); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | $result .= $this->format( |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | $e->getLine() |
82 | 82 | ); |
83 | 83 | |
84 | - if ($verbosity >= self::VERBOSITY_DEBUG) { |
|
84 | + if ($verbosity >= self::VERBOSITY_DEBUG){ |
|
85 | 85 | $result .= $this->renderTrace($e, new Highlighter( |
86 | 86 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle() |
87 | 87 | )); |
88 | - } elseif ($verbosity >= self::VERBOSITY_VERBOSE) { |
|
88 | + } elseif ($verbosity >= self::VERBOSITY_VERBOSE){ |
|
89 | 89 | $result .= $this->renderTrace($e); |
90 | 90 | } |
91 | 91 | |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | $length += $padding; |
115 | 115 | |
116 | - foreach ($lines as $line) { |
|
116 | + foreach ($lines as $line){ |
|
117 | 117 | $result .= $this->format( |
118 | 118 | "<{$style}>%s%s%s</reset>\n", |
119 | 119 | str_repeat(' ', $padding + 1), |
@@ -135,34 +135,34 @@ discard block |
||
135 | 135 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
136 | 136 | { |
137 | 137 | $stacktrace = $this->getStacktrace($e); |
138 | - if (empty($stacktrace)) { |
|
138 | + if (empty($stacktrace)){ |
|
139 | 139 | return ''; |
140 | 140 | } |
141 | 141 | |
142 | 142 | $result = $this->format("\n<red>Exception Trace:</reset>\n"); |
143 | 143 | |
144 | - foreach ($stacktrace as $trace) { |
|
145 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
144 | + foreach ($stacktrace as $trace){ |
|
145 | + if (isset($trace['type']) && isset($trace['class'])){ |
|
146 | 146 | $line = $this->format( |
147 | 147 | ' <white>%s%s%s()</reset>', |
148 | 148 | $trace['class'], |
149 | 149 | $trace['type'], |
150 | 150 | $trace['function'] |
151 | 151 | ); |
152 | - } else { |
|
152 | + }else{ |
|
153 | 153 | $line = $this->format( |
154 | 154 | ' <white>%s()</reset>', |
155 | 155 | $trace['function'] |
156 | 156 | ); |
157 | 157 | } |
158 | 158 | |
159 | - if (isset($trace['file'])) { |
|
159 | + if (isset($trace['file'])){ |
|
160 | 160 | $line .= $this->format( |
161 | 161 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
162 | 162 | $trace['file'], |
163 | 163 | $trace['line'] |
164 | 164 | ); |
165 | - } else { |
|
165 | + }else{ |
|
166 | 166 | $line .= $this->format( |
167 | 167 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
168 | 168 | 'n/a', |
@@ -170,14 +170,14 @@ discard block |
||
170 | 170 | ); |
171 | 171 | } |
172 | 172 | |
173 | - $result .= $line . "\n"; |
|
173 | + $result .= $line."\n"; |
|
174 | 174 | |
175 | - if (!empty($h) && !empty($trace['file'])) { |
|
175 | + if (!empty($h) && !empty($trace['file'])){ |
|
176 | 176 | $result .= $h->highlightLines( |
177 | 177 | file_get_contents($trace['file']), |
178 | 178 | $trace['line'], |
179 | 179 | static::SHOW_LINES |
180 | - ) . "\n"; |
|
180 | + )."\n"; |
|
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | */ |
194 | 194 | private function format(string $format, ...$args): string |
195 | 195 | { |
196 | - if (!$this->colorsSupport) { |
|
196 | + if (!$this->colorsSupport){ |
|
197 | 197 | $format = preg_replace('/<[^>]+>/', '', $format); |
198 | - } else { |
|
199 | - $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial) { |
|
198 | + }else{ |
|
199 | + $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial){ |
|
200 | 200 | $style = ''; |
201 | - foreach (explode(',', trim($partial[2], '/')) as $color) { |
|
202 | - if (isset(self::COLORS[$color])) { |
|
201 | + foreach (explode(',', trim($partial[2], '/')) as $color){ |
|
202 | + if (isset(self::COLORS[$color])){ |
|
203 | 203 | $style .= self::COLORS[$color]; |
204 | 204 | } |
205 | 205 | } |
@@ -69,9 +69,12 @@ discard block |
||
69 | 69 | { |
70 | 70 | $result = ''; |
71 | 71 | |
72 | - if ($e instanceof \Error) { |
|
72 | + if ($e instanceof \Error) |
|
73 | + { |
|
73 | 74 | $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:magenta,white'); |
74 | - } else { |
|
75 | + } |
|
76 | + else |
|
77 | + { |
|
75 | 78 | $result .= $this->renderHeader('[' . get_class($e) . "]\n" . $e->getMessage(), 'bg:red,white'); |
76 | 79 | } |
77 | 80 | |
@@ -81,11 +84,14 @@ discard block |
||
81 | 84 | $e->getLine() |
82 | 85 | ); |
83 | 86 | |
84 | - if ($verbosity >= self::VERBOSITY_DEBUG) { |
|
87 | + if ($verbosity >= self::VERBOSITY_DEBUG) |
|
88 | + { |
|
85 | 89 | $result .= $this->renderTrace($e, new Highlighter( |
86 | 90 | $this->colorsSupport ? new ConsoleStyle() : new PlainStyle() |
87 | 91 | )); |
88 | - } elseif ($verbosity >= self::VERBOSITY_VERBOSE) { |
|
92 | + } |
|
93 | + elseif ($verbosity >= self::VERBOSITY_VERBOSE) |
|
94 | + { |
|
89 | 95 | $result .= $this->renderTrace($e); |
90 | 96 | } |
91 | 97 | |
@@ -113,7 +119,8 @@ discard block |
||
113 | 119 | |
114 | 120 | $length += $padding; |
115 | 121 | |
116 | - foreach ($lines as $line) { |
|
122 | + foreach ($lines as $line) |
|
123 | + { |
|
117 | 124 | $result .= $this->format( |
118 | 125 | "<{$style}>%s%s%s</reset>\n", |
119 | 126 | str_repeat(' ', $padding + 1), |
@@ -135,34 +142,42 @@ discard block |
||
135 | 142 | private function renderTrace(\Throwable $e, Highlighter $h = null): string |
136 | 143 | { |
137 | 144 | $stacktrace = $this->getStacktrace($e); |
138 | - if (empty($stacktrace)) { |
|
145 | + if (empty($stacktrace)) |
|
146 | + { |
|
139 | 147 | return ''; |
140 | 148 | } |
141 | 149 | |
142 | 150 | $result = $this->format("\n<red>Exception Trace:</reset>\n"); |
143 | 151 | |
144 | - foreach ($stacktrace as $trace) { |
|
145 | - if (isset($trace['type']) && isset($trace['class'])) { |
|
152 | + foreach ($stacktrace as $trace) |
|
153 | + { |
|
154 | + if (isset($trace['type']) && isset($trace['class'])) |
|
155 | + { |
|
146 | 156 | $line = $this->format( |
147 | 157 | ' <white>%s%s%s()</reset>', |
148 | 158 | $trace['class'], |
149 | 159 | $trace['type'], |
150 | 160 | $trace['function'] |
151 | 161 | ); |
152 | - } else { |
|
162 | + } |
|
163 | + else |
|
164 | + { |
|
153 | 165 | $line = $this->format( |
154 | 166 | ' <white>%s()</reset>', |
155 | 167 | $trace['function'] |
156 | 168 | ); |
157 | 169 | } |
158 | 170 | |
159 | - if (isset($trace['file'])) { |
|
171 | + if (isset($trace['file'])) |
|
172 | + { |
|
160 | 173 | $line .= $this->format( |
161 | 174 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
162 | 175 | $trace['file'], |
163 | 176 | $trace['line'] |
164 | 177 | ); |
165 | - } else { |
|
178 | + } |
|
179 | + else |
|
180 | + { |
|
166 | 181 | $line .= $this->format( |
167 | 182 | ' <yellow>at</reset> <green>%s</reset><yellow>:</reset><white>%s</reset>', |
168 | 183 | 'n/a', |
@@ -172,7 +187,8 @@ discard block |
||
172 | 187 | |
173 | 188 | $result .= $line . "\n"; |
174 | 189 | |
175 | - if (!empty($h) && !empty($trace['file'])) { |
|
190 | + if (!empty($h) && !empty($trace['file'])) |
|
191 | + { |
|
176 | 192 | $result .= $h->highlightLines( |
177 | 193 | file_get_contents($trace['file']), |
178 | 194 | $trace['line'], |
@@ -193,13 +209,19 @@ discard block |
||
193 | 209 | */ |
194 | 210 | private function format(string $format, ...$args): string |
195 | 211 | { |
196 | - if (!$this->colorsSupport) { |
|
212 | + if (!$this->colorsSupport) |
|
213 | + { |
|
197 | 214 | $format = preg_replace('/<[^>]+>/', '', $format); |
198 | - } else { |
|
199 | - $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial) { |
|
215 | + } |
|
216 | + else |
|
217 | + { |
|
218 | + $format = preg_replace_callback('/(<([^>]+)>)/', function ($partial) |
|
219 | + { |
|
200 | 220 | $style = ''; |
201 | - foreach (explode(',', trim($partial[2], '/')) as $color) { |
|
202 | - if (isset(self::COLORS[$color])) { |
|
221 | + foreach (explode(',', trim($partial[2], '/')) as $color) |
|
222 | + { |
|
223 | + if (isset(self::COLORS[$color])) |
|
224 | + { |
|
203 | 225 | $style .= self::COLORS[$color]; |
204 | 226 | } |
205 | 227 | } |