• Edited

The following bit of code is formatted in 2 passes:

$this->addFlash('success', sprintf(
    'A bit of text.'
));
$this->addFlash('success', sprintf(
    'A bit of text.'
)
);
$this->addFlash(
    'success',
    sprintf(
        'A bit of text.'
    )
);

Formatting options used:

"php.format.rules.arrayInitializersNewLineBeforeFirstElement": true,
"php.format.rules.newLineAfterImplements": true,
"php.format.rules.forStatementNewLineBeforeRightParen": true,
"php.format.rules.groupUseNewLineBeforeFirstDeclaration": true,
"php.format.rules.ifStatementNewLineAfterLeftParen": true,
"php.format.rules.ifStatementNewLineBeforeRightParen": true,
"php.format.rules.forStatementNewLineAfterLeftParen": true,
"php.format.rules.declParametersNewLineBeforeRightParen": true,
"php.format.rules.declParametersNewLineAfterLeftParen": true,
"php.format.rules.declCompactEmptyBody": true,
"php.format.rules.chainedMethodCallsSemicolonOnNewLine": true,
"php.format.rules.callParametersNewLineBeforeRightParen": true,
"php.format.rules.whileStatementNewLineAfterLeftParen": true,
"php.format.rules.whileStatementNewLineBeforeRightParen": true,
"php.format.rules.callParametersNewLineAfterLeftParen": true,
"php.format.rules.arrayInitializersNewLineAfterLastElement": true,
"php.format.rules.arrayInitializersAlignKeyValuePairs": false,
"php.format.rules.spaceBeforeParenthesesInControlStatements": true,
"php.format.rules.spaceBeforeParenthesesInArrowFunctions": true,
"php.format.rules.spaceAroundConcatenation": true,
"php.format.rules.spaceAfterUnaryNot": false,
"php.format.rules.spaceAfterCast": true,
"php.format.rules.openBraceOnNewLineForTypes": true,
"php.format.rules.openBraceOnNewLineForNamespaces": true,
"php.format.rules.openBraceOnNewLineForFunctions": true,
"php.format.rules.endWithNewLine": true,
"php.format.rules.removeReduntandClosingTag": true,
"php.format.rules.indentBraces": false,
"php.format.rules.nullConstantCasing": "lowercase",
"php.format.rules.booleanConstantCasing": "lowercase",
"php.format.rules.addCommaAfterLastDeclParameter": false,
"php.format.rules.addCommaAfterLastCallParameter": false,
"php.format.rules.addCommaAfterLastArrayElement": true,

    Hello,

    Thank you again for the report. I can confirm this is happening, we'll take a look at it and fix ASAP.

      Wonderful, thank you!

        Thanks again for the feedback.

        We've fixed this and it will be available in the next pre-release.

        This behavior is influenced by php.format.rules.callParametersWrap setting and by default it inherits from PSR-12 code style which sets it to onEveryItem. So when the function call is spread across multiple lines it gets wrapped, but not when the actual parameters are on multiple lines (not sure if I'm explaining myself correctly? :-) )

        The issue here was during the first pass, It should have just left the code as it is:

        $this->addFlash('success', sprintf(
            'A bit of text.'
        ));

        The first function call shouldn't trigger wrapping. but it did in a weird way. But the second pass behaved correctly and wrapped it all the way.

          Write a Reply...