1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
<?php
/**
* GitHub Issue: https://github.com/emacs-php/php-mode/issues/135
*
* Test indentation of method calls
*/
// Test indentation cascaded calls
$variable->method() // ###php-mode-test### ((indent 0))
/* | column 9 */
->chained(); // ###php-mode-test### ((indent 9))
// Test indentation of statement continuations (statement-cont)
$variable
->method() // ###php-mode-test### ((indent 4))
->method(); // ###php-mode-test### ((indent 4))
ClassName::method()
->chained(); // ###php-mode-test### ((indent 4))
// Test same behaviour inside a block
function foo() {
$variable->method() // ###php-mode-test### ((indent 4))
/* | column 13 */
->chained(); // ###php-mode-test### ((indent 13))
ClassName::method()
->chained(); // ###php-mode-test### ((indent 8))
}
// Test same behaviour inside an arglist
foo($db->baz()
/* | column 7 */
->quux()); // ###php-mode-test### ((indent 7))
foo(
$variable->method() // ###php-mode-test### ((indent 4))
/* | column 13 */
->chained(), // ###php-mode-test### ((indent 13))
// Note that below indentation is different than when not inside
// an arglist. When inside an arglist, cc-mode doesn't provide the
// information that we're in a statement-cont as well.
//
// Future improvement: create a function like c-lineup-cascaded-calls
// to have this indented like statement-cont.
ClassName::method()
->chained() // ###php-mode-test### ((indent 4))
);
// Test same behaviour inside method
class Test {
public function test() {
$variable->method() // ###php-mode-test### ((indent 8))
/* | column 17 */
->chained(); // ###php-mode-test### ((indent 17))
ClassName::method() // ###php-mode-test### ((indent 8))
->chained(); // ###php-mode-test### ((indent 12))
}
}
|