mirror of
https://github.com/nvim-treesitter/nvim-treesitter
synced 2024-09-16 14:34:05 +02:00
feat(php): php 8.4 support (#6741)
* chore(php): update maintainers * feat(php): update php rules, highlight imported functions/consts * feat(php): indent inside property hooks * chore: update php and php_only revision
This commit is contained in:
parent
24ddf60d68
commit
ec8776ed9e
9 changed files with 85 additions and 13 deletions
|
@ -343,8 +343,8 @@ We are looking for maintainers to add more parsers and to write query files for
|
|||
- [x] [passwd](https://github.com/ath3/tree-sitter-passwd) (maintained by @amaanq)
|
||||
- [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] [php](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka, @calebdw)
|
||||
- [x] [php_only](https://github.com/tree-sitter/tree-sitter-php) (maintained by @tk-shirasaka, @calebdw)
|
||||
- [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)
|
||||
|
|
|
@ -510,10 +510,10 @@
|
|||
"revision": "3a21d9cb2a20a062c17f8f53d5983fd473c4673c"
|
||||
},
|
||||
"php": {
|
||||
"revision": "c07d69739ba71b5a449bdbb7735991f8aabf8546"
|
||||
"revision": "71605bf96303144c2ecfc2c0b69d95c716ed9e13"
|
||||
},
|
||||
"php_only": {
|
||||
"revision": "c07d69739ba71b5a449bdbb7735991f8aabf8546"
|
||||
"revision": "71605bf96303144c2ecfc2c0b69d95c716ed9e13"
|
||||
},
|
||||
"phpdoc": {
|
||||
"revision": "1d0e255b37477d0ca46f1c9e9268c8fa76c0b3fc"
|
||||
|
|
|
@ -1495,7 +1495,7 @@ list.php = {
|
|||
location = "php",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
},
|
||||
maintainers = { "@tk-shirasaka" },
|
||||
maintainers = { "@tk-shirasaka", "@calebdw" },
|
||||
}
|
||||
|
||||
list.php_only = {
|
||||
|
@ -1504,7 +1504,7 @@ list.php_only = {
|
|||
location = "php_only",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
},
|
||||
maintainers = { "@tk-shirasaka" },
|
||||
maintainers = { "@tk-shirasaka", "@calebdw" },
|
||||
}
|
||||
|
||||
-- Parsers for injections
|
||||
|
|
|
@ -221,10 +221,26 @@
|
|||
(name) @type
|
||||
(qualified_name
|
||||
(name) @type)
|
||||
alias: (name) @type.definition
|
||||
])
|
||||
|
||||
(namespace_aliasing_clause
|
||||
(name) @type.definition)
|
||||
(namespace_use_clause
|
||||
type: "function"
|
||||
[
|
||||
(name) @function
|
||||
(qualified_name
|
||||
(name) @function)
|
||||
alias: (name) @function
|
||||
])
|
||||
|
||||
(namespace_use_clause
|
||||
type: "const"
|
||||
[
|
||||
(name) @constant
|
||||
(qualified_name
|
||||
(name) @constant)
|
||||
alias: (name) @constant
|
||||
])
|
||||
|
||||
(class_interface_clause
|
||||
[
|
||||
|
@ -369,9 +385,8 @@
|
|||
name: (namespace_name
|
||||
(name) @module))
|
||||
|
||||
(namespace_name_as_prefix
|
||||
(namespace_name
|
||||
(name) @module))
|
||||
(namespace_name
|
||||
(name) @module)
|
||||
|
||||
; Attributes
|
||||
(attribute_list) @attribute
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
(match_block)
|
||||
(case_statement)
|
||||
(default_statement)
|
||||
(property_hook_list)
|
||||
] @indent.begin
|
||||
|
||||
(return_statement
|
||||
[
|
||||
(object_creation_expression)
|
||||
(anonymous_function_creation_expression)
|
||||
(anonymous_function)
|
||||
(arrow_function)
|
||||
(match_expression)
|
||||
]) @indent.dedent
|
||||
|
@ -49,6 +50,9 @@
|
|||
(return_statement
|
||||
";" @indent.end)
|
||||
|
||||
(property_hook_list
|
||||
"}" @indent.end)
|
||||
|
||||
(ERROR
|
||||
"(" @indent.align
|
||||
.
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
name: (name) @local.definition.function) @local.scope
|
||||
(#set! definition.function.scope "parent"))
|
||||
|
||||
(anonymous_function_creation_expression
|
||||
(anonymous_function
|
||||
(anonymous_function_use_clause
|
||||
(variable_name
|
||||
(name) @local.definition.var))) @local.scope
|
||||
|
|
13
tests/indent/php/property-hooks.php
Normal file
13
tests/indent/php/property-hooks.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
class Foo
|
||||
{
|
||||
private string $_baz;
|
||||
|
||||
public string $baz {
|
||||
&get => $this->_baz;
|
||||
set {
|
||||
$this->_baz = strtoupper($value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -67,5 +67,10 @@ describe("indent PHP:", function()
|
|||
run:new_line("issue-6888.php", { on_line = 6, text = "$a;", indent = 0 })
|
||||
run:new_line("issue-6888.php", { on_line = 8, text = "$a;", indent = 4 })
|
||||
run:new_line("issue-6888.php", { on_line = 11, text = "$a;", indent = 0 })
|
||||
run:new_line("property-hooks.php", { on_line = 7, text = "get;", indent = 8 })
|
||||
run:new_line("property-hooks.php", { on_line = 8, text = "set;", indent = 8 })
|
||||
run:new_line("property-hooks.php", { on_line = 9, text = "$a;", indent = 12 })
|
||||
run:new_line("property-hooks.php", { on_line = 11, text = "get;", indent = 8 })
|
||||
run:new_line("property-hooks.php", { on_line = 12, text = "get;", indent = 4 })
|
||||
end)
|
||||
end)
|
||||
|
|
|
@ -1,5 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Foo\Bar;
|
||||
//^^^^^^^ @keyword.type
|
||||
// ^^^ @module
|
||||
// ^^^ @module
|
||||
|
||||
use Foo\Baz as Baaz;
|
||||
//^ @keyword.import
|
||||
// ^^^ @module
|
||||
// ^^^ @type
|
||||
// ^^ @keyword.operator
|
||||
// ^^^^ @type.definition
|
||||
|
||||
use function Foo\foo as fooo;
|
||||
// ^^^^^^^^ @keyword.function
|
||||
// ^^^ @function
|
||||
// ^^^^ @function
|
||||
|
||||
use const Foo\FOO as FOOO;
|
||||
// ^^^^^ @keyword.modifier
|
||||
// ^^^ @constant
|
||||
// ^^^^ @constant
|
||||
|
||||
use Foo\Baz\{
|
||||
// ^^^ @module
|
||||
// ^^^ @module
|
||||
Bar,
|
||||
//^^^ @type
|
||||
function foo,
|
||||
//^^^^^^^^ @keyword.function
|
||||
// ^^^ @function
|
||||
const FOO,
|
||||
//^^^^^ @keyword.modifier
|
||||
// ^^^ @constant
|
||||
};
|
||||
|
||||
abstract class A
|
||||
{
|
||||
protected readonly static $a;
|
||||
|
|
Loading…
Reference in a new issue