aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/php/highlights.scm
blob: 77c9424fef64794e761f70f673c9d71d20cdb330 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
(php_tag) @tag
"?>" @tag

; Types

(primitive_type) @type.builtin
(cast_type) @type.builtin
(named_type (name) @type) @type
(named_type (qualified_name) @type) @type

(namespace_definition
  name: (namespace_name (name) @namespace))

; Superglobals
(subscript_expression
  (variable_name(name) @constant.builtin
    (#match? @constant.builtin "^_?[A-Z][A-Z\\d_]+$")))

; Functions

(array_creation_expression "array" @function.builtin)
(list_literal "list" @function.builtin)

(method_declaration
  name: (name) @function.method)

(function_call_expression
  function: (_) @function)

(scoped_call_expression
  name: (name) @function)

(member_call_expression
  name: (name) @function.method)

(function_definition
  name: (name) @function)


; Member

(property_element
  (variable_name) @variable.other.member)

(member_access_expression
  name: (variable_name (name)) @variable.other.member)
(member_access_expression
  name: (name) @variable.other.member)

; Variables

(relative_scope) @variable.builtin

((name) @constant
 (#match? @constant "^_?[A-Z][A-Z\\d_]+$"))

((name) @constructor
 (#match? @constructor "^[A-Z]"))

((name) @variable.builtin
 (#eq? @variable.builtin "this"))

(variable_name) @variable

; Basic tokens

(string) @string
(heredoc) @string
(boolean) @constant.builtin.boolean
(null) @constant.builtin
(integer) @constant.numeric.integer
(float) @constant.numeric.float
(comment) @comment

"$" @operator

; Keywords

[
  "abstract" 
  "as" 
  "break" 
  "case" 
  "catch" 
  "class" 
  "const" 
  "continue" 
  "declare" 
  "default" 
  "do" 
  "echo" 
  "else" 
  "elseif" 
  "enddeclare" 
  "endforeach" 
  "endif" 
  "endswitch" 
  "endwhile" 
  "enum" 
  "extends" 
  "final" 
  "finally" 
  "foreach" 
  "fn" 
  "function" 
  "global" 
  "if" 
  "implements" 
  "include_once" 
  "include" 
  "insteadof" 
  "interface" 
  "match" 
  "namespace" 
  "new" 
  "private" 
  "protected" 
  "public" 
  "require_once" 
  "require" 
  "return" 
  "static" 
  "switch" 
  "throw" 
  "trait" 
  "try" 
  "use" 
  "while" 
] @keyword