Add support for fully multiline control structure conditions

Author: smaresCreated Sep 26, 2026Updated Sep 26, 2026
Labelsstatus/to verifykind/feature request

Feature request

Add a fixer option for control-structure conditions that ensures multiline conditions are fully multiline.

For example, both of these:

php
if ($firstCondition
    && $secondCondition
) {
    // ...
}
php
if ($firstCondition
    && $secondCondition) {
    // ...
}

should be formatted as:

php
if (
    $firstCondition
    && $secondCondition
) {
    // ...
}

The same behavior could apply to other control structures with parenthesized conditions, such as while.

Motivation

PHP-CS-Fixer already supports a similar concept for multiline method arguments via method_argument_space with:

php
'on_multiline' => 'ensure_fully_multiline'

It would be useful to have equivalent formatting for control-structure conditions.

Once a condition spans multiple lines, having both the opening and closing parenthesis on their own lines makes the structure clearer and keeps multiline boolean expressions consistently formatted.

For example, combined with operator_linebreak:

php
if (
    $firstCondition
    && $secondCondition
    && $thirdCondition
) {
    // ...
}

Single-line conditions should remain unchanged:

php
if ($condition) {
    // ...
}

In other words, the fixer should ensure that whenever the expression between the control-structure parentheses contains a line break:

  • the first expression starts on the line after (
  • the closing ) appears on its own line

Possible implementations could either extend an existing control-structure-related fixer or introduce a dedicated option/fixer analogous to ensure_fully_multiline for method arguments.

Link to Discussion where feature request was formed

No response

Contribution Checks

  • I have verified if this feature request was already discussed
  • I am familiar with "Feature or bug?"

Source: PHP-CS-Fixer/PHP-CS-Fixer