aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortk-shirasaka <tk.shirasaka@gmail.com>2024-01-20 21:34:49 +0900
committerGitHub <noreply@github.com>2024-01-20 12:34:49 +0000
commit64b3d5e5698d485a4f197ffbe85a4b6c29e16325 (patch)
treedf6723ec690b4b4dad98cdcbffaa99c3a66b4587
parentfix(highlights): use `markup.raw.delimiter` for fences (diff)
downloadnvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.tar
nvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.tar.gz
nvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.tar.bz2
nvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.tar.lz
nvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.tar.xz
nvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.tar.zst
nvim-treesitter-64b3d5e5698d485a4f197ffbe85a4b6c29e16325.zip
feat: add the php_only parser included in tree-sitter-php (#5876)
Add parser `php_only` for PHP files without HTML embedded. Make queries for combined parser `php` inherit from `php_only` (no extensions needed). --------- Co-authored-by: shirasaka <tk.shirasaka@gmail>
-rw-r--r--README.md1
-rw-r--r--lockfile.json3
-rw-r--r--lua/nvim-treesitter/parsers.lua9
-rw-r--r--queries/php/folds.scm17
-rw-r--r--queries/php/highlights.scm374
-rw-r--r--queries/php/indents.scm39
-rw-r--r--queries/php/injections.scm45
-rw-r--r--queries/php/locals.scm87
-rw-r--r--queries/php_only/folds.scm16
-rw-r--r--queries/php_only/highlights.scm373
-rw-r--r--queries/php_only/indents.scm38
-rw-r--r--queries/php_only/injections.scm43
-rw-r--r--queries/php_only/locals.scm86
13 files changed, 574 insertions, 557 deletions
diff --git a/README.md b/README.md
index a765566f3..1cb65a6cf 100644
--- a/README.md
+++ b/README.md
@@ -322,6 +322,7 @@ We are looking for maintainers to add more parsers and to write query files for
- [x] [pem](https://github.com/ObserverOfTime/tree-sitter-pem) (maintained by @ObserverOfTime)
- [x] [perl](https://github.com/tree-sitter-perl/tree-sitter-perl) (maintained by @RabbiVeesh, @LeoNerd)
- [x] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka)
+- [x] [php_only](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka)
- [x] [phpdoc](https://github.com/claytonrcarter/tree-sitter-phpdoc) (experimental, maintained by @mikehaertl)
- [x] [pioasm](https://github.com/leo60228/tree-sitter-pioasm) (maintained by @leo60228)
- [x] [po](https://github.com/erasin/tree-sitter-po) (maintained by @amaanq)
diff --git a/lockfile.json b/lockfile.json
index 4d915d387..a8c051124 100644
--- a/lockfile.json
+++ b/lockfile.json
@@ -446,6 +446,9 @@
"php": {
"revision": "b569a5f2c0d592e67430520d1a0e1f765d83ceb0"
},
+ "php_only": {
+ "revision": "b569a5f2c0d592e67430520d1a0e1f765d83ceb0"
+ },
"phpdoc": {
"revision": "915a527d5aafa81b31acf67fab31b0ac6b6319c0"
},
diff --git a/lua/nvim-treesitter/parsers.lua b/lua/nvim-treesitter/parsers.lua
index d60553206..7a945e11e 100644
--- a/lua/nvim-treesitter/parsers.lua
+++ b/lua/nvim-treesitter/parsers.lua
@@ -1332,6 +1332,15 @@ list.php = {
maintainers = { "@tk-shirasaka" },
}
+list.php_only = {
+ install_info = {
+ url = "https://github.com/tree-sitter/tree-sitter-php",
+ location = "php_only",
+ files = { "src/parser.c", "src/scanner.c" },
+ },
+ maintainers = { "@tk-shirasaka" },
+}
+
-- Parsers for injections
list.phpdoc = {
install_info = {
diff --git a/queries/php/folds.scm b/queries/php/folds.scm
index 56eb33e77..f32463888 100644
--- a/queries/php/folds.scm
+++ b/queries/php/folds.scm
@@ -1,16 +1 @@
-[
- (if_statement)
- (switch_statement)
- (while_statement)
- (do_statement)
- (for_statement)
- (foreach_statement)
- (try_statement)
- (function_definition)
- (class_declaration)
- (interface_declaration)
- (trait_declaration)
- (enum_declaration)
- (function_static_declaration)
- (method_declaration)
-] @fold
+; inherits: php_only
diff --git a/queries/php/highlights.scm b/queries/php/highlights.scm
index cbc7e1839..f32463888 100644
--- a/queries/php/highlights.scm
+++ b/queries/php/highlights.scm
@@ -1,373 +1 @@
-; Variables
-(variable_name) @variable
-
-; Constants
-((name) @constant
- (#lua-match? @constant "^_?[A-Z][A-Z%d_]*$"))
-
-((name) @constant.builtin
- (#lua-match? @constant.builtin "^__[A-Z][A-Z%d_]+__$"))
-
-(const_declaration
- (const_element
- (name) @constant))
-
-; Types
-[
- (primitive_type)
- (cast_type)
- (bottom_type)
-] @type.builtin
-
-(named_type
- [
- (name) @type
- (qualified_name
- (name) @type)
- ])
-
-(class_declaration
- name: (name) @type)
-
-(base_clause
- [
- (name) @type
- (qualified_name
- (name) @type)
- ])
-
-(enum_declaration
- name: (name) @type)
-
-(interface_declaration
- name: (name) @type)
-
-(namespace_use_clause
- [
- (name) @type
- (qualified_name
- (name) @type)
- ])
-
-(namespace_aliasing_clause
- (name) @type.definition)
-
-(class_interface_clause
- [
- (name) @type
- (qualified_name
- (name) @type)
- ])
-
-(scoped_call_expression
- scope:
- [
- (name) @type
- (qualified_name
- (name) @type)
- ])
-
-(class_constant_access_expression
- .
- [
- (name) @type
- (qualified_name
- (name) @type)
- ]
- (name) @constant)
-
-(trait_declaration
- name: (name) @type)
-
-(use_declaration
- (name) @type)
-
-(binary_expression
- operator: "instanceof"
- right:
- [
- (name) @type
- (qualified_name
- (name) @type)
- ])
-
-; Functions, methods, constructors
-(array_creation_expression
- "array" @function.builtin)
-
-(list_literal
- "list" @function.builtin)
-
-(method_declaration
- name: (name) @function.method)
-
-(function_call_expression
- function:
- (qualified_name
- (name) @function.call))
-
-(function_call_expression
- (name) @function.call)
-
-(scoped_call_expression
- name: (name) @function.call)
-
-(member_call_expression
- name: (name) @function.method.call)
-
-(function_definition
- name: (name) @function)
-
-(nullsafe_member_call_expression
- name: (name) @function.method)
-
-(method_declaration
- name: (name) @constructor
- (#eq? @constructor "__construct"))
-
-(object_creation_expression
- [
- (name) @constructor
- (qualified_name
- (name) @constructor)
- ])
-
-; Parameters
-[
- (simple_parameter)
- (variadic_parameter)
-] @variable.parameter
-
-(argument
- (name) @variable.parameter)
-
-; Member
-(property_element
- (variable_name) @property)
-
-(member_access_expression
- name:
- (variable_name
- (name)) @property)
-
-(member_access_expression
- name: (name) @property)
-
-; Variables
-(relative_scope) @variable.builtin
-
-((variable_name) @variable.builtin
- (#eq? @variable.builtin "$this"))
-
-; Namespace
-(namespace_definition
- name:
- (namespace_name
- (name) @module))
-
-(namespace_name_as_prefix
- (namespace_name
- (name) @module))
-
-; Attributes
-(attribute_list) @attribute
-
-; Conditions ( ? : )
-(conditional_expression) @keyword.conditional
-
-; Directives
-(declare_directive
- [
- "strict_types"
- "ticks"
- "encoding"
- ] @variable.parameter)
-
-; Basic tokens
-[
- (string)
- (encapsed_string)
- (heredoc_body)
- (nowdoc_body)
- (shell_command_expression) ; backtick operator: `ls -la`
-] @string
-
-(escape_sequence) @string.escape
-
-[
- (heredoc_start)
- (heredoc_end)
-] @label
-
-(nowdoc
- "'" @label)
-
-(boolean) @boolean
-
-(null) @constant.builtin
-
-(integer) @number
-
-(float) @number.float
-
-(comment) @comment @spell
-
-(named_label_statement) @label
-
-; Keywords
-[
- "and"
- "as"
- "instanceof"
- "or"
- "xor"
-] @keyword.operator
-
-[
- "fn"
- "function"
-] @keyword.function
-
-[
- "break"
- "class"
- "clone"
- "declare"
- "default"
- "echo"
- "enddeclare"
- "enum"
- "extends"
- "global"
- "goto"
- "implements"
- "insteadof"
- "interface"
- "namespace"
- "new"
- "trait"
- "unset"
-] @keyword
-
-[
- "abstract"
- "const"
- "final"
- "private"
- "protected"
- "public"
- "readonly"
- "static"
-] @type.qualifier
-
-[
- "return"
- "yield"
-] @keyword.return
-
-[
- "case"
- "else"
- "elseif"
- "endif"
- "endswitch"
- "if"
- "switch"
- "match"
- "??"
-] @keyword.conditional
-
-[
- "continue"
- "do"
- "endfor"
- "endforeach"
- "endwhile"
- "for"
- "foreach"
- "while"
-] @keyword.repeat
-
-[
- "catch"
- "finally"
- "throw"
- "try"
-] @keyword.exception
-
-[
- "include_once"
- "include"
- "require_once"
- "require"
- "use"
-] @keyword.import
-
-[
- ","
- ";"
- ":"
- "\\"
-] @punctuation.delimiter
-
-[
- (php_tag)
- "?>"
- "("
- ")"
- "["
- "]"
- "{"
- "}"
- "#["
-] @punctuation.bracket
-
-[
- "="
- "."
- "-"
- "*"
- "/"
- "+"
- "%"
- "**"
- "~"
- "|"
- "^"
- "&"
- "<<"
- ">>"
- "<<<"
- "->"
- "?->"
- "=>"
- "<"
- "<="
- ">="
- ">"
- "<>"
- "=="
- "!="
- "==="
- "!=="
- "!"
- "&&"
- "||"
- ".="
- "-="
- "+="
- "*="
- "/="
- "%="
- "**="
- "&="
- "|="
- "^="
- "<<="
- ">>="
- "??="
- "--"
- "++"
- "@"
- "::"
-] @operator
+; inherits: php_only
diff --git a/queries/php/indents.scm b/queries/php/indents.scm
index a81faed62..f32463888 100644
--- a/queries/php/indents.scm
+++ b/queries/php/indents.scm
@@ -1,38 +1 @@
-[
- (array_creation_expression)
- (compound_statement)
- (declaration_list)
- (binary_expression)
- (return_statement)
- (arguments)
- (formal_parameters)
- (enum_declaration_list)
- (switch_block)
- (match_block)
- (case_statement)
-] @indent.begin
-
-[
- ")"
- "}"
- "]"
-] @indent.branch
-
-(comment) @indent.auto
-
-(compound_statement
- "}" @indent.end)
-
-(ERROR
- "(" @indent.align
- .
- (_)
- (#set! indent.open_delimiter "(")
- (#set! indent.close_delimiter ")"))
-
-(ERROR
- "[" @indent.align
- .
- (_)
- (#set! indent.open_delimiter "[")
- (#set! indent.close_delimiter "]"))
+; inherits: php_only
diff --git a/queries/php/injections.scm b/queries/php/injections.scm
index 0c9d25ce6..141f65eaa 100644
--- a/queries/php/injections.scm
+++ b/queries/php/injections.scm
@@ -1,47 +1,4 @@
+; inherits: php_only
((text) @injection.content
(#set! injection.language "html")
(#set! injection.combined))
-
-((comment) @injection.content
- (#set! injection.language "phpdoc"))
-
-((heredoc
- (heredoc_body) @injection.content
- (heredoc_end) @injection.language
- (#set! injection.include-children)
- (#downcase! @injection.language)))
-
-((nowdoc
- (nowdoc_body) @injection.content
- (heredoc_end) @injection.language
- (#set! injection.include-children)
- (#downcase! @injection.language)))
-
-; regex
-((function_call_expression
- function: (_) @_preg_func_identifier
- arguments:
- (arguments
- .
- (argument
- (_
- (string_value) @injection.content))))
- (#set! injection.language "regex")
- (#lua-match? @_preg_func_identifier "^preg_"))
-
-; bash
-((function_call_expression
- function: (_) @_shell_func_identifier
- arguments:
- (arguments
- .
- (argument
- (_
- (string_value) @injection.content))))
- (#set! injection.language "bash")
- (#any-of? @_shell_func_identifier "shell_exec" "escapeshellarg" "escapeshellcmd" "exec" "passthru" "proc_open" "shell_exec" "system"))
-
-(expression_statement
- (shell_command_expression
- (string_value) @injection.content)
- (#set! injection.language "bash"))
diff --git a/queries/php/locals.scm b/queries/php/locals.scm
index 8d509b37c..f32463888 100644
--- a/queries/php/locals.scm
+++ b/queries/php/locals.scm
@@ -1,86 +1 @@
-; Scopes
-;-------
-((class_declaration
- name: (name) @local.definition.type) @local.scope
- (#set! definition.type.scope "parent"))
-
-((method_declaration
- name: (name) @local.definition.method) @local.scope
- (#set! definition.method.scope "parent"))
-
-((function_definition
- name: (name) @local.definition.function) @local.scope
- (#set! definition.function.scope "parent"))
-
-(anonymous_function_creation_expression
- (anonymous_function_use_clause
- (variable_name
- (name) @local.definition.var))) @local.scope
-
-; Definitions
-;------------
-(simple_parameter
- (variable_name
- (name) @local.definition.var))
-
-(foreach_statement
- (pair
- (variable_name
- (name) @local.definition.var)))
-
-(foreach_statement
- (variable_name
- (name) @local.reference
- (#set! reference.kind "var"))
- (variable_name
- (name) @local.definition.var))
-
-(property_declaration
- (property_element
- (variable_name
- (name) @local.definition.field)))
-
-(namespace_use_clause
- (qualified_name
- (name) @local.definition.type))
-
-; References
-;------------
-(named_type
- (name) @local.reference
- (#set! reference.kind "type"))
-
-(named_type
- (qualified_name) @local.reference
- (#set! reference.kind "type"))
-
-(variable_name
- (name) @local.reference
- (#set! reference.kind "var"))
-
-(member_access_expression
- name: (name) @local.reference
- (#set! reference.kind "field"))
-
-(member_call_expression
- name: (name) @local.reference
- (#set! reference.kind "method"))
-
-(function_call_expression
- function:
- (qualified_name
- (name) @local.reference
- (#set! reference.kind "function")))
-
-(object_creation_expression
- (qualified_name
- (name) @local.reference
- (#set! reference.kind "type")))
-
-(scoped_call_expression
- scope:
- (qualified_name
- (name) @local.reference
- (#set! reference.kind "type"))
- name: (name) @local.reference
- (#set! reference.kind "method"))
+; inherits: php_only
diff --git a/queries/php_only/folds.scm b/queries/php_only/folds.scm
new file mode 100644
index 000000000..56eb33e77
--- /dev/null
+++ b/queries/php_only/folds.scm
@@ -0,0 +1,16 @@
+[
+ (if_statement)
+ (switch_statement)
+ (while_statement)
+ (do_statement)
+ (for_statement)
+ (foreach_statement)
+ (try_statement)
+ (function_definition)
+ (class_declaration)
+ (interface_declaration)
+ (trait_declaration)
+ (enum_declaration)
+ (function_static_declaration)
+ (method_declaration)
+] @fold
diff --git a/queries/php_only/highlights.scm b/queries/php_only/highlights.scm
new file mode 100644
index 000000000..cbc7e1839
--- /dev/null
+++ b/queries/php_only/highlights.scm
@@ -0,0 +1,373 @@
+; Variables
+(variable_name) @variable
+
+; Constants
+((name) @constant
+ (#lua-match? @constant "^_?[A-Z][A-Z%d_]*$"))
+
+((name) @constant.builtin
+ (#lua-match? @constant.builtin "^__[A-Z][A-Z%d_]+__$"))
+
+(const_declaration
+ (const_element
+ (name) @constant))
+
+; Types
+[
+ (primitive_type)
+ (cast_type)
+ (bottom_type)
+] @type.builtin
+
+(named_type
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ])
+
+(class_declaration
+ name: (name) @type)
+
+(base_clause
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ])
+
+(enum_declaration
+ name: (name) @type)
+
+(interface_declaration
+ name: (name) @type)
+
+(namespace_use_clause
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ])
+
+(namespace_aliasing_clause
+ (name) @type.definition)
+
+(class_interface_clause
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ])
+
+(scoped_call_expression
+ scope:
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ])
+
+(class_constant_access_expression
+ .
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ]
+ (name) @constant)
+
+(trait_declaration
+ name: (name) @type)
+
+(use_declaration
+ (name) @type)
+
+(binary_expression
+ operator: "instanceof"
+ right:
+ [
+ (name) @type
+ (qualified_name
+ (name) @type)
+ ])
+
+; Functions, methods, constructors
+(array_creation_expression
+ "array" @function.builtin)
+
+(list_literal
+ "list" @function.builtin)
+
+(method_declaration
+ name: (name) @function.method)
+
+(function_call_expression
+ function:
+ (qualified_name
+ (name) @function.call))
+
+(function_call_expression
+ (name) @function.call)
+
+(scoped_call_expression
+ name: (name) @function.call)
+
+(member_call_expression
+ name: (name) @function.method.call)
+
+(function_definition
+ name: (name) @function)
+
+(nullsafe_member_call_expression
+ name: (name) @function.method)
+
+(method_declaration
+ name: (name) @constructor
+ (#eq? @constructor "__construct"))
+
+(object_creation_expression
+ [
+ (name) @constructor
+ (qualified_name
+ (name) @constructor)
+ ])
+
+; Parameters
+[
+ (simple_parameter)
+ (variadic_parameter)
+] @variable.parameter
+
+(argument
+ (name) @variable.parameter)
+
+; Member
+(property_element
+ (variable_name) @property)
+
+(member_access_expression
+ name:
+ (variable_name
+ (name)) @property)
+
+(member_access_expression
+ name: (name) @property)
+
+; Variables
+(relative_scope) @variable.builtin
+
+((variable_name) @variable.builtin
+ (#eq? @variable.builtin "$this"))
+
+; Namespace
+(namespace_definition
+ name:
+ (namespace_name
+ (name) @module))
+
+(namespace_name_as_prefix
+ (namespace_name
+ (name) @module))
+
+; Attributes
+(attribute_list) @attribute
+
+; Conditions ( ? : )
+(conditional_expression) @keyword.conditional
+
+; Directives
+(declare_directive
+ [
+ "strict_types"
+ "ticks"
+ "encoding"
+ ] @variable.parameter)
+
+; Basic tokens
+[
+ (string)
+ (encapsed_string)
+ (heredoc_body)
+ (nowdoc_body)
+ (shell_command_expression) ; backtick operator: `ls -la`
+] @string
+
+(escape_sequence) @string.escape
+
+[
+ (heredoc_start)
+ (heredoc_end)
+] @label
+
+(nowdoc
+ "'" @label)
+
+(boolean) @boolean
+
+(null) @constant.builtin
+
+(integer) @number
+
+(float) @number.float
+
+(comment) @comment @spell
+
+(named_label_statement) @label
+
+; Keywords
+[
+ "and"
+ "as"
+ "instanceof"
+ "or"
+ "xor"
+] @keyword.operator
+
+[
+ "fn"
+ "function"
+] @keyword.function
+
+[
+ "break"
+ "class"
+ "clone"
+ "declare"
+ "default"
+ "echo"
+ "enddeclare"
+ "enum"
+ "extends"
+ "global"
+ "goto"
+ "implements"
+ "insteadof"
+ "interface"
+ "namespace"
+ "new"
+ "trait"
+ "unset"
+] @keyword
+
+[
+ "abstract"
+ "const"
+ "final"
+ "private"
+ "protected"
+ "public"
+ "readonly"
+ "static"
+] @type.qualifier
+
+[
+ "return"
+ "yield"
+] @keyword.return
+
+[
+ "case"
+ "else"
+ "elseif"
+ "endif"
+ "endswitch"
+ "if"
+ "switch"
+ "match"
+ "??"
+] @keyword.conditional
+
+[
+ "continue"
+ "do"
+ "endfor"
+ "endforeach"
+ "endwhile"
+ "for"
+ "foreach"
+ "while"
+] @keyword.repeat
+
+[
+ "catch"
+ "finally"
+ "throw"
+ "try"
+] @keyword.exception
+
+[
+ "include_once"
+ "include"
+ "require_once"
+ "require"
+ "use"
+] @keyword.import
+
+[
+ ","
+ ";"
+ ":"
+ "\\"
+] @punctuation.delimiter
+
+[
+ (php_tag)
+ "?>"
+ "("
+ ")"
+ "["
+ "]"
+ "{"
+ "}"
+ "#["
+] @punctuation.bracket
+
+[
+ "="
+ "."
+ "-"
+ "*"
+ "/"
+ "+"
+ "%"
+ "**"
+ "~"
+ "|"
+ "^"
+ "&"
+ "<<"
+ ">>"
+ "<<<"
+ "->"
+ "?->"
+ "=>"
+ "<"
+ "<="
+ ">="
+ ">"
+ "<>"
+ "=="
+ "!="
+ "==="
+ "!=="
+ "!"
+ "&&"
+ "||"
+ ".="
+ "-="
+ "+="
+ "*="
+ "/="
+ "%="
+ "**="
+ "&="
+ "|="
+ "^="
+ "<<="
+ ">>="
+ "??="
+ "--"
+ "++"
+ "@"
+ "::"
+] @operator
diff --git a/queries/php_only/indents.scm b/queries/php_only/indents.scm
new file mode 100644
index 000000000..a81faed62
--- /dev/null
+++ b/queries/php_only/indents.scm
@@ -0,0 +1,38 @@
+[
+ (array_creation_expression)
+ (compound_statement)
+ (declaration_list)
+ (binary_expression)
+ (return_statement)
+ (arguments)
+ (formal_parameters)
+ (enum_declaration_list)
+ (switch_block)
+ (match_block)
+ (case_statement)
+] @indent.begin
+
+[
+ ")"
+ "}"
+ "]"
+] @indent.branch
+
+(comment) @indent.auto
+
+(compound_statement
+ "}" @indent.end)
+
+(ERROR
+ "(" @indent.align
+ .
+ (_)
+ (#set! indent.open_delimiter "(")
+ (#set! indent.close_delimiter ")"))
+
+(ERROR
+ "[" @indent.align
+ .
+ (_)
+ (#set! indent.open_delimiter "[")
+ (#set! indent.close_delimiter "]"))
diff --git a/queries/php_only/injections.scm b/queries/php_only/injections.scm
new file mode 100644
index 000000000..70f693853
--- /dev/null
+++ b/queries/php_only/injections.scm
@@ -0,0 +1,43 @@
+((comment) @injection.content
+ (#set! injection.language "phpdoc"))
+
+((heredoc
+ (heredoc_body) @injection.content
+ (heredoc_end) @injection.language
+ (#set! injection.include-children)
+ (#downcase! @injection.language)))
+
+((nowdoc
+ (nowdoc_body) @injection.content
+ (heredoc_end) @injection.language
+ (#set! injection.include-children)
+ (#downcase! @injection.language)))
+
+; regex
+((function_call_expression
+ function: (_) @_preg_func_identifier
+ arguments:
+ (arguments
+ .
+ (argument
+ (_
+ (string_value) @injection.content))))
+ (#set! injection.language "regex")
+ (#lua-match? @_preg_func_identifier "^preg_"))
+
+; bash
+((function_call_expression
+ function: (_) @_shell_func_identifier
+ arguments:
+ (arguments
+ .
+ (argument
+ (_
+ (string_value) @injection.content))))
+ (#set! injection.language "bash")
+ (#any-of? @_shell_func_identifier "shell_exec" "escapeshellarg" "escapeshellcmd" "exec" "passthru" "proc_open" "shell_exec" "system"))
+
+(expression_statement
+ (shell_command_expression
+ (string_value) @injection.content)
+ (#set! injection.language "bash"))
diff --git a/queries/php_only/locals.scm b/queries/php_only/locals.scm
new file mode 100644
index 000000000..8d509b37c
--- /dev/null
+++ b/queries/php_only/locals.scm
@@ -0,0 +1,86 @@
+; Scopes
+;-------
+((class_declaration
+ name: (name) @local.definition.type) @local.scope
+ (#set! definition.type.scope "parent"))
+
+((method_declaration
+ name: (name) @local.definition.method) @local.scope
+ (#set! definition.method.scope "parent"))
+
+((function_definition
+ name: (name) @local.definition.function) @local.scope
+ (#set! definition.function.scope "parent"))
+
+(anonymous_function_creation_expression
+ (anonymous_function_use_clause
+ (variable_name
+ (name) @local.definition.var))) @local.scope
+
+; Definitions
+;------------
+(simple_parameter
+ (variable_name
+ (name) @local.definition.var))
+
+(foreach_statement
+ (pair
+ (variable_name
+ (name) @local.definition.var)))
+
+(foreach_statement
+ (variable_name
+ (name) @local.reference
+ (#set! reference.kind "var"))
+ (variable_name
+ (name) @local.definition.var))
+
+(property_declaration
+ (property_element
+ (variable_name
+ (name) @local.definition.field)))
+
+(namespace_use_clause
+ (qualified_name
+ (name) @local.definition.type))
+
+; References
+;------------
+(named_type
+ (name) @local.reference
+ (#set! reference.kind "type"))
+
+(named_type
+ (qualified_name) @local.reference
+ (#set! reference.kind "type"))
+
+(variable_name
+ (name) @local.reference
+ (#set! reference.kind "var"))
+
+(member_access_expression
+ name: (name) @local.reference
+ (#set! reference.kind "field"))
+
+(member_call_expression
+ name: (name) @local.reference
+ (#set! reference.kind "method"))
+
+(function_call_expression
+ function:
+ (qualified_name
+ (name) @local.reference
+ (#set! reference.kind "function")))
+
+(object_creation_expression
+ (qualified_name
+ (name) @local.reference
+ (#set! reference.kind "type")))
+
+(scoped_call_expression
+ scope:
+ (qualified_name
+ (name) @local.reference
+ (#set! reference.kind "type"))
+ name: (name) @local.reference
+ (#set! reference.kind "method"))