From 80357823f6252a8b99c05bbd5338cf3be80bd052 Mon Sep 17 00:00:00 2001 From: Richard van Velzen Date: Wed, 1 Mar 2023 00:07:24 +0100 Subject: Improve lexing PHP's variable variable syntax (#2358) --- pygments/lexers/php.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'pygments') diff --git a/pygments/lexers/php.py b/pygments/lexers/php.py index c99daa4d..f48fa382 100644 --- a/pygments/lexers/php.py +++ b/pygments/lexers/php.py @@ -224,7 +224,7 @@ class PhpLexer(RegexLexer): r'finally|match)\b', Keyword), (r'(true|false|null)\b', Keyword.Constant), include('magicconstants'), - (r'\$\{\$+' + _ident_inner + r'\}', Name.Variable), + (r'\$\{', Name.Variable, 'variablevariable'), (r'\$+' + _ident_inner, Name.Variable), (_ident_inner, Name.Other), (r'(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?', Number.Float), @@ -237,6 +237,10 @@ class PhpLexer(RegexLexer): (r'`([^`\\]*(?:\\.[^`\\]*)*)`', String.Backtick), (r'"', String.Double, 'string'), ], + 'variablevariable': [ + (r'\}', Name.Variable, '#pop'), + include('php') + ], 'magicfuncs': [ # source: http://php.net/manual/en/language.oop5.magic.php (words(( -- cgit v1.2.1