File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -1066,6 +1066,28 @@ MUST follow the same style rules as other binary [comparison][] operators:
1066
1066
$variable = $foo ?: 'bar';
1067
1067
```
1068
1068
1069
+ ### 6.4. Operator's placement
1070
+
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:
1076
+
1077
+ ``` php
1078
+ <?php
1079
+
1080
+ $variable1 = $ternaryOperatorExpr
1081
+ ? 'fizz'
1082
+ : 'buzz';
1083
+
1084
+ $variable2 = $possibleNullableExpr
1085
+ ?? 'fallback';
1086
+
1087
+ $variable3 = $elvisExpr
1088
+ ?: 'qix';
1089
+ ```
1090
+
1069
1091
## 7. Closures
1070
1092
1071
1093
Closures, also known as anonymous functions, MUST be declared with a space
You can’t perform that action at this time.
0 commit comments