Function argument formatting discussion
$db->Execute([
$foo,
$bar,
$foobar,
$somewhatLongParameter,
$somewhatLongParameterX,
$somewhatLongParameterXYZ
], $sql, $someOtherArg);
VS
$db->Execute(
[
$foo,
$bar,
$foobar,
$somewhatLongParameter,
$somewhatLongParameterX,
$somewhatLongParameterXYZ
],
$sql,
$someOtherArg
);
Vote :+1: on first, Vote :heart: on second
Continuing from https://github.com/prettier/plugin-php/pull/398#discussion_r181853745
@evilebottnawi @czosel @nicoder
Basically discussing
$db->Execute([
$foo,
$bar,
$foobar,
$somewhatLongParameter,
$somewhatLongParameterX,
$somewhatLongParameterXYZ
], $sql, $someOtherArg);
vs
$db->Execute(
[
$foo,
$bar,
$foobar,
$somewhatLongParameter,
$somewhatLongParameterX,
$somewhatLongParameterXYZ
],
$sql,
$someOtherArg
);
We went with the 2nd option in #398, since we followed the same logic from prettierjs. PSR12 docs seem to say that either is acceptable, and seems to leave it up to the developer when to split arguments onto multiple lines vs keep them in a single line. However most of their examples seem to prefer the 1st one
https://github.com/php-fig/fig-standards/blob/master/proposed/extended-coding-style-guide.md#47-method-and-function-calls
My opinion is that we should follow prettierJS. They already have thought through this logic quite a bit, and from what I can tell it still aligns with PSR12 standards
@mgrip I think will be better ping something from PSR-12 and ask this question about second example (valid or invalid)
- In my opinion, if a function call spans multiple lines, then each argument should be on a separate line, for readability. (i.e. option 2)
- I'm using a custom PHP_CodeSniffer standard that extends PSR-12, and the code in option 2 is valid.