Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix indentation of object operator (->) at the beginning of line #624

Merged
merged 2 commits into from
May 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -636,8 +636,11 @@ might be to handle switch and goto labels differently."
(defun php-lineup-cascaded-calls (langelem)
"Line up chained methods using `c-lineup-cascaded-calls',
but only if the setting is enabled"
(when php-mode-lineup-cascaded-calls
(c-lineup-cascaded-calls langelem)))
(if php-mode-lineup-cascaded-calls
(c-lineup-cascaded-calls langelem)
(save-excursion
(beginning-of-line)
(if (looking-at-p "\\s-*->") '+ nil))))

(c-add-style
"php"
Expand Down
17 changes: 17 additions & 0 deletions tests/indent/issue-623.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$object = new DateTime();

$object->something()
->something(); // ###php-mode-test### ((indent 4))

var_dump(
$object->something() // ###php-mode-test### ((indent 4))
->something(), // ###php-mode-test### ((indent 8))
); // ###php-mode-test### ((indent 0))

$arr = [
$object->something() // ###php-mode-test### ((indent 4))
/* comment */ ->something() // ###php-mode-test### ((indent 4))
->something(), // ###php-mode-test### ((indent 8))
]; // ###php-mode-test### ((indent 0))
4 changes: 4 additions & 0 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -645,6 +645,10 @@ Meant for `php-mode-test-issue-503'."
(goto-char (point-min))
(should (eq (php-mode-test-in-function-p nil) nil))))

(ert-deftest php-mode-test-issue-623 ()
"Proper alignment object -> accessor."
(with-php-mode-test ("indent/issue-623.php" :indent t :magic t)))

(ert-deftest php-mode-test-php74 ()
"Test highlighting language constructs added in PHP 7.4."
(with-php-mode-test ("7.4/arrow-function.php" :faces t))
Expand Down