Skip to content

Commit

Permalink
PHP: Added support for PHP 8.1 enums (#2752)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayesh committed Feb 18, 2021
1 parent 3419fb7 commit f79b0ee
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions components/prism-php.js
Expand Up @@ -34,7 +34,7 @@
}
},
'class-name-definition': {
pattern: /(\b(?:class|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
lookbehind: true,
alias: 'class-name'
},
Expand Down Expand Up @@ -85,7 +85,7 @@
alias: 'static-context',
greedy: true
},
/\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
/\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
],
'argument-name': /\b[a-z_]\w*(?=\s*:(?!:))/i,
'class-name': [
Expand Down
2 changes: 1 addition & 1 deletion components/prism-php.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions tests/languages/php/class-name_feature.test
Expand Up @@ -22,6 +22,8 @@ class Foo extends Bar implements Baz {}

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

enum Foo implements Bar {}

----------------------------------------------------

[
Expand Down Expand Up @@ -194,6 +196,13 @@ class Foo extends \Package\Bar implements App\Baz {}
"Baz"
]],
["punctuation", "{"],
["punctuation", "}"],

["keyword", "enum"],
["class-name-definition", "Foo"],
["keyword", "implements"],
["class-name", "Bar"],
["punctuation", "{"],
["punctuation", "}"]
]

Expand Down

0 comments on commit f79b0ee

Please sign in to comment.