From 86d91ee98fe0898e20ce4455335bca9d4275f2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sun, 31 May 2026 21:28:32 +0900 Subject: [PATCH] lang: Update php --- languages.toml | 4 ++-- runtime/queries/php-only/highlights.scm | 8 ++++++-- runtime/queries/php/highlights.scm | 15 ++++++++++----- runtime/queries/php/indents.scm | 1 + runtime/queries/php/injections.scm | 6 +++--- runtime/queries/php/textobjects.scm | 8 +++++++- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/languages.toml b/languages.toml index 264f44b0..1fbf9b18 100644 --- a/languages.toml +++ b/languages.toml @@ -1352,7 +1352,7 @@ indent = { tab-width = 4, unit = " " } [[grammar]] name = "php" -source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "f860e598194f4a71747f91789bf536b393ad4a56" } +source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "3f2465c217d0a966d41e584b42d75522f2a3149e", subpath = "php" } [[language]] name = "php-only" @@ -1364,7 +1364,7 @@ roots = ["composer.json", "index.php"] [[grammar]] name = "php-only" -source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "cf1f4a0f1c01c705c1d6cf992b104028d5df0b53", subpath = "php_only" } +source = { git = "https://github.com/tree-sitter/tree-sitter-php", rev = "3f2465c217d0a966d41e584b42d75522f2a3149e", subpath = "php_only" } [[language]] name = "blade" diff --git a/runtime/queries/php-only/highlights.scm b/runtime/queries/php-only/highlights.scm index 720d6ea1..349f7372 100644 --- a/runtime/queries/php-only/highlights.scm +++ b/runtime/queries/php-only/highlights.scm @@ -1,5 +1,5 @@ (php_tag) @tag -"?>" @tag +(php_end_tag) @tag ; Variables @@ -45,6 +45,10 @@ (function_definition name: (name) @function) +; Property hooks (PHP 8.4): `get`/`set` parse as a plain `name`; anchor to the +; first child so names in the hook body aren't caught. +(property_hook . (name) @keyword) + ; Member (property_element @@ -58,7 +62,7 @@ ; Basic tokens [ (string) - (string_value) + (string_content) (encapsed_string) (heredoc) (heredoc_body) diff --git a/runtime/queries/php/highlights.scm b/runtime/queries/php/highlights.scm index c11c5fb7..624b876c 100644 --- a/runtime/queries/php/highlights.scm +++ b/runtime/queries/php/highlights.scm @@ -1,5 +1,5 @@ (php_tag) @tag -"?>" @tag +(php_end_tag) @tag ; Variables @@ -45,14 +45,15 @@ (namespace_definition name: (namespace_name (name) @namespace)) -(namespace_name_as_prefix - (namespace_name (name) @namespace)) +(qualified_name + prefix: (namespace_name (name) @namespace)) (namespace_use_clause [ (name) @namespace (qualified_name (name) @type) ]) -(namespace_aliasing_clause (name) @namespace) +(namespace_use_clause + alias: (name) @namespace) (class_interface_clause [(name) @type @@ -115,6 +116,10 @@ (argument (name) @variable.parameter) +; Property hooks (PHP 8.4): the `get`/`set` accessor name parses as a plain +; `name`; anchor to the first child so names inside the hook body aren't caught. +(property_hook . (name) @keyword) + ; Member (property_element @@ -251,7 +256,7 @@ [ (php_tag) - "?>" + (php_end_tag) "(" ")" "[" diff --git a/runtime/queries/php/indents.scm b/runtime/queries/php/indents.scm index 04229d2f..1af1b21b 100644 --- a/runtime/queries/php/indents.scm +++ b/runtime/queries/php/indents.scm @@ -9,6 +9,7 @@ (expression_statement) (switch_block) (anonymous_function_use_clause) + (property_hook_list) ] @indent [ diff --git a/runtime/queries/php/injections.scm b/runtime/queries/php/injections.scm index 8d1b9740..1cf4d225 100644 --- a/runtime/queries/php/injections.scm +++ b/runtime/queries/php/injections.scm @@ -7,19 +7,19 @@ ((function_call_expression function: (name) @_function - arguments: (arguments . (argument (_ (string_value) @injection.content)))) + arguments: (arguments . (argument (_ (string_content) @injection.content)))) (#match? @_function "^preg_") (#set! injection.language "regex")) ((function_call_expression function: (name) @_function - arguments: (arguments (_) (argument (_ (string_value) @injection.content)))) + arguments: (arguments (_) (argument (_ (string_content) @injection.content)))) (#match? @_function "^mysqli_") (#set! injection.language "sql")) ((member_call_expression object: (_) name: (name) @_function - arguments: (arguments . (argument (_ (string_value) @injection.content)))) + arguments: (arguments . (argument (_ (string_content) @injection.content)))) (#match? @_function "^(prepare|query)$") (#set! injection.language "sql")) diff --git a/runtime/queries/php/textobjects.scm b/runtime/queries/php/textobjects.scm index e721b864..9d405ff1 100644 --- a/runtime/queries/php/textobjects.scm +++ b/runtime/queries/php/textobjects.scm @@ -19,7 +19,13 @@ (arrow_function body: (_) @function.inside) @function.around -(anonymous_function_creation_expression +(anonymous_function + body: (_) @function.inside) @function.around + +(anonymous_class + body: (_) @class.inside) @class.around + +(property_hook body: (_) @function.inside) @function.around (anonymous_function_use_clause -- 2.51.2