-
Notifications
You must be signed in to change notification settings - Fork 0
/
ruleset.xml
138 lines (111 loc) · 4.71 KB
/
ruleset.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?xml version="1.0"?>
<ruleset name="WonderNetwork">
<description>The WonderNetwork coding standard.</description>
<arg name="tab-width" value="4"/>
<!-- Include the whole PSR-2 standard: http://www.php-fig.org/psr/psr-2/ -->
<rule ref="PSR2">
<!-- everything excluded here is part of the PSR2 definition, but we don't
want it -->
<!-- We want the K&R rule below, and this interferes with that -->
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine" />
<!-- Requires class names start with capital letters. Ours don't and we
don't care. -->
<exclude name="Squiz.Classes.ValidClassName" />
<!-- Requires braces be on the next line from the class declaration. We
want them on the same line. -->
<exclude name="PSR1.Classes.ClassDeclaration" />
<exclude name="PSR2.Classes.ClassDeclaration" />
<!-- Forbids empty `catch` statements in try/catch blocks. We don't want
empty catch statements either, but we'll accept them if there's a
comment explaining why the statement is empty. We handle that case
later. -->
<exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch" />
</rule>
<!-- Require functions braces be on the same line and multi-line arguments
are aligned properly:
function thing() {
function stuff(
array $b,
$c,
callable $z
) {
-->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie"/>
<!-- Forbids empty statements:
if (thing) {
doStuff();
} else {
// WTF IS THIS
}
-->
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<!-- Requires a space after typecasting, e.g. `(int) "4"` -->
<rule ref="Generic.Formatting.SpaceAfterCast"/>
<!-- Requires PHP5-style class constructors:
class MyClass {
public function MyClass() // bad
public function __construct() // good
}
-->
<rule ref="Generic.NamingConventions.ConstructorName"/>
<!-- Requires camel-caps naming for functions -->
<rule ref="Generic.NamingConventions.CamelCapsFunctionName">
<properties>
<!-- allow things like getMyID zomg two caps next to each other! -->
<property name="strict" value="false"/>
</properties>
</rule>
<!-- Forbids pointless string concatenations, e.g. "foo"."bar" -->
<rule ref="Generic.Strings.UnnecessaryStringConcat"/>
<!-- Requires short array syntax, i.e. [] instead of array() -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<!-- Requires that include is only used in conditional situations, and
require is used elsewhere. Also forbids parenthesis around the file
being included, because require/include aren't functions. -->
<rule ref="PEAR.Files.IncludingFile"/>
<!-- Forbids Perl-style comments, e.g. # this is a comment -->
<rule ref="PEAR.Commenting.InlineComment"/>
<!-- Require multi-line if conditions to be indented correctly. Also
requires each conditional line to start with a boolean operator, to
improve readability:
if (this
&& that
|| stuff
) {
doStuff();
}
We customized PEAR.ControlStructures.MultiLineCondition to indent
nested conditionals properly, so instead of this:
if (this
&& (that
|| stuff) // this indentation is visually confusing
) {}
we do this:
if (this
&& (that
|| stuff // way more sensible
)
) {}
-->
<!-- Forbids whitespace in typecasts, e.g. ( int ) -->
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<!-- Forbids whitespace before semicolons, e.g. doStuff() ; -->
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
<!-- Requires whitespace around logical operators, e.g. (this && that) -->
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<!-- Forbids spacing around the concatenation operator, e.g. $this . $that -->
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<!-- Allows newlines around concat operators -->
<property name="ignoreNewlines" value="true"/>
</properties>
</rule>
<!-- Requires empty catch blocks to have a comment explaining why they're
empty -->
<rule ref="Squiz.Commenting.EmptyCatchComment"/>
<!-- this would force camel caps for variables, but we can't use it because
we pull some variable names directly from the database, which uses
underscores. Drat.
<rule ref="Zend.NamingConventions.ValidVariableName"/>
-->
</ruleset>