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';
1068
1068
1069
1069
### 6.4. Operator's placement
1070
1070
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:
1073
1076
1074
1077
``` php
1075
1078
<?php
1076
1079
1077
- $variable1 = $possibleNullableExpr
1078
- ?? 'fallback';
1079
-
1080
- $variable2 = $ternaryOperatorExpr
1080
+ $variable1 = $ternaryOperatorExpr
1081
1081
? 'fizz'
1082
1082
: 'buzz';
1083
1083
1084
+ $variable2 = $possibleNullableExpr
1085
+ ?? 'fallback';
1086
+
1084
1087
$variable3 = $elvisExpr
1085
1088
?: 'qix';
1086
1089
```
You can’t perform that action at this time.
0 commit comments