Skip to content

Commit c25da5c

Browse files
committed
[ErrorHandler] Fix rendered exception code highlighting on PHP 8.3
1 parent c6c8f96 commit c25da5c

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

ErrorRenderer/HtmlErrorRenderer.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,10 @@ private function fileExcerpt(string $file, int $line, int $srcContext = 3): stri
274274
if (\PHP_VERSION_ID >= 80300) {
275275
// remove main pre/code tags
276276
$code = preg_replace('#^<pre.*?>\s*<code.*?>(.*)</code>\s*</pre>#s', '\\1', $code);
277-
// split multiline code tags
278-
$code = preg_replace_callback('#<code ([^>]++)>((?:[^<]*+\\n)++[^<]*+)</code>#', function ($m) {
279-
return "<code $m[1]>".str_replace("\n", "</code>\n<code $m[1]>", $m[2]).'</code>';
277+
// split multiline span tags
278+
$code = preg_replace_callback('#<span ([^>]++)>((?:[^<\\n]*+\\n)++[^<]*+)</span>#', function ($m) {
279+
return "<span $m[1]>".str_replace("\n", "</span>\n<span $m[1]>", $m[2]).'</span>';
280280
}, $code);
281-
// Convert spaces to html entities to preserve indentation when rendered
282-
$code = str_replace(' ', '&nbsp;', $code);
283281
$content = explode("\n", $code);
284282
} else {
285283
// remove main code/span tags

Resources/assets/css/exception.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ header .container { display: flex; justify-content: space-between; }
242242
.trace-code li { color: #969896; margin: 0; padding-left: 10px; float: left; width: 100%; }
243243
.trace-code li + li { margin-top: 5px; }
244244
.trace-code li.selected { background: var(--trace-selected-background); margin-top: 2px; }
245-
.trace-code li code { color: var(--base-6); white-space: nowrap; }
245+
.trace-code li code { color: var(--base-6); white-space: pre; }
246246

247247
.trace-as-text .stacktrace { line-height: 1.8; margin: 0 0 15px; white-space: pre-wrap; }
248248

0 commit comments

Comments
 (0)