-
-
Notifications
You must be signed in to change notification settings - Fork 221
Expand file tree
/
Copy pathsection-stack-callStack.phtml
More file actions
120 lines (101 loc) · 3.9 KB
/
section-stack-callStack.phtml
File metadata and controls
120 lines (101 loc) · 3.9 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<?php
declare(strict_types=1);
namespace Tracy;
/**
* @var callable $dump
* @var int $expanded
* @var array $stack
* @var ?array $realArgs
* @var ?array $variables
*/
if (!$stack) {
return;
}
?>
<section class="tracy-section">
<h2 class="tracy-section-label"><a href="#" data-tracy-ref="^+" class="tracy-toggle">Call stack</a></h2>
<div class="tracy-section-panel">
<div class="tracy-callstack">
<?php foreach ($stack as $key => $row): ?>
<?php $clickable = !empty($row['args']) || (isset($row['file']) && @is_file($row['file'])) // @ - may trigger error ?>
<div class="tracy-callstack-file">
<?php if (isset($row['file']) && @is_file($row['file'])): // @ - may trigger error ?>
<?= Helpers::editorLink($row['file'], $row['line']) ?>
<?php else: ?>
<i>inner-code</i><?php if (isset($row['line'])) echo ':', $row['line'] ?>
<?php endif ?>
</div>
<div class="tracy-callstack-callee">
<?php if ($clickable): ?>
<a href="#" data-tracy-ref="^div + div" class="tracy-toggle<?php if ($expanded !== $key) echo ' tracy-collapsed' ?>"><?php endif ?>
<?php if (isset($row['class'])) echo Helpers::escapeHtml($row['class']), '::' ?><b><?= Helpers::escapeHtml($row['function']) ?></b> <?= empty($row['args']) ? '()' : '(...)' ?>
<?php if ($clickable): ?></a><?php endif ?>
</div>
<?php if ($clickable): ?>
<div class="tracy-callstack-additional<?php if ($expanded !== $key) echo ' tracy-collapsed' ?>">
<?php $sourceOriginal = isset($row['file']) && @is_file($row['file']) ? [$row['file'], $row['line']] : null // @ - may trigger error ?>
<?php $sourceMapped = $sourceOriginal ? Debugger::mapSource(...$sourceOriginal) : null ?>
<?php if ($sourceOriginal && $sourceMapped): ?>
<div class="tracy-tabs">
<ul class="tracy-tab-bar">
<li class="tracy-tab-label<?= $sourceMapped['active'] ? '' : ' tracy-active' ?>"><a href="#">PHP</a></li>
<li class="tracy-tab-label<?= $sourceMapped['active'] ? ' tracy-active' : '' ?>"><a href="#"><?= Helpers::escapeHtml($sourceMapped['label']) ?></a></li>
</ul>
<div>
<div class="tracy-tab-panel<?= $sourceMapped['active'] ? '' : ' tracy-active' ?>">
<?= BlueScreen::highlightFile(...$sourceOriginal) ?>
</div>
<div class="tracy-tab-panel<?= $sourceMapped['active'] ? ' tracy-active' : '' ?>">
<?= BlueScreen::highlightFile($sourceMapped['file'], $sourceMapped['line'], php: false) ?>
</div>
</div>
</div>
<?php elseif ($sourceOriginal): ?>
<?= BlueScreen::highlightFile(...$sourceOriginal) ?>
<?php endif ?>
<?php if (!empty($realArgs[$key])): ?>
<table class="tracy-callstack-args">
<?php
foreach ($realArgs[$key] as $argName => $v) {
echo '<tr><th>', Helpers::escapeHtml((is_string($argName) ? '$' : '#') . $argName), '</th><td>';
echo $dump($v, $argName);
echo "</td></tr>\n";
}
?>
</table>
<?php elseif (!empty($row['args'])): ?>
<table class="tracy-callstack-args tracy-callstack-args-warning">
<?php
if (isset($row['class']) ? method_exists($row['class'], $row['function']) : function_exists($row['function'])) {
$r = isset($row['class']) ? new \ReflectionMethod($row['class'], $row['function']) : new \ReflectionFunction($row['function']);
$params = $r->getParameters();
} else {
$params = [];
}
foreach ($row['args'] as $k => $v) {
$argName = isset($params[$k]) && !$params[$k]->isVariadic() ? $params[$k]->name : $k;
echo '<tr><th>', Helpers::escapeHtml((is_string($argName) ? '$' : '#') . $argName), '</th><td>';
echo $dump($v, (string) $argName);
echo "</td></tr>\n";
}
?>
</table>
<?php endif ?>
<?php if (!empty($variables[$key])): ?>
<h3>Local Variables</h3>
<table class="tracy-callstack-args">
<?php
foreach ($variables[$key] as $k => $v) {
echo '<tr><th>$', Helpers::escapeHtml($k), '</th><td>';
echo $dump($v, $k);
echo "</td></tr>\n";
}
?>
</table>
<?php endif ?>
</div>
<?php endif ?>
<?php endforeach ?>
</div>
</div>
</section>