MD_QA/rules/md_phpcs_rules.xml

301 lines
11 KiB
XML

<?xml version="1.0"?>
<ruleset name="museumdigital">
<description>Coding standard for museum-digital.
Based on Zend with some additions.</description>
<arg name="tab-width" value="4"/>
<!-- Handle commenting -->
<rule ref='PEAR.Commenting.FunctionComment'/>
<!-- <rule ref='Generic.Commenting'/> -->
<!-- <rule ref='Generic.Commenting.DocComment' /> -->
<rule ref='Squiz.Commenting.DocCommentAlignment'/>
<rule ref='Squiz.Commenting.FunctionComment'/>
<rule ref='Squiz.Commenting.ClassComment'/>
<!-- <rule ref='SlevomatCodingStandard.PHP.UselessParentheses'/>-->
<rule ref='SlevomatCodingStandard.PHP.OptimizedFunctionsWithoutUnpacking'/>
<!-- <rule ref='SlevomatCodingStandard.Variables.DisallowSuperGlobalVariable'/> -->
<rule ref='SlevomatCodingStandard.Variables.DuplicateAssignmentToVariable'/>
<!-- <rule ref='SlevomatCodingStandard.Variables.UnusedVariable'/> -->
<rule ref='SlevomatCodingStandard.Variables.UselessVariable'/>
<rule ref='SlevomatCodingStandard.Arrays.SingleLineArrayWhitespace'/>
<rule ref='SlevomatCodingStandard.Classes.ConstantSpacing'/>
<rule ref='SlevomatCodingStandard.PHP.TypeCast'/>
<rule ref='SlevomatCodingStandard.Classes.ClassConstantVisibility'/>
<rule ref='SlevomatCodingStandard.TypeHints.ParameterTypeHintSpacing'/>
<!-- <rule ref='SlevomatCodingStandard.TypeHints.PropertyTypeHintSpacing'/> -->
<!--
<rule ref="SlevomatCodingStandard.Classes.ClassStructure">
<properties>
<property name="groups" type="array">
<element value="uses"/>
Public constants are first but you don't care about the order of protected or private constants
<element value="public constants"/>
<element value="constants"/>
You don't care about the order among the properties. The same can be done with "properties" shortcut
<element value="public static properties, protected static properties, private static properties"/>
<element value="public properties, protected properties, private properties"/>
<element value="methods"/>
<element value="magic methods"/>
<element value="constructor"/>
<element value="destructor"/>
</property>
</properties>
</rule>
-->
<!--
<rule ref='PEAR.ControlStructures.ControlSignature'>
<properties>
<property name="spacing" value="5" />
</properties>
</rule>
-->
<rule ref='PEAR.ControlStructures.MultiLineCondition'/>
<rule ref='Squiz.ControlStructures.ElseIfDeclaration'/>
<rule ref='Squiz.ControlStructures.ForEachLoopDeclaration'/>
<rule ref='Squiz.ControlStructures.ForLoopDeclaration'/>
<!--
Warn about lines longer than 100 chars,
and error for lines longer than 135 chars.
-> This is currently disabled, as HTML lines easily go beyond any reasonable limits if they include links.
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="130" />
<property name="absoluteLineLimit" value="140" />
</properties>
</rule>
-->
<!-- Don't check function braces, but check closure braces. -->
<rule ref="Generic.Functions.OpeningFunctionBraceKernighanRitchie">
<properties>
<property name="checkFunctions" value="false" />
<property name="checkClosures" value="true" />
</properties>
</rule>
<rule ref="Generic.Debug.ClosureLinter">
<properties>
<property name="errorCodes" type="array" value="0210"/>
<property name="ignoreCodes" type="array" value="0001,0110,0240"/>
</properties>
</rule>
<rule ref='Generic.CodeAnalysis.UnconditionalIfStatement'/>
<rule ref='Generic.CodeAnalysis.UnusedFunctionParameter'/>
<rule ref='PEAR.Files'/>
<rule ref='PEAR.Formatting'/>
<rule ref='Generic.Functions.OpeningFunctionBraceKernighanRitchie'/>
<rule ref='Generic.Functions.FunctionCallArgumentSpacing'/>
<!--
<rule ref='PEAR.Functions.FunctionCallSignature'/>
<rule ref='PEAR.Functions.FunctionDeclaration'/>
-->
<rule ref='Squiz.Functions.FunctionDeclaration'/>
<rule ref='PEAR.Functions.ValidDefaultValue'/>
<rule ref='PEAR.NamingConventions.ValidClassName'/>
<!-- <rule ref="Squiz.Classes.ValidClassName"/>-->
<!--
Have code block comments look like // end foreach() etc.
<rule ref="Squiz.Commenting.LongConditionClosingComment">
<properties>
<property name="commentFormat" value="// end" />
</properties>
</rule>
-->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1" />
</properties>
</rule>
<rule ref='Zend.Files.ClosingTag'/>
<!--
<rule ref='PEAR.NamingConventions.ValidFunctionName'/>
<rule ref='Zend.NamingConventions.ValidVariableName' />
We may enforce these at some point in time. We don't at the moment.
<rule ref="Generic.Metrics.CyclomaticComplexity">
<properties>
<property name="complexity" value="24" />
<property name="absoluteComplexity" value="36" />
</properties>
</rule>
-->
<rule ref="Generic.Metrics.NestingLevel">
<properties>
<property name="nestingLevel" value="24" />
<property name="absoluteNestingLevel" value="30" />
</properties>
</rule>
<rule ref='PEAR.NamingConventions.ValidVariableName' />
<rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
<rule ref="Generic.Files.ByteOrderMark"/>
<rule ref='Generic.PHP.DeprecatedFunctions' />
<rule ref='Generic.PHP.CharacterBeforePHPOpeningTag' />
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
<rule ref='Generic.PHP.DisallowShortOpenTag' />
<!--
-->
<rule ref='Generic.Classes.OpeningBraceSameLine' />
<rule ref='Generic.PHP.NoSilencedErrors' />
<rule ref='Generic.PHP.SAPIUsage' />
<rule ref='Generic.PHP.Syntax' />
<rule ref='Generic.Arrays.DisallowLongArraySyntax' />
<rule ref='Generic.Files.LineEndings' />
<rule ref='Generic.Files.InlineHTML' />
<rule ref='Generic.Functions.OpeningFunctionBraceKernighanRitchie' />
<!--
Forbidden functinos.
Using this sniff, it is established that count is preferred over sizeof() etc.
Notably, we use the OOP style for mysqli function calls.
-->
<rule ref="Generic.PHP.ForbiddenFunctions">
<properties>
<!-- Starting phpcs 3.3 we should use this
<property name="forbiddenFunctions" type="array">
<element key="delete" value="unset"/>
<element key="print" value="echo"/>
<element key="create_function" value="null"/>
<element key="system" value="null"/>
<element key="sizeof" value="count"/>
</property>
-->
<property name="forbiddenFunctions" type="array" value="delete=>unset,print=>echo,create_function=>null,system=>null,sizeof=>count,mysql_query=>mysqli_query,mysqli_query=>null,mysql_num_rows=>mysqli_num_rows,mysqli_num_rows=>null,mysql_error=>mysqli_error,mysqli_stmt_init=>null,mysqli_stmt_close=>null,mysqli_real_escape_string=>null,mysqli_fetch_array=>mysqli_fetch_assoc,mysqli_fetch_assoc=>null,session_id=>null,print_r=>null,var_dump=>null,escapeshellcmd=>escapeshellarg" />
</properties>
</rule>
<rule ref="Internal.NoCodeFound">
</rule>
<!--
<rule ref="Squiz.PHP.DiscouragedFunctions">
<properties>
<property name="error" value="true" />
</properties>
</rule>
-->
<rule ref='Squiz.PHP.DisallowSizeFunctionsInLoops'/>
<rule ref='Squiz.Strings.EchoedStrings'/>
<rule ref="Squiz.Strings.ConcatenationSpacing">
<properties>
<property name="spacing" value="1" />
</properties>
</rule>
<rule ref='PEAR.WhiteSpace'/>
<rule ref='Generic.WhiteSpace.DisallowTabIndent'/>
<rule ref="Generic.Strings.UnnecessaryStringConcat">
<properties>
<property name="allowMultiline" value="true" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.OperatorSpacing">
<properties>
<property name="ignoreNewlines" value="true" />
</properties>
</rule>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
<properties>
<!-- <property name="ignoreBlankLines" value="true" /> -->
</properties>
</rule>
<!-- Ensure 1 blank line before and after functions, except at the top and bottom. -->
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="0" />
<property name="spacingAfterLast" value="0" />
</properties>
</rule>
<rule ref='Squiz.WhiteSpace.SemicolonSpacing'/>
<rule ref='Squiz.WhiteSpace.ScopeKeywordSpacing'/>
<rule ref='Squiz.WhiteSpace.ScopeClosingBrace'/>
<rule ref='Squiz.WhiteSpace.CastSpacing'/>
<rule ref='Squiz.WhiteSpace.FunctionClosingBraceSpace'/>
<rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
<!-- PHP keywords MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseKeyword"/>
<!-- The PHP constants true, false, and null MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseConstant"/>
<rule ref="PSR2.Classes.PropertyDeclaration.SpacingAfterType" />
<!-- 4.3 Methods -->
<!-- Visibility MUST be declared on all methods. -->
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
<rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
<!-- <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen"/> -->
<!-- <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose"/> -->
<rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
<!-- <rule ref="Squiz.ControlStructures.ControlSignature"/> -->
<!-- <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/> -->
<rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingAfterOpen">
<severity>0</severity>
</rule>
<rule ref="Squiz.ControlStructures.ForLoopDeclaration.SpacingBeforeClose">
| <severity>0</severity>
</rule>
<rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
<!-- <rule ref="Generic.ControlStructures.InlineControlStructure"/> -->
<rule ref='Squiz.PHP.Eval'/>
<rule ref='Squiz.PHP.DisallowBooleanStatement'/>
<rule ref="Generic.Formatting.DisallowMultipleStatements"/>
<rule ref='Squiz.Arrays.ArrayBracketSpacing'/>
<!--
<rule ref='Squiz.Operators.ComparisonOperatorUsage'/>
CSS
-->
<!-- Include some CSS rules I want to enforce
-->
<rule ref='Squiz.CSS.DuplicateStyleDefinition'/>
<rule ref='Squiz.CSS.ClassDefinitionNameSpacing'/>
<rule ref='Squiz.CSS.ColonSpacing'/>
<rule ref='Squiz.CSS.EmptyClassDefinition'/>
<!-- <rule ref='Squiz.CSS.ColourDefinition'/> -->
<rule ref='Squiz.CSS.SemicolonSpacing'/>
<!--
Javascript
-->
<rule ref='Generic.Debug.JSHint'/>
<rule ref='Squiz.Debug.JSLint'/>
</ruleset>