Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2b46e2a

Browse filesBrowse files
committed
[ErrorHandler] Fix rendered exception code highlighting on PHP 8.3
1 parent f4b0c27 commit 2b46e2a
Copy full SHA for 2b46e2a

File tree

3 files changed

+7
-11
lines changed
Filter options

3 files changed

+7
-11
lines changed

‎src/Symfony/Bridge/Twig/Extension/CodeExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/Extension/CodeExtension.php
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,10 @@ public function fileExcerpt(string $file, int $line, int $srcContext = 3): ?stri
129129
if (\PHP_VERSION_ID >= 80300) {
130130
// remove main pre/code tags
131131
$code = preg_replace('#^<pre.*?>\s*<code.*?>(.*)</code>\s*</pre>#s', '\\1', $code);
132-
// split multiline code tags
133-
$code = preg_replace_callback('#<code ([^>]++)>((?:[^<]*+\\n)++[^<]*+)</code>#', function ($m) {
134-
return "<code $m[1]>".str_replace("\n", "</code>\n<code $m[1]>", $m[2]).'</code>';
132+
// split multiline span tags
133+
$code = preg_replace_callback('#<span ([^>]++)>((?:[^<\\n]*+\\n)++[^<]*+)</span>#', function ($m) {
134+
return "<span $m[1]>".str_replace("\n", "</span>\n<span $m[1]>", $m[2]).'</span>';
135135
}, $code);
136-
// Convert spaces to html entities to preserve indentation when rendered
137-
$code = str_replace(' ', '&nbsp;', $code);
138136
$content = explode("\n", $code);
139137
} else {
140138
// remove main code/span tags

‎src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php
+3-5Lines 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

‎src/Symfony/Component/ErrorHandler/Resources/assets/css/exception.css

Copy file name to clipboardExpand all lines: src/Symfony/Component/ErrorHandler/Resources/assets/css/exception.css
+1-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.