on master help sign in
Update highlight for PHP (#6203)
622f90aErasin Wang
languages.toml+1−1
@@ -571,7 +571,7 @@ indent = { tab-width = 4, unit = " " }
571
571
572[[grammar]]
572[[grammar]]
573name = "php"
573name = "php"
574−source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "57f855461aeeca73bd4218754fb26b5ac143f98f" }
574+source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "f860e598194f4a71747f91789bf536b393ad4a56" }
575
575
576[[language]]
576[[language]]
577name = "twig"
577name = "twig"
runtime/queries/php/highlights.scm+227−40
@@ -2,15 +2,63 @@
2"?>" @tag
2"?>" @tag
3
3
4; Types
4; Types
5+[
6+ (primitive_type)
7+ (cast_type)
8+] @type.builtin
9+
10+(named_type
11+ [ (name) @type
12+ (qualified_name (name) @type)])
13+
14+(base_clause
15+ [ (name) @type
16+ (qualified_name (name) @type)])
17+
18+(enum_declaration
19+ name: (name) @type.enum)
5
20
6−(primitive_type) @type.builtin
21+(interface_declaration
7−(cast_type) @type.builtin
22+ name: (name) @constructor)
8−(named_type (name) @type) @type
23+
9−(named_type (qualified_name) @type) @type
24+(class_declaration
25+ name: (name) @constructor)
26+
27+(trait_declaration
28+ name:(name) @constructor)
10
29
11(namespace_definition
30(namespace_definition
12 name: (namespace_name (name) @namespace))
31 name: (namespace_name (name) @namespace))
13
32
33+(namespace_name_as_prefix
34+ (namespace_name (name) @namespace))
35+
36+(namespace_use_clause
37+ [ (name) @namespace
38+ (qualified_name (name) @type) ])
39+
40+(namespace_aliasing_clause (name) @namespace)
41+
42+(class_interface_clause
43+ [(name) @type
44+ (qualified_name (name) @type)])
45+
46+(scoped_call_expression
47+ scope: [(name) @type
48+ (qualified_name (name) @type)])
49+
50+(class_constant_access_expression
51+ . [(name) @constructor
52+ (qualified_name (name) @constructor)]
53+ (name) @constant)
54+
55+(use_declaration (name) @type)
56+
57+(binary_expression
58+ operator: "instanceof"
59+ right: [(name) @type
60+ (qualified_name (name) @type)])
61+
14; Superglobals
62; Superglobals
15(subscript_expression
63(subscript_expression
16 (variable_name(name) @constant.builtin
64 (variable_name(name) @constant.builtin
@@ -36,6 +84,21 @@
36(function_definition
84(function_definition
37 name: (name) @function)
85 name: (name) @function)
38
86
87+(nullsafe_member_call_expression
88+ name: (name) @function.method)
89+
90+(object_creation_expression
91+ [(name) @constructor
92+ (qualified_name (name) @constructor)])
93+
94+; Parameters
95+[
96+ (simple_parameter)
97+ (variadic_parameter)
98+] @variable.parameter
99+
100+(argument
101+ (name) @variable.parameter)
39
102
40; Member
103; Member
41
104
@@ -62,68 +125,192 @@
62
125
63(variable_name) @variable
126(variable_name) @variable
64
127
128+; Attributes
129+(attribute_list) @attribute
130+
65; Basic tokens
131; Basic tokens
66
132
133+[
67−(string) @string
134+ (string)
68−(heredoc) @string
135+ (encapsed_string)
136+ (heredoc_body)
137+ (nowdoc_body)
138+ (shell_command_expression)
139+] @string
140+(escape_sequence) @constant.character.escape
141+
69(boolean) @constant.builtin.boolean
142(boolean) @constant.builtin.boolean
70(null) @constant.builtin
143(null) @constant.builtin
71(integer) @constant.numeric.integer
144(integer) @constant.numeric.integer
72(float) @constant.numeric.float
145(float) @constant.numeric.float
73(comment) @comment
146(comment) @comment
74
147
75−"$" @operator
148+(goto_statement (name) @label)
149+(named_label_statement (name) @label)
76
150
77; Keywords
151; Keywords
78
152
79[
153[
80− "abstract"
81− "as"
82− "break"
83− "case"
84− "catch"
85− "class"
86− "const"
87− "continue"
88− "declare"
89 "default"
154 "default"
90− "do"
91 "echo"
155 "echo"
92− "else"
93− "elseif"
94− "enddeclare"
95− "endforeach"
96− "endif"
97− "endswitch"
98− "endwhile"
99 "enum"
156 "enum"
100 "extends"
157 "extends"
101 "final"
158 "final"
102− "finally"
159+ "goto"
103− "foreach"
104− "fn"
105− "function"
106 "global"
160 "global"
107− "if"
108 "implements"
161 "implements"
109− "include_once"
110− "include"
111 "insteadof"
162 "insteadof"
112− "interface"
113− "match"
114− "namespace"
115 "new"
163 "new"
116 "private"
164 "private"
117 "protected"
165 "protected"
118 "public"
166 "public"
167+] @keyword
168+
169+[
170+ "if"
171+ "else"
172+ "elseif"
173+ "endif"
174+ "switch"
175+ "endswitch"
176+ "case"
177+ "match"
178+ "declare"
179+ "enddeclare"
180+ "??"
181+] @keyword.control.conditional
182+
183+[
184+ "for"
185+ "endfor"
186+ "foreach"
187+ "endforeach"
188+ "while"
189+ "endwhile"
190+ "do"
191+] @keyword.control.repeat
192+
193+[
194+
195+ "include_once"
196+ "include"
119 "require_once"
197 "require_once"
120 "require"
198 "require"
199+ "use"
200+] @keyword.control.import
201+
202+[
121 "return"
203 "return"
122− "static"
204+ "break"
123− "switch"
205+ "continue"
206+ "yield"
207+] @keyword.control.return
208+
209+[
124 "throw"
210 "throw"
125− "trait"
126 "try"
211 "try"
127− "use"
212+ "catch"
128− "while"
213+ "finally"
214+] @keyword.control.exception
215+
216+[
217+ "as"
218+ "or"
219+ "xor"
220+ "and"
221+ "instanceof"
222+] @keyword.operator
223+
224+[
225+ "fn"
226+ "function"
227+] @keyword.function
228+
229+[
230+ "namespace"
231+ "class"
232+ "interface"
233+ "trait"
234+ "abstract"
235+] @keyword.storage.type
236+
237+[
238+ "static"
239+ "const"
129−] @keyword
240+] @keyword.storage.modifier
241+
242+[
243+ ","
244+ ";"
245+ ":"
246+ "\\"
247+ ] @punctuation.delimiter
248+
249+[
250+ (php_tag)
251+ "?>"
252+ "("
253+ ")"
254+ "["
255+ "]"
256+ "{"
257+ "}"
258+ "#["
259+] @punctuation.bracket
260+
261+[
262+ "="
263+
264+ "."
265+ "-"
266+ "*"
267+ "/"
268+ "+"
269+ "%"
270+ "**"
271+
272+ "~"
273+ "|"
274+ "^"
275+ "&"
276+ "<<"
277+ ">>"
278+
279+ "->"
280+ "?->"
281+
282+ "=>"
283+
284+ "<"
285+ "<="
286+ ">="
287+ ">"
288+ "<>"
289+ "=="
290+ "!="
291+ "==="
292+ "!=="
293+
294+ "!"
295+ "&&"
296+ "||"
297+
298+ ".="
299+ "-="
300+ "+="
301+ "*="
302+ "/="
303+ "%="
304+ "**="
305+ "&="
306+ "|="
307+ "^="
308+ "<<="
309+ ">>="
310+ "??="
311+ "--"
312+ "++"
313+
314+ "@"
315+ "::"
316+] @operator