You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// the added values now have different indents, which makes it harder to read stack of variables
$sum = $amount
+ $tax
- $discount;
or
// operators with different precedence have the same indentation,
// but the execution order does not correspond to the reading sequence from top to bottom
$sum
= $amount
+ $tax
- $discount;
Both versions are worse than the original in terms of readability. Thereforce i'm looking for a way to make it as readable, as it was before. But currently i cannot understand, if some cases obey standard rules or not.
I find this way of writing the best (operators with different precedence have different indents, all variables in sum are stacked whell). But php-cs-fixer disallow me to write such way in @PER-CS3.0 ruleset, requring to write = and $amount on same line. I examined standard (firstly 6.4 and 5.1 sections), but cannot find such a requirements.
$sum
=
$amount
+ $tax
- $discount;
Please clarify whether this example meets the requirements of the standard.
php-cs-fixer accepted this option
$sum
= $amount
+ $tax
- $discount;
please clarify, if it meets the requirements and original idea of standard.
I'm thinking about some new rule for cs fixer for such formatting, or maybe some rule in standard to require this. Main idea, is that operators with different precedence should not have same indents, because it may reduce readability and lead to the false impression that the statements will be executed in top-to-bottom reading order.
// Logic.
// not passed
$getReward
=
$isBirthday
or
$isLoggedIn
and $hasPremium
xor $completedQuest
and $defeatedBoss;
// passed
$getReward
= $isBirthday
or $isLoggedIn
and $hasPremium
xor $completedQuest
and $defeatedBoss;
Activity
vadimonus commentedon Jun 14, 2026
I'm thinking about some new rule for cs fixer for such formatting, or maybe some rule in standard to require this. Main idea, is that operators with different precedence should not have same indents, because it may reduce readability and lead to the false impression that the statements will be executed in top-to-bottom reading order.
Some more examples to think about
As for me, i found here variants with operator on same line as more readable, than one, that passed php-cs-fixer