+1
Zitat von Joe T. <[email protected]>:
For what it's worth...
The requirement for my team is that any time a function call
spans multiple lines, /ALL/ arguments must be split to individual
lines, and any additional formatting for the arguments goes
according to their own rules.
someFunction(
$foo,
$bar,
['short', 'array', 'arg'],
$baz
);
//or
someFunction(
$foo,
$bar,
[
'longer' => 'array',
'with' => 'keys',
'or',
'other',
'mixed up stuff',
],
$baz
);
i find the PSR incredibly frustrating sometimes. It seems it's not
written for readability and consistency (especially to assist young
devs to acclimate quickly), it's written so legacy code authors
won't cry. That's a cynical statement, i suppose, but some of the
rules seem to have no rationale behind them.
-jlt
On Friday, 26 October 2018 12:42:30 UTC-4, Miguel Rosales wrote:
Sorry I'm new to the group so I'm not 100% aware of the process,
but the site says PSR-12 is under draft, so I guess things can
still be discussed...
I was going to open a new topic about this but found this one,
and just wanted to say I agree with the previous message - I don't
like this part of the recommendation:
A single argument being split across multiple lines (as might be
the case with an anonymous function or array) does not constitute
splitting the argument list itself.
somefunction($foo, $bar, [
// ...
], $baz);
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello ' . $app->escape($name);
});
I know many developers are used this in some scenarios, but
particularly when there are many arguments it gets lets readable.
Also I assume that implementation of auto-formatting allowing
this would be quite trickier (in fact for example PhpStorm doesn't
support this atm).
So, is this something that has been decided already or is it
open to changes?
El sábado, 20 de enero de 2018, 17:34:26 (UTC), Joe T. escribió:
The short-style syntax does make arrays much more readable, as it
no longer makes them look like function calls.
However, the rule you're referencing is for when you are
keeping arguments on the *same* line. It permits for splitting an
array in that signature to multiple lines, and continuing the
signature after the end of the multi-line array.
i see now your first example was following the guideline of
the format from your second message. Your right, technically that
does comply with the standard. When you start the signature on the
same line as the opening "(", all successive arguments after
should continue on the line where the previous argument ends. But
hopefully you can see how muddled that pattern is for readability.
It's hard to tell where the arrays begin or end, particularly in
context of being function arguments. So many commas and brackets...
Honestly, i dislike the standard's allowance of the style in
your second message. It seems very awkward and visually clunky to
me. But i don't have a vote in accepting the standard, and came to
the group a bit late to make a case for changing it. For me (and
the guide my team uses), any time any argument is split to
multiple lines, the whole signature should follow the multi-line
signature rule.
Ultimately, i think the goal is readable & maintainable
code, so when two versions are technically legal, let that
objective be the deciding factor.
Hope that helps.
-jlt
--
You received this message because you are subscribed to the Google
Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/2083e29f-f66e-4769-a6fb-f6b9dc710586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
-------------------------
Jan Schneider
The Horde Project
https://www.horde.org/
--
You received this message because you are subscribed to the Google Groups "PHP
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/php-fig/20181029083739.Horde.pGZ_h14bCR3r0iOf_SV465s%40yunosh.horde.org.
For more options, visit https://groups.google.com/d/optout.