diff options
| -rw-r--r-- | queries/php/indents.scm | 5 | ||||
| -rw-r--r-- | tests/indent/php/example.php | 12 | ||||
| -rw-r--r-- | tests/indent/php_spec.lua | 20 |
3 files changed, 34 insertions, 3 deletions
diff --git a/queries/php/indents.scm b/queries/php/indents.scm index 27cd7ed0..5c2a2924 100644 --- a/queries/php/indents.scm +++ b/queries/php/indents.scm @@ -10,14 +10,13 @@ ] @indent [ - "(" ")" - "{" "}" - "[" "]" ] @branch [ (comment) ] @ignore + +(compound_statement "}" @indent_end) diff --git a/tests/indent/php/example.php b/tests/indent/php/example.php new file mode 100644 index 00000000..6b0ec56b --- /dev/null +++ b/tests/indent/php/example.php @@ -0,0 +1,12 @@ +<?php + +class example +{ + public int $variable; + // indentation works correctly here + + public function foo() + { + // indentation works correctly here + } +} diff --git a/tests/indent/php_spec.lua b/tests/indent/php_spec.lua new file mode 100644 index 00000000..f081c3a2 --- /dev/null +++ b/tests/indent/php_spec.lua @@ -0,0 +1,20 @@ +local Runner = require("tests.indent.common").Runner + +local run = Runner:new(it, "tests/indent/php", { + tabstop = 4, + shiftwidth = 4, + softtabstop = 0, + expandtab = true, +}) + +describe("indent PHP:", function() + describe("whole file:", function() + run:whole_file(".", { + expected_failures = {}, + }) + end) + + describe("new line:", function() + run:new_line("example.php", { on_line = 11, text = "// new line starts 1 indentation to far", indent = 4 }) + end) +end) |
