summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pygments/lexers/php.py1
-rw-r--r--tests/snippets/php/anonymous_class.txt28
2 files changed, 29 insertions, 0 deletions
diff --git a/pygments/lexers/php.py b/pygments/lexers/php.py
index f48fa382..702bdd8d 100644
--- a/pygments/lexers/php.py
+++ b/pygments/lexers/php.py
@@ -205,6 +205,7 @@ class PhpLexer(RegexLexer):
(r'[~!%^&*+=|:.<>/@-]+', Operator),
(r'\?', Operator), # don't add to the charclass above!
(r'[\[\]{}();,]+', Punctuation),
+ (r'(new)(\s+)(class)\b', bygroups(Keyword, Text, Keyword)),
(r'(class)(\s+)', bygroups(Keyword, Text), 'classname'),
(r'(function)(\s*)(?=\()', bygroups(Keyword, Text)),
(r'(function)(\s+)(&?)(\s*)',
diff --git a/tests/snippets/php/anonymous_class.txt b/tests/snippets/php/anonymous_class.txt
new file mode 100644
index 00000000..4f5e2aef
--- /dev/null
+++ b/tests/snippets/php/anonymous_class.txt
@@ -0,0 +1,28 @@
+---input---
+<?php
+$containerObject = new class {
+ public $something;
+}
+
+---tokens---
+'<?php' Comment.Preproc
+'\n' Text
+
+'$containerObject' Name.Variable
+' ' Text
+'=' Operator
+' ' Text
+'new' Keyword
+' ' Text
+'class' Keyword
+' ' Text
+'{' Punctuation
+'\n ' Text
+'public' Keyword
+' ' Text
+'$something' Name.Variable
+';' Punctuation
+'\n' Text
+
+'}' Punctuation
+'\n' Text