2011-09-22 12:38:54 +02:00
<?xml version="1.0"?>
<!DOCTYPE phpstandard SYSTEM "phpstandard.dtd">
2010-07-21 18:04:19 +02:00
<!-- somewhat inspired by java checkstyle -->
<phpcheckstyle-configuration >
2010-07-21 19:14:45 +02:00
<!-- **************** -->
2010-07-21 18:04:19 +02:00
<!-- Naming -->
<!-- **************** -->
<!-- Check Constant Naming -->
2010-07-21 19:14:45 +02:00
<!-- Disabled to avoid warning with $sql="SELECT ..."
2010-07-21 18:04:19 +02:00
<test name= "constantNaming" regexp= "/^[A-Z_][A-Z_]*[A-Z_]$/" level= "ERROR" />
2010-07-21 19:14:45 +02:00
-->
2010-07-21 18:04:19 +02:00
<!-- Check Variable Naming -->
2010-07-21 20:01:08 +02:00
<test name= "variableNaming" regexp= "/^[a-zA-Z_][a-zA-Z0-9_]*$/" />
2010-07-21 18:04:19 +02:00
<!-- Check Function Naming -->
2010-07-21 19:39:18 +02:00
<test name= "functionNaming" regexp= "/^[a-z_]/" level= "WARNING" />
2010-07-21 18:04:19 +02:00
<!-- Check Private Function Naming -->
2010-07-21 20:09:46 +02:00
<test name= "privateFunctionNaming" regexp= "/^[a-z_]/" level= "ERROR" />
2010-07-21 18:04:19 +02:00
<!-- Checks the constuctor naming -->
<!-- old = old style (constructor = name of the class) -->
<!-- new = "__construct()" -->
<test name= "constructorNaming" >
<property name= "naming" value= "old" />
</test>
<!-- Check Class Naming -->
2010-07-21 19:39:18 +02:00
<test name= "classNaming" regexp= "/^[A-Z]/" level= "WARNING" />
2010-07-21 18:04:19 +02:00
2010-07-21 19:14:45 +02:00
<!-- **************** -->
2010-07-21 18:04:19 +02:00
<!-- PHP Tags -->
<!-- **************** -->
2010-07-21 20:26:49 +02:00
<!-- Test if a short php code open tag is used (? instead of ?php ). -->
2010-07-21 18:04:19 +02:00
<test name= "noShortPhpCodeTag" />
<!-- Test if a PHP closing file is present at the end of a file -->
2010-07-21 19:14:45 +02:00
<!-- <test name="noFileCloseTag"/> -->
2010-07-21 18:04:19 +02:00
<!-- Test if a file finish with some inner HTML (OK for some view but could provoque "header already sent" error) -->
2010-07-21 19:50:06 +02:00
<!-- <test name="noFileFinishHTML" level="ERROR" /> -->
2010-07-21 18:04:19 +02:00
<!-- **************** -->
<!-- Comments -->
<!-- **************** -->
2010-07-21 19:14:45 +02:00
<!-- Check if some C style comments are used (#) -->
2010-07-21 18:04:19 +02:00
<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" />
</test>
2010-07-21 23:57:23 +02:00
2010-07-21 18:04:19 +02:00
<!-- **************** -->
<!-- Indentation -->
<!-- **************** -->
2010-07-21 23:57:23 +02:00
2010-07-21 18:04:19 +02:00
<!-- Tests to make sure that a line does not contain the tab character. -->
<!-- <test name="noTabs"/> -->
<!-- Test to make sure that every control structure is included within a {} block, even if it is syntactically optional. -->
2010-07-21 20:26:49 +02:00
<!-- <test name="controlStructNeedCurly"/> -->
2010-07-21 18:04:19 +02:00
<!-- Check the position of the open curly brace in a control structure (if) -->
<!-- sl = same line -->
2010-07-21 23:57:23 +02:00
<!-- nl = new line -->
2010-07-21 18:04:19 +02:00
<test name= "controlStructOpenCurly" >
2010-07-21 19:14:45 +02:00
<property name= "position" value= "nl" />
2010-07-21 18:04:19 +02:00
</test>
2010-07-21 23:57:23 +02:00
2010-07-21 18:04:19 +02:00
<!-- Check the position of the close curly brace -->
<test name= "controlCloseCurly" level= "INFO" >
</test>
<!-- Check the position of the open curly brace after a function -->
<!-- sl = same line -->
<!-- nl = new line -->
<test name= "funcDefinitionOpenCurly" >
2010-07-21 19:14:45 +02:00
<property name= "position" value= "nl" />
2010-07-21 18:04:19 +02:00
</test>
2010-07-21 19:14:45 +02:00
<!-- Check the position of the else -->
<!-- sl = same line -->
2010-07-21 18:04:19 +02:00
<!-- nl = new line -->
<test name= "controlStructElse" >
2010-07-21 19:14:45 +02:00
<property name= "position" value= "nl" />
</test>
2010-07-21 18:04:19 +02:00
<!-- **************** -->
<!-- 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.
-->
2010-07-21 23:57:23 +02:00
<!--
<test name= "spaceAfterControlStmt" />
-->
2010-07-21 18:04:19 +02:00
<!-- Check that there is no space after a function name in a function call -->
<!-- <test name="noSpaceAfterFunctionName" level="INFO"></test> -->
2010-07-21 19:14:45 +02:00
2010-07-21 18:04:19 +02:00
<!-- Check for the (required) presence of a white space after some tokens (like ,) -->
2010-07-21 19:14:45 +02:00
<!--
2010-07-21 18:04:19 +02:00
<test name= "checkWhiteSpaceAfter" >
2010-07-21 19:14:45 +02:00
<exception value= "." />
2010-07-21 18:04:19 +02:00
</test>
2010-07-21 19:14:45 +02:00
-->
2010-07-21 18:04:19 +02:00
<!-- Check for the (required) presence of a white space before some tokens -->
2010-07-21 19:14:45 +02:00
<!--
2010-07-21 18:04:19 +02:00
<test name= "checkWhiteSpaceBefore" >
2010-07-21 19:14:45 +02:00
<exception value= "." />
<exception value= ":" />
2010-07-21 18:04:19 +02:00
</test>
2010-07-21 19:14:45 +02:00
-->
2010-07-21 18:04:19 +02:00
<!-- Check that there is no space before before some tokens -->
2010-07-21 19:14:45 +02:00
<!--
2010-07-21 18:04:19 +02:00
<test name= "noSpaceBeforeToken" level= "INFO" >
</test>
2010-07-21 19:14:45 +02:00
-->
2010-07-21 18:04:19 +02:00
<!-- Check that there is no space after some tokens -->
2010-07-21 19:14:45 +02:00
<!--
2010-07-21 18:04:19 +02:00
<test name= "noSpaceAfterToken" level= "INFO" >
</test>
2010-07-21 19:14:45 +02:00
-->
2010-07-21 18:04:19 +02:00
<!-- **************** -->
<!-- Metrics -->
<!-- **************** -->
<!-- Check that the lenght of the line doesn't pass the max value -->
<test name= "lineLength" level= "INFO" >
<property name= "maxLineLength" value= "160" />
</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= "500" />
</test>
<!-- Checks for excessive parameters in a function declaration -->
<!-- <test name="functionMaxParameters">
<property name= "maxParameters" value= "4" />
</test> -->
<!-- Check Cyclomatic Complexity -->
2010-07-21 19:14:45 +02:00
<!-- see http://www.aivosto.com/project/help/pm - complexity.html -->
<test name= "cyclomaticComplexity" >
2010-07-21 18:04:19 +02:00
<!-- Level raising a warning -->
<property name= "warningLevel" value= "10" />
<!-- Level raising an error -->
<property name= "errorLevel" value= "20" />
</test>
<!-- **************** -->
<!-- Other -->
<!-- **************** -->
<!-- All arguments with default values should be at the end -->
<test name= "defaultValuesOrder" />
<!-- Check for prohibited functions -->
<!-- @see http://www.php.net/manual/en/indexes.php -->
<test name= "checkProhibitedFunctions" >
2010-07-21 19:14:45 +02:00
<item value= "echo" />
<item value= "system" />
<item value= "print_r" />
<item value= "var_dump" />
<item value= "dl" />
<!-- <item value="exec"/> -->
<item value= "passthru" />
<!-- <item value="delete"/> We disable because of false report when using method delete -->
<item value= "ereg_replace" />
<item value= "ereg" />
<item value= "eregi" />
<!-- <item value="copy"/> -->
<!-- <item value="fwrite"/> -->
2010-07-21 18:04:19 +02:00
</test>
<!-- Check for prohibited tokens -->
<!-- @see http://www.php.net/manual/en/tokens.php -->
<test name= "checkProhibitedTokens" >
2010-07-21 19:14:45 +02:00
<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"/> -->
2010-07-21 18:04:19 +02:00
</test>
<!-- Check for silenced errors before function calls (@function) -->
<test name= "checkSilencedError" >
2010-07-21 19:14:45 +02:00
<exception value= "rename" /> <!-- Exceptions to this rule -->
<exception value= "mkdir" />
<exception value= "chmod" />
2010-07-21 18:04:19 +02:00
</test>
<!-- Check for encapsed variables inside a String ("$a") -->
<test name= "encapsedVariablesInsideString" >
</test>
<!-- Avoid passing parameters by reference -->
<test name= "avoidPassingReferences" >
</test>
<test name= "showTODOs" >
</test>
<!-- Use boolean operators (&&) instead of logical operators (AND) -->
<test name= "useBooleanOperators" >
</test>
<!-- Check empty block like if ($a) {} -->
<test name= "checkEmptyBlock" >
2010-07-21 19:14:45 +02:00
<!-- <exception value="catch"/> -->
2010-07-21 18:04:19 +02:00
</test>
<!-- Check empty statement ( ;; ) -->
<test name= "checkEmptyStatement" >
</test>
<!-- Check for the presence of heredoc -->
<test name= "checkHeredoc" >
</test>
<!-- Check for braces around code blocs (if, else, elseif, do, while, for, foreach) -->
2010-07-21 23:57:23 +02:00
<!--
2010-07-21 18:04:19 +02:00
<test name= "needBraces" >
</test>
2010-07-21 23:57:23 +02:00
-->
2010-07-21 18:04:19 +02:00
<!-- Switch need a default value -->
<test name= "switchNeedDefault" >
</test>
<!-- Switch case should have a break -->
<!-- <test name="switchCaseNeedBreak">
</test> -->
<!-- Switch default value should be at the end -->
<test name= "switchDefaultOrder" >
</test>
<!--
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" >
2010-07-21 19:14:45 +02:00
<exception value= "for" />
2010-07-21 18:04:19 +02:00
</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" >
2010-07-21 19:14:45 +02:00
<exception value= "for" />
2010-07-21 18:04:19 +02:00
</test>
<!-- Detect unused private functions (detecting unused public ones is more difficult) -->
<test name= "checkUnusedPrivateFunctions" >
</test>
<!-- Detect unused variables -->
<test name= "checkUnusedVariables" >
</test>
<!-- Detect unused function parameters -->
<test name= "checkUnusedFunctionParameters" >
</test>
<!-- Only one class declaration per PHP file -->
<test name= "oneClassPerFile" >
</test>
<!-- ******************* -->
<!-- Optimisation -->
<!-- ******************* -->
<!-- Only one class declaration per PHP file -->
<test name= "functionInsideLoop" >
</test>
</phpcheckstyle-configuration>