Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Fix multiple modifiers with non-typed property (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
KapitanOczywisty authored Mar 30, 2021
1 parent 9b703d8 commit 7382930
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion grammars/php.cson
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@
}
{
'match': '''(?xi)
((?:(?:public|private|protected|static)(?:\\s+|(?=\\?)))+) # At least one modifier
((?:(?:public|private|protected|static)(?:\\s+|(?=\\?)))++) # At least one modifier
(
(?:\\?\\s*)? [a-z0-9_\\x{7f}-\\x{7fffffff}\\\\]+ | # nullable type
[a-z0-9_\\x{7f}-\\x{7fffffff}\\\\]+ (?: \\s*\\|\\s* [a-z0-9_\\x{7f}-\\x{7fffffff}\\\\]+)+ # union type
Expand Down
12 changes: 12 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,18 @@ describe 'PHP grammar', ->
expect(lines[1][2]).toEqual value: '?', scopes: ["source.php", "meta.class.php", "meta.class.body.php", "keyword.operator.nullable-type.php"]
expect(lines[1][4]).toEqual value: 'string', scopes: ["source.php", "meta.class.php", "meta.class.body.php", "storage.type.php"]

it 'tokenizes 2 modifiers correctly', ->
lines = grammar.tokenizeLines '''
class Foo {
public static $bar = 'baz';
}
'''

expect(lines[1][1]).toEqual value: 'public', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'storage.modifier.php']
expect(lines[1][3]).toEqual value: 'static', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'storage.modifier.php']
expect(lines[1][5]).toEqual value: '$', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'variable.other.php', 'punctuation.definition.variable.php']
expect(lines[1][6]).toEqual value: 'bar', scopes: ['source.php', 'meta.class.php', 'meta.class.body.php', 'variable.other.php']

it 'tokenizes namespaces', ->
lines = grammar.tokenizeLines '''
class A {
Expand Down

0 comments on commit 7382930

Please sign in to comment.