Permalink
Browse files

Merge branch 'issue-19'

* issue-19:
  Make chained method calls line up in all scopes
  Indent the test case for issue 19 the way it should look
  Expand the test case for issue 19 to include different scopes
  • Loading branch information...
2 parents b1778a9 + 96cf431 commit 25c57ff605f88961270d500feb9b4420550e5af0 Eric James Michael Ritz committed Sep 21, 2012
Showing with 39 additions and 3 deletions.
  1. +4 −0 php-mode.el
  2. +35 −3 tests/issue-19.php
View
@@ -443,7 +443,11 @@ This is was done due to the problem reported here:
(set (make-local-variable 'c-opt-cpp-start) php-tags-key)
(set (make-local-variable 'c-opt-cpp-prefix) php-tags-key)
+ ;; These settings ensure that chained method calls line up correctly
+ ;; over multiple lines.
(c-set-offset 'topmost-intro-cont 'c-lineup-cascaded-calls)
+ (c-set-offset 'statement-cont 'c-lineup-cascaded-calls)
+ (c-set-offset 'brace-list-entry 'c-lineup-cascaded-calls)
(set (make-local-variable 'c-block-stmt-1-key) php-block-stmt-1-key)
(set (make-local-variable 'c-block-stmt-2-key) php-block-stmt-2-key)
View
@@ -10,8 +10,40 @@
* $object->method()
* ->another();
*
+ * Alignment should occur on the '->' characters regardless of the
+ * scope in which the method calls appear.
*/
-$object = new SomeClass();
-$object->method()
- ->another();
+$object = new StdClass();
+$object->call()
+ ->something();
+
+class Whatever
+{
+ public function __construct()
+ {
+ $object = new StdClass();
+ $object->call()
+ ->something();
+ }
+
+ public function something()
+ {
+ $object = new StdClass();
+ $object->call()
+ ->something();
+ }
+}
+
+$closure = function() {
+ $object = new StdClass();
+ $object->call()
+ ->something();
+};
+
+function something()
+{
+ $object = new StdClass();
+ $object->call()
+ ->something();
+}

0 comments on commit 25c57ff

Please sign in to comment.