Skip to content

Commit

Permalink
feat: classname in type declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
TomPavelec committed Oct 12, 2020
1 parent 7db59ed commit 3993ee1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions components/prism-php.js
Expand Up @@ -73,6 +73,19 @@
'punctuation': /\\/
}
},
{
pattern: /\b[a-z_]\w*(?=\s*\$)/i,
alias: 'type-declaration',
greedy: true
},
{
pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
alias: ['class-name-fully-qualified', 'type-declaration'],
greedy: true,
inside: {
'punctuation': /\\/
}
},
{
pattern: /\b[a-z_]\w*(?=\s*::)/i,
alias: 'static-context',
Expand Down
7 changes: 7 additions & 0 deletions tests/languages/php/class-name_feature.test
@@ -1,3 +1,5 @@
public Foo $a;

Foo::bar();
\Foo::bar();
\Package\Foo::bar();
Expand All @@ -14,6 +16,11 @@ class Foo extends \Package\Bar implements App\Baz {}
----------------------------------------------------

[
["keyword", "public"],
["class-name", "Foo"],
["variable", "$a"],
["punctuation", ";"],

["class-name", "Foo"],
["operator", "::"],
["function", "bar"],
Expand Down

0 comments on commit 3993ee1

Please sign in to comment.