|
| 1 | +<?xml version="1.0"?> |
| 2 | +<ruleset name="Backdevs Base" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../vendor/squizlabs/php_codesniffer/phpcs.xsd"> |
| 3 | + <!-- Forbid `array(...)` --> |
| 4 | + <rule ref="Generic.Arrays.DisallowLongArraySyntax"/> |
| 5 | + <!-- Forbid duplicate classes --> |
| 6 | + <rule ref="Generic.Classes.DuplicateClassName"/> |
| 7 | + <!-- Forbid empty statements --> |
| 8 | + <rule ref="Generic.CodeAnalysis.EmptyStatement"> |
| 9 | + <!-- But allow empty catch --> |
| 10 | + <exclude name="Generic.CodeAnalysis.EmptyStatement.DetectedCatch"/> |
| 11 | + </rule> |
| 12 | + <!-- Forbid final methods in final classes --> |
| 13 | + <rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/> |
| 14 | + <!-- Forbid useless empty method overrides --> |
| 15 | + <rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/> |
| 16 | + <!-- Forbid inline HTML in PHP code --> |
| 17 | + <rule ref="Generic.Files.InlineHTML"/> |
| 18 | + <!-- Force whitespace after a type cast --> |
| 19 | + <rule ref="Generic.Formatting.SpaceAfterCast"/> |
| 20 | + <!-- Forbid PHP 4 constructors --> |
| 21 | + <rule ref="Generic.NamingConventions.ConstructorName"/> |
| 22 | + <!-- Forbid any content before opening tag --> |
| 23 | + <rule ref="Generic.PHP.CharacterBeforePHPOpeningTag"/> |
| 24 | + <!-- Forbid deprecated functions --> |
| 25 | + <rule ref="Generic.PHP.DeprecatedFunctions"/> |
| 26 | + <!-- Forbid alias functions, i.e. `sizeof()`, `delete()` --> |
| 27 | + <rule ref="Generic.PHP.ForbiddenFunctions"> |
| 28 | + <properties> |
| 29 | + <property name="forbiddenFunctions" type="array" |
| 30 | + value=" |
| 31 | + chop => rtrim, |
| 32 | + close => closedir, |
| 33 | + delete => unset, |
| 34 | + doubleval => floatval, |
| 35 | + fputs => fwrite, |
| 36 | + ini_alter => ini_set, |
| 37 | + is_double => is_float, |
| 38 | + is_integer => is_int, |
| 39 | + is_long => is_int, |
| 40 | + is_null => null, |
| 41 | + is_real => is_float, |
| 42 | + is_writeable => is_writable, |
| 43 | + join => implode, |
| 44 | + key_exists => array_key_exists, |
| 45 | + pos => current, |
| 46 | + show_source => highlight_file, |
| 47 | + sizeof => count, |
| 48 | + strchr => strstr |
| 49 | + "/> |
| 50 | + </properties> |
| 51 | + </rule> |
| 52 | + <!-- Forbid useless inline string concatenation --> |
| 53 | + <rule ref="Generic.Strings.UnnecessaryStringConcat"> |
| 54 | + <!-- But multiline is useful for readability --> |
| 55 | + <properties> |
| 56 | + <property name="allowMultiline" type="boolean" value="true"/> |
| 57 | + </properties> |
| 58 | + </rule> |
| 59 | + <!-- Forbid backtick operator --> |
| 60 | + <rule ref="Generic.PHP.BacktickOperator"/> |
| 61 | + <!-- Forbid short open tag --> |
| 62 | + <rule ref="Generic.PHP.DisallowShortOpenTag"/> |
| 63 | + <!-- Forbid `php_sapi_name()` function --> |
| 64 | + <rule ref="Generic.PHP.SAPIUsage"/> |
| 65 | + |
| 66 | + <!-- Forbid comments starting with # --> |
| 67 | + <rule ref="PEAR.Commenting.InlineComment"/> |
| 68 | + |
| 69 | + <!-- Forbid spaces around square brackets --> |
| 70 | + <rule ref="Squiz.Arrays.ArrayBracketSpacing"/> |
| 71 | + <!-- Force array declaration structure --> |
| 72 | + <rule ref="Squiz.Arrays.ArrayDeclaration"> |
| 73 | + <!-- Disable arrow alignment --> |
| 74 | + <exclude name="Squiz.Arrays.ArrayDeclaration.DoubleArrowNotAligned"/> |
| 75 | + <!-- Uses indentation of only single space --> |
| 76 | + <exclude name="Squiz.Arrays.ArrayDeclaration.KeyNotAligned"/> |
| 77 | + <!-- Allow multiple values on a single line --> |
| 78 | + <exclude name="Squiz.Arrays.ArrayDeclaration.SingleLineNotAllowed"/> |
| 79 | + <!-- Allow single values on multi line array --> |
| 80 | + <exclude name="Squiz.Arrays.ArrayDeclaration.MultiLineNotAllowed"/> |
| 81 | + <!-- Disable alignment of braces --> |
| 82 | + <exclude name="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned"/> |
| 83 | + <!-- Disable alignment of values with opening brace --> |
| 84 | + <exclude name="Squiz.Arrays.ArrayDeclaration.ValueNotAligned"/> |
| 85 | + <!-- Checked by SlevomatCodingStandard.Arrays.TrailingArrayComma.MissingTrailingComma --> |
| 86 | + <exclude name="Squiz.Arrays.ArrayDeclaration.NoCommaAfterLast"/> |
| 87 | + </rule> |
| 88 | + <!-- Forbid class being in a file with different name --> |
| 89 | + <rule ref="Squiz.Classes.ClassFileName"/> |
| 90 | + <!-- Force `self::` for self-reference, force lower-case self, forbid spaces around `::` --> |
| 91 | + <rule ref="Squiz.Classes.SelfMemberReference"/> |
| 92 | + <!-- Force phpDoc alignment --> |
| 93 | + <rule ref="Squiz.Commenting.DocCommentAlignment"> |
| 94 | + <!-- Allow extra spaces after star, i.e. for indented annotations --> |
| 95 | + <exclude name="Squiz.Commenting.DocCommentAlignment.SpaceAfterStar"/> |
| 96 | + </rule> |
| 97 | + <!-- Force rules for function phpDoc --> |
| 98 | + <rule ref="Squiz.Commenting.FunctionComment"> |
| 99 | + <!-- Allow `@throws` without description --> |
| 100 | + <exclude name="Squiz.Commenting.FunctionComment.EmptyThrows"/> |
| 101 | + <!-- Does not work properly with PHP 7 / short-named types --> |
| 102 | + <exclude name="Squiz.Commenting.FunctionComment.IncorrectParamVarName"/> |
| 103 | + <!-- Does not support collections, i.e. `string[]` --> |
| 104 | + <exclude name="Squiz.Commenting.FunctionComment.IncorrectTypeHint"/> |
| 105 | + <!-- Forces incorrect types --> |
| 106 | + <exclude name="Squiz.Commenting.FunctionComment.InvalidReturn"/> |
| 107 | + <!-- Breaks with compound return types, i.e. `string|null` --> |
| 108 | + <exclude name="Squiz.Commenting.FunctionComment.InvalidReturnNotVoid"/> |
| 109 | + <!-- Breaks when all params are not documented --> |
| 110 | + <exclude name="Squiz.Commenting.FunctionComment.InvalidTypeHint"/> |
| 111 | + <!-- Doc comment is not required for every method --> |
| 112 | + <exclude name="Squiz.Commenting.FunctionComment.Missing"/> |
| 113 | + <!-- Do not require comments for `@param` --> |
| 114 | + <exclude name="Squiz.Commenting.FunctionComment.MissingParamComment"/> |
| 115 | + <!-- Do not require `@param` for all parameters --> |
| 116 | + <exclude name="Squiz.Commenting.FunctionComment.MissingParamTag"/> |
| 117 | + <!-- Do not require `@return` for void methods --> |
| 118 | + <exclude name="Squiz.Commenting.FunctionComment.MissingReturn"/> |
| 119 | + <!-- Comments don't have to be sentences --> |
| 120 | + <exclude name="Squiz.Commenting.FunctionComment.ParamCommentFullStop"/> |
| 121 | + <!-- Comments don't have to be sentences --> |
| 122 | + <exclude name="Squiz.Commenting.FunctionComment.ParamCommentNotCapital"/> |
| 123 | + <!-- Breaks when all params are not documented --> |
| 124 | + <exclude name="Squiz.Commenting.FunctionComment.ParamNameNoMatch"/> |
| 125 | + <!-- Doesn't respect inheritance --> |
| 126 | + <exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/> |
| 127 | + <!-- Don't require @param variable names to be aligned --> |
| 128 | + <exclude name="Squiz.Commenting.FunctionComment.SpacingAfterParamType"/> |
| 129 | + <!-- Doesn't work with self as typehint --> |
| 130 | + <exclude name="Squiz.Commenting.FunctionComment.TypeHintMissing"/> |
| 131 | + </rule> |
| 132 | + <!-- Forbid global functions --> |
| 133 | + <rule ref="Squiz.Functions.GlobalFunction"/> |
| 134 | + <!-- Forbid `AND` and `OR`, require `&&` and `||` --> |
| 135 | + <rule ref="Squiz.Operators.ValidLogicalOperators"/> |
| 136 | + <!-- Forbid `global` --> |
| 137 | + <rule ref="Squiz.PHP.GlobalKeyword"/> |
| 138 | + <!-- Forbid functions inside functions --> |
| 139 | + <rule ref="Squiz.PHP.InnerFunctions"/> |
| 140 | + <!-- Require PHP function calls in lowercase --> |
| 141 | + <rule ref="Squiz.PHP.LowercasePHPFunctions"/> |
| 142 | + <!-- Forbid dead code --> |
| 143 | + <rule ref="Squiz.PHP.NonExecutableCode"/> |
| 144 | + <!-- Forbid `$this` inside static function --> |
| 145 | + <rule ref="Squiz.Scope.StaticThisUsage"/> |
| 146 | + <!-- Forbid strings in `"` unless necessary --> |
| 147 | + <rule ref="Squiz.Strings.DoubleQuoteUsage"/> |
| 148 | + <rule ref="Squiz.Strings.DoubleQuoteUsage.ContainsVar"> |
| 149 | + <message>Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead</message> |
| 150 | + </rule> |
| 151 | + <!-- Forbid braces around string in `echo` --> |
| 152 | + <rule ref="Squiz.Strings.EchoedStrings"/> |
| 153 | + <!-- Forbid spaces in type casts --> |
| 154 | + <rule ref="Squiz.WhiteSpace.CastSpacing"/> |
| 155 | + <!-- Forbid blank line after function opening brace --> |
| 156 | + <rule ref="Squiz.WhiteSpace.FunctionOpeningBraceSpace"/> |
| 157 | + <!-- Require space after language constructs --> |
| 158 | + <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing"/> |
| 159 | + <!-- Require space around logical operators --> |
| 160 | + <rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/> |
| 161 | + <!-- Forbid spaces around `->` operator --> |
| 162 | + <rule ref="Squiz.WhiteSpace.ObjectOperatorSpacing"> |
| 163 | + <properties> |
| 164 | + <property name="ignoreNewlines" type="boolean" value="true"/> |
| 165 | + </properties> |
| 166 | + </rule> |
| 167 | + <!-- Forbid superfluous whitespaces --> |
| 168 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"> |
| 169 | + <properties> |
| 170 | + <!-- turned on by PSR2 -> turning back off --> |
| 171 | + <property name="ignoreBlankLines" type="boolean" value="false"/> |
| 172 | + </properties> |
| 173 | + </rule> |
| 174 | + <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines"> |
| 175 | + <!-- turned off by PSR2 -> turning back on --> |
| 176 | + <severity>5</severity> |
| 177 | + </rule> |
| 178 | +</ruleset> |
0 commit comments