|
1 | 1 | <?xml version="1.0"?>
|
2 | 2 | <ruleset>
|
3 |
| - <arg name="basepath" value="."/> |
4 |
| - <arg name="extensions" value="php"/> |
5 |
| - <arg name="parallel" value="80"/> |
6 |
| - <arg name="cache" value=".phpcs-cache"/> |
| 3 | + <arg name="basepath" value="." /> |
| 4 | + <arg name="extensions" value="php" /> |
| 5 | + <arg name="parallel" value="80" /> |
| 6 | + <arg name="cache" value=".phpcs-cache" /> |
7 | 7 | <arg name="colors" />
|
8 | 8 |
|
9 |
| - <!-- Ignore warnings, show progress of the run, and show sniff names --> |
| 9 | + <!-- Ignore warnings (n), show progress of the run (p), and show sniff names (s) --> |
10 | 10 | <arg value="nps"/>
|
11 | 11 |
|
12 |
| - <autoload>.phpcs/autoload.php</autoload> |
13 |
| - |
14 |
| - <file>.phpcs</file> |
15 | 12 | <file>src</file>
|
16 | 13 | <file>tests</file>
|
17 | 14 |
|
| 15 | + <!-- ****************************************** --> |
| 16 | + <!-- Import rules from doctrine/coding-standard --> |
| 17 | + <!-- ****************************************** --> |
18 | 18 | <rule ref="Doctrine">
|
| 19 | + <!-- ********************************************** --> |
19 | 20 | <!-- Exclude sniffs that require newer PHP versions -->
|
20 |
| - <!-- Available with PHP 7.1 --> |
21 |
| - <exclude name="SlevomatCodingStandard.Classes.ClassConstantVisibility" /> |
22 |
| - <exclude name="SlevomatCodingStandard.PHP.ShortList.LongListUsed" /> |
23 |
| - <exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue" /> |
| 21 | + <!-- ********************************************** --> |
24 | 22 |
|
25 |
| - <!-- Can cause subtle BC breaks, disabled for now --> |
26 |
| - <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" /> |
| 23 | + <!-- Requires PHP 7.4 --> |
| 24 | + <exclude name="SlevomatCodingStandard.ControlStructures.RequireNullCoalesceEqualOperator" /> |
27 | 25 |
|
28 |
| - <!-- No statement alignment so far --> |
29 |
| - <exclude name="Generic.Formatting.MultipleStatementAlignment" /> |
| 26 | + <!-- Requires PHP 8.0 --> |
| 27 | + <exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall" /> |
30 | 28 |
|
31 |
| - <!-- Class naming sniffs are excluded to preserve BC --> |
| 29 | + |
| 30 | + <!-- *********************************** --> |
| 31 | + <!-- Exclude sniffs that cause BC breaks --> |
| 32 | + <!-- *********************************** --> |
32 | 33 | <exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" />
|
33 | 34 | <exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming" />
|
34 | 35 | <exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
|
35 | 36 | <exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming" />
|
36 | 37 |
|
37 |
| - <!-- Forbid useless annotations - Git and LICENCE file provide more accurate information --> |
38 |
| - <!-- Disable forbidden annotation sniff as excluding @api from the list doesn't work --> |
39 |
| - <exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden" /> |
| 38 | + <!-- Can cause subtle BC breaks --> |
| 39 | + <exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" /> |
| 40 | + |
| 41 | + |
| 42 | + <!-- **************************************** --> |
| 43 | + <!-- Exclude sniffs that force unwanted style --> |
| 44 | + <!-- **************************************** --> |
| 45 | + <exclude name="Generic.Formatting.MultipleStatementAlignment" /> |
| 46 | + <exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop" /> |
40 | 47 |
|
41 | 48 | <!-- Keep long typehints (for now) -->
|
| 49 | + <exclude name="PSR12.Keywords.ShortFormTypeKeywords" /> |
42 | 50 | <exclude name="SlevomatCodingStandard.PHP.TypeCast.InvalidCastUsed" />
|
43 | 51 | <exclude name="SlevomatCodingStandard.TypeHints.LongTypeHints" />
|
44 | 52 |
|
45 |
| - <!-- Don't require a full stop after @throws tags --> |
46 |
| - <exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop" /> |
47 | 53 |
|
48 |
| - <!-- Disable some sniffs as they can cause functional changes. These will be enabled later --> |
| 54 | + <!-- ************************************************ --> |
| 55 | + <!-- Exclude sniffs that may cause functional changes --> |
| 56 | + <!-- ************************************************ --> |
49 | 57 | <exclude name="Generic.PHP.ForbiddenFunctions.FoundWithAlternative" />
|
50 |
| - <exclude name="SlevomatCodingStandard.Classes.UnusedPrivateElements" /> |
51 | 58 | <exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
|
52 | 59 | <exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit" />
|
53 | 60 | <exclude name="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
|
54 | 61 | <exclude name="SlevomatCodingStandard.Functions.StaticClosure" />
|
55 | 62 | <exclude name="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
|
56 | 63 | <exclude name="SlevomatCodingStandard.Operators.DisallowEqualOperators" />
|
57 | 64 |
|
58 |
| - <!-- These sniffs cause a large diff, so enable them in separate steps --> |
| 65 | + |
| 66 | + <!-- ********************************************************* --> |
| 67 | + <!-- Exclude sniffs that cause a huge diff - enable separately --> |
| 68 | + <!-- ********************************************************* --> |
59 | 69 | <exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectAnnotationsGroup" />
|
60 | 70 | <exclude name="Squiz.Strings.DoubleQuoteUsage" />
|
61 | 71 |
|
62 |
| - <!-- Sniff currently breaks, see https://github.com/slevomat/coding-standard/issues/727 --> |
63 |
| - <exclude name="SlevomatCodingStandard.Namespaces.NamespaceSpacing" /> |
| 72 | + |
| 73 | + <!-- ********************* --> |
| 74 | + <!-- Exclude broken sniffs --> |
| 75 | + <!-- ********************* --> |
64 | 76 |
|
65 | 77 | <!-- Sniff currently broken when casting arrays, see https://github.com/squizlabs/PHP_CodeSniffer/issues/2937#issuecomment-615498860 -->
|
66 | 78 | <exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />
|
67 |
| - </rule> |
68 | 79 |
|
69 |
| - <!-- Change use statement sorting to be compatible with PSR-12 --> |
70 |
| - <rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"> |
71 |
| - <properties> |
72 |
| - <property name="psr12Compatible" value="true"/> |
73 |
| - </properties> |
| 80 | + <!-- Disable forbidden annotation sniff as excluding @api from the list doesn't work --> |
| 81 | + <exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden" /> |
74 | 82 | </rule>
|
75 | 83 |
|
| 84 | + |
| 85 | + <!-- ***************************************************** --> |
76 | 86 | <!-- Forbid fully qualified names even for colliding names -->
|
| 87 | + <!-- ***************************************************** --> |
77 | 88 | <rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
|
78 | 89 | <properties>
|
79 | 90 | <property name="allowFallbackGlobalConstants" value="false"/>
|
|
88 | 99 | </properties>
|
89 | 100 | </rule>
|
90 | 101 |
|
91 |
| - <!-- Only enable some checks regarding type hints --> |
92 |
| - <!-- In addition to requiring PHP 7.0, this sniff will cause a significant amount of BC breaks. Proceed with caution! --> |
93 |
| - <rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration"> |
94 |
| - <!-- Traversable type hints often end up as mixed[], so we skip them for now --> |
95 |
| - <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversablePropertyTypeHintSpecification" /> |
96 |
| - <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableParameterTypeHintSpecification" /> |
97 |
| - <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingTraversableReturnTypeHintSpecification" /> |
98 | 102 |
|
99 |
| - <!-- Will cause BC breaks to method signatures - disabled for now --> |
100 |
| - <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint" /> |
101 |
| - <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint" /> |
| 103 | + <!-- **************************************************************************** --> |
| 104 | + <!-- Exclude BC breaking type hints for parameters, properties, and return values --> |
| 105 | + <!-- **************************************************************************** --> |
| 106 | + <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint"> |
| 107 | + <properties> |
| 108 | + <!-- Requires PHP 7.4 --> |
| 109 | + <property name="enableObjectTypeHint" value="false" /> |
| 110 | + <!-- Requires PHP 8.0 --> |
| 111 | + <property name="enableMixedTypeHint" value="false" /> |
| 112 | + <!-- Requires PHP 8.0 --> |
| 113 | + <property name="enableUnionTypeHint" value="false" /> |
| 114 | + </properties> |
| 115 | + |
| 116 | + <exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" /> |
| 117 | + <exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" /> |
| 118 | + </rule> |
| 119 | + |
| 120 | + <rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint"> |
| 121 | + <properties> |
| 122 | + <!-- Requires PHP 7.4 --> |
| 123 | + <property name="enableNativeTypeHint" value="false" /> |
| 124 | + <!-- Requires PHP 8.0 --> |
| 125 | + <property name="enableMixedTypeHint" value="false" /> |
| 126 | + <!-- Requires PHP 8.0 --> |
| 127 | + <property name="enableUnionTypeHint" value="false" /> |
| 128 | + </properties> |
| 129 | + |
| 130 | + <exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" /> |
| 131 | + <exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation" /> |
| 132 | + </rule> |
102 | 133 |
|
| 134 | + <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint"> |
103 | 135 | <properties>
|
104 |
| - <property name="enableObjectTypeHint" value="true" /> |
105 |
| - <property name="enableEachParameterAndReturnInspection" value="false" /> |
| 136 | + <!-- Requires PHP 7.2 --> |
| 137 | + <property name="enableObjectTypeHint" value="false" /> |
| 138 | + <!-- Requires PHP 8.0 --> |
| 139 | + <property name="enableStaticTypeHint" value="false" /> |
| 140 | + <!-- Requires PHP 8.0 --> |
| 141 | + <property name="enableMixedTypeHint" value="false" /> |
| 142 | + <!-- Requires PHP 8.0 --> |
| 143 | + <property name="enableUnionTypeHint" value="false" /> |
106 | 144 | </properties>
|
| 145 | + |
| 146 | + <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" /> |
| 147 | + <exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation" /> |
107 | 148 | </rule>
|
108 | 149 |
|
| 150 | + |
| 151 | + <!-- ************************************************************************** --> |
| 152 | + <!-- Require type hints for all parameters, properties, and return types in src --> |
| 153 | + <!-- ************************************************************************** --> |
| 154 | + <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint"> |
| 155 | + <exclude-pattern>tests</exclude-pattern> |
| 156 | + </rule> |
| 157 | + <rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint"> |
| 158 | + <exclude-pattern>tests</exclude-pattern> |
| 159 | + </rule> |
| 160 | + <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"> |
| 161 | + <exclude-pattern>tests</exclude-pattern> |
| 162 | + </rule> |
| 163 | + |
| 164 | + |
| 165 | + <!-- *********************************************************************************** --> |
| 166 | + <!-- Require native type hints for all parameters, properties, and return types in tests --> |
| 167 | + <!-- *********************************************************************************** --> |
| 168 | + <rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"> |
| 169 | + <exclude-pattern>src</exclude-pattern> |
| 170 | + </rule> |
| 171 | + <rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint"> |
| 172 | + <exclude-pattern>src</exclude-pattern> |
| 173 | + </rule> |
| 174 | + <rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"> |
| 175 | + <exclude-pattern>src</exclude-pattern> |
| 176 | + </rule> |
| 177 | + |
| 178 | + |
| 179 | + <!-- ************************************************************* --> |
| 180 | + <!-- Ignore errors for certain files where this is part of the API --> |
| 181 | + <!-- ************************************************************* --> |
109 | 182 | <rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps">
|
110 | 183 | <exclude-pattern>/src/GridFS/StreamWrapper</exclude-pattern>
|
111 | 184 | <exclude-pattern>/tests/DocumentationExamplesTest.php</exclude-pattern>
|
112 | 185 | <exclude-pattern>/tests/GridFS/UnusableStream.php</exclude-pattern>
|
113 | 186 | </rule>
|
114 |
| - |
115 | 187 | <rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
|
116 | 188 | <exclude-pattern>/tests/PHPUnit/ConstraintTrait.php</exclude-pattern>
|
117 | 189 | </rule>
|
|
0 commit comments