Skip to content

Chained method calls aren't indented #19

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

Closed
metaturso opened this issue Sep 6, 2012 · 12 comments
Closed

Chained method calls aren't indented #19

metaturso opened this issue Sep 6, 2012 · 12 comments

Comments

@metaturso
Copy link

Chained method calls are not aligned to the first object operator in php-mode 1.6.6 and Emacs 24.2.

Indenting a region such as

    $object = new SomeClass();
    $object->method()
           ->another();

produces the same result as previous version of php-mode

    $object = new SomeClass();
    $object->method()
    ->another();
@rev22
Copy link
Contributor

rev22 commented Sep 6, 2012

This requires restoring a setting in the major mode definition:

(c-set-offset 'topmost-intro-cont 'c-lineup-cascaded-calls)

I've pushed the fix: 47b371f

@ejmr
Copy link
Collaborator

ejmr commented Sep 6, 2012

Thanks both for the bug report and the fix guys.

@ejmr ejmr closed this as completed Sep 6, 2012
@metaturso
Copy link
Author

Hello guys cascaded calls are still not indented properly when not in the global scope, e.g.:

// global scope
$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();
}

@ejmr ejmr reopened this Sep 21, 2012
@ejmr
Copy link
Collaborator

ejmr commented Sep 21, 2012

Thanks for the bug report. I fixed the issue and put the patch into master, along with adding your test case to the file tests/issue-19.php. I am going to close this issue now but please let me know if it fixes the problem for you.

@ejmr ejmr closed this as completed Sep 21, 2012
@metaturso
Copy link
Author

It does, but it apparently it also does break font locking. I have to issue font-lock-fontify-buffer whenever a change unfontifies the buffer. Can you confirm this behaviour?

@ejmr
Copy link
Collaborator

ejmr commented Sep 21, 2012

Yes, I can confirm the behavior. It is caused by 78cb2fc which I have reverted for the time being and described in issue #24. My apologies for introducing the font-lock bug. With that reversion in place you should no longer have that issue.

haxney added a commit to haxney/php-mode that referenced this issue Jan 28, 2013
haxney added a commit to haxney/php-mode that referenced this issue Jan 28, 2013
ejmr pushed a commit that referenced this issue Jan 28, 2013
* haxney/ert-tests:
  Mark tests 9, 14, and 19 as expected failures.
  ERT tests for remaining example files.
  Require `php-mode` in `php-mode-test.el`, duh.
  ERT test for #19
  ERT tests for issues 14, 16, and 18
  ERT test for issue #8.
  Create ERT-based test for issue #9.
haxney added a commit to haxney/php-mode that referenced this issue Feb 8, 2013
ejmr pushed a commit that referenced this issue Feb 8, 2013
This massively cuts back on the elisp code needed.

Signed-off-by: Eric James Michael Ritz <[email protected]>
ejmr pushed a commit that referenced this issue Feb 8, 2013
* haxney/tests-with-magic-comments:
  Use magic for tests of issues #14, #19, #27, #29, #42
  Use "magic" comments in PHP files to simplify indentation testing
@TatriX
Copy link

TatriX commented Apr 11, 2013

Is it possible to indent the following:

$object->prop
->foo()
->bar();

if(true) {
    $object->prop
    ->foo()
    ->bar();
}

to this:

$object->prop
       ->foo()
       ->bar();

if(true) {
    $object->prop
           ->foo()
           ->bar();
}

@ejmr
Copy link
Collaborator

ejmr commented Apr 13, 2013

@TatriX

That should work if you are using the styles (i.e. C-c .) pear, drupal, or wordpress. If it is not working then that is a bug. If you load php-mode-tests.el and run then with M-x ert do they pass? Specifically the test for issue-19? We may need to make that test more stringent.

@TatriX
Copy link

TatriX commented Apr 13, 2013

I am using a worpress style.

Selector: t
Passed: 9
Failed: 3 (2 unexpected)
Total:  12/12

Started at:   2013-04-13 10:06:34+0400
Finished.
Finished at:  2013-04-13 10:06:35+0400

F.......F..f

F php-mode-test-issue-14
    Array indentation.
    (ert-test-failed
     ((should
       (reduce
    (lambda
      (l r)
      (and l r))
    (php-mode-test-process-magics)))
      :form
      (reduce
       (lambda
     (l r)
     (and l r))
       (nil t t t))
      :value nil))

F php-mode-test-issue-29
    Indentation of anonymous functions as arguments.
    (ert-test-failed
     ((should
       (reduce
    (lambda
      (l r)
      (and l r))
    (php-mode-test-process-magics)))
      :form
      (reduce
       (lambda
     (l r)
     (and l r))
       (nil nil))
      :value nil))

@ejmr
Copy link
Collaborator

ejmr commented Apr 14, 2013

Thanks for the test output. I will try to figure out the problem.

@fabacino
Copy link
Contributor

fabacino commented Mar 4, 2019

Is this still a problem? I cannot reproduce with v1.21

@zonuexe
Copy link
Member

zonuexe commented May 11, 2019

I'm closing it because it looks like there is no problem today.

@zonuexe zonuexe closed this as completed May 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants