If we are conforming to PSR-2 standards, going off their description for multi-line arguments:
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.
When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them.
Does that mean arguments should be formatted as the following:
return JsonResponse(
Request::STATUS_OK,
[
'success' => true,
'message' => 'Example Message Here.'
]
)
Or is the following format also valid when strictly following their standards?
return JsonResponse(
Request::STATUS_OK, [
'success' => true,
'message' => 'Example Message Here.'
]
)
If you look at the The PSR-2 Meta Document it has a section regarding multiline arguments, especially referring to arrays and closures:
Using one or more multi-line arguments (i.e: arrays or anonymous functions) does not constitute splitting the argument list itself, therefore Section 4.6 is not automatically enforced. Arrays and anonymous functions are able to span multiple lines.
So in your case even the following it perfectly valid, including your first example following the specification to the letter.
return JsonResponse(Request::STATUS_OK, [
'success' => true,
'message' => 'Example Message Here.'
]);
At this level it might just come down to personal preference.