FP php:S1808 - foreach - space before as

Hello.

Consider the following PHP code:

foreach (
    $varXXXXXXXXXXXXXXXXXXXXX_long_variable_XXXXXXXXXXXXXXXXXXXXX
    as $keyXXXXXXXXXXXXXXXXXXXXX_long_variable_XXXXXXXXXXXXXXXXXXXXX
    => $valueXXXXXXXXXXXXXXXXXXXXX_long_variable_XXXXXXXXXXXXXXXXXXXXX
) {
}

This reports php:S1808 (Put exactly one space after and before “as” in “foreach” statement.).

I don’t understand, why this is not PSR2 conform, although it’s ok to split argument lists and
variable lists across multiple lines in case of long lines.

psr-2:method-arguments

In the argument list, there MUST NOT be a space before each comma, and there
MUST be one space after each comma.

Argument lists MAY be split across multiple lines, where each subsequent line
is indented once.

Best regards,
Steve

Hello Steve,

Thanks for the feedback. It seems to be indeed a FP with the implementation of S1808 for PHP. The rule should allow spreading arguments on dedicated lines. I consequently created the following ticket to handle it: SONARPHP-795

Cheers,
Michael