Skip to content

Commit

Permalink
Add new attributes
Browse files Browse the repository at this point in the history
- add SensitiveParameter and AllowDynamicProperties (PHP 8.2)
- add ReturnTypeWillChange (PHP 8.1)
  • Loading branch information
KapitanOczywisty committed Feb 26, 2023
1 parent 51901f7 commit baf3485
Show file tree
Hide file tree
Showing 2 changed files with 16 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 @@ -1019,7 +1019,7 @@
{
# There will be other attributes in the future
'match': '''(?xi)
(\\\\)?\\b(Attribute)\\b
(\\\\)?\\b(Attribute|SensitiveParameter|AllowDynamicProperties|ReturnTypeWillChange)\\b
'''
'name': 'support.attribute.builtin.php'
'captures':
Expand Down
15 changes: 15 additions & 0 deletions spec/php-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2639,6 +2639,21 @@ describe 'PHP grammar', ->
expect(lines[1][0]).toEqual value: 'class', scopes: ['source.php', 'meta.class.php', 'storage.type.class.php']
expect(lines[1][2]).toEqual value: 'FooAttribute', scopes: ['source.php', 'meta.class.php', 'entity.name.type.class.php']

lines = grammar.tokenizeLines '''
#[Attribute]
#[Attributes]
#[SensitiveParameter]
#[\\AllowDynamicProperties]
#[ReturnTypeWillChange]
'''

expect(lines[0][1]).toEqual value: 'Attribute', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php']
expect(lines[1][1]).toEqual value: 'Attributes', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.php']
expect(lines[2][1]).toEqual value: 'SensitiveParameter', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php']
expect(lines[3][1]).toEqual value: '\\', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php', 'punctuation.separator.inheritance.php']
expect(lines[3][2]).toEqual value: 'AllowDynamicProperties', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php']
expect(lines[4][1]).toEqual value: 'ReturnTypeWillChange', scopes: ['source.php', 'meta.attribute.php', 'support.attribute.builtin.php']

describe 'PHPDoc', ->
it 'should tokenize @api tag correctly', ->
lines = grammar.tokenizeLines '''
Expand Down

0 comments on commit baf3485

Please sign in to comment.