Skip to content

Commit 9736a18

Browse files
authored
Bump PHP & update highlights (#53)
* feat(php): Bump PHP & update highlights Update the PHP repo, and update the highlights to reflect changes * doc: Add CHANGELOG entry for php bumps
1 parent 3d8d152 commit 9736a18

File tree

3 files changed

+160
-57
lines changed

3 files changed

+160
-57
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

33
## Unreleased
4+
- Updated `php` highlighting to support php8 changes
5+
- Resolve bugs with `php` preventing `evil-textobj-tree-sitter` motions from working
46

57
## 0.10.9 - 2021-12-05
68

queries/php/highlights.scm

Lines changed: 157 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
(php_tag) @tag
22
"?>" @tag
3+
; Variables
4+
5+
(variable_name) @variable
36

47
; Types
58

6-
(primitive_type) @type.builtin
7-
(cast_type) @type.builtin
8-
(type_name (name) @type)
9+
[
10+
(primitive_type)
11+
(cast_type)
12+
] @type.builtin
13+
(named_type (name)) @type
14+
(named_type (qualified_name)) @type
915

1016
; Functions
1117

@@ -27,13 +33,17 @@
2733
(function_definition
2834
name: (name) @function)
2935

36+
(nullsafe_member_call_expression
37+
name: (name) @function.method)
38+
3039
; Member
3140

3241
(property_element
3342
(variable_name) @property)
3443

3544
(member_access_expression
3645
name: (variable_name (name)) @property)
46+
3747
(member_access_expression
3848
name: (name) @property)
3949

@@ -42,7 +52,7 @@
4252
(relative_scope) @variable.builtin
4353

4454
((name) @constant
45-
(.match? @constant "^[A-Z_][A-Z_\\d]*$"))
55+
(.match? @constant "^_?[A-Z][A-Z\d_]+$"))
4656

4757
((name) @constructor
4858
(.match? @constructor "^[A-Z]"))
@@ -54,61 +64,152 @@
5464

5565
; Basic tokens
5666

57-
(string) @string
58-
(heredoc) @string
59-
(boolean) @constant.builtin
67+
[
68+
(string)
69+
(heredoc)
70+
] @string
71+
72+
(boolean) @constant.boolean
6073
(null) @constant.builtin
6174
(integer) @number
62-
(float) @number
75+
(float) @float
6376
(comment) @comment
6477

65-
"$" @operator
66-
6778
; Keywords
6879

69-
"abstract" @keyword
70-
"as" @keyword
71-
"break" @keyword
72-
"case" @keyword
73-
"catch" @keyword
74-
"class" @keyword
75-
"const" @keyword
76-
"continue" @keyword
77-
"declare" @keyword
78-
"default" @keyword
79-
"do" @keyword
80-
"echo" @keyword
81-
"else" @keyword
82-
"elseif" @keyword
83-
"enddeclare" @keyword
84-
"endforeach" @keyword
85-
"endif" @keyword
86-
"endswitch" @keyword
87-
"endwhile" @keyword
88-
"extends" @keyword
89-
"final" @keyword
90-
"finally" @keyword
91-
"foreach" @keyword
92-
"function" @keyword
93-
"global" @keyword
94-
"if" @keyword
95-
"implements" @keyword
96-
"include_once" @keyword
97-
"include" @keyword
98-
"insteadof" @keyword
99-
"interface" @keyword
100-
"namespace" @keyword
101-
"new" @keyword
102-
"private" @keyword
103-
"protected" @keyword
104-
"public" @keyword
105-
"require_once" @keyword
106-
"require" @keyword
107-
"return" @keyword
108-
"static" @keyword
109-
"switch" @keyword
110-
"throw" @keyword
111-
"trait" @keyword
112-
"try" @keyword
113-
"use" @keyword
114-
"while" @keyword
80+
[
81+
"as"
82+
] @keyword.operator
83+
84+
[
85+
"fn"
86+
"function"
87+
] @keyword.function
88+
89+
[
90+
"$"
91+
"abstract"
92+
"break"
93+
"class"
94+
"const"
95+
"continue"
96+
"declare"
97+
"default"
98+
"echo"
99+
"enddeclare"
100+
"extends"
101+
"final"
102+
"global"
103+
"implements"
104+
"insteadof"
105+
"instanceof"
106+
"interface"
107+
"namespace"
108+
"new"
109+
"private"
110+
"protected"
111+
"public"
112+
"static"
113+
"trait"
114+
] @keyword
115+
116+
"return" @keyword.return
117+
118+
[
119+
"case"
120+
"else"
121+
"elseif"
122+
"endif"
123+
"endswitch"
124+
"if"
125+
"switch"
126+
"match"
127+
] @conditional
128+
129+
[
130+
"do"
131+
"endfor"
132+
"endforeach"
133+
"endwhile"
134+
"for"
135+
"foreach"
136+
"while"
137+
] @repeat
138+
139+
[
140+
"catch"
141+
"finally"
142+
"throw"
143+
"try"
144+
] @exception
145+
146+
[
147+
"include_once"
148+
"include"
149+
"require_once"
150+
"require"
151+
"use"
152+
] @include
153+
154+
[
155+
","
156+
";"
157+
"."
158+
] @punctuation.delimiter
159+
160+
[
161+
(php_tag)
162+
"?>"
163+
"("
164+
")"
165+
"["
166+
"]"
167+
"{"
168+
"}"
169+
] @punctuation.bracket
170+
171+
[
172+
"="
173+
174+
"-"
175+
"*"
176+
"/"
177+
"+"
178+
"%"
179+
180+
"~"
181+
"|"
182+
"&"
183+
"<<"
184+
">>"
185+
186+
"->"
187+
"?->"
188+
189+
"=>"
190+
191+
"<"
192+
"<="
193+
">="
194+
">"
195+
"=="
196+
"!="
197+
"==="
198+
"!=="
199+
200+
"!"
201+
"&&"
202+
"||"
203+
204+
"-="
205+
"+="
206+
"*="
207+
"/="
208+
"%="
209+
"|="
210+
"&="
211+
"--"
212+
"++"
213+
] @operator
214+
215+
(ERROR) @error

0 commit comments

Comments
 (0)