Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 47 additions & 8 deletions packages/language-php/grammars/tree-sitter/queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -245,22 +245,54 @@
(class_declaration (base_clause (name) @entity.other.inherited-class.php))
(class_declaration (class_interface_clause (name) @entity.other.implemented-interface.php))

; usage or consumption of traits
(use_declaration (name) @entity.name.type.trait.php)
; in use lists, "bar" in `Foo::bar` is a method, not a constant
(use_list
(_
(class_constant_access_expression (name) @support.other.function.method.php .)
(name) @support.other.function.method.php
)
(#set! capture.final true)
)

; the "Foo" and "bar" in `Foo::bar`
(class_constant_access_expression . (name) @support.class.php)
(class_constant_access_expression (name) @variable.other.property.php .)

; the "Foo" and "$bar" in Foo::$bar
(scoped_property_access_expression
scope: (name) @support.class.php
name: (variable_name) @variable.other.property.static.php
(#set! capture.final true))

; Static method calls.
(scoped_call_expression
scope: (name) @support.class.php
name: (name) @support.other.function.method.static.php)

(member_call_expression
name: (name) @support.other.function.method.php)

(scoped_call_expression
scope: (name) @support.class.php)


; TRAITS
; ======

(trait_declaration (name) @entity.name.type.trait.php)

; INTERFACES
; ======

(interface_declaration (name) @entity.name.type.interface.php)

; ENUMS
; =====

(enum_declaration
name: (name) @entity.name.type.enum.php
(enum_declaration_list
(enum_case
name: (name) @constant.other.enum.php)))

; TYPES
; =====
Expand All @@ -272,7 +304,7 @@

"global" @storage.modifier.global.php

["trait" "class"] @storage.type._TYPE_.php
["enum" "interface" "trait" "class"] @storage.type._TYPE_.php
"function" @storage.type.function.php
"fn" @storage.type.function.arrow.php

Expand Down Expand Up @@ -300,9 +332,9 @@
"$" @punctuation.definition.variable.php
) @variable.parameter.php))

; The "$bar" in `$foo->$bar`.
; The "bar" and "$bar" in `$foo->bar` and `$foo->$bar`.
(member_access_expression
name: (variable_name) @variable.other.property.php
name: [(name) (variable_name)] @variable.other.property.php
(#set! capture.final true))

((variable_name
Expand Down Expand Up @@ -349,7 +381,6 @@


[
"abstract"
"as"
"break"
"case"
Expand All @@ -375,7 +406,6 @@
"include_once"
"include"
"insteadof"
"interface"
"namespace"
"new"
"require_once"
Expand All @@ -389,6 +419,7 @@
] @keyword.control._TYPE_.php

[
"abstract"
"final"
"private"
"protected"
Expand Down Expand Up @@ -484,7 +515,15 @@
"-="
"*="
"/="
"%="
"**="
"&="
"|="
"^="
"<<="
">>="
".="
"??="
] @keyword.operator.assignment.compound.php

"->" @keyword.operator.class.php
Expand Down