forked from enjoping/DXFighter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
phpcheckstyle.xml
513 lines (428 loc) · 17.3 KB
/
phpcheckstyle.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
<!-- somewhat inspired by java checkstyle -->
<phpcheckstyle-configuration>
<test name="phpException" level="error" />
<!-- ********************************************************* -->
<!-- These functions are not tested for naming -->
<!-- cf http://www.php.net/manual/en/language.oop5.magic.php -->
<!-- ********************************************************* -->
<config name="specialFunctions">
<configItem value="__construct" />
<configItem value="__destruct" />
<configItem value="__call" />
<configItem value="__get" />
<configItem value="__set" />
<configItem value="__isset" />
<configItem value="__unset" />
<configItem value="__sleep" />
<configItem value="__wakeup" />
<configItem value="__toString" />
<configItem value="__set_state" />
<configItem value="__clone" />
<configItem value="__autoload" />
<configItem value="__invoke" />
<configItem value="__callStatic" />
</config>
<!-- ********************************************************* -->
<!-- These variables are not tested for naming -->
<!-- ********************************************************* -->
<config name="systemVariables">
<configItem value="$this" />
<configItem value="$_GET" />
<configItem value="$_POST" />
<configItem value="$_FILES" />
<configItem value="$_COOKIE" />
<configItem value="$_SESSION" />
<configItem value="$_ENV" />
<configItem value="$_SERVER" />
<configItem value="$_REQUEST" />
<configItem value="$HTTP_GET_VARS" />
<configItem value="$HTTP_POST_VARS" />
<configItem value="$HTTP_COOKIE_VARS" />
<configItem value="$HTTP_SERVER_VARS" />
<configItem value="$HTTP_ENV_VARS" />
<configItem value="$HTTP_SESSION_VARS" />
</config>
<!-- **************** -->
<!-- Naming -->
<!-- **************** -->
<!-- Check Constant Naming -->
<test name="constantNaming" regexp="/^[A-Z][A-Z0-9_]*$/" level="error" />
<!-- Check Variable Naming -->
<test name="variableNaming" regexp="/^[a-z_][a-zA-Z0-9]*$/" /> <!-- default naming -->
<test name="topLevelVariableNaming" regexp="/^[a-z_][a-zA-Z0-9]*$/" /> <!-- for top level variables -->
<test name="localVariableNaming" regexp="/^[a-z_][a-zA-Z0-9]*$/" /> <!-- for local variables (inside a class) -->
<test name="memberVariableNaming" regexp="/^[a-z_][a-zA-Z0-9]*$/" /> <!-- for member variables (inside a function) -->
<!-- Check Function Naming -->
<test name="functionNaming" regexp="/^[a-z][a-zA-Z0-9_]*$/" level="error" />
<!-- Check Protected Naming -->
<test name="protectedFunctionNaming" regexp="/^[a-z][a-zA-Z0-9_]*$/" level="error" />
<!-- Check Private Function Naming -->
<test name="privateFunctionNaming" regexp="/^[a-z][a-zA-Z0-9_]*$/" level="error" />
<!-- Checks the constructor naming -->
<!-- old = old style (constructor = name of the class) -->
<!-- new = "__construct()" -->
<test name="constructorNaming">
<property name="naming" value="new" />
</test>
<!-- Check Class Naming -->
<test name="classNaming" regexp="/^[A-Z][a-zA-Z0-9_]*$/" level="error" />
<!-- Check Interface Naming -->
<test name="interfaceNaming" regexp="/^[A-Z][a-zA-Z0-9_]*$/"
level="error" />
<!-- File Naming -->
<test name="fileNaming" regexp="/^[a-zA-Z][a-zA-Z0-9._]*$/" level="error" />
<!-- Short variable names -->
<test name="localScopeVariableLength">
<property name="minLength" value="2" />
<property name="maxLength" value="30" />
<exception value="i" /> <!-- For iterators -->
<exception value="j" />
<exception value="k" />
<exception value="e" /> <!-- for exception $e -->
</test>
<!-- **************** -->
<!-- PHP Tags -->
<!-- **************** -->
<!-- Test if a short php code open tag is used (<? instead of <?php ). -->
<test name="noShortPhpCodeTag" />
<!-- Test if a PHP closing file is present at the end of a file -->
<test name="noFileCloseTag" />
<!-- Test if a file finish with some inner HTML (OK for some view but could
provoque "header already sent" error) -->
<test name="noFileFinishHTML" level="error" />
<!-- PHP tags (start and stop) should be at the beginning of a line -->
<test name="phpTagsStartLine" />
<!-- **************** -->
<!-- Comments -->
<!-- **************** -->
<!-- Check if some C style comments are used (#) -->
<test name="noShellComments" />
<!-- Tests that every function and class is immediately preceded by a docblock.
A property "excludePrivateMembers" can be set if you want to disable docblocks
for private member functions. -->
<test name="docBlocks">
<property name="excludePrivateMembers" value="true" />
<property name="testReturn" value="true" />
<property name="testParam" value="true" />
<property name="testThrow" value="true" />
<exception value="__toString" />
</test>
<!-- Check for the presence of a mandatory header (licence for exemple) -->
<!-- Does not take into account spaces, tabs and returns -->
<!-- Does not check that the content is a the beginning of the file -->
<!-- <test name="mandatoryHeader"> <property name="header" value=" /** *
Mandatory Header. * "/> </test> -->
<!-- **************** -->
<!-- Indentation -->
<!-- **************** -->
<!-- Tests to make sure that a line does not contain the tab character. -->
<test name="indentation"> <!-- noTabs -->
<property name="type" value="spaces" /> <!-- tabs or spaces -->
<property name="number" value="2" /> <!-- number of spaces if type = spaces -->
</test>
<!-- Check the position of the open curly brace in a control structure (if) -->
<!-- sl = same line -->
<!-- nl = new line -->
<test name="controlStructOpenCurly">
<property name="position" value="sl" />
</test>
<!-- Check the position of the close curly brace -->
<test name="controlCloseCurly" level="info" />
<!-- Check the position of the open curly brace after a function -->
<!-- sl = same line -->
<!-- nl = new line -->
<test name="funcDefinitionOpenCurly">
<property name="position" value="sl" />
</test>
<!-- Check the position of the else -->
<!-- sl = same line -->
<!-- nl = new line -->
<test name="controlStructElse">
<property name="position" value="sl" />
</test>
<!-- **************** -->
<!-- Quotes -->
<!-- **************** -->
<test name="preferQuotes">
<property name="type" value="single" />
</test>
<!-- **************** -->
<!-- Spaces -->
<!-- **************** -->
<!-- Tests that the control statements ("if", "else", "while", "for", etc.)
are followed by a space before the opening parenthesis. PEAR standard stipulates
this to distinguish it from function calls. -->
<test name="spaceAfterControlStmt" />
<!-- Check that there is no space after a function name in a function call -->
<test name="noSpaceAfterFunctionName" level="info"></test>
<!-- Check for the (required) presence of a white space after some tokens
: "," "}" "-" -->
<test name="checkWhiteSpaceAfter" />
<!-- Check for the (required) presence of a white space before some tokens
: "{" "-" -->
<test name="checkWhiteSpaceBefore">
<exception value=":" /> <!-- Because of the switch/case -->
</test>
<!-- Check that there is no space before before some tokens : "," ";" ")"
"->" -->
<test name="noSpaceBeforeToken" level="info" />
<!-- Check that there is no space after some tokens : "!" "(" "->" -->
<test name="noSpaceAfterToken" level="info" />
<!-- **************** -->
<!-- Metrics -->
<!-- **************** -->
<!-- Check that the lenght of the line doesn't pass the max value -->
<test name="lineLength" level="info">
<property name="maxLineLength" value="160" />
<property name="checkHTMLLines" value="false" />
</test>
<!-- Checks that the lenght (in lines) of a function doesn't pass the max
value -->
<test name="functionLength" level="info">
<property name="maxLength" value="200" />
</test>
<!-- Checks for excessive parameters in a function declaration -->
<test name="functionMaxParameters">
<property name="maxParameters" value="4" />
</test>
<!-- Check Cyclomatic Complexity -->
<!-- see http://www.aivosto.com/project/help/pm-complexity.html -->
<test name="cyclomaticComplexity">
<!-- Level raising a warning -->
<property name="warningLevel" value="10" />
<!-- Level raising an error -->
<property name="errorLevel" value="20" />
</test>
<!-- Check NPath Complexity -->
<test name="npathComplexity">
<!-- Level raising a warning -->
<property name="warningLevel" value="100" />
<!-- Level raising an error -->
<property name="errorLevel" value="200" />
</test>
<!-- **************** -->
<!-- Prohibited -->
<!-- **************** -->
<!-- Check for prohibited functions -->
<!-- @see http://www.php.net/manual/en/indexes.php -->
<test name="checkProhibitedFunctions">
<item value="echo" />
<item value="system" />
<item value="print_r" />
<item value="var_dump" />
<item value="dl" />
<item value="define_syslog_variables" />
<item value="set_magic_quotes_runtime" />
<item value="magic_quotes_runtime" />
<item value="sql_regcase " />
<item value="exec" />
<item value="passthru" />
<item value="delete" />
<item value="unlink" />
<item value="phpinfo" />
<item value="die" />
<!-- <item value="copy"/> -->
<!-- <item value="fwrite"/> -->
</test>
<!-- Check for prohibited tokens -->
<!-- @see http://www.php.net/manual/en/tokens.php -->
<test name="checkProhibitedTokens">
<item value="T_BAD_CHARACTER" />
<item value="T_DECLARE" />
<item value="T_ENDDECLARE" />
<item value="T_ENDFOR" />
<item value="T_ENDFOREACH" />
<item value="T_ENDIF" />
<item value="T_ENDSWITCH" />
<item value="T_ENDWHILE" />
<item value="T_HALT_COMPILER" />
<item value="T_OLD_FUNCTION" />
<item value="T_PRINT" />
<!-- Same thing as the noShortPhpCodeTag rule -->
<!-- <item value="T_OPEN_TAG_WITH_ECHO"/> -->
<!-- <item value="T_INLINE_HTML"/> -->
<!-- <item value="T_ECHO"/> -->
</test>
<!-- Check Prohibited Keywords -->
<test name="checkProhibitedKeywords" level="error">
<!-- <item value="FORBIDDEN"/> -->
<!-- <item value="your prohibited keyword 2"/> -->
</test>
<!-- Check Prohibited Keywords Regex -->
<!-- Note: The regular expression must be correctly escaped -->
<test name="checkProhibitedKeywordsRegex" level="error">
<!-- <item value="/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/"/> IP ADDRESS -->
</test>
<!-- **************** -->
<!-- Other -->
<!-- **************** -->
<!-- All arguments with default values should be at the end -->
<test name="defaultValuesOrder" />
<!-- Check for silenced errors before function calls (@function) -->
<test name="checkSilencedError">
<exception value="rename" /> <!-- Exceptions to this rule -->
<exception value="mkdir" />
<exception value="chmod" />
</test>
<!-- Check for encapsed variables inside a String ("$a") -->
<test name="encapsedVariablesInsideString" />
<!-- Avoid passing parameters by reference -->
<test name="avoidPassingReferences" />
<test name="showTODOs" />
<!-- Use boolean operators (&&) instead of logical operators (AND) -->
<test name="useBooleanOperators" />
<!-- Check empty block like if ($a) {} -->
<test name="checkEmptyBlock">
<!-- <exception value="catch"/> -->
</test>
<!-- Check empty statement ( ;; ) -->
<test name="checkEmptyStatement" />
<!-- Check for the presence of heredoc -->
<test name="checkHeredoc" />
<!-- Check for braces around code blocs (if, else, elseif, do, while, for,
foreach) -->
<test name="needBraces" />
<!-- Switch need a default value -->
<test name="switchNeedDefault" />
<!-- Switch case should have a break -->
<test name="switchCaseNeedBreak" />
<!-- Switch default value should be at the end -->
<test name="switchDefaultOrder" />
<!-- Avoid using unary operators (++) inside a control statement With the
exception of for iterators, all variable incrementation or decrementation
should occur in their own toplevel statement to increase readability. -->
<test name="checkUnaryOperator">
<exception value="for" />
</test>
<!-- With inner assignments it is difficult to see all places where a variable
is set. With the exception of for iterators, all assignments should occur
in their own toplevel statement to increase readability. -->
<test name="checkInnerAssignment">
<exception value="for" />
</test>
<!-- Only one class declaration per PHP file -->
<test name="oneClassPerFile" />
<!-- Detect empty files -->
<test name="checkEmptyFile" />
<!-- Avoid using variable variables -->
<test name="variableVariable" />
<!-- $this cannot be used in a static function -->
<test name="thisInStatic" level="error"/>
<!-- **************** -->
<!-- Unused -->
<!-- **************** -->
<!-- Detect unused private functions (detecting unused public ones is more
difficult) -->
<test name="checkUnusedPrivateFunctions" />
<!-- Detect unused variables -->
<test name="checkUnusedVariables" />
<!-- Detect unused function parameters -->
<test name="checkUnusedFunctionParameters" />
<!-- Detect unused code (after return or throw) -->
<test name="checkUnusedCode" />
<!-- ******************* -->
<!-- Optimisation -->
<!-- ******************* -->
<!-- Avoid using a count/sizeof function inside a loop -->
<test name="functionInsideLoop" />
<!-- ******************* -->
<!-- Deprecation -->
<!-- see http://php.net/manual/en/migration53.deprecated.php -->
<!-- ******************* -->
<!-- Replace deprecated methods -->
<test name="checkDeprecation">
<deprecated old="call_user_method" new="call_user_func"
version="4.1" />
<deprecated old="call_user_method_array" new="call_user_func_array"
version="4.1" />
<deprecated old="define_syslog_variables" new="none"
version="5.4" />
<deprecated old="dl" new="extension_loaded" version="5.3" />
<deprecated old="ereg" new="preg_match('@'.$pattern.'@', $string)"
version="5.3" />
<deprecated old="eregi" new="preg_match('@'.$pattern.'@i', $string)"
version="5.3" />
<deprecated old="ereg_replace" new="preg_replace('@'.$pattern.'@', $string)"
version="5.3" />
<deprecated old="eregi_replace" new="preg_replace('@'.$pattern.'@i', $string)"
version="5.3" />
<deprecated old="import_request_variables" new="none"
version="5.4" />
<deprecated old="magic_quotes_runtime" new="none" version="5.3" />
<deprecated old="set_magic_quotes_runtime" new="none"
version="5.3" />
<deprecated old="mcrypt_generic_end" new="mcrypt_generic_deinit"
version="5.4" />
<deprecated old="mysql_list_dbs" new="none" version="5.4" />
<deprecated old="mysql_db_query" new="mysql_select_db and mysql_query"
version="5.3" />
<deprecated old="mysql_escape_string" new="mysql_real_escape_string"
version="5.3" />
<deprecated old="mysqli_bind_param" new="mysqli_stmt_bind_param"
version="5.4" />
<deprecated old="mysqli_bind_result" new="mysqli_stmt_bind_result"
version="5.4" />
<deprecated old="mysqli_client_encoding" new="mysqli_character_set_name"
version="5.4" />
<deprecated old="mysqli_fetch" new="mysqli_stmt_fetch"
version="5.4" />
<deprecated old="mysqli_param_count" new="mysqli_stmt_param_count"
version="5.4" />
<deprecated old="mysqli_get_metadata" new="mysqli_stmt_result_metadata"
version="5.4" />
<deprecated old="mysqli_send_long_data" new=" mysqli_stmt_send_long_data"
version="5.4" />
<deprecated old="session_register" new="$_SESSION" version="5.3" />
<deprecated old="session_unregister" new="$_SESSION"
version="5.3" />
<deprecated old="session_is_registered" new="$_SESSION"
version="5.3" />
<deprecated old="set_socket_blocking" new="stream_set_blocking"
version="5.3" />
<deprecated old="split"
new="explode($pattern, $string) or preg_split('@'.$pattern.'@', $string)"
version="5.3" />
<deprecated old="spliti" new="preg_split('@'.$pattern.'@i', $string)"
version="5.3" />
<deprecated old="sql_regcase" new="none" version="5.3" />
<deprecated old="$HTTP_GET_VARS" new="$_GET" version="5.3" />
<deprecated old="$HTTP_POST_VARS" new="$_POST" version="5.3" />
<deprecated old="$HTTP_COOKIE_VARS" new="$_COOKIE" version="5.3" />
<deprecated old="$HTTP_SERVER_VARS" new="$_SERVER" version="5.3" />
<deprecated old="$HTTP_ENV_VARS" new="$_ENV" version="5.3" />
<deprecated old="$HTTP_SESSION_VARS" new="$_SESSION"
version="5.3" />
</test>
<!-- ******************* -->
<!-- FindBugs -->
<!-- ******************* -->
<!-- Use only strict comparison -->
<!-- see : http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/ -->
<test name="strictCompare" />
<!-- ******************* -->
<!-- PHP Aliases -->
<!-- ******************* -->
<!-- Replace deprecated methods -->
<test name="checkAliases">
<alias old="chop" new="rtrim()" />
<alias old="close" new="closedir()" />
<alias old="die" new="exit()" />
<alias old="dir" new="getdir()" />
<alias old="doubleval" new="floatval()" />
<alias old="fputs" new="fwrite()" />
<alias old="ini_alter" new="ini_set()" />
<alias old="is_double" new="is_float()" />
<alias old="is_integer" new="is_int()" />
<alias old="is_long" new="is_int()" />
<alias old="is_real" new="is_float()" />
<alias old="is_writeable" new="is_writable()" />
<alias old="join" new="implode()" />
<alias old="key_exists" new="array_key_exists()" />
<alias old="magic_quotes_runtime" new="set_magic_quotes_runtime()" />
<alias old="pos" new="current()" />
<alias old="rewind" new="rewinddir()" />
<alias old="show_source" new="highlight_file()" />
<alias old="sizeof" new="count()" />
<alias old="strchr" new="strstr()" />
</test>
</phpcheckstyle-configuration>