diff --git a/grammars/php.cson b/grammars/php.cson index 2cc371ee..55ec4733 100644 --- a/grammars/php.cson +++ b/grammars/php.cson @@ -313,6 +313,41 @@ } ] } + { + 'begin': '(?x)\n\t\t\t\t\t\t\t\\s*(array) # Typehint\n\t\t\t\t\t\t\t\\s*(&)? \t\t\t\t\t# Reference\n\t\t\t\t\t\t\t\\s*((\\$+)[a-zA-Z_\\x{7f}-\\x{ff}][a-zA-Z0-9_\\x{7f}-\\x{ff}]*) # The variable name\n\t\t\t\t\t\t\t\\s*(=)\t# A default value\n\t\t\t\t\t\t\t\\s*()\\s*(\\\[)\n\t\t\t\t\t\t\t' + 'beginCaptures': + '1': + 'name': 'storage.type.php' + '2': + 'name': 'storage.modifier.reference.php' + '3': + 'name': 'variable.other.php' + '4': + 'name': 'punctuation.definition.variable.php' + '5': + 'name': '' + '6': + 'name': 'support.function.construct.php' + '7': + 'name': 'punctuation.definition.short.array.begin.php' + 'contentName': 'meta.short.array.php' + 'end': '(\\\])' + 'endCaptures': + '0': + 'name': 'punctuation.definition.short.array.end.php' + 'name': 'meta.function.argument.short.array.php' + 'patterns': [ + { + 'include': '#comments' + } + { + 'include': '#strings' + } + { + 'include': '#numbers' + } + ] + } { 'captures': '1': diff --git a/spec/php-spec.coffee b/spec/php-spec.coffee index 8994fcdd..432a536f 100644 --- a/spec/php-spec.coffee +++ b/spec/php-spec.coffee @@ -211,3 +211,46 @@ describe 'PHP grammar', -> expect(tokens[1][1]).toEqual value: ' ', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'meta.namespace.php'] expect(tokens[1][2]).toEqual value: 'Test', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'meta.namespace.php', 'entity.name.type.namespace.php'] expect(tokens[1][3]).toEqual value: ';', scopes: ['text.html.php', 'meta.embedded.block.php', 'source.php', 'punctuation.terminator.expression.php'] + + it 'should tokenize default array type with old array value correctly', -> + tokens = grammar.tokenizeLines " + tokens = grammar.tokenizeLines "