Thank you for the reference to PSR-12 - I was looking for that.
What about 4.7 Method and Function Calls
> 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);
I would say that the new array notation does bring some benefit to code
readability.
Opening and closing angle brackets ([]) for arrays could be treated like
function/method curly brackets ({}).
On Friday, January 19, 2018 at 3:08:00 PM UTC+1, Joe T. wrote:
>
> My understanding of PSR-2 (and 12) is only the second one is permitted.
>
> *PSR-12 4.5*
>
>> Argument lists MAY be split across multiple lines, where each subsequent
>> line is indented once. When doing so, the first item in the list MUST be on
>> the next line, and there MUST be only one argument per line.
>>
>
> With that said, the shorter arrays *can* be condensed to single line if
> they fit. So you could have:
> SomeClass::someMethod(
> // also, 4-space indents ;)
> ['arg1' => 111],
> // Okay, but in my opinion starts to risk readability.
> ['arg2' => SomeClass::someMethod(['arg5' => 999])]
> ['arg3' => ['arg4' => 'zzz']]
> );
>
>
>
>
> On Thursday, 18 January 2018 10:56:53 UTC-5, Hrvoje A. wrote:
>>
>> // is this allowed or is it a personal preference?
>>
>>
>> SomeClass::someMethod([
>> 'arg1' => 111,
>> ], [
>> 'arg2' => SomeClass::someMethod([
>> 'arg5' => 999
>> ]),
>> ], [
>> 'arg3' => [
>> 'arg4' => 'zzz'
>> ]
>> ]);
>>
>> //
>> // vs all array notations must be in new line
>> //
>>
>> SomeClass::someMethod(
>> [
>> 'arg1' => 111,
>> ],
>> [
>> 'arg2' => SomeClass::someMethod(
>> [
>> 'arg5' => 999
>> ]
>> ),
>> ],
>> [
>> 'arg3' => [
>> 'arg4' => 'zzz'
>> ],
>> ]
>> );
>>
>>
>>
>>
--
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/127add2b-cd5c-46d6-bbcb-d95b8af44e17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.