Support for indentation of PHP alternative syntax control structures
authorVincenzo Pupillo <v.pupillo@gmail.com>
Fri, 21 Jun 2024 21:24:33 +0000 (23:24 +0200)
committerEli Zaretskii <eliz@gnu.org>
Sat, 22 Jun 2024 09:42:10 +0000 (12:42 +0300)
For some control structures, PHP provides an alternative syntax.
A new rule has been added to handle this syntax.
* lisp/progmodes/php-ts-mode.el (php-ts-mode--indent-styles):
New rule for PHP alternative syntax.  (Bug#71710)

lisp/progmodes/php-ts-mode.el

index 71f51b23ebfb4d3ea4b5d8a0a3e952ef080beeed..7171baf27c9a4ecca871dc41ce22e0fbbfe06d75 100644 (file)
@@ -651,6 +651,12 @@ characters of the current line."
 
            ;; These rules are for cases where the body is bracketless.
            ((match "while" "do_statement") parent-bol 0)
+           ;; rule for PHP alternative syntax
+           ((or (node-is "else_if_clause")
+                (node-is "endif")
+                (node-is "endforeach")
+                (node-is "endwhile"))
+            parent-bol 0)
            ((or (parent-is "if_statement")
                 (parent-is "else_clause")
                 (parent-is "for_statement")