Skip to content

Commit a950253

Browse files
committed
Add the documentation for the PSR12 Boolean Operator Placement sniff
1 parent 040f675 commit a950253

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<documentation title="Boolean Operator Placement">
2+
<standard>
3+
<![CDATA[
4+
Boolean operators between conditions MUST always be at the beginning or at the end of the line, not a mix of both.
5+
]]>
6+
</standard>
7+
<code_comparison>
8+
<code title="Valid: Boolean operator between conditions at the beginning of the line.">
9+
=<![CDATA[
10+
if (
11+
$expr1
12+
&& $expr2
13+
&& ($expr3
14+
|| $expr4)
15+
&& $expr5
16+
) {
17+
// if body.
18+
}
19+
]]>
20+
</code>
21+
<code title="Invalid: Boolean operators between conditions at the beginning and the end of the line.">
22+
<![CDATA[
23+
if (
24+
$expr1 &&
25+
($expr2 || $expr3)
26+
&& $expr4
27+
) {
28+
// if body.
29+
}
30+
]]>
31+
</code>
32+
</code_comparison>
33+
<code_comparison>
34+
<code title="Valid: Boolean operator between conditions at the end of the line.">
35+
<![CDATA[
36+
if (
37+
$expr1 &&
38+
($expr2 || $expr3) &&
39+
$expr4
40+
) {
41+
// if body.
42+
}
43+
]]>
44+
</code>
45+
<code title="Invalid: Boolean operators between conditions at the beginning and the end of the line.">
46+
<![CDATA[
47+
match (
48+
$expr1
49+
&& $expr2 &&
50+
$expr3
51+
) {
52+
// structure body.
53+
};
54+
]]>
55+
</code>
56+
</code_comparison>
57+
</documentation>

0 commit comments

Comments
 (0)