@@ -852,6 +852,30 @@ describe 'PHP grammar', ->
852852 expect (lines[3 ][13 ]).toEqual value : ' $' , scopes : [" source.php" , " meta.class.php" , " meta.class.body.php" , " variable.other.php" , " punctuation.definition.variable.php" ]
853853 expect (lines[3 ][14 ]).toEqual value : ' c2' , scopes : [" source.php" , " meta.class.php" , " meta.class.body.php" , " variable.other.php" ]
854854
855+ it ' tokenizes readonly properties' , ->
856+ lines = grammar .tokenizeLines '''
857+ class Foo {
858+ public readonly mixed $a;
859+ readonly string $b;
860+ readonly public mixed $c;
861+ }
862+ '''
863+
864+ expect (lines[1 ][1 ]).toEqual value : ' public' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' storage.modifier.php' ]
865+ expect (lines[1 ][3 ]).toEqual value : ' readonly' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' storage.modifier.php' ]
866+ expect (lines[1 ][5 ]).toEqual value : ' mixed' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' keyword.other.type.php' ]
867+ expect (lines[1 ][7 ]).toEqual value : ' $' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' variable.other.php' , ' punctuation.definition.variable.php' ]
868+ expect (lines[1 ][8 ]).toEqual value : ' a' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' variable.other.php' ]
869+ expect (lines[2 ][1 ]).toEqual value : ' readonly' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' storage.modifier.php' ]
870+ expect (lines[2 ][3 ]).toEqual value : ' string' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' keyword.other.type.php' ]
871+ expect (lines[2 ][5 ]).toEqual value : ' $' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' variable.other.php' , ' punctuation.definition.variable.php' ]
872+ expect (lines[2 ][6 ]).toEqual value : ' b' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' variable.other.php' ]
873+ expect (lines[3 ][1 ]).toEqual value : ' readonly' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' storage.modifier.php' ]
874+ expect (lines[3 ][3 ]).toEqual value : ' public' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' storage.modifier.php' ]
875+ expect (lines[3 ][5 ]).toEqual value : ' mixed' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' keyword.other.type.php' ]
876+ expect (lines[3 ][7 ]).toEqual value : ' $' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' variable.other.php' , ' punctuation.definition.variable.php' ]
877+ expect (lines[3 ][8 ]).toEqual value : ' c' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' variable.other.php' ]
878+
855879 describe ' methods' , ->
856880 it ' tokenizes basic method' , ->
857881 lines = grammar .tokenizeLines '''
@@ -943,6 +967,26 @@ describe 'PHP grammar', ->
943967 expect (lines[1 ][17 ]).toEqual value : ' $' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.typehinted.php' , ' variable.other.php' , ' punctuation.definition.variable.php' ]
944968 expect (lines[1 ][18 ]).toEqual value : ' b' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.typehinted.php' , ' variable.other.php' ]
945969
970+ it ' tokenizes readonly promoted properties' , ->
971+ lines = grammar .tokenizeLines '''
972+ class Test {
973+ public function __construct(public readonly int $a, readonly protected? string $b) {}
974+ }
975+ '''
976+
977+ expect (lines[1 ][5 ]).toEqual value : ' __construct' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' support.function.constructor.php' ]
978+ expect (lines[1 ][7 ]).toEqual value : ' public' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' storage.modifier.php' ]
979+ expect (lines[1 ][9 ]).toEqual value : ' readonly' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' storage.modifier.php' ]
980+ expect (lines[1 ][11 ]).toEqual value : ' int' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' keyword.other.type.php' ]
981+ expect (lines[1 ][13 ]).toEqual value : ' $' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' variable.other.php' , ' punctuation.definition.variable.php' ]
982+ expect (lines[1 ][14 ]).toEqual value : ' a' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' variable.other.php' ]
983+ expect (lines[1 ][17 ]).toEqual value : ' readonly' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' storage.modifier.php' ]
984+ expect (lines[1 ][19 ]).toEqual value : ' protected' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' storage.modifier.php' ]
985+ expect (lines[1 ][20 ]).toEqual value : ' ?' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' keyword.operator.nullable-type.php' ]
986+ expect (lines[1 ][22 ]).toEqual value : ' string' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' keyword.other.type.php' ]
987+ expect (lines[1 ][24 ]).toEqual value : ' $' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' variable.other.php' , ' punctuation.definition.variable.php' ]
988+ expect (lines[1 ][25 ]).toEqual value : ' b' , scopes : [' source.php' , ' meta.class.php' , ' meta.class.body.php' , ' meta.function.php' , ' meta.function.parameters.php' , ' meta.function.parameter.promoted-property.php' , ' variable.other.php' ]
989+
946990 it ' tokenizes constructor with illegal return type declaration' , ->
947991 lines = grammar .tokenizeLines '''
948992 class Test {
0 commit comments