-
Notifications
You must be signed in to change notification settings - Fork 13
/
.phpcs.xml.dist
191 lines (155 loc) · 8.29 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?xml version="1.0"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Coding Standard for PHPUnit Polyfills" xsi:noNamespaceSchemaLocation="./vendor/squizlabs/php_codesniffer/phpcs.xsd">
<description>Check the code of PHPUnit Polyfills.</description>
<!--
#############################################################################
COMMAND LINE ARGUMENTS
https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
#############################################################################
-->
<file>.</file>
<!-- Only check PHP files. -->
<arg name="extensions" value="php"/>
<!-- Show progress, show the error codes for each message (source). -->
<arg value="ps"/>
<!-- Strip the filepaths down to the relevant bit. -->
<arg name="basepath" value="./"/>
<!-- Check up to 8 files simultaneously. -->
<arg name="parallel" value="8"/>
<!-- Cache the results between runs. -->
<arg name="cache" value="./.cache/phpcs.cache"/>
<!--
#############################################################################
USE THE YoastCS RULESET
#############################################################################
-->
<rule ref="Yoast">
<!-- Duplicate classes is by design and part of the cross-version compatibility mechanism. -->
<exclude name="Generic.Classes.DuplicateClassName"/>
<!-- Exclude some rules which conflicts with the naming conventions used in PHPUnit. -->
<exclude name="Yoast.Files.FileName"/>
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
<exclude name="WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid"/>
<!-- Exclude some rules which are irrelevant.
The code in this package is not run in the context of a WordPress plugin. -->
<exclude name="WordPress.DB"/>
<exclude name="WordPress.PHP.DevelopmentFunctions.error_log_var_export"/>
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.system_calls_popen"/>
<exclude name="WordPress.Security"/>
<exclude name="WordPress.WP"/>
<exclude name="Yoast.Yoast.JsonEncodeAlternative"/>
<exclude name="Yoast.NamingConventions.ObjectNameDepth.MaxExceeded"/>
<exclude name="WordPressVIPMinimum"/>
<!-- Exclude select "modern PHP" sniffs, which conflict with the minimum supported PHP version of this package. -->
<exclude name="PSR12.Properties.ConstantVisibility"/><!-- PHP 7.1+. -->
<exclude name="SlevomatCodingStandard.TypeHints.NullableTypeForNullDefaultValue"/><!-- PHP 7.1+. -->
<!-- As this repo is about providing assertions, "mixed" is a perfectly valid type. -->
<exclude name="SlevomatCodingStandard.TypeHints.DisallowMixedTypeHint"/>
</rule>
<!-- While PHPCompatibility is already included in the Yoast ruleset, it uses
the PHPCompatibilityWP ruleset, which excludes rules polyfilled by WP.
Setting the severity for all PHPCompatibility rules to 5 prevents WP
polyfilled functionality from not being flagged in this repo. -->
<rule ref="PHPCompatibility">
<severity>5</severity>
</rule>
<!-- Enforce PSR1 compatible namespaces. -->
<rule ref="PSR1.Classes.ClassDeclaration">
<!-- YoastCS only applies this rule to test files. Overrule it to apply to all files. -->
<include-pattern>*\.php</include-pattern>
</rule>
<!--
#############################################################################
SNIFF SPECIFIC CONFIGURATION
#############################################################################
-->
<rule ref="Yoast.NamingConventions.NamespaceName">
<properties>
<property name="psr4_paths" type="array">
<element key="Yoast\PHPUnitPolyfills\\" value="src/"/>
<element key="Yoast\PHPUnitPolyfills\Tests\\" value="tests/"/>
</property>
</properties>
</rule>
<!--
#############################################################################
SELECTIVE EXCLUSIONS
Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
#############################################################################
-->
<!-- The polyfills for the PHP native exceptions can not have a namespace
and making those the only files with a file comment would create more,
not less inconsistency. -->
<rule ref="Yoast.Commenting.FileComment">
<exclude-pattern>/src/Exceptions/*Error\.php$</exclude-pattern>
</rule>
<!-- For named parameter support, the parameters in the polyfilled assertions *must*
mirror the parameter name as used in PHPUnit itself.
These cannot be changed until PHPUnit itself changes the names. -->
<rule ref="Universal.NamingConventions.NoReservedKeywordParameterNames.arrayFound">
<exclude-pattern>/src/Polyfills/AssertIsList\.php$</exclude-pattern>
</rule>
<rule ref="Universal.NamingConventions.NoReservedKeywordParameterNames.objectFound">
<exclude-pattern>/src/Polyfills/AssertObjectProperty\.php$</exclude-pattern>
</rule>
<rule ref="Universal.NamingConventions.NoReservedKeywordParameterNames.stringFound">
<exclude-pattern>/src/Polyfills/AssertionRenames\.php$</exclude-pattern>
</rule>
<!-- Deliberately empty Catch statements. -->
<rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedCatch">
<exclude-pattern>/src/Helpers/ResourceHelper\.php$</exclude-pattern>
</rule>
<!-- Targetted error silencing. This is okay. -->
<rule ref="WordPress.PHP.NoSilencedErrors">
<exclude-pattern>/src/Helpers/ResourceHelper\.php$</exclude-pattern>
</rule>
<!-- The TestCase for PHPUnit 8+ will only ever be loaded on PHP 7.2+. -->
<!-- The TestListenerDefaultImplementation for PHPUnit 7+ will only ever be loaded on PHP 7.1+. -->
<rule ref="PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.voidFound">
<exclude-pattern>/src/TestCases/TestCasePHPUnitGte8\.php$</exclude-pattern>
<exclude-pattern>/src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7\.php$</exclude-pattern>
</rule>
<!-- The TestListenerDefaultImplementation for PHPUnit 7+ will only ever be loaded on PHP 7.1+. -->
<rule ref="PHPCompatibility.Interfaces.NewInterfaces.throwableFound">
<exclude-pattern>/src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7\.php$</exclude-pattern>
</rule>
<!-- The TestListenerDefaultImplementation for PHPUnit 7+ will only ever be loaded on PHP 7.1+. -->
<rule ref="PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations.floatFound">
<exclude-pattern>/src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7\.php$</exclude-pattern>
</rule>
<!-- TEST CODE -->
<!-- Final classes is irrelevant for test fixtures. -->
<rule ref="Universal.Classes.RequireFinalClass">
<exclude-pattern>/tests/*/Fixtures/*\.php$</exclude-pattern>
</rule>
<!-- The use of `array` annotations/types is intentional and part of the actual test case. -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObject*\.php$</exclude-pattern>
</rule>
<!-- Make some allowances for test files. -->
<rule ref="WordPress.PHP.DevelopmentFunctions">
<exclude-pattern>/tests/*\.php$</exclude-pattern>
</rule>
<!-- The use of `static` in the test cases is on purpose to test support. -->
<rule ref="Universal.CodeAnalysis.StaticInFinalClass">
<exclude-pattern>/tests/*</exclude-pattern>
</rule>
<!-- Covers annotations are in the test classes, not the trait. -->
<rule ref="Yoast.Commenting.TestsHaveCoversTag.Missing">
<exclude-pattern>/tests/TestCases/TestCaseTestTrait\.php$</exclude-pattern>
<exclude-pattern>/tests/Polyfills/Fixtures/*\.php$</exclude-pattern>
</rule>
<!-- These fixtures for the assertEqualObject() tests will only be loaded on PHP 7.1+/8+ respectively. -->
<rule ref="PHPCompatibility.FunctionDeclarations.NewNullableTypes.typeDeclarationFound">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObjectParamNotRequired\.php$</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionDeclarations.NewNullableTypes.returnTypeFound">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObjectNullableReturnType\.php$</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations.UnionTypeFound">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObjectUnion\.php$</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations.UnionTypeFound">
<exclude-pattern>/tests/Polyfills/Fixtures/ValueObjectUnionReturnType\.php$</exclude-pattern>
</rule>
</ruleset>