From d5529534ce064d19a6d0e33a465fb1ba40a861d2 Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Sun, 12 Oct 2025 17:30:34 -0500 Subject: [PATCH 1/2] Add syntax highlighting for variables --- include/layout.inc | 13 +++++++++++++ styles/php85.css | 12 +++++++++++- styles/theme-medium.css | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/include/layout.inc b/include/layout.inc index 17f76b8fd4..2f3f8207a6 100644 --- a/include/layout.inc +++ b/include/layout.inc @@ -47,6 +47,19 @@ function highlight_php_trimmed($code, $return = false) $highlighted_code = highlight_php($code, true); $highlighted_code = preg_replace("!<\?php(
)+!", '', $highlighted_code, 1); + // add syntax highlighting for variables + $variableReplacer = function (array $matches) { + if ($matches[1] !== '') { + $replacement = '' . $matches[1] . ''; + } else { + $replacement = ''; + } + return $replacement . '' . $matches[2] . ''; + }; + + $pattern = '!([\w\s]*)(\$[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*\s*)!'; + $highlighted_code = preg_replace_callback($pattern, $variableReplacer, $highlighted_code); + if ($return) { return $highlighted_code; } echo $highlighted_code; return null; diff --git a/styles/php85.css b/styles/php85.css index d8523e91aa..4ac3708350 100644 --- a/styles/php85.css +++ b/styles/php85.css @@ -3564,6 +3564,11 @@ footer p:where(.dark,.dark *) { background-color: transparent; } +.php85 .phpcode span.variable { + color: #7d55ba; + background-color: transparent; +} + .php85 .phpcode span.keyword { color: #07a; background-color: transparent; @@ -3585,13 +3590,18 @@ footer p:where(.dark,.dark *) { background-color: transparent; } +.dark .php85 .phpcode span.variable { + color: #a5d6ff; + background-color: transparent; +} + .dark .php85 .phpcode span.keyword { color: #ff7b72; background-color: transparent; } .dark .php85 .phpcode span.string { - color: #a5d6ff; + color: #80b83c; background-color: transparent; } diff --git a/styles/theme-medium.css b/styles/theme-medium.css index d171ea4c45..1f1b9d142f 100644 --- a/styles/theme-medium.css +++ b/styles/theme-medium.css @@ -832,7 +832,7 @@ div.warning a:focus { color: var(--dark-blue-color); background-color: transparent; } -div.phpcode span.default { +div.phpcode span.default, div.phpcode span.variable { color: #369; background-color: transparent; } From a64c86a6369fa03a55beea3cf1dbb2a77d2b3e4e Mon Sep 17 00:00:00 2001 From: Theodore Brown Date: Wed, 19 Nov 2025 11:56:55 -0600 Subject: [PATCH 2/2] Add trailing commas --- releases/8.5/release.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/releases/8.5/release.inc b/releases/8.5/release.inc index ee33e7769c..79578488da 100644 --- a/releases/8.5/release.inc +++ b/releases/8.5/release.inc @@ -509,7 +509,7 @@ final class PostsController )] public function update( Request $request, - Post $post + Post $post, ): Response { // ... } @@ -545,7 +545,7 @@ final class PostsController })] public function update( Request $request, - Post $post + Post $post, ): Response { // ... }