File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 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:
10661066$variable = $foo ?: 'bar';
10671067```
10681068
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+
10691091## 7. Closures
10701092
10711093Closures, also known as anonymous functions, MUST be declared with a space
You can’t perform that action at this time.
0 commit comments