-
Notifications
You must be signed in to change notification settings - Fork 47
/
phpcs.xml.dist
169 lines (138 loc) · 8.27 KB
/
phpcs.xml.dist
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?xml version="1.0"?>
<ruleset>
<arg name="basepath" value="." />
<arg name="extensions" value="php" />
<arg name="cache" value=".phpcs-cache" />
<arg name="colors" />
<!-- Ignore warnings (n), show progress of the run (p), and show sniff names (s) -->
<arg value="nps"/>
<file>src</file>
<file>tests</file>
<rule ref="PSR12">
<!-- ********************************************** -->
<!-- Exclude sniffs that require newer PHP versions -->
<!-- ********************************************** -->
<!-- Requires PHP 8.0 -->
<exclude name="SlevomatCodingStandard.Classes.ModernClassNameReference.ClassNameReferencedViaFunctionCall" />
<!-- *********************************** -->
<!-- Exclude sniffs that cause BC breaks -->
<!-- *********************************** -->
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming" />
<exclude name="SlevomatCodingStandard.Classes.SuperfluousTraitNaming" />
<!-- **************************************** -->
<!-- Exclude sniffs that force unwanted style -->
<!-- **************************************** -->
<exclude name="Generic.Formatting.MultipleStatementAlignment" />
<exclude name="Squiz.Commenting.FunctionComment.ThrowsNoFullStop" />
<!-- Keep long typehints (for now) -->
<exclude name="SlevomatCodingStandard.PHP.TypeCast.InvalidCastUsed" />
<exclude name="SlevomatCodingStandard.TypeHints.LongTypeHints" />
<!-- ************************************************ -->
<!-- Exclude sniffs that may cause functional changes -->
<!-- ************************************************ -->
<exclude name="Generic.PHP.ForbiddenFunctions.FoundWithAlternative" />
<exclude name="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison" />
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit" />
<exclude name="SlevomatCodingStandard.ControlStructures.UselessIfConditionWithReturn" />
<exclude name="SlevomatCodingStandard.Functions.StaticClosure" />
<exclude name="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure" />
<exclude name="SlevomatCodingStandard.Operators.DisallowEqualOperators" />
<!-- ********************************************************* -->
<!-- Exclude sniffs that cause a huge diff - enable separately -->
<!-- ********************************************************* -->
<exclude name="SlevomatCodingStandard.Commenting.DocCommentSpacing.IncorrectAnnotationsGroup" />
<exclude name="Squiz.Strings.DoubleQuoteUsage" />
<!-- ********************* -->
<!-- Exclude broken sniffs -->
<!-- ********************* -->
<!-- Sniff currently broken when casting arrays, see https://github.com/squizlabs/PHP_CodeSniffer/issues/2937#issuecomment-615498860 -->
<exclude name="Squiz.Arrays.ArrayDeclaration.ValueNoNewline" />
<!-- Disable forbidden annotation sniff as excluding @api from the list doesn't work -->
<exclude name="SlevomatCodingStandard.Commenting.ForbiddenAnnotations.AnnotationForbidden" />
</rule>
<!-- ***************************************************** -->
<!-- Forbid fully qualified names even for colliding names -->
<!-- ***************************************************** -->
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowFallbackGlobalFunctions" value="false"/>
<property name="allowFullyQualifiedGlobalClasses" value="false"/>
<property name="allowFullyQualifiedGlobalConstants" value="false"/>
<property name="allowFullyQualifiedGlobalFunctions" value="false"/>
<property phpcs-only="true" name="allowFullyQualifiedNameForCollidingClasses" value="true"/>
<property phpcs-only="true" name="allowFullyQualifiedNameForCollidingConstants" value="false"/>
<property phpcs-only="true" name="allowFullyQualifiedNameForCollidingFunctions" value="false"/>
<property name="searchAnnotations" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses"/>
<!-- **************************************************************************** -->
<!-- Exclude BC breaking type hints for parameters, properties, and return values -->
<!-- **************************************************************************** -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<properties>
<!-- Requires PHP 8.0 -->
<property name="enableMixedTypeHint" value="false" />
<!-- Requires PHP 8.0 -->
<property name="enableUnionTypeHint" value="false" />
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<!-- Requires PHP 8.0 -->
<property name="enableMixedTypeHint" value="false" />
<!-- Requires PHP 8.0 -->
<property name="enableUnionTypeHint" value="false" />
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation" />
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<properties>
<!-- Requires PHP 8.0 -->
<property name="enableStaticTypeHint" value="false" />
<!-- Requires PHP 8.0 -->
<property name="enableMixedTypeHint" value="false" />
<!-- Requires PHP 8.0 -->
<property name="enableUnionTypeHint" value="false" />
</properties>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification" />
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation" />
</rule>
<!-- ************************************************************************** -->
<!-- Require type hints for all parameters, properties, and return types in src -->
<!-- ************************************************************************** -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint">
<exclude-pattern>tests</exclude-pattern>
</rule>
<!-- *********************************************************************************** -->
<!-- Require native type hints for all parameters, properties, and return types in tests -->
<!-- *********************************************************************************** -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint">
<exclude-pattern>src</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint">
<exclude-pattern>src</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint">
<exclude-pattern>src</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="newlinesCountBetweenOpenTagAndDeclare" type="int" value="2" />
<property name="spacesCountAroundEqualsSign" type="int" value="0" />
</properties>
</rule>
<rule ref="Generic.Arrays.DisallowLongArraySyntax" />
</ruleset>