-
Notifications
You must be signed in to change notification settings - Fork 0
/
.phpcs.xml
258 lines (253 loc) · 13.3 KB
/
.phpcs.xml
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
<?xml version="1.0"?>
<ruleset name="MediaWiki">
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="Generic.ControlStructures.InlineControlStructure" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingVar" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.SpacingAfter" />
<exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
<exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
<exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
<exclude name="MediaWiki.PHPUnit.AssertCount.NotUsed" />
<exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgUser" />
<exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgVersion" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
<exclude name="MediaWiki.Usage.ForbiddenFunctions.is_resource" />
<exclude name="MediaWiki.Usage.ForbiddenFunctions.passthru" />
<exclude name="MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals" />
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
<exclude name="PSR2.Classes.PropertyDeclaration.Multiple" />
</rule>
<rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
<properties>
<!--
includes/GlobalFunctions.php
* mimeTypeMatch
maintenance/language/transstat.php
* showUsage
maintenance/mcc.php
* mccGetHelp
* mccShowUsage
maintenance/storage/moveToExternal.php
* moveToExternal
maintenance/storage/resolveStubs.php
* resolveStub
* resolveStubs
tests/phpunit/includes/HooksTest.php
* NothingFunction
* NothingFunctionData
tests/qunit/data/styleTest.css.php
* cssfilter
-->
<property name="ignoreList" type="array" value="cssfilter,mccGetHelp,mccShowUsage,mimeTypeMatch,moveToExternal,NothingFunction,NothingFunctionData,resolveStub,resolveStubs,showUsage" />
</properties>
</rule>
<rule ref="MediaWiki.NamingConventions.ValidGlobalName">
<properties>
<property name="ignoreList" type="array" value="$IP" />
</properties>
</rule>
<rule ref="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix">
<exclude-pattern>maintenance/doMaintenance\.php</exclude-pattern>
<exclude-pattern>maintenance/mergeMessageFileList\.php</exclude-pattern>
<exclude-pattern>maintenance/CommandLineInc\.php</exclude-pattern>
<exclude-pattern>tests/phpunit/MediaWikiIntegrationTestCase\.php</exclude-pattern>
</rule>
<rule ref="Generic.Classes.DuplicateClassName.Found">
<exclude-pattern>*/includes/libs/rdbms/database/MWPostgreSqlPlatformCompat\.php</exclude-pattern>
</rule>
<rule ref="Generic.Files.LineLength">
<exclude-pattern>*/languages/messages/Messages*\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Files.ClassMatchesFilename.NotMatch">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/includes/specials/SpecialMostimages\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialMovepage\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialRandompage\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialUserrights\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialWantedfiles\.php</exclude-pattern>
<exclude-pattern>*/includes/specials/SpecialWantedpages\.php</exclude-pattern>
<exclude-pattern>*/maintenance/archives/upgradeLogging\.php</exclude-pattern>
<exclude-pattern>*/maintenance/benchmarks/bench_HTTP_HTTPS\.php</exclude-pattern>
<exclude-pattern>*/maintenance/benchmarks/bench_Wikimedia_base_convert\.php</exclude-pattern>
<exclude-pattern>*/maintenance/benchmarks/bench_delete_truncate\.php</exclude-pattern>
<exclude-pattern>*/maintenance/benchmarks/bench_if_switch\.php</exclude-pattern>
<exclude-pattern>*/maintenance/benchmarks/bench_utf8_title_check\.php</exclude-pattern>
<exclude-pattern>*/maintenance/benchmarks/bench_wfIsWindows\.php</exclude-pattern>
<exclude-pattern>*/maintenance/cleanupTitles\.php</exclude-pattern>
<exclude-pattern>*/maintenance/edit\.php</exclude-pattern>
<exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
<exclude-pattern>*/maintenance/getText\.php</exclude-pattern>
<exclude-pattern>*/maintenance/importDump\.php</exclude-pattern>
<exclude-pattern>*/maintenance/install\.php</exclude-pattern>
<exclude-pattern>*/maintenance/invalidateUserSessions\.php</exclude-pattern>
<exclude-pattern>*/maintenance/jsparse\.php</exclude-pattern>
<exclude-pattern>*/maintenance/lag\.php</exclude-pattern>
<exclude-pattern>*/maintenance/language/StatOutputs\.php</exclude-pattern>
<exclude-pattern>*/maintenance/language/date-formats\.php</exclude-pattern>
<exclude-pattern>*/maintenance/minify\.php</exclude-pattern>
<exclude-pattern>*/maintenance/mysql\.php</exclude-pattern>
<exclude-pattern>*/maintenance/parse\.php</exclude-pattern>
<exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
<exclude-pattern>*/maintenance/rebuildImages\.php</exclude-pattern>
<exclude-pattern>*/maintenance/renderDump\.php</exclude-pattern>
<exclude-pattern>*/maintenance/shell\.php</exclude-pattern>
<exclude-pattern>*/maintenance/sql\.php</exclude-pattern>
<exclude-pattern>*/maintenance/term/MWTerm\.php</exclude-pattern>
<exclude-pattern>*/maintenance/update\.php</exclude-pattern>
<exclude-pattern>*/maintenance/userOptions\.php</exclude-pattern>
<exclude-pattern>*/maintenance/view\.php</exclude-pattern>
<!-- Language converters use the pattern of 2 classes in one file -->
<exclude-pattern>*/languages/*\.php</exclude-pattern>
<!-- Skip violations in some tests for now -->
<exclude-pattern>*/tests/parser/*\.php</exclude-pattern>
<exclude-pattern>*/tests/phpunit/maintenance/*\.php</exclude-pattern>
<exclude-pattern>*/tests/phpunit/bootstrap\.php</exclude-pattern>
<exclude-pattern>*/tests/phpunit/phpunit\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Files.ClassMatchesFilename.WrongCase">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/maintenance/language/alltrans\.php</exclude-pattern>
<exclude-pattern>*/maintenance/language/digit2html\.php</exclude-pattern>
<exclude-pattern>*/maintenance/language/langmemusage\.php</exclude-pattern>
<exclude-pattern>*/maintenance/mctest\.php</exclude-pattern>
<exclude-pattern>*/maintenance/mergeMessageFileList\.php</exclude-pattern>
<exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
<exclude-pattern>*/maintenance/rebuildall\.php</exclude-pattern>
<exclude-pattern>*/maintenance/rebuildmessages\.php</exclude-pattern>
<exclude-pattern>*/maintenance/rebuildrecentchanges\.php</exclude-pattern>
<exclude-pattern>*/maintenance/rebuildtextindex\.php</exclude-pattern>
<exclude-pattern>*/maintenance/storage/checkStorage\.php</exclude-pattern>
<exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
<exclude-pattern>*/maintenance/storage/trackBlobs\.php</exclude-pattern>
<!-- Skip violations in some tests for now -->
<exclude-pattern>*/tests/phpunit/unit/includes/GlobalFunctions/*\.php</exclude-pattern>
<exclude-pattern>*/tests/phpunit/includes/GlobalFunctions/*\.php</exclude-pattern>
<exclude-pattern>*/tests/phpunit/maintenance/*\.php</exclude-pattern>
<exclude-pattern>*/tests/phpunit/integration/includes/GlobalFunctions/*\.php</exclude-pattern>
</rule>
<rule ref="Generic.PHP.NoSilencedErrors.Discouraged">
<!--
Our normal policy of using Wikimedia\AtEase does not always make sense tests.
AtEase cannot be cleanly used in tests that also use expectException() as
the restoreWarnings() call would never be reached:
$this->expectException( PasswordError::class );
AtEase::suppressWarnings();
$password->crypt( 'whatever' );
AtEase::restoreWarnings();
The above will stop at crypt(), as expected, and leave AtEase in a dirty
state for unrelated tests.
TODO: Stop using PHPUnit TestCase directly. Require with a structure test
or with a high-level check in our run() hook, that all test cases use either
MediaWikiUnitTestCase or MediaWikiIntegrationTestCase. Otherwise the check
in MediaWikiTestCaseTrait can still be bypassed and cause a random failures.
-->
<exclude-pattern>*/tests/*\.php</exclude-pattern>
</rule>
<rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/includes/libs/rdbms/database/MWPostgreSqlPlatformCompat\.php</exclude-pattern>
<exclude-pattern>*/maintenance/dumpIterator\.php</exclude-pattern>
<exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
<exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
<exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
<exclude-pattern>*/maintenance/language/StatOutputs\.php</exclude-pattern>
<exclude-pattern>*/maintenance/language/generateCollationData\.php</exclude-pattern>
<exclude-pattern>*/maintenance/term/MWTerm\.php</exclude-pattern>
<!-- Language converters use the pattern of 2 classes in one file -->
<exclude-pattern>*/languages/*\.php</exclude-pattern>
<!-- We don't care that much about violations in tests -->
<exclude-pattern>*/tests/*\.php</exclude-pattern>
</rule>
<rule ref="PSR2.Methods.MethodDeclaration.Underscore">
<exclude-pattern>*/includes/StubObject\.php</exclude-pattern>
<exclude-pattern>*/includes/StubUserLang\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.AssignmentInReturn.AssignmentInReturn">
<exclude-pattern>*/tests/phpunit/*\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.ForbiddenFunctions.escapeshellarg">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/includes/libs/filebackend/FSFileBackend\.php</exclude-pattern>
<exclude-pattern>*/includes/shell/Command\.php</exclude-pattern>
<exclude-pattern>*/includes/shell/Shell\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.ForbiddenFunctions.popen">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/includes/GlobalFunctions\.php</exclude-pattern>
<exclude-pattern>*/includes/libs/filebackend/FSFileBackend\.php</exclude-pattern>
<exclude-pattern>*/maintenance/includes/SevenZipStream\.php</exclude-pattern>
<exclude-pattern>*/maintenance/populateImageSha1\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.ForbiddenFunctions.proc_open">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>includes/export/DumpPipeOutput\.php</exclude-pattern>
<exclude-pattern>includes/resourceloader/ResourceLoaderImage\.php</exclude-pattern>
<exclude-pattern>includes/shell/Command\.php</exclude-pattern>
<exclude-pattern>maintenance/includes/TextPassDumper\.php</exclude-pattern>
<exclude-pattern>maintenance/mysql\.php</exclude-pattern>
<exclude-pattern>maintenance/storage/recompressTracked\.php</exclude-pattern>
<exclude-pattern>tests/parser/editTests\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.ForbiddenFunctions.shell_exec">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
<exclude-pattern>*/maintenance/updateCredits\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Usage.ForbiddenFunctions.system">
<!--
Whitelist existing violations, but enable the sniff to prevent
any new occurrences.
-->
<exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
</rule>
<rule ref="MediaWiki.Commenting.MissingCovers.MissingCovers">
<exclude-pattern>tests/phpunit/structure/*</exclude-pattern>
</rule>
<rule ref="Generic.Arrays.DisallowShortArraySyntax">
<!--
T273340: Rule not to be enabled on any other file.
PHPVersionCheck.php requires syntax to be old PHP compatible.
The rest should therefore use [] rather than array() as per the
MediaWiki style guide.
-->
<include-pattern>includes/PHPVersionCheck\.php</include-pattern>
</rule>
<file>.</file>
<arg name="encoding" value="UTF-8"/>
<arg name="extensions" value="php,sample"/>
<exclude-pattern type="relative">^extensions/</exclude-pattern>
<exclude-pattern type="relative">^skins/</exclude-pattern>
<exclude-pattern>LocalSettings\.php</exclude-pattern>
<exclude-pattern>LocalSettings-installer\.php</exclude-pattern>
</ruleset>