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:
10571057
10581058``` php
10591059$variable = $foo ? 'foo' : 'bar';
1060-
1061- $variableMultiLine = $foo
1062- ? 'foo'
1063- : 'bar';
10641060```
10651061
10661062When 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:
10701066$variable = $foo ?: 'bar';
10711067```
10721068
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+
10731088## 7. Closures
10741089
10751090Closures, also known as anonymous functions, MUST be declared with a space
You can’t perform that action at this time.
0 commit comments