Skip to content

Commit 24b1d44

Browse files
committed
Add ruleset example with all optional rules
1 parent 14db1de commit 24b1d44

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="VariableAnalysis">
3+
<description>A code sniff to detect problems with variables.</description>
4+
5+
<!-- If you want everything, with the defaults, just include this line -->
6+
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis"/>
7+
<!--
8+
You can also refer to these policy codes to customize them:
9+
VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable
10+
VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
11+
VariableAnalysis.CodeAnalysis.VariableAnalysis.VariableRedeclaration
12+
VariableAnalysis.CodeAnalysis.VariableAnalysis.SelfOutsideClass
13+
-->
14+
15+
<!-- Include this block to customize VariableAnalysis behaviour -->
16+
<rule ref="VariableAnalysis.CodeAnalysis.VariableAnalysis">
17+
<properties>
18+
<!--
19+
Include the following property if you want to include your own list of pass-by-reference
20+
functions defined in your codebase.
21+
Format is "function:argnum" or "function:argnum1,argnum2" etc.
22+
Whitespace delimits function definitions.
23+
Argument numbers start at 1 and an elipsis '...' means all argument numbers
24+
after the previous should be considered pass-by-reference.
25+
-->
26+
<property name="sitePassByRefFunctions" value="
27+
function_with_first_arg_by_ref:1
28+
function_with_second_and_third_arg_by_ref:2,3
29+
function_with_third_and_remaining_args_by_ref:3,...
30+
"/>
31+
<!--
32+
Include the following property if you want to prevent exception variables declared
33+
in a catch block from causing an unused variable warning, this supports the common
34+
(but not always wanted) pattern of:
35+
try {
36+
// stuff here
37+
} catch (Exception $e) {
38+
// Do something without ever using $e
39+
}
40+
-->
41+
<property name="allowUnusedCaughtExceptions" value="1"/>
42+
<!--
43+
Include the following property if you want to prevent function parametets from causing an
44+
unused variable warning, this supports the common pattern of defining callback functions that
45+
demand a fixed parameter list without actually using all the paramets.
46+
function foo ($a, $b, $c) {
47+
// Do something without ever using some of $a, $b and/or $c
48+
}
49+
-->
50+
<property name="allowUnusedFunctionParameters" value="1"/>
51+
<!--
52+
Include the following property if you want to have a whitelist of variable names
53+
that are commonly used for placeholder "junk" values that ignored and that you
54+
don't want to provoke an unused variable warning for.
55+
Format is "variableName" without a leading $ with whitespace delimiting names.
56+
-->
57+
<property name="validUnusedVariableNames" value="
58+
junk
59+
dummy
60+
"/>
61+
</properties>
62+
</rule>
63+
64+
</ruleset>

0 commit comments

Comments
 (0)