1; Keywords
2
3[
4 "and"
5 "as"
6 "break"
7 "case"
8 "catch"
9 "class"
10 "clone"
11 "const"
12 "continue"
13 "declare"
14 "default"
15 "do"
16 "echo"
17 "else"
18 "elseif"
19 "enddeclare"
20 "endfor"
21 "endforeach"
22 "endif"
23 "endswitch"
24 "endwhile"
25 "enum"
26 "exit"
27 "extends"
28 "finally"
29 "fn"
30 "for"
31 "foreach"
32 "function"
33 "global"
34 "goto"
35 "if"
36 "implements"
37 "include"
38 "include_once"
39 "instanceof"
40 "insteadof"
41 "interface"
42 "match"
43 "namespace"
44 "new"
45 "or"
46 "print"
47 "require"
48 "require_once"
49 "return"
50 "switch"
51 "throw"
52 "trait"
53 "try"
54 "use"
55 "while"
56 "xor"
57 (abstract_modifier)
58 (final_modifier)
59 (readonly_modifier)
60 (static_modifier)
61 (visibility_modifier)
62] @keyword
63
64(function_static_declaration "static" @keyword)
65
66; Namespace
67
68(namespace_definition
69 name: (namespace_name
70 (name) @module))
71
72(namespace_name
73 (name) @module)
74
75; Variables
76
77(relative_scope) @variable.builtin
78
79(variable_name) @variable
80
81(method_declaration name: (name) @constructor
82 (#eq? @constructor "__construct"))
83
84((name) @constant
85 (#match? @constant "^_?[A-Z][A-Z\\d_]+$"))
86((name) @constant.builtin
87 (#match? @constant.builtin "^__[A-Z][A-Z\d_]+__$"))
88(const_declaration (const_element (name) @constant))
89
90; Functions
91
92(array_creation_expression "array" @function.builtin)
93(list_literal "list" @function.builtin)
94(exit_statement "exit" @function.builtin "(")
95
96(method_declaration
97 name: (name) @function.method)
98
99(scoped_call_expression
100 name: (name) @function)
101
102(member_call_expression
103 name: (name) @function.method)
104
105(function_definition
106 name: (name) @function)
107
108; Member
109
110(property_element
111 (variable_name) @property)
112
113(member_access_expression
114 name: (variable_name (name)) @property)
115(member_access_expression
116 name: (name) @property)
117
118; Basic tokens
119[
120 (string)
121 (string_content)
122 (encapsed_string)
123 (heredoc)
124 (heredoc_body)
125 (nowdoc_body)
126] @string
127(boolean) @constant.builtin
128(null) @constant.builtin
129(integer) @number
130(float) @number
131(comment) @comment
132
133((name) @variable.builtin
134 (#eq? @variable.builtin "this"))
135
136"$" @operator