diff options
| author | Caleb White <cdwhite3@pm.me> | 2024-03-18 21:19:50 -0500 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-03-27 08:29:44 +0100 |
| commit | 34007887059238f63a49ab4d382d839d9405c66c (patch) | |
| tree | a5d7b7aa35fa3a8dda72194023eec2e587d13c74 /tests/query/highlights/php/keywords.php | |
| parent | bot(lockfile): update djot, hlsplaylist, html, meson, muttrc, query, svelte, ... (diff) | |
| download | nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.tar nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.tar.gz nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.tar.bz2 nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.tar.lz nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.tar.xz nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.tar.zst nvim-treesitter-34007887059238f63a49ab4d382d839d9405c66c.zip | |
feat(php): add highlight tests
Diffstat (limited to 'tests/query/highlights/php/keywords.php')
| -rw-r--r-- | tests/query/highlights/php/keywords.php | 173 |
1 files changed, 173 insertions, 0 deletions
diff --git a/tests/query/highlights/php/keywords.php b/tests/query/highlights/php/keywords.php new file mode 100644 index 000000000..e11a9f351 --- /dev/null +++ b/tests/query/highlights/php/keywords.php @@ -0,0 +1,173 @@ +<?php +//^^^ @punctuation.bracket + +declare(strict_types=1); +//^^^^^ @keyword +// ^^^^^^^^^^^^ @variable.parameter +// ^ @operator +// ^ @number +// ^ @punctuation.delimiter + +include "file.php"; +//^^^^^ @keyword.import +// ^^^^^^^^^ @string +include_once "file.php"; +//^^^^^^^^^^ @keyword.import +require "file.php"; +//^^^^^ @keyword.import +require_once "file.php"; +//^^^^^^^^^^ @keyword.import + +namespace A\B; +//^^^^^^^ @keyword +// ^^^ @module + +if ($a and $b or $c xor $d) {} elseif ($b) {} else {} +// <- @keyword.conditional +// ^^^ @keyword.operator +// ^^ @keyword.operator +// ^^^ @keyword.operator +// ^^^^^^ @keyword.conditional +// ^^^^ @keyword.conditional + +for ($i = 0; $i < 1; $i++) { continue; } +// <- @keyword.repeat +// ^ @operator +// ^^ @operator +// ^^^^^^^^ @keyword.repeat + +while ($b) {} +//^^^ @keyword.repeat + +do { } while ($c); +// <- @keyword.repeat +// ^^^^^ @keyword.repeat + +foreach ($foos as $foo) {} +//^^^^^ @keyword.repeat +// ^^ @keyword.operator + +try {} catch (Exception $e) {} finally {} +//^ @keyword.exception +// ^^^^^ @keyword.exception +// ^^^^^^^^^ @type +// ^^^^^^^ @keyword.exception + +function a() {} +//^^^^^^ @keyword.function +// ^ @function + +abstract class A +//^^^^^^ @keyword.modifier +// ^^^^^ @keyword +// ^ @type +{ + private const BAR = 1; +//^^^^^^^ @keyword.modifier +// ^^^^^ @keyword.modifier + // ^^^ @constant + protected readonly static $a; +//^^^^^^^^^ @keyword.modifier +// ^^^^^^^^ @keyword.modifier +// ^^^^^^ @keyword.modifier + // ^^ @property + final public $b; +//^^^^^ @keyword.modifier + public static function foo(): static {} +//^^^^^^ @keyword.modifier +// ^^^^^^ @keyword.modifier +// ^^^^^^^^ @keyword.function +// ^^^ @function.method +// ^^^^^^ @type.builtin + public function __construct() {} +// ^^^^^^^^^^^ @constructor +} + +class B extends A implements T +// ^ @type +// ^^^^^^^ @keyword +// ^ @type +// ^^^^^^^^^^ @keyword +// ^ @type +{ + use T, U { +//^^^ @keyword.import +// ^ @punctuation.delimiter + U::small insteadof T; +// ^ @type +// ^^ @operator +// ^^^^^ @constant +// ^^^^^^^^^ @keyword +// ^ @type + } + public function foo(callable $call): self +// ^^^^^^^^ @type.builtin +// ^^^^ @type.builtin + { + $call instanceof Closure; +// ^^^^^ @variable +// ^^^^^^^^^^ @keyword +// ^^^^^^^ @type + fn ($a, $b) => $a + $b; +// ^^ @keyword.function + static $a; +// ^^^^^^ @keyword.modifier + global $a; +// ^^^^^^ @keyword + clone $call; +// ^^^^^ @keyword + match ($a) { +// ^^^^^ @keyword.conditional + default => "other", +// ^^^^^^^ @keyword +// ^^ @operator + }; + + switch ($a) { +// ^^^^^^ @keyword.conditional + case 'value': +// ^^^^ @keyword.conditional + break; +// ^^^^^ @keyword + default: +// ^^^^^^^ @keyword + } + yield $a; +// ^^^^^ @keyword.return + yield from $a; +// ^^^^ @keyword.return + return $a; +// ^^^^^^ @keyword.return + goto a; +// ^^^^ @keyword + echo "a"; +// ^^^^ @keyword + print "a"; +// ^^^^^ @keyword + print("a"); +// ^^^^^ @keyword + exit; +// ^^^^ @keyword + exit(); +// ^^^^ @function.builtin + exit(1); +// ^^^^ @function.builtin + } +} + +throw new Exception("oh"); +//^^^ @keyword.exception +// ^^^ @keyword +// ^^^^^^^^^ @constructor + +interface T {} +//^^^^^^^ @keyword +// ^ @type + +trait T { public function small(): void {} } +//^^^ @keyword +// ^ @type +// ^^^^ @type.builtin +enum Foo { case Bar; } +//^^ @keyword +// ^^^^ @keyword.conditional |
