Skip to content

Commit

Permalink
Merge pull request #598 from emacs-php/fix/class-indentation
Browse files Browse the repository at this point in the history
Fix anonymous class indentation
  • Loading branch information
zonuexe authored Dec 9, 2019
2 parents 095b707 + a9fec82 commit d3a61b1
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 1 deletion.
1 change: 1 addition & 0 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ but only if the setting is enabled"
(case-label . +)
(class-open . 0)
(comment-intro . 0)
(inexpr-class . 0)
(inlambda . 0)
(inline-open . 0)
(namespace-open . 0)
Expand Down
9 changes: 9 additions & 0 deletions tests/lang/class/anonymous-class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

$class = new class () extends IteratorAggregate {
// ###php-mode-test### ((indent 4))
};

is_object(1, new class () extends IteratorAggregate {
// ###php-mode-test### ((indent 4))
});
32 changes: 32 additions & 0 deletions tests/lang/class/anonymous-class.php.faces
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
;; -*- mode: emacs-lisp -*-
(("<?php" . php-php-tag)
("\n\n")
("$" . php-variable-sigil)
("class" . php-variable-name)
(" ")
("=" . php-assignment-op)
(" ")
("new" . php-keyword)
(" ")
("class" . php-keyword)
(" () ")
("extends" . php-keyword)
(" ")
("IteratorAggregate" . font-lock-type-face)
(" {\n ")
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
("};\n\n")
("is_object" . php-function-call)
("(1, ")
("new" . php-keyword)
(" ")
("class" . php-keyword)
(" () ")
("extends" . php-keyword)
(" ")
("IteratorAggregate" . font-lock-type-face)
(" {\n ")
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
("});\n"))
9 changes: 9 additions & 0 deletions tests/lang/function/closure.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

is_object(static function () {
// ###php-mode-test### ((indent 4))
});

is_object(static function (): void {
// ###php-mode-test### ((indent 4))
});
23 changes: 23 additions & 0 deletions tests/lang/function/closure.php.faces
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
;; -*- mode: emacs-lisp -*-
(("<?php" . php-php-tag)
("\n\n")
("is_object" . php-function-call)
("(")
("static" . php-keyword)
(" ")
("function" . php-keyword)
(" () {\n ")
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
("});\n\n")
("is_object" . php-function-call)
("(")
("static" . php-keyword)
(" ")
("function" . php-keyword)
(" (): ")
("void" . font-lock-type-face)
(" {\n ")
("// " . font-lock-comment-delimiter-face)
("###php-mode-test### ((indent 4))\n" . font-lock-comment-face)
("});\n"))
5 changes: 4 additions & 1 deletion tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ style from Drupal."
(ert-deftest php-mode-test-issue-227 ()
"multi-line strings indents "
(custom-set-variables '(php-lineup-cascaded-calls t))
(with-php-mode-test ("issue-227.php" :indent t :style pear)))
(with-php-mode-test ("issue-227.php" :indent t :style pear :magic t)))

(ert-deftest php-mode-test-issue-237 ()
"Indent chaining method for PSR2."
(with-php-mode-test ("issue-237.php" :indent t :style psr2 :magic t)))
Expand Down Expand Up @@ -680,7 +681,9 @@ Meant for `php-mode-test-issue-503'."
(t t))))
(with-php-mode-test ("doc-comment/return-type.php" :faces t))
(with-php-mode-test ("doc-comment/inheritdoc.php" :faces t))
(with-php-mode-test ("lang/class/anonymous-class.php" :indent t :magic t :faces t))
(with-php-mode-test ("lang/function/calls.php" :faces t))
(with-php-mode-test ("lang/function/closure.php" :indent t :magic t :faces t))
(with-php-mode-test ("lang/try-cactch/multiple.php" :faces t))
(with-php-mode-test ("lang/types/cast.php" :faces t))
(with-php-mode-test ("lang/types/function.php" :faces t))
Expand Down

0 comments on commit d3a61b1

Please sign in to comment.