Skip to content

Commit 704c4b3

Browse files
committed
improve backtrace
1 parent 523b005 commit 704c4b3

File tree

7 files changed

+68
-3
lines changed

7 files changed

+68
-3
lines changed

demo/backtrace.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Chevere.
5+
*
6+
* (c) Rodolfo Berrios <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
require_once 'autoload.php';
15+
16+
xr('BACKTRACE', f: XR_BACKTRACE);
17+
18+
include __DIR__ . '/traces/a.php';

demo/traces/a.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Chevere.
5+
*
6+
* (c) Rodolfo Berrios <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
xr('A', f: XR_BACKTRACE);
15+
16+
include __DIR__ . '/b.php';

demo/traces/b.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Chevere.
5+
*
6+
* (c) Rodolfo Berrios <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
xr('B', f: XR_BACKTRACE);
15+
16+
include __DIR__ . '/c.php';

demo/traces/c.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
/*
4+
* This file is part of Chevere.
5+
*
6+
* (c) Rodolfo Berrios <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
declare(strict_types=1);
13+
14+
xr('C', f: XR_BACKTRACE);

src/Message.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ private function handleBacktrace(): void
204204
$this->backtrace,
205205
new ThrowableHandlerHtmlFormat()
206206
);
207+
$count = count($trace->toArray());
207208
$this->body .= <<<HTML
208-
<div class="xrdebug-backtrace">{$trace->__toString()}</div>
209+
<div class="xrdebug-backtrace" data-count="{$count}">{$trace->__toString()}</div>
209210
HTML;
210211
}
211212
}

tests/MessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function testWithBacktraceFlag(): void
172172
$withBacktraceFlag = $message->withFlags(XR_BACKTRACE);
173173
$this->assertNotSame($message, $withBacktraceFlag);
174174
$this->assertTrue($withBacktraceFlag->isEnableBacktrace());
175-
$expected = $body . '<div class="xrdebug-backtrace">';
175+
$expected = $body . '<div class="xrdebug-backtrace" data-count="13">';
176176
$this->assertStringContainsString(
177177
$expected,
178178
$withBacktraceFlag->toArray()['body']

tests/ThrowableParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function testWithPrevious(): void
8888
$body = strip_tags($parser->body());
8989
$this->assertStringContainsString(
9090
<<<PLAIN
91-
#0 {$file}:{$line}
91+
0 {$file}:{$line}
9292
{main}()
9393
PLAIN,
9494
$body

0 commit comments

Comments
 (0)