7777 ; ; "compound_statement" contains the body of many statements.
7878 ; ; For example function_definition, foreach_statement, etc.
7979 ((parent-is " compound_statement" ) parent-bol , offset )
80+ ((parent-is " method_declaration" ) parent-bol 0 )
8081 ((parent-is " array_creation_expression" ) parent-bol , offset )
8182 ((parent-is " base_clause" ) parent-bol , offset )
8283 ((parent-is " class_interface_clause" ) parent-bol , offset )
8687 ((parent-is " binary_expression" ) parent-bol, 0 )
8788 ((parent-is " switch_block" ) parent-bol , offset )
8889 ((parent-is " case_statement" ) parent-bol , offset )
90+ ((parent-is " default_statement" ) parent-bol , offset )
91+ ((parent-is " match_block" ) parent-bol , offset )
8992 ((parent-is " assignment_expression" ) parent-bol , offset )
9093 ((parent-is " return_statement" ) parent-bol , offset ))))
9194 " Tree-sitter indent rules." )
9699 " elseif" " enddeclare" " endforeach" " endif" " endswitch"
97100 " endwhile" " enum" " extends" " final" " finally" " for" " foreach"
98101 " fn" " function" " global" " if" " implements" " include_once"
99- " include" " insteadof" " interface" " namespace" " new"
102+ " include" " instanceof " " insteadof" " interface" " match " " namespace" " new"
100103 " private" " protected" " public" " readonly" " require_once" " require"
101104 " return" " static" " switch" " throw" " trait" " try" " use"
102105 " while" " yield" )
103106 " PHP keywords for tree-sitter font-locking." )
104107
108+ (defvar php-ts-mode--built-in-functions
109+ '(" die" " empty" " isset" )
110+ " PHP built-in functions for tree-sitter font-locking." )
111+
105112(defvar php-ts-mode--operators
106113 '(" !=" " !==" " %" " %=" " &" " &&" " &=" " *" " **" " *="
107114 " +" " ++" " +=" " ," " -" " -" " --" " -=" " ->" " ."
@@ -145,9 +152,10 @@ see https://www.php.net/manual/language.constants.predefined.php")
145152 (named_type (name) @php-type)
146153 (named_type (qualified_name) @php-type)
147154 (namespace_use_clause)
148- (namespace_name (name))]
155+ (namespace_name (name))
156+ (optional_type " ?" @php-type)]
149157 @php-type
150- (class_interface_clause (name) @php-class)
158+ (class_interface_clause [ (name) (qualified_name)] @php-class)
151159 (class_constant_access_expression
152160 (name) @php-keyword
153161 (:match ,(rx bos " class" eos)
@@ -157,16 +165,20 @@ see https://www.php.net/manual/language.constants.predefined.php")
157165 (:match ,(rx bos (? " _" ) (in " A-Z" ) (+ (in " 0-9A-Z_" )) eos)
158166 @php-constant))
159167 (class_constant_access_expression
160- (name) @php-class)
168+ [ (name) (qualified_name)] @php-class)
161169 [(boolean)
162170 (null )]
163171 @php-constant
164172 [(integer)
165173 (float )]
166- @font-lock-number-face)
174+ @font-lock-number-face
175+ (binary_expression
176+ operator: " instanceof"
177+ right: [(name) (qualified_name)] @php-class))
167178
168179 :language 'php
169180 :feature 'definition
181+ :override t
170182 `((class_declaration
171183 name: (name) @php-class)
172184 (interface_declaration
@@ -176,26 +188,28 @@ see https://www.php.net/manual/language.constants.predefined.php")
176188 (trait_declaration
177189 name: (name) @php-class)
178190 (enum_case
179- name: (name) @php-class))
191+ name: (name) @php-class)
192+ (base_clause [(name) (qualified_name)] @php-class)
193+ (use_declaration [(name) (qualified_name)] @php-class))
180194
181195 :language 'php
182196 :feature 'function
197+ :override t
183198 `((array_creation_expression " array" @php-builtin)
184199 (list_literal " list" @php-builtin)
185200 (method_declaration
186201 name: (name) @php-function-name)
187202 (function_call_expression
188203 function: [(qualified_name (name)) (name)] @php-function-call)
189204 (scoped_call_expression
190- scope: (name) @php-class)
191- (scoped_call_expression
205+ scope: [(name) (qualified_name)] @php-class
192206 name: (name) @php-static-method-call)
207+ (scoped_property_access_expression
208+ scope: [(name) (qualified_name)] @php-class)
193209 (member_call_expression
194210 name: (name) @php-method-call)
195- (object_creation_expression (name) @php-class)
196- (attribute (name) @php-class)
197- (attribute (qualified_name) @php-class)
198-
211+ (object_creation_expression [(name) (qualified_name)] @php-class)
212+ (attribute [(name) (qualified_name)] @php-class)
199213 (function_definition
200214 name: (name) @php-function-name))
201215
@@ -207,15 +221,17 @@ see https://www.php.net/manual/language.constants.predefined.php")
207221
208222 ; ; ((name) @constructor
209223 ; ; (:match ,(rx-to-string '(: bos (in "A-Z")))))
210-
211- ; ; (variable_name (name) @php-$this
212- ; ; (:match ,(rx bos "this" eos)
213- ; ; @php-$this))
214224 (member_access_expression name: (name) @php-property-name)
215225 ; ;(variable_name (name) @font-lock-variable-name-face)
216226 (variable_name (name) @php-variable-name)
217227 (variable_name " $" @php-variable-sigil))
218228
229+ :language 'php
230+ :feature 'this
231+ :override t
232+ `((variable_name " $" @php-this-sigil (name) @php-this
233+ (:match ,(rx bos " this" eos) @php-this)))
234+
219235 :language 'php
220236 :feature 'comment
221237 `(((comment) @font-lock-doc-face
@@ -226,7 +242,7 @@ see https://www.php.net/manual/language.constants.predefined.php")
226242 :language 'php
227243 :feature 'string
228244 `([(string )
229- (string_value )
245+ (string_content )
230246 (encapsed_string)
231247 (heredoc)
232248 (heredoc_body)
@@ -240,10 +256,18 @@ see https://www.php.net/manual/language.constants.predefined.php")
240256
241257 :language 'php
242258 :feature 'keyword
259+ :override t
243260 `([,@php-ts-mode--keywords ] @php-keyword
244261 (print_intrinsic " print" @php-keyword)
245262 (goto_statement " goto" @php-keyword)
246- (yield_expression " from" @php-keyword))
263+ (yield_expression " from" @php-keyword)
264+ (function_call_expression
265+ function: (name) @php-keyword
266+ (:match ,(rx-to-string
267+ `(seq bol
268+ (or ,@php-ts-mode--built-in-functions )
269+ eol)) @php-keyword))
270+ (unset_statement " unset" @php-keyword))
247271
248272 :language 'php
249273 :feature 'label
@@ -347,7 +371,7 @@ Currently there are `php-mode' and `php-ts-mode'."
347371 '((comment definition preprocessor)
348372 (keyword string type)
349373 (function constant label)
350- (bracket delimiter operator variables)))
374+ (bracket delimiter operator variables this )))
351375
352376 ; ; Imenu.
353377 (setq-local treesit-simple-imenu-settings
0 commit comments