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

fix: bug #2614 class-name is now matched before keyword #2731

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions components/prism-php.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
'punctuation': /\\/
}
},
'class-name-definition': [
TomPavelec marked this conversation as resolved.
Show resolved Hide resolved
{
pattern: /(\b(?:class|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
TomPavelec marked this conversation as resolved.
Show resolved Hide resolved
greedy: true,
TomPavelec marked this conversation as resolved.
Show resolved Hide resolved
lookbehind: true,
alias: 'class-name'
},
],
'keyword': [
{
pattern: /(\(\s*)\b(?:bool|boolean|int|integer|float|string|object|array)\b(?=\s*\))/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.

2 changes: 1 addition & 1 deletion tests/languages/php/attribute_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ function main() {}
["delimiter", "]"]
]],
["keyword", "class"],
["class-name", "Foo"],
["class-name-definition", "Foo"],
["punctuation", "{"],
["keyword", "public"],
["keyword", "function"],
Expand Down
4 changes: 2 additions & 2 deletions tests/languages/php/class-name_feature.test
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class Foo extends \Package\Bar implements App\Baz {}
["punctuation", "}"],

["keyword", "class"],
["class-name", "Foo"],
["class-name-definition", "Foo"],
["keyword", "extends"],
["class-name", "Bar"],
["keyword", "implements"],
Expand All @@ -179,7 +179,7 @@ class Foo extends \Package\Bar implements App\Baz {}
["punctuation", "}"],

["keyword", "class"],
["class-name", "Foo"],
["class-name-definition", "Foo"],
["keyword", "extends"],
["class-name", [
["punctuation", "\\"],
Expand Down