File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -1068,19 +1068,22 @@ $variable = $foo ?: 'bar';
10681068
10691069### 6.4. Operator's placement
10701070
1071- When a statement that includes an operator must be split into multiple lines,
1072- the operator SHOULD be placed at the beginning of the new line.
1071+ A statement that includes an operator MAY be split across multiple lines, where
1072+ each subsequent line is indented once. When doing so, the operator MUST be
1073+ placed at the beginning of the new line; ternaries MUST occupy 3 lines, never 2.
1074+
1075+ For example:
10731076
10741077``` php
10751078<?php
10761079
1077- $variable1 = $possibleNullableExpr
1078- ?? 'fallback';
1079-
1080- $variable2 = $ternaryOperatorExpr
1080+ $variable1 = $ternaryOperatorExpr
10811081 ? 'fizz'
10821082 : 'buzz';
10831083
1084+ $variable2 = $possibleNullableExpr
1085+ ?? 'fallback';
1086+
10841087$variable3 = $elvisExpr
10851088 ?: 'qix';
10861089```
You can’t perform that action at this time.
0 commit comments