emacs-php / php-ts-mode

A Tree-sitter based major mode for editing PHP codes
GNU General Public License v3.0
20 stars 8 forks source link

Indentation of functions prefixed with attribute #39

Closed zonuexe closed 8 months ago

zonuexe commented 1 year ago

M-x treesit-check-indent php-ts-mode

diff -u /var/folders/pg/c8fzpdv12hxbcqr9tg9hyl0r0000gn/T/buffer-content-8QRWS0 /var/folders/pg/c8fzpdv12hxbcqr9tg9hyl0r0000gn/T/buffer-content-Ai7ymh
--- /var/folders/pg/c8fzpdv12hxbcqr9tg9hyl0r0000gn/T/buffer-content-8QRWS0  2023-08-28 21:00:10
+++ /var/folders/pg/c8fzpdv12hxbcqr9tg9hyl0r0000gn/T/buffer-content-Ai7ymh  2023-08-28 21:00:10
@@ -6,23 +6,23 @@
  * @return never
  */
 #[\ReturnTypeWillChange()]
-function f(int|string $v = null): void
-{
-    $foo;
-    $foo = $v ?: [];
-    $n = (int)$v;
-    $datetime = new DateTimeImmutable();
+    function f(int|string $v = null): void
+    {
+        $foo;
+        $foo = $v ?: [];
+        $n = (int)$v;
+        $datetime = new DateTimeImmutable();

-    echo __FILE__;
-    if (true) {
-        echo "foo.{$v}";
-    } else {
-        list($a, $b) = array(1, 3);
-        echo $datetime->format('Y-m-d H:i:s'), PHP_EOL;
+        echo __FILE__;
+        if (true) {
+            echo "foo.{$v}";
+        } else {
+            list($a, $b) = array(1, 3);
+            echo $datetime->format('Y-m-d H:i:s'), PHP_EOL;
+        }
+        $class = LogicException::class;
+        throw new LogicException('test');
     }
-    $class = LogicException::class;
-    throw new LogicException('test');
-}

 ?>
 <!DOCTYPE html>