Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for PHP 8.1 enums #2770

Merged
merged 3 commits into from
Feb 19, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
alias: 'boolean'
},
/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/,
{
pattern: /(case\s+|::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
RunDevelopment marked this conversation as resolved.
Show resolved Hide resolved
alias: 'enum-constant',
greedy: true,
lookbehind: true,
},
/\b(?:null)\b/i,
];
var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
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: 0 additions & 9 deletions tests/languages/php/class-name_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ class Foo extends Bar implements Baz {}

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

enum Foo implements Bar {}

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

[
Expand Down Expand Up @@ -196,13 +194,6 @@ enum Foo implements Bar {}
"Baz"
]],
["punctuation", "{"],
["punctuation", "}"],

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

Expand Down
52 changes: 52 additions & 0 deletions tests/languages/php/enum_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
enum Foo implements Bar {}

enum Suit {
case Hearts;
case Diamonds = 'D';
}

$val = Suit::Diamonds;

Suit::Spades->name;

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

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

["keyword", "enum"],
["class-name-definition", "Suit"],
["punctuation", "{"],
["keyword", "case"],
["constant", "Hearts"],
["punctuation", ";"],
["keyword", "case"],
["constant", "Diamonds"],
["operator", "="],
["string", "'D'"],
["punctuation", ";"],
["punctuation", "}"],

["variable", "$val"],
["operator", "="],
["class-name", "Suit"],
["operator", "::"],
["constant", "Diamonds"],
["punctuation", ";"],

["class-name", "Suit"],
["operator", "::"],
["constant", "Spades"],
["operator", "->"],
["property", "name"],
["punctuation", ";"]
]

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

Checks for enums.