Gert-dev / php-ide-serenata

Atom IDE package that integrates the Serenata server to provide PHP code assistance
https://serenata.gitlab.io/
Other
274 stars 19 forks source link

Allow wrapping and collapsing function and method call parameters #394

Open Gert-dev opened 6 years ago

Gert-dev commented 6 years ago

A neat feature would be to be able to collapse and wrap method or function calls, for example:

$this->test(1, 2, 3);

// "Wrap parameters over several lines"
$this->test(
    1,
    2,
    3
);
$this->test(
    1,
    2,
    3
);

// "Collapse parameters to a single line"
$this->test(1, 2, 3);

This is useful when working with PSR-2 or a soft line length boundary. Adding new arguments to an invocation can exceed the line length and removing existing arguments can make the wrapping over several lines unnecessary.

twifty commented 6 years ago

Wouldn't this be better left to a package like csfixer? Personally, I find it an inconvenience when multiple packages/linters tell me how I should be writing my code.

Gert-dev commented 6 years ago

This isn't about linting for it, though, but just about the command to "fix" it. I often find myself collapsing and expanding function calls if they exceed the line length limit, which is always the same task and could probably be automated.

Though on the other hand, how arguments are split depends on the coding style, which isn't necessarily PSR-2. Another tool, such as PHPCS, would indeed probably be better suited to such a task.

I haven't actually used php-cs-fixer yet. I'll give it a try and if it already does this properly, I'll close this.