Skip to content

Commit

Permalink
Merge pull request #777 from emacs-php/modify-pear-style
Browse files Browse the repository at this point in the history
Modify over-indentation for PEAR style
  • Loading branch information
zonuexe authored Dec 17, 2023
2 parents 2a52f97 + c6efeaa commit a1781e2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ All notable changes of the PHP Mode 1.19.1 release series are documented in this
### Changed

* Make `php-mode` inherit from `php-base-mode` instead of `c-mode` ([#772])
* Modify indentation of [PEAR Coding Standards] ([#774], [#777])
* No longer overindent it by default, since we don't see any mention in the coding style that it should hang `.`. (refs [#227] and [#229])
* **If you have any feedback on PEAR style, please let us know in [the discussion #776][#776].**

### Removed

* Remove `php-mode-disable-c-mode-hook` custom variable and `php-mode-neutralize-cc-mode-effect` function ([#775])
* `php-mode` no longer inherits `c-mode`, so this variable won't work.

[#227]: https://github.com/emacs-php/php-mode/pull/227
[#229]: https://github.com/emacs-php/php-mode/pull/229
[#772]: https://github.com/emacs-php/php-mode/pull/772
[#774]: https://github.com/emacs-php/php-mode/issues/774
[#775]: https://github.com/emacs-php/php-mode/pull/775
[#776]: https://github.com/emacs-php/php-mode/discussions/776
[#777]: https://github.com/emacs-php/php-mode/pull/777
[PEAR Coding Standards]: https://pear.php.net/manual/en/standards.php

## [1.25.1] - 2023-11-24

Expand Down
2 changes: 1 addition & 1 deletion lisp/php-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ a backward search limit."
"pear"
'("php"
(c-basic-offset . 4)
(c-offsets-alist . ((case-label . 0)))
(c-offsets-alist . ((case-label . 0) (statement-cont . +)))
(tab-width . 4)
(php-mode-lineup-cascaded-calls . nil)))

Expand Down
2 changes: 1 addition & 1 deletion tests/issue-227.php → tests/indent/issue-227.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

function my_func() {
return "a really long string with = inside " .
"some more text"; // ###php-mode-test### ((indent 49))
"some more text"; // ###php-mode-test### ((indent 8))
}
11 changes: 11 additions & 0 deletions tests/indent/issue-774.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$someObject->someFunction("some", "parameter") // ###php-mode-test### ((indent 0))
->someOtherFunc(23, 42) // ###php-mode-test### ((indent 4))
->andAThirdFunction(); // ###php-mode-test### ((indent 4))

$result = DateTime::createFromFormat('Y-m-d', '2112-09-03') // ###php-mode-test### ((indent 0))
->someFunction(); // ###php-mode-test### ((indent 4))

$pages = $dbOld->createQueryBuilder() // ###php-mode-test### ((indent 0))
->select('*'); // ###php-mode-test### ((indent 4))
10 changes: 5 additions & 5 deletions tests/php-mode-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,6 @@ style from Drupal."
(search-forward "return")
(should (eq (current-indentation) (* 2 c-basic-offset)))))

(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 :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 @@ -696,6 +691,11 @@ Meant for `php-mode-test-issue-503'."
(with-php-mode-test ("lang/errorcontrol.php" :faces t))
(with-php-mode-test ("lang/magical-constants/echo.php" :faces t)))

(ert-deftest php-mode-test-pear ()
"Tests for PEAR style."
(with-php-mode-test ("indent/issue-227.php" :indent t :magic t :style pear))
(with-php-mode-test ("indent/issue-774.php" :indent t :magic t :style pear)))

;; For developers: How to make .faces list file.
;;
;; 1. Press `M-x eval-buffer' in this file bufffer.
Expand Down

0 comments on commit a1781e2

Please sign in to comment.