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

Wrong indentation for multiline instance method calls #29

Open
kq-li opened this issue Jul 23, 2019 · 1 comment
Open

Wrong indentation for multiline instance method calls #29

kq-li opened this issue Jul 23, 2019 · 1 comment

Comments

@kq-li
Copy link

kq-li commented Jul 23, 2019

When spanning multiple lines, instance method calls don't have the expected indentation. For example:

Expected:

$node->query()
  ->selectByLambda($node ==>
    checkValid($node),
  )
  ->whereLambda(
    $node ==> condition($node),
  );

Actual:

$node->query()
  ->selectByLambda($node ==>
                   checkValid($node),
                   )
  ->whereLambda(
  $node ==> condition($node),
);
Wilfred added a commit that referenced this issue Apr 21, 2020
Previously we had custom logic to handle hanging arguments.

    foo($x,
        $y);

This was getting confused by other forms of trailing text after
parens:

    if (true) { // hello
      foo();
    }

foo() should not line up with { here.

This heuristic isn't useful, because hackfmt only uses the following
two forms:

    foo($x, $y);
    // or
    foo(
      $x,
      $y,
    );

Remove this heuristic. This also solves most of #29.
@Wilfred
Copy link
Contributor

Wilfred commented Apr 21, 2020

This is much improved now. Indenting now gives:

$node->query()
  ->selectByLambda($node ==>
  checkValid($node),
)
  ->whereLambda(
  $node ==> condition($node),
);

which is correct, apart from the second method call.

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

2 participants