File tree Expand file tree Collapse file tree 1 file changed +59
-0
lines changed
src/Standards/PSR12/Docs/ControlStructures Expand file tree Collapse file tree 1 file changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ <documentation title =" Boolean Operator Placement" >
2+ <standard >
3+ <![CDATA[
4+ Boolean operators between conditions in control structures must always be at the beginning or at the end of the line, not a mix of both.
5+
6+ This rule applies to if/else conditions, while loops and switch/match statements.
7+ ]]>
8+ </standard >
9+ <code_comparison >
10+ <code title =" Valid: Boolean operator between conditions consistently at the beginning of the line." >
11+ <![CDATA[
12+ if (
13+ $expr1
14+ && $expr2
15+ && ($expr3
16+ || $expr4)
17+ && $expr5
18+ ) {
19+ // if body.
20+ }
21+ ]]>
22+ </code >
23+ <code title =" Invalid: Mix of boolean operators at the beginning and the end of the line." >
24+ <![CDATA[
25+ if (
26+ $expr1 &&
27+ ($expr2 || $expr3)
28+ && $expr4
29+ ) {
30+ // if body.
31+ }
32+ ]]>
33+ </code >
34+ </code_comparison >
35+ <code_comparison >
36+ <code title =" Valid: Boolean operator between conditions consistently at the end of the line." >
37+ <![CDATA[
38+ if (
39+ $expr1 ||
40+ ($expr2 || $expr3) &&
41+ $expr4
42+ ) {
43+ // if body.
44+ }
45+ ]]>
46+ </code >
47+ <code title =" Invalid: Mix of boolean operators at the beginning and the end of the line." >
48+ <![CDATA[
49+ match (
50+ $expr1
51+ && $expr2 ||
52+ $expr3
53+ ) {
54+ // structure body.
55+ };
56+ ]]>
57+ </code >
58+ </code_comparison >
59+ </documentation >
You can’t perform that action at this time.
0 commit comments