File size: 2,490 Bytes
d2897cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php

$formatArgs = function ($args) use (&$formatArgs) {
    $result = [];
    foreach ($args as $key => $item) {
        if (is_array($item) && isset($item[0]) && is_string($item[0]) && 2 === count($item)) {
            if ('object' === $item[0]) {
                $parts          = explode('\\', $item[1]);
                $short          = array_pop($parts);
                $formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
            } elseif ('array' === $item[0]) {
                $formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $formatArgs($item[1]) : $item[1]);
            } elseif ('string' === $item[0]) {
                $formattedValue = sprintf("'%s'", htmlspecialchars($item[1]));
            } elseif ('null' === $item[0]) {
                $formattedValue = '<em>null</em>';
            } elseif ('boolean' === $item[0]) {
                $formattedValue = '<em>'.strtolower(var_export($item[1], true)).'</em>';
            } elseif ('resource' === $item[0]) {
                $formattedValue = '<em>resource</em>';
            } else {
                $formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1]), true));
            }
        } elseif (is_object($item)) {
            $formattedValue = get_class($item);
        } elseif (is_string($item)) {
            $formattedValue = '<em>'.htmlspecialchars($item).'</em>';
        } elseif (is_array($item)) {
            $formattedValue = sprintf('<em>array</em>(%s)', $formatArgs($item));
        } else {
            $formattedValue = '';
        }

        $result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
    }

    return implode(', ', $result);
};

echo "<ol>\n";
$root = realpath(__DIR__.'/../../../../../');

foreach ($traces as $trace) {
    echo '<li class="pt-3 break-word">';
    if (isset($trace['file'])) {
        $trace['file'] = str_replace($root, '', $trace['file']);
        echo "<strong>{$trace['file']}";
        if ($trace['line']) {
            echo ':'.$trace['line'];
        }
        echo '</strong> at ';
    }
    if (!empty($trace['function'])) {
        if (isset($trace['class'])) {
            echo "{$trace['class']} {$trace['type']} ";
        }
        echo " {$trace['function']} ( ";
        if (!empty($trace['args'])) {
            echo $formatArgs($trace['args']);
        }
        echo ' )';
    }
    echo '</li>';
}
echo "</ol>\n";