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

Fix multiple modifiers with non-typed property #417

Merged
merged 1 commit into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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