Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
115 / 115 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
||
| 1 | <?php |
| 2 | /** |
| 3 | * @var Exception $exception |
| 4 | * @var Framework\Debug\ExceptionHandler $handler |
| 5 | */ |
| 6 | |
| 7 | use Framework\Helpers\ArraySimple; |
| 8 | |
| 9 | ?> |
| 10 | <!doctype html> |
| 11 | <html lang="<?= $handler->getLanguage()->getCurrentLocale() ?>" dir="<?= $handler->getLanguage() |
| 12 | ->getCurrentLocaleDirection() ?>"> |
| 13 | <head> |
| 14 | <meta charset="utf-8"> |
| 15 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 16 | <title><?= $handler->getLanguage()->render('debug', 'exception') ?>: <?= |
| 17 | htmlentities($exception->getMessage()) ?></title> |
| 18 | <style> |
| 19 | <?= file_get_contents(__DIR__ . '/../assets/prism-aplus.css') ?> |
| 20 | </style> |
| 21 | <style> |
| 22 | body { |
| 23 | background-color: #000; |
| 24 | color: #fff; |
| 25 | font-family: Arial, Helvetica, sans-serif; |
| 26 | font-size: 16px; |
| 27 | margin: 0 0 20px; |
| 28 | } |
| 29 | |
| 30 | header { |
| 31 | background: #f00; |
| 32 | border: solid #222; |
| 33 | border-width: 1px 0; |
| 34 | color: #fff; |
| 35 | padding: 20px 20px; |
| 36 | } |
| 37 | |
| 38 | h1, h2, h3 { |
| 39 | margin: 0 0 5px; |
| 40 | } |
| 41 | |
| 42 | section { |
| 43 | border-bottom: 1px solid #222; |
| 44 | padding: 10px 20px; |
| 45 | } |
| 46 | |
| 47 | section:last-of-type { |
| 48 | border-bottom: 0; |
| 49 | } |
| 50 | |
| 51 | section .header { |
| 52 | background: #f00; |
| 53 | border: 1px solid red; |
| 54 | color: #fff; |
| 55 | font-weight: bold; |
| 56 | padding: 10px; |
| 57 | } |
| 58 | |
| 59 | .top { |
| 60 | border-top: 0; |
| 61 | } |
| 62 | |
| 63 | .file { |
| 64 | background: #111; |
| 65 | } |
| 66 | |
| 67 | .file div { |
| 68 | display: inline-block; |
| 69 | } |
| 70 | |
| 71 | .file div.line { |
| 72 | margin-left: 10px; |
| 73 | } |
| 74 | |
| 75 | dl { |
| 76 | background-color: #000; |
| 77 | border: 1px solid #222; |
| 78 | font-family: monospace; |
| 79 | font-size: 14px; |
| 80 | margin: 10px 0 0; |
| 81 | } |
| 82 | |
| 83 | dt { |
| 84 | background: #111; |
| 85 | border-bottom: 1px solid #222; |
| 86 | color: #fff; |
| 87 | padding: 1%; |
| 88 | width: 98%; |
| 89 | } |
| 90 | |
| 91 | dd { |
| 92 | background: #000; |
| 93 | margin: 0; |
| 94 | overflow-x: auto; |
| 95 | } |
| 96 | |
| 97 | pre.code { |
| 98 | display: inline-block; |
| 99 | float: left; |
| 100 | line-height: 20px; |
| 101 | margin: 0; |
| 102 | padding: 5px; |
| 103 | width: 80%; |
| 104 | } |
| 105 | |
| 106 | dd div { |
| 107 | background: #111; |
| 108 | border-right: 1px solid #222; |
| 109 | display: inline-block; |
| 110 | float: left; |
| 111 | line-height: 20px; |
| 112 | min-width: 25px; |
| 113 | padding: 5px; |
| 114 | text-align: right; |
| 115 | white-space: pre; |
| 116 | } |
| 117 | |
| 118 | dd div span { |
| 119 | color: #f00; |
| 120 | font-weight: bold; |
| 121 | } |
| 122 | |
| 123 | dt span { |
| 124 | background: #f00; |
| 125 | padding: 2px 6px; |
| 126 | } |
| 127 | |
| 128 | table { |
| 129 | border: 1px solid #222; |
| 130 | border-bottom: 0; |
| 131 | border-spacing: 0; |
| 132 | margin-top: 10px; |
| 133 | width: 100%; |
| 134 | } |
| 135 | |
| 136 | th { |
| 137 | border-right: 2px solid #222; |
| 138 | } |
| 139 | |
| 140 | th, td { |
| 141 | border-bottom: 1px solid #222; |
| 142 | padding: 5px; |
| 143 | } |
| 144 | |
| 145 | td pre code { |
| 146 | margin: 0; |
| 147 | white-space: pre-wrap !important; |
| 148 | } |
| 149 | |
| 150 | tr:hover { |
| 151 | background: #111; |
| 152 | } |
| 153 | |
| 154 | thead th { |
| 155 | background: #111; |
| 156 | border-bottom: 2px solid #222; |
| 157 | border-right: 0; |
| 158 | color: #fff; |
| 159 | font-size: 110%; |
| 160 | text-align: left; |
| 161 | } |
| 162 | |
| 163 | tbody th { |
| 164 | background: #111; |
| 165 | min-width: 40%; |
| 166 | text-align: right; |
| 167 | } |
| 168 | </style> |
| 169 | </head> |
| 170 | <body class="aplus-debug"> |
| 171 | <header class="top"> |
| 172 | <small><?= $handler->getLanguage()->render('debug', 'exception') ?>:</small> |
| 173 | <h1><?= $exception::class ?></h1> |
| 174 | <small><?= $handler->getLanguage()->render('debug', 'message') ?>:</small> |
| 175 | <h2><?= htmlentities($exception->getMessage()) ?></h2> |
| 176 | </header> |
| 177 | <section class="file"> |
| 178 | <div> |
| 179 | <small><?= $handler->getLanguage()->render('debug', 'file') ?>:</small> |
| 180 | <h3><?= htmlentities($exception->getFile()) ?></h3> |
| 181 | </div> |
| 182 | <div class="line"> |
| 183 | <small><?= $handler->getLanguage()->render('debug', 'line') ?>:</small> |
| 184 | <h3><?= $exception->getLine() ?></h3> |
| 185 | </div> |
| 186 | </section> |
| 187 | <section class="trace"> |
| 188 | <div class="header"><?= $handler->getLanguage()->render('debug', 'trace') ?>:</div> |
| 189 | <?php |
| 190 | $traces = $exception->getTrace(); |
| 191 | if ($traces |
| 192 | && isset($traces[0]['file']) |
| 193 | && ($traces[0]['file'] !== $exception->getFile() |
| 194 | || (isset($traces[0]['line']) && $traces[0]['line'] !== $exception->getLine())) |
| 195 | ) { |
| 196 | $traces = array_reverse($traces); |
| 197 | $traces[] = [ |
| 198 | 'file' => $exception->getFile(), |
| 199 | 'line' => $exception->getLine(), |
| 200 | ]; |
| 201 | $traces = array_reverse($traces); |
| 202 | } |
| 203 | ?> |
| 204 | <?php foreach ($traces as $key => $trace) : ?> |
| 205 | <?php if (isset($trace['file'])) : ?> |
| 206 | <?php if (is_readable($trace['file'])) : ?> |
| 207 | <dl> |
| 208 | <dt> |
| 209 | <span><?= count($traces) - $key ?></span> |
| 210 | <?= $trace['file'] ?><?= |
| 211 | isset($trace['line']) ? ':' . $trace['line'] : '' |
| 212 | ?> |
| 213 | </dt> |
| 214 | <dd> |
| 215 | <?php |
| 216 | $lines = []; |
| 217 | $pre = ''; |
| 218 | $handle = fopen($trace['file'], 'rb'); |
| 219 | $line = 1; |
| 220 | while ($handle && ! feof($handle)) { |
| 221 | $code = fgets($handle); |
| 222 | if (isset($trace['line']) |
| 223 | && $line >= ($trace['line'] - 10) |
| 224 | && $line <= ($trace['line'] + 10) |
| 225 | ) { |
| 226 | $pre .= rtrim((string) $code) . \PHP_EOL; |
| 227 | $lines[] = $line; |
| 228 | } |
| 229 | $line++; |
| 230 | } |
| 231 | if ($handle) { |
| 232 | fclose($handle); |
| 233 | } |
| 234 | ?> |
| 235 | <div><?php |
| 236 | foreach ($lines as $line) { |
| 237 | if (isset($trace['line']) && $line === $trace['line']) { |
| 238 | echo '<span>'; |
| 239 | echo $line . \PHP_EOL; |
| 240 | echo '</span>'; |
| 241 | } else { |
| 242 | echo $line . \PHP_EOL; |
| 243 | } |
| 244 | } |
| 245 | ?></div> |
| 246 | <pre class="code"><code class="language-php"><?= htmlentities($pre) ?></code></pre> |
| 247 | </dd> |
| 248 | </dl> |
| 249 | <?php else : ?> |
| 250 | <dl> |
| 251 | <dt> |
| 252 | <span><?= $key ?></span> File |
| 253 | <em><?= $trace['file'] ?></em> is not readable. |
| 254 | </dt> |
| 255 | </dl> |
| 256 | <?php endif ?> |
| 257 | <?php endif ?> |
| 258 | <?php endforeach ?> |
| 259 | </section> |
| 260 | <section class="input"> |
| 261 | <div class="header">Input:</div> |
| 262 | <?php |
| 263 | $input = [ |
| 264 | 'ENV' => filter_input_array(\INPUT_ENV) ?: [], |
| 265 | 'SERVER' => filter_input_array(\INPUT_SERVER) ?: [], |
| 266 | 'GET' => ArraySimple::convert(filter_input_array(\INPUT_GET) ?: []), |
| 267 | 'POST' => ArraySimple::convert(filter_input_array(\INPUT_POST) ?: []), |
| 268 | 'COOKIE' => filter_input_array(\INPUT_COOKIE) ?: [], |
| 269 | ]; |
| 270 | foreach ($input as &$item) { |
| 271 | ksort($item); |
| 272 | } |
| 273 | unset($item); |
| 274 | ?> |
| 275 | |
| 276 | <?php foreach ($input as $key => $values) : ?> |
| 277 | <?php |
| 278 | if (empty($values)) { |
| 279 | continue; |
| 280 | } |
| 281 | ?> |
| 282 | <table> |
| 283 | <thead> |
| 284 | <tr> |
| 285 | <th colspan="2"><?= $key ?></th> |
| 286 | </tr> |
| 287 | </thead> |
| 288 | <tbody> |
| 289 | <?php foreach ($values as $field => $value) : ?> |
| 290 | <tr> |
| 291 | <th><?= htmlentities($field) ?></th> |
| 292 | <td><?= htmlentities(is_array($value) ? print_r($value, true) : $value) ?></td> |
| 293 | </tr> |
| 294 | <?php endforeach ?> |
| 295 | </tbody> |
| 296 | </table> |
| 297 | <?php endforeach ?> |
| 298 | </section> |
| 299 | <?php |
| 300 | $log = $handler->getLogger()?->getLastLog(); |
| 301 | if ($log): ?> |
| 302 | <section class="log"> |
| 303 | <div class="header">Log:</div> |
| 304 | <table> |
| 305 | <tr> |
| 306 | <th>Date</th> |
| 307 | <td><?= date('Y-m-d', $log->time) ?></td> |
| 308 | </tr> |
| 309 | <tr> |
| 310 | <th>Time</th> |
| 311 | <td><?= date('H:i:s', $log->time) ?></td> |
| 312 | </tr> |
| 313 | <tr> |
| 314 | <th>Level</th> |
| 315 | <td><?= htmlentities($log->level->name) ?></td> |
| 316 | </tr> |
| 317 | <tr> |
| 318 | <th>ID</th> |
| 319 | <td><?= htmlentities($log->id) ?></td> |
| 320 | </tr> |
| 321 | <tr> |
| 322 | <th>Message</th> |
| 323 | <td> |
| 324 | <pre><code class="language-log"><?= htmlentities($log->message) ?></code></pre> |
| 325 | </td> |
| 326 | </tr> |
| 327 | </table> |
| 328 | </section> |
| 329 | <?php |
| 330 | endif ?> |
| 331 | <script> |
| 332 | <?= file_get_contents(__DIR__ . '/../assets/prism.js') ?> |
| 333 | </script> |
| 334 | </body> |
| 335 | </html> |