Sync up with Parsoid parserTests.txt
[mediawiki.git] / .phpcs.xml
blob5ccd941502d73bda5af1f531687b84bb97a2fe69
1 <?xml version="1.0"?>
2 <ruleset name="MediaWiki">
3         <rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
4                 <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPrivate" />
5                 <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
6                 <exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
7                 <exclude name="MediaWiki.Commenting.FunctionComment.WrongStyle" />
8                 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPrivate" />
9                 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationProtected" />
10                 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingDocumentationPublic" />
11                 <exclude name="MediaWiki.Commenting.PropertyDocumentation.MissingVar" />
12                 <exclude name="MediaWiki.Commenting.PropertyDocumentation.SpacingAfter" />
13                 <exclude name="MediaWiki.Commenting.PropertyDocumentation.WrongStyle" />
14                 <exclude name="MediaWiki.ControlStructures.AssignmentInControlStructures.AssignmentInControlStructures" />
15                 <exclude name="MediaWiki.NamingConventions.LowerCamelFunctionsName.FunctionName" />
16                 <exclude name="MediaWiki.Usage.DbrQueryUsage.DbrQueryFound" />
17                 <exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgTitle" />
18                 <exclude name="MediaWiki.Usage.DeprecatedGlobalVariables.Deprecated$wgVersion" />
19                 <exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionVarUsage" />
20                 <exclude name="MediaWiki.Usage.ForbiddenFunctions.passthru" />
21                 <exclude name="MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals" />
22                 <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
23                 <exclude name="PSR2.Classes.PropertyDeclaration.Multiple" />
24         </rule>
25         <rule ref="MediaWiki.NamingConventions.PrefixedGlobalFunctions">
26                 <properties>
27                         <!--
28                         maintenance/language/transstat.php
29                         * showUsage
30                         maintenance/mcc.php
31                         * mccGetHelp
32                         * mccShowUsage
33                         maintenance/storage/moveToExternal.php
34                         * moveToExternal
35                         maintenance/storage/resolveStubs.php
36                         * resolveStub
37                         * resolveStubs
38                         tests/phpunit/includes/HooksTest.php
39                         * NothingFunction
40                         * NothingFunctionData
41                         tests/qunit/data/styleTest.css.php
42                         * cssfilter
43                         -->
44                         <property name="ignoreList" type="array" value="cssfilter,mccGetHelp,mccShowUsage,moveToExternal,NothingFunction,NothingFunctionData,resolveStub,resolveStubs,showUsage" />
45                 </properties>
46         </rule>
47         <rule ref="MediaWiki.NamingConventions.ValidGlobalName">
48                 <properties>
49                         <property name="ignoreList" type="array" value="$IP" />
50                 </properties>
51         </rule>
52         <rule ref="MediaWiki.NamingConventions.ValidGlobalName.allowedPrefix">
53                 <exclude-pattern>*/maintenance/doMaintenance\.php</exclude-pattern>
54                 <exclude-pattern>*/maintenance/mergeMessageFileList\.php</exclude-pattern>
55                 <exclude-pattern>*/maintenance/CommandLineInc\.php</exclude-pattern>
56                 <exclude-pattern>*/tests/phpunit/MediaWikiIntegrationTestCase\.php</exclude-pattern>
57         </rule>
58         <rule ref="Generic.Classes.DuplicateClassName.Found">
59                 <exclude-pattern>*/includes/libs/rdbms/dbal/MWPostgreSqlPlatformCompat\.php</exclude-pattern>
60         </rule>
61         <rule ref="Generic.Files.LineLength">
62                 <exclude-pattern>*/languages/messages/*</exclude-pattern>
63                 <exclude-pattern>*/tests/*</exclude-pattern>
64         </rule>
65         <rule ref="MediaWiki.Files.ClassMatchesFilename.NotMatch">
66                 <!--
67                         Continue to allow existing violations, but enable the sniff to prevent
68                         any new occurrences.
69                 -->
70                 <exclude-pattern>*/includes/specials/SpecialMostimages\.php</exclude-pattern>
71                 <exclude-pattern>*/includes/specials/SpecialMovepage\.php</exclude-pattern>
72                 <exclude-pattern>*/includes/specials/SpecialUserrights\.php</exclude-pattern>
73                 <exclude-pattern>*/includes/specials/SpecialWantedfiles\.php</exclude-pattern>
74                 <exclude-pattern>*/includes/specials/SpecialWantedpages\.php</exclude-pattern>
75                 <exclude-pattern>*/maintenance/benchmarks/bench_HTTP_HTTPS\.php</exclude-pattern>
76                 <exclude-pattern>*/maintenance/benchmarks/bench_Wikimedia_base_convert\.php</exclude-pattern>
77                 <exclude-pattern>*/maintenance/benchmarks/bench_delete_truncate\.php</exclude-pattern>
78                 <exclude-pattern>*/maintenance/benchmarks/bench_if_switch\.php</exclude-pattern>
79                 <exclude-pattern>*/maintenance/benchmarks/bench_utf8_title_check\.php</exclude-pattern>
80                 <exclude-pattern>*/maintenance/cleanupTitles\.php</exclude-pattern>
81                 <exclude-pattern>*/maintenance/edit\.php</exclude-pattern>
82                 <exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
83                 <exclude-pattern>*/maintenance/getText\.php</exclude-pattern>
84                 <exclude-pattern>*/maintenance/importDump\.php</exclude-pattern>
85                 <exclude-pattern>*/maintenance/install\.php</exclude-pattern>
86                 <exclude-pattern>*/maintenance/jsparse\.php</exclude-pattern>
87                 <exclude-pattern>*/maintenance/lag\.php</exclude-pattern>
88                 <exclude-pattern>*/maintenance/language/StatOutputs\.php</exclude-pattern>
89                 <exclude-pattern>*/maintenance/language/date-formats\.php</exclude-pattern>
90                 <exclude-pattern>*/maintenance/mysql\.php</exclude-pattern>
91                 <exclude-pattern>*/maintenance/parse\.php</exclude-pattern>
92                 <exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
93                 <exclude-pattern>*/maintenance/rebuildImages\.php</exclude-pattern>
94                 <exclude-pattern>*/maintenance/renderDump\.php</exclude-pattern>
95                 <exclude-pattern>*/maintenance/shell\.php</exclude-pattern>
96                 <exclude-pattern>*/maintenance/sql\.php</exclude-pattern>
97                 <exclude-pattern>*/maintenance/term/MWTerm\.php</exclude-pattern>
98                 <exclude-pattern>*/maintenance/update\.php</exclude-pattern>
99                 <exclude-pattern>*/maintenance/userOptions\.php</exclude-pattern>
100                 <exclude-pattern>*/maintenance/view\.php</exclude-pattern>
101                 <!-- Language converters use the pattern of 2 classes in one file -->
102                 <exclude-pattern>*/languages/*</exclude-pattern>
103                 <!-- Skip violations in some tests for now -->
104                 <exclude-pattern>*/tests/parser/*</exclude-pattern>
105                 <exclude-pattern>*/tests/phpunit/maintenance/*</exclude-pattern>
106                 <exclude-pattern>*/tests/phpunit/bootstrap\.php</exclude-pattern>
107                 <exclude-pattern>*/tests/phpunit/phpunit\.php</exclude-pattern>
108         </rule>
109         <rule ref="MediaWiki.Files.ClassMatchesFilename.WrongCase">
110                 <!--
111                         Continue to allow existing violations, but enable the sniff to prevent
112                         any new occurrences.
113                 -->
114                 <exclude-pattern>*/maintenance/language/alltrans\.php</exclude-pattern>
115                 <exclude-pattern>*/maintenance/language/digit2html\.php</exclude-pattern>
116                 <exclude-pattern>*/maintenance/language/langmemusage\.php</exclude-pattern>
117                 <exclude-pattern>*/maintenance/mctest\.php</exclude-pattern>
118                 <exclude-pattern>*/maintenance/mergeMessageFileList\.php</exclude-pattern>
119                 <exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
120                 <exclude-pattern>*/maintenance/rebuildall\.php</exclude-pattern>
121                 <exclude-pattern>*/maintenance/rebuildmessages\.php</exclude-pattern>
122                 <exclude-pattern>*/maintenance/rebuildrecentchanges\.php</exclude-pattern>
123                 <exclude-pattern>*/maintenance/rebuildtextindex\.php</exclude-pattern>
124                 <exclude-pattern>*/maintenance/storage/checkStorage\.php</exclude-pattern>
125                 <exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
126                 <exclude-pattern>*/maintenance/storage/trackBlobs\.php</exclude-pattern>
127                 <!-- Skip violations in some tests for now -->
128                 <exclude-pattern>*/tests/phpunit/unit/includes/GlobalFunctions/*</exclude-pattern>
129                 <exclude-pattern>*/tests/phpunit/includes/GlobalFunctions/*</exclude-pattern>
130                 <exclude-pattern>*/tests/phpunit/maintenance/*</exclude-pattern>
131                 <exclude-pattern>*/tests/phpunit/integration/includes/GlobalFunctions/*</exclude-pattern>
132         </rule>
133         <rule ref="Generic.PHP.NoSilencedErrors.Discouraged">
134                 <!--
135                 Our normal policy of using Wikimedia\AtEase does not always make sense tests.
137                 AtEase cannot be cleanly used in tests that also use expectException() as
138                 the restoreWarnings() call would never be reached:
140                         $this->expectException( PasswordError::class );
141                         AtEase::suppressWarnings();
142                         $password->crypt( 'whatever' );
143                         AtEase::restoreWarnings();
145                 The above will stop at crypt(), as expected, and leave AtEase in a dirty
146                 state for unrelated tests.
148                 TODO: Stop using PHPUnit TestCase directly. Require with a structure test
149                 or with a high-level check in our run() hook, that all test cases use either
150                 MediaWikiUnitTestCase or MediaWikiIntegrationTestCase. Otherwise the check
151                 in MediaWikiTestCaseTrait can still be bypassed and cause a random failures.
153                 -->
154                 <exclude-pattern>*/tests/*</exclude-pattern>
155         </rule>
156         <rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
157                 <!--
158                         Continue to allow existing violations, but enable the sniff to prevent
159                         any new occurrences.
160                 -->
161                 <exclude-pattern>*/includes/libs/rdbms/dbal/MWPostgreSqlPlatformCompat\.php</exclude-pattern>
162                 <exclude-pattern>*/maintenance/dumpIterator\.php</exclude-pattern>
163                 <exclude-pattern>*/maintenance/findDeprecated\.php</exclude-pattern>
164                 <exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
165                 <exclude-pattern>*/maintenance/preprocessorFuzzTest\.php</exclude-pattern>
166                 <exclude-pattern>*/maintenance/language/StatOutputs\.php</exclude-pattern>
167                 <exclude-pattern>*/maintenance/language/generateCollationData\.php</exclude-pattern>
168                 <exclude-pattern>*/maintenance/term/MWTerm\.php</exclude-pattern>
169                 <!-- Language converters use the pattern of 2 classes in one file -->
170                 <exclude-pattern>*/languages/*</exclude-pattern>
171                 <!-- We don't care that much about violations in tests -->
172                 <exclude-pattern>*/tests/*</exclude-pattern>
173         </rule>
174         <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
175                 <exclude-pattern>*/includes/StubObject\.php</exclude-pattern>
176                 <exclude-pattern>*/includes/StubGlobalUser\.php</exclude-pattern>
177                 <exclude-pattern>*/includes/StubUserLang\.php</exclude-pattern>
178         </rule>
179         <rule ref="MediaWiki.Usage.AssignmentInReturn.AssignmentInReturn">
180                 <exclude-pattern>*/tests/phpunit/*</exclude-pattern>
181         </rule>
182         <rule ref="MediaWiki.Usage.ForbiddenFunctions.popen">
183                 <!--
184                         Continue to allow existing violations, but enable the sniff to prevent
185                         any new occurrences.
186                 -->
187                 <exclude-pattern>*/includes/GlobalFunctions\.php</exclude-pattern>
188                 <exclude-pattern>*/includes/libs/filebackend/FSFileBackend\.php</exclude-pattern>
189                 <exclude-pattern>*/maintenance/includes/SevenZipStream\.php</exclude-pattern>
190                 <exclude-pattern>*/maintenance/populateImageSha1\.php</exclude-pattern>
191         </rule>
192         <rule ref="MediaWiki.Usage.ForbiddenFunctions.proc_open">
193                 <!--
194                         Continue to allow existing violations, but enable the sniff to prevent
195                         any new occurrences.
196                 -->
197                 <exclude-pattern>*/includes/export/DumpPipeOutput\.php</exclude-pattern>
198                 <exclude-pattern>*/includes/resourceloader/ResourceLoaderImage\.php</exclude-pattern>
199                 <exclude-pattern>*/includes/shell/Command\.php</exclude-pattern>
200                 <exclude-pattern>*/maintenance/includes/TextPassDumper\.php</exclude-pattern>
201                 <exclude-pattern>*/maintenance/mysql\.php</exclude-pattern>
202                 <exclude-pattern>*/maintenance/storage/recompressTracked\.php</exclude-pattern>
203                 <exclude-pattern>*/tests/parser/editTests\.php</exclude-pattern>
204         </rule>
205         <rule ref="MediaWiki.Usage.ForbiddenFunctions.shell_exec">
206                 <!--
207                         Continue to allow existing violations, but enable the sniff to prevent
208                         any new occurrences.
209                 -->
210                 <exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
211                 <exclude-pattern>*/maintenance/updateCredits\.php</exclude-pattern>
212         </rule>
213         <rule ref="MediaWiki.Usage.ForbiddenFunctions.system">
214                 <!--
215                         Continue to allow existing violations, but enable the sniff to prevent
216                         any new occurrences.
217                 -->
218                 <exclude-pattern>*/maintenance/mwdocgen\.php</exclude-pattern>
219         </rule>
220         <rule ref="MediaWiki.Commenting.MissingCovers.MissingCovers">
221                 <exclude-pattern>*/tests/phpunit/structure/*</exclude-pattern>
222         </rule>
223         <rule ref="Generic.Arrays.DisallowShortArraySyntax">
224                 <!--
225                         T273340: Rule not to be enabled on any other file.
226                         PHPVersionCheck.php requires syntax to be old PHP compatible.
227                         The rest should therefore use [] rather than array() as per the
228                         MediaWiki style guide.
229                 -->
230                 <include-pattern>includes/PHPVersionCheck\.php</include-pattern>
231         </rule>
232         <file>.</file>
233         <arg name="encoding" value="UTF-8"/>
234         <arg name="extensions" value="php"/>
235         <exclude-pattern type="relative">^(extensions|skins)/*</exclude-pattern>
236         <exclude-pattern>LocalSettings(-installer)?\.php</exclude-pattern>
237 </ruleset>