php-ide-serenata
php-ide-serenata copied to clipboard
Allow wrapping and collapsing function and method call parameters
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.
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.
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.