|
| 1 | +<?xml version="1.0"?> |
| 2 | +<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="PHPCSDev" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"> |
| 3 | + |
| 4 | + <description>A PSR-12 based standard for use by sniff developers to check the code style of external PHPCS standards</description> |
| 5 | + |
| 6 | + <!-- |
| 7 | + #################################################################### |
| 8 | + PHP: Check PHP cross version compatibility. |
| 9 | + For optimal results, the custom project ruleset should set the testVersion |
| 10 | + config variable. |
| 11 | + For compatibility with the PHP version supported by PHP_CodeSniffer 3.0+, |
| 12 | + this would typically be set like: <config name="testVersion" value="5.4-"/>. |
| 13 | + #################################################################### |
| 14 | + --> |
| 15 | + <rule ref="PHPCompatibility"> |
| 16 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_finallyFound"/> |
| 17 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_yieldFound"/> |
| 18 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_ellipsisFound"/> |
| 19 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_powFound"/> |
| 20 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_pow_equalFound"/> |
| 21 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_spaceshipFound"/> |
| 22 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_coalesceFound"/> |
| 23 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_coalesce_equalFound"/> |
| 24 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_yield_fromFound"/> |
| 25 | + <exclude name="PHPCompatibility.Constants.NewConstants.t_bad_characterFound"/> |
| 26 | + </rule> |
| 27 | + |
| 28 | + |
| 29 | + <!-- |
| 30 | + #################################################################### |
| 31 | + Code style: Check style for compliance with PSR12. |
| 32 | + #################################################################### |
| 33 | + --> |
| 34 | + <rule ref="PSR12"> |
| 35 | + <!-- As PHP 5.4 is the minimum supported PHP version for PHP_CodeSniffer and |
| 36 | + most external standards, adding constant visibility is not (yet) an option. --> |
| 37 | + <exclude name="PSR12.Properties.ConstantVisibility"/> |
| 38 | + |
| 39 | + <!-- Allow for the first condition of a multi-line control structure to be on the same line |
| 40 | + as the control structure keyword. --> |
| 41 | + <exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/> |
| 42 | + </rule> |
| 43 | + |
| 44 | + |
| 45 | + <!-- |
| 46 | + #################################################################### |
| 47 | + Code style: Naming Conventions. |
| 48 | + #################################################################### |
| 49 | + --> |
| 50 | + |
| 51 | + <!-- Check that variable names are in camelCase. --> |
| 52 | + <rule ref="Squiz.NamingConventions.ValidVariableName"> |
| 53 | + <exclude name="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore"/> |
| 54 | + </rule> |
| 55 | + |
| 56 | + <!-- Check that function and method names are in camelCase. --> |
| 57 | + <rule ref="Generic.NamingConventions.CamelCapsFunctionName"> |
| 58 | + <properties> |
| 59 | + <!-- Allow for two adjacent capital letters for acronyms. --> |
| 60 | + <property name="strict" value="false"/> |
| 61 | + </properties> |
| 62 | + </rule> |
| 63 | + |
| 64 | + |
| 65 | + <!-- |
| 66 | + #################################################################### |
| 67 | + Code style: Various other additions. |
| 68 | + #################################################################### |
| 69 | + --> |
| 70 | + |
| 71 | + <!-- PSR12 appears to ignore blank lines for superfluous whitespace and in several other places. Let's fix that. --> |
| 72 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"> |
| 73 | + <properties> |
| 74 | + <property name="ignoreBlankLines" value="false"/> |
| 75 | + </properties> |
| 76 | + </rule> |
| 77 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile"> |
| 78 | + <severity>5</severity> |
| 79 | + </rule> |
| 80 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile"> |
| 81 | + <severity>5</severity> |
| 82 | + </rule> |
| 83 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"> |
| 84 | + <severity>5</severity> |
| 85 | + </rule> |
| 86 | + |
| 87 | + <!-- Ensure exactly one blank line before each property declaration. --> |
| 88 | + <rule ref="Squiz.WhiteSpace.MemberVarSpacing"/> |
| 89 | + |
| 90 | + <!-- Ensure exactly one blank line before each function declaration, two blank lines |
| 91 | + before the first function and 0 after the last. --> |
| 92 | + <rule ref="Squiz.WhiteSpace.FunctionSpacing"> |
| 93 | + <properties> |
| 94 | + <property name="spacing" value="1"/> |
| 95 | + <property name="spacingBeforeFirst" value="1"/> |
| 96 | + <property name="spacingAfterLast" value="0"/> |
| 97 | + </properties> |
| 98 | + </rule> |
| 99 | + |
| 100 | + <rule ref="Generic.WhiteSpace.ArbitraryParenthesesSpacing"/> |
| 101 | + |
| 102 | + <!-- Align the equal operator in assignment blocks. --> |
| 103 | + <rule ref="Generic.Formatting.MultipleStatementAlignment"> |
| 104 | + <properties> |
| 105 | + <property name="maxPadding" value="25"/> |
| 106 | + </properties> |
| 107 | + </rule> |
| 108 | + |
| 109 | + <rule ref="PEAR.Files.IncludingFile"/> |
| 110 | + <rule ref="PEAR.Files.IncludingFile.UseInclude"> |
| 111 | + <severity>0</severity> |
| 112 | + </rule> |
| 113 | + <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce"> |
| 114 | + <severity>0</severity> |
| 115 | + </rule> |
| 116 | + |
| 117 | + <!-- Disallow Yoda conditions. --> |
| 118 | + <rule ref="Generic.ControlStructures.DisallowYodaConditions"/> |
| 119 | + |
| 120 | + <!-- Use self or static when referring to the class in use. --> |
| 121 | + <rule ref="Squiz.Classes.SelfMemberReference"/> |
| 122 | + |
| 123 | + <!-- Only one object structure per file. --> |
| 124 | + <rule ref="Generic.Files.OneObjectStructurePerFile"/> |
| 125 | + |
| 126 | + |
| 127 | + <!-- |
| 128 | + #################################################################### |
| 129 | + Code style: Array declarations. |
| 130 | + #################################################################### |
| 131 | + --> |
| 132 | + |
| 133 | + <!-- Use normalized array indentation. --> |
| 134 | + <rule ref="Generic.Arrays.ArrayIndent"/> |
| 135 | + <rule ref="Squiz.Arrays.ArrayDeclaration"/> |
| 136 | + |
| 137 | + <!-- Ignoring the Squiz indentation rules as normalized arrays are preferred. --> |
| 138 | + <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"> |
| 139 | + <severity>0</severity> |
| 140 | + </rule> |
| 141 | + <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"> |
| 142 | + <severity>0</severity> |
| 143 | + </rule> |
| 144 | + <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"> |
| 145 | + <severity>0</severity> |
| 146 | + </rule> |
| 147 | + |
| 148 | + <!-- Single and multi-line arrays are both allowed. --> |
| 149 | + <rule ref="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"> |
| 150 | + <severity>0</severity> |
| 151 | + </rule> |
| 152 | + <rule ref="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed"> |
| 153 | + <severity>0</severity> |
| 154 | + </rule> |
| 155 | + |
| 156 | + |
| 157 | + <!-- |
| 158 | + #################################################################### |
| 159 | + Docs: Verify the documentation. |
| 160 | + #################################################################### |
| 161 | + --> |
| 162 | + |
| 163 | + <rule ref="Generic.Commenting.DocComment"> |
| 164 | + <!-- Having a @see or @internal tag before the @param tags is fine. --> |
| 165 | + <exclude name="Generic.Commenting.DocComment.ParamNotFirst"/> |
| 166 | + </rule> |
| 167 | + |
| 168 | + <rule ref="PEAR.Commenting"> |
| 169 | + <!-- Exclude PEAR specific tag requirements. --> |
| 170 | + <exclude name="PEAR.Commenting.FileComment.MissingVersion"/> |
| 171 | + <exclude name="PEAR.Commenting.FileComment.MissingAuthorTag"/> |
| 172 | + <exclude name="PEAR.Commenting.FileComment.MissingCategoryTag"/> |
| 173 | + <exclude name="PEAR.Commenting.FileComment.MissingLicenseTag"/> |
| 174 | + <exclude name="PEAR.Commenting.FileComment.MissingLinkTag"/> |
| 175 | + <exclude name="PEAR.Commenting.ClassComment.MissingAuthorTag"/> |
| 176 | + <exclude name="PEAR.Commenting.ClassComment.MissingCategoryTag"/> |
| 177 | + <exclude name="PEAR.Commenting.ClassComment.MissingLicenseTag"/> |
| 178 | + <exclude name="PEAR.Commenting.ClassComment.MissingLinkTag"/> |
| 179 | + <exclude name="PEAR.Commenting.ClassComment.MissingPackageTag"/> |
| 180 | + |
| 181 | + <!-- Having a @see or @internal tag before the @category tag is fine. --> |
| 182 | + <exclude name="PEAR.Commenting.ClassComment.CategoryTagOrder"/> |
| 183 | + |
| 184 | + <!-- Using @since for class changelog demands multiple tags. --> |
| 185 | + <exclude name="PEAR.Commenting.ClassComment.DuplicateSinceTag"/> |
| 186 | + </rule> |
| 187 | + |
| 188 | + |
| 189 | + <!-- |
| 190 | + #################################################################### |
| 191 | + Code Analysis additions. |
| 192 | + #################################################################### |
| 193 | + --> |
| 194 | + |
| 195 | + <!-- Efficiency: don't use function calls within the condition of a for loop. --> |
| 196 | + <rule ref="Generic.CodeAnalysis.ForLoopWithTestFunctionCall"/> |
| 197 | + |
| 198 | + <!-- Efficiency: don't use size functions within a loop. --> |
| 199 | + <rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/> |
| 200 | + |
| 201 | + <!-- Efficiency: don't unnecessarily use double quotes. --> |
| 202 | + <rule ref="Squiz.Strings.DoubleQuoteUsage.NotRequired"/> |
| 203 | + |
| 204 | + <!-- Error prevention: warns when an inner loop uses the same incrementor as the outer loop. --> |
| 205 | + <rule ref="Generic.CodeAnalysis.JumbledIncrementer"/> |
| 206 | + |
| 207 | + <!-- Error prevention: don't assign from within a condition. --> |
| 208 | + <rule ref="Generic.CodeAnalysis.AssignmentInCondition"> |
| 209 | + <exclude name="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/> |
| 210 | + </rule> |
| 211 | + |
| 212 | + <!-- Clean up: remove redundant code. --> |
| 213 | + <rule ref="Squiz.PHP.NonExecutableCode"/> |
| 214 | + |
| 215 | + <!-- Clean up: no empty statements. --> |
| 216 | + <rule ref="Generic.CodeAnalysis.EmptyPHPStatement"/> |
| 217 | + |
| 218 | + <!-- Parse error prevention: guard against merge conflict artifacts. --> |
| 219 | + <rule ref="Generic.VersionControl.GitMergeConflict"/> |
| 220 | + |
| 221 | +</ruleset> |
0 commit comments