Skip to content

Commit f79b0ee

Browse files
authored
PHP: Added support for PHP 8.1 enums (#2752)
1 parent 3419fb7 commit f79b0ee

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

components/prism-php.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
}
3535
},
3636
'class-name-definition': {
37-
pattern: /(\b(?:class|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
37+
pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
3838
lookbehind: true,
3939
alias: 'class-name'
4040
},
@@ -85,7 +85,7 @@
8585
alias: 'static-context',
8686
greedy: true
8787
},
88-
/\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i
88+
/\b(?:__halt_compiler|abstract|and|array|as|break|callable|case|catch|class|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|namespace|match|new|or|parent|print|private|protected|public|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield)\b/i
8989
],
9090
'argument-name': /\b[a-z_]\w*(?=\s*:(?!:))/i,
9191
'class-name': [

components/prism-php.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/languages/php/class-name_feature.test

+9
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class Foo extends Bar implements Baz {}
2222

2323
class Foo extends \Package\Bar implements App\Baz {}
2424

25+
enum Foo implements Bar {}
26+
2527
----------------------------------------------------
2628

2729
[
@@ -194,6 +196,13 @@ class Foo extends \Package\Bar implements App\Baz {}
194196
"Baz"
195197
]],
196198
["punctuation", "{"],
199+
["punctuation", "}"],
200+
201+
["keyword", "enum"],
202+
["class-name-definition", "Foo"],
203+
["keyword", "implements"],
204+
["class-name", "Bar"],
205+
["punctuation", "{"],
197206
["punctuation", "}"]
198207
]
199208

0 commit comments

Comments
 (0)