Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Tracy/BlueScreen/BlueScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ public function getAgentDumper(): \Closure
{
return fn($v, $k = null): string => Dumper::toText($v, [
Dumper::DEPTH => 3,
Dumper::TRUNCATE => $this->maxLength,
Dumper::ITEMS => $this->maxItems,
Dumper::SCRUBBER => $this->scrubber,
Dumper::KEYS_TO_HIDE => $this->keysToHide,
], $k);
Expand Down
2 changes: 1 addition & 1 deletion src/Tracy/BlueScreen/dist/agent.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ in ';
$argParts = [] /* pos 84:5 */;
foreach ($row['args'] as $k => $v) /* pos 85:5 */ {
$name = isset($params[$k]) && !$params[$k]->isVariadic() ? '$' . $params[$k]->getName() : '#' . $k /* pos 86:6 */;
$dump = rtrim($agentDump($v)) /* pos 87:6 */;
$dump = rtrim($agentDump($v, $name)) /* pos 87:6 */;
if (str_contains($dump, '
') || strlen($dump) > 50) /* pos 88:6 */ {
$allSimple = false /* pos 89:7 */;
Expand Down
23 changes: 23 additions & 0 deletions tests/Tracy/BlueScreen.renderAgent().phpt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,29 @@ test('stack trace section with arguments', function () use ($blueScreen) {
});


test('stack trace argument dumps are limited', function () {
$blueScreen = new Tracy\BlueScreen;
$blueScreen->maxItems = 3;
$blueScreen->maxLength = 10;
$fn = function (array $items, string $text) {
throw new RuntimeException('Large arguments');
};
try {
$fn(range(1, 10), str_repeat('x', 50));
} catch (RuntimeException $e) {
$output = $blueScreen->renderAgent($e);
}

Assert::contains('$items = array (10)', $output);
Assert::contains(' 0 => 1', $output);
Assert::contains(' 1 => 2', $output);
Assert::contains(' 2 => 3', $output);
Assert::contains(' ...', $output);
Assert::notContains(' 3 => 4', $output);
Assert::contains('$text = \'xxxxxxxxxx ... xxxxxxxxxx\'', $output);
});


test('caused by section for chained exceptions', function () use ($blueScreen) {
$prev = new InvalidArgumentException('Root cause', 7);
$exception = new RuntimeException('Wrapper', 5, $prev);
Expand Down