File tree Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Expand file tree Collapse file tree 1 file changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -1057,10 +1057,6 @@ and `:` characters:
1057
1057
1058
1058
``` php
1059
1059
$variable = $foo ? 'foo' : 'bar';
1060
-
1061
- $variableMultiLine = $foo
1062
- ? 'foo'
1063
- : 'bar';
1064
1060
```
1065
1061
1066
1062
When the middle operand of the conditional operator is omitted, the operator
@@ -1070,6 +1066,25 @@ MUST follow the same style rules as other binary [comparison][] operators:
1070
1066
$variable = $foo ?: 'bar';
1071
1067
```
1072
1068
1069
+ ### 6.4. Operator's placement
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.
1073
+
1074
+ ``` php
1075
+ <?php
1076
+
1077
+ $variable1 = $possibleNullableExpr
1078
+ ?? 'fallback';
1079
+
1080
+ $variable2 = $ternaryOperatorExpr
1081
+ ? 'fizz'
1082
+ : 'buzz';
1083
+
1084
+ $variable3 = $elvisExpr
1085
+ ?: 'qix';
1086
+ ```
1087
+
1073
1088
## 7. Closures
1074
1089
1075
1090
Closures, also known as anonymous functions, MUST be declared with a space
You can’t perform that action at this time.
0 commit comments