Make WordPress Core

source: trunk/phpcs.xml.dist

Last change on this file was 62144, checked in by desrosj, 45 hours ago

Build/Test Tools: Commiting changes to built files after [62143].

This commits changes to built files that were not included in the previous commit that restored version history for files that were previously subject to version control.

This also reverts [62069], which was a temporary fix to ensure deleted files that are no longer desired were cleaned up on the build server prior to committing the changes.

Finally, the src/wp-includes/build and all its contents to the exclusion list for PHPCS scans. There are small coding standards failures in these files that need to be resolved upstream before the scan will pass on this directory.

Props dmsnell, ellatrix, desrosj.
See #64393.

  • Property svn:eol-style set to native
File size: 15.9 KB
Line 
1<?xml version="1.0"?>
2<ruleset name="WordPress Coding Standards">
3        <description>Apply WordPress Coding Standards to all Core files</description>
4
5        <!--
6        #############################################################################
7        COMMAND LINE ARGUMENTS
8        https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-Ruleset
9        #############################################################################
10        -->
11
12        <!-- Only scan PHP files. -->
13        <arg name="extensions" value="php"/>
14
15        <!-- Whenever possible, cache the scan results and re-use those for unchanged files on the next scan. -->
16        <arg name="cache" value=".cache/phpcs.json"/>
17
18        <!-- Set the memory limit to 512M.
19                 For most standard PHP configurations, this means the memory limit will temporarily be raised.
20                 Ref: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#specifying-phpini-settings
21        -->
22        <ini name="memory_limit" value="512M"/>
23
24        <!-- Strip the filepaths down to the relevant bit. -->
25        <arg name="basepath" value="./"/>
26
27        <!-- Check up to 20 files simultaneously. -->
28        <arg name="parallel" value="20"/>
29
30        <!-- Show sniff codes in all reports. -->
31        <arg value="ps"/>
32
33        <!--
34        #############################################################################
35        FILE SELECTION
36        Set which files will be subject to the scans executed using this ruleset.
37        #############################################################################
38        -->
39
40        <file>.</file>
41
42        <!-- Exclude the build folder in the current directory. -->
43        <exclude-pattern type="relative">^build/*</exclude-pattern>
44
45        <!-- Exclude the local copy of the Gutenberg repository. -->
46        <exclude-pattern>/gutenberg/*</exclude-pattern>
47
48        <!-- Directories and third party library exclusions. -->
49        <exclude-pattern>/node_modules/*</exclude-pattern>
50        <exclude-pattern>/vendor/*</exclude-pattern>
51
52        <exclude-pattern>/src/wp-admin/includes/class-ftp*</exclude-pattern>
53        <exclude-pattern>/src/wp-admin/includes/class-pclzip\.php</exclude-pattern>
54        <exclude-pattern>/src/wp-admin/includes/deprecated\.php</exclude-pattern>
55        <exclude-pattern>/src/wp-admin/includes/ms-deprecated\.php</exclude-pattern>
56
57        <exclude-pattern>/src/wp-includes/atomlib\.php</exclude-pattern>
58        <exclude-pattern>/src/wp-includes/class-avif-info\.php</exclude-pattern>
59        <exclude-pattern>/src/wp-includes/class-IXR\.php</exclude-pattern>
60        <exclude-pattern>/src/wp-includes/class-json\.php</exclude-pattern>
61        <exclude-pattern>/src/wp-includes/class-phpass\.php</exclude-pattern>
62        <exclude-pattern>/src/wp-includes/class-pop3\.php</exclude-pattern>
63        <exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
64        <exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
65        <exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
66        <exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
67        <exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
68        <exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
69        <exclude-pattern>/src/wp-includes/rss\.php</exclude-pattern>
70
71        <exclude-pattern>/src/wp-includes/assets/*</exclude-pattern>
72        <exclude-pattern>/src/wp-includes/blocks/*/*.asset.php</exclude-pattern>
73        <exclude-pattern>/src/wp-includes/blocks/blocks-json.php</exclude-pattern>
74        <exclude-pattern>/src/wp-includes/build/*</exclude-pattern>
75        <exclude-pattern>/src/wp-includes/ID3/*</exclude-pattern>
76        <exclude-pattern>/src/wp-includes/IXR/*</exclude-pattern>
77        <exclude-pattern>/src/wp-includes/js/*</exclude-pattern>
78        <exclude-pattern>/src/wp-includes/PHPMailer/*</exclude-pattern>
79        <exclude-pattern>/src/wp-includes/Requests/*</exclude-pattern>
80        <exclude-pattern>/src/wp-includes/php-ai-client/*</exclude-pattern>
81        <exclude-pattern>/src/wp-includes/SimplePie/*</exclude-pattern>
82        <exclude-pattern>/src/wp-includes/sodium_compat/*</exclude-pattern>
83        <exclude-pattern>/src/wp-includes/Text/*</exclude-pattern>
84
85        <!-- Test data and fixtures. -->
86        <exclude-pattern>/tests/phpunit/build*</exclude-pattern>
87        <exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
88
89        <!-- PHPStan bootstrap, stubs, and baseline. -->
90        <exclude-pattern>/tests/phpstan/*</exclude-pattern>
91
92        <exclude-pattern>/tools/*</exclude-pattern>
93
94        <!-- Drop-in plugins. -->
95        <exclude-pattern>/src/wp-content/advanced-cache\.php</exclude-pattern>
96        <exclude-pattern>/src/wp-content/blog-deleted\.php</exclude-pattern>
97        <exclude-pattern>/src/wp-content/blog-inactive\.php</exclude-pattern>
98        <exclude-pattern>/src/wp-content/blog-suspended\.php</exclude-pattern>
99        <exclude-pattern>/src/wp-content/db-error\.php</exclude-pattern>
100        <exclude-pattern>/src/wp-content/db\.php</exclude-pattern>
101        <exclude-pattern>/src/wp-content/fatal-error-handler\.php</exclude-pattern>
102        <exclude-pattern>/src/wp-content/install\.php</exclude-pattern>
103        <exclude-pattern>/src/wp-content/maintenance\.php</exclude-pattern>
104        <exclude-pattern>/src/wp-content/object-cache\.php</exclude-pattern>
105        <exclude-pattern>/src/wp-content/php-error\.php</exclude-pattern>
106        <exclude-pattern>/src/wp-content/sunrise\.php</exclude-pattern>
107
108        <!-- Must-Use plugins. -->
109        <exclude-pattern>/src/wp-content/mu-plugins/*</exclude-pattern>
110
111        <!-- Plugins. -->
112        <exclude-pattern>/src/wp-content/plugins/*</exclude-pattern>
113
114        <!-- Themes except the twenty* themes. -->
115        <exclude-pattern>/src/wp-content/themes/(?!twenty)*</exclude-pattern>
116
117        <!-- Translation files. -->
118        <exclude-pattern>/src/wp-content/languages/*</exclude-pattern>
119
120
121        <!--
122        #############################################################################
123        SET UP THE RULESET
124        #############################################################################
125        -->
126
127        <rule ref="WordPress-Core"/>
128
129
130        <!--
131        #############################################################################
132        SNIFF-SPECIFIC CONFIGURATION
133        #############################################################################
134        -->
135
136        <!-- These rules are being set as warnings instead of errors, so we can error check the entire codebase. -->
137        <rule ref="Generic.Files.OneObjectStructurePerFile.MultipleFound">
138                <type>warning</type>
139                <!-- Exclude the unit tests as no warnings are allowed there. Note: these issues should be fixed and the exclude removed! -->
140                <exclude-pattern>/tests/phpunit/*</exclude-pattern>
141        </rule>
142        <rule ref="WordPress.DB.PreparedSQL.InterpolatedNotPrepared">
143                <type>warning</type>
144        </rule>
145        <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
146                <type>warning</type>
147        </rule>
148        <rule ref="WordPress.Files.FileName.InvalidClassFileName">
149                <type>warning</type>
150        </rule>
151        <rule ref="WordPress.NamingConventions.ValidVariableName.VariableNotSnakeCase">
152                <type>warning</type>
153        </rule>
154
155        <rule ref="WordPress.NamingConventions.ValidVariableName">
156                <properties>
157                        <property name="allowed_custom_properties" type="array">
158                                <!-- From database structure queries. -->
159                                <element value="Collation"/>
160                                <element value="Column_name"/>
161                                <element value="Default"/>
162                                <element value="Extra"/>
163                                <element value="Field"/>
164                                <element value="Index_type"/>
165                                <element value="Key"/>
166                                <element value="Key_name"/>
167                                <element value="Msg_text"/>
168                                <element value="Non_unique"/>
169                                <element value="Null"/>
170                                <element value="Sub_part"/>
171                                <element value="Type"/>
172                                <!-- From plugin/theme data. -->
173                                <element value="authorAndUri"/>
174                                <element value="Name"/>
175                                <element value="Version"/>
176                                <!-- From the result of wp_xmlrpc_server::wp_getPageList(). -->
177                                <element value="dateCreated"/>
178
179                                <!-- From DOMDocument. -->
180                                <element value="childNodes"/>
181                                <element value="firstChild"/>
182                                <element value="formatOutput"/>
183                                <element value="lastChild"/>
184                                <element value="nodeName"/>
185                                <element value="nodeType"/>
186                                <element value="nodeValue"/>
187                                <element value="parentNode"/>
188                                <element value="preserveWhiteSpace"/>
189                                <element value="textContent"/>
190                                <!-- From PHPMailer. -->
191                                <element value="AltBody"/>
192                                <element value="Body"/>
193                                <element value="CharSet"/>
194                                <element value="ContentType"/>
195                                <element value="Encoding"/>
196                                <element value="Hostname"/>
197                                <element value="mailHeader"/>
198                                <element value="MIMEBody"/>
199                                <element value="MIMEHeader"/>
200                                <element value="Sender"/>
201                                <element value="Subject"/>
202                                <!-- From PHPUnit_Util_Getopt. -->
203                                <element value="longOptions"/>
204                                <!-- From POP3. -->
205                                <element value="ERROR"/>
206                                <!-- From ZipArchive. -->
207                                <element value="numFiles"/>
208                        </property>
209                </properties>
210        </rule>
211
212        <rule ref="WordPress.PHP.NoSilencedErrors">
213                <properties>
214                        <property name="customAllowedFunctionsList" type="array">
215                                <element value="ssh2_connect"/>
216                                <element value="ssh2_auth_password"/>
217                                <element value="ssh2_auth_pubkey_file"/>
218                                <element value="ftp_ssl_connect"/>
219                                <element value="ftp_connect"/>
220                                <element value="ftp_get_option"/>
221                                <element value="ftp_set_option"/>
222                                <element value="disk_free_space"/>
223                                <element value="getimagesize"/>
224                                <element value="iptcparse"/>
225                                <element value="exif_read_data"/>
226                                <element value="gzinflate"/>
227                                <element value="gzuncompress"/>
228                                <element value="gzdecode"/>
229                                <element value="imagecreatefromwebp"/>
230                                <element value="imagecreatefromavif"/>
231                        </property>
232                </properties>
233        </rule>
234
235
236        <!--
237        #############################################################################
238        SELECTIVE EXCLUSIONS
239        Exclude specific files for specific sniffs and/or exclude sub-groups in sniffs.
240
241        These exclusions are listed ordered by alphabetic sniff name.
242        #############################################################################
243        -->
244
245        <!-- Assignments in while conditions are a valid method of looping over iterables. -->
246        <rule ref="Generic.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition">
247                <exclude-pattern>*</exclude-pattern>
248        </rule>
249
250        <!-- Exclude checking of line endings when reporting errors, but fix them when running phpcbf.
251                 Git and SVN manage these pretty well cross-platform as "native".
252                 Allow configuration files. -->
253        <rule ref="Generic.Files.LineEndings">
254                <exclude-pattern>/wp-config\.php</exclude-pattern>
255                <exclude-pattern>/wp-config-sample\.php</exclude-pattern>
256                <exclude phpcs-only="true" name="Generic.Files.LineEndings"/>
257        </rule>
258
259        <rule ref="Generic.Functions.FunctionCallArgumentSpacing">
260                <exclude-pattern>/wp-config\.php</exclude-pattern>
261                <exclude-pattern>/wp-config-sample\.php</exclude-pattern>
262                <exclude-pattern>/wp-tests-config\.php</exclude-pattern>
263                <exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
264        </rule>
265
266        <rule ref="Generic.PHP.DiscourageGoto.Found">
267                <!-- Exclude forbidding goto in the HTML Processor, which mimics algorithms that are written
268                         this way in the HTML specification, and these particular algorithms are complex and
269                         highly imperative. Avoiding the goto introduces a number of risks that could make it
270                         more difficult to maintain the relationship to the standard, lead to subtle differences
271                         in the parsing, and distance the code from its standard. -->
272                <exclude-pattern>/wp-includes/html-api/class-wp-html-processor\.php</exclude-pattern>
273                <exclude-pattern>/wp-includes/html-api/class-wp-html-doctype-info\.php</exclude-pattern>
274
275                <!-- Goto is an effective way to handle errors in decoders which expect valid bytes
276                     without impacting the fast path while avoiding bloating the code with redundant
277                     and risky handling code. Exclude forbidding goto in parser code. -->
278                <exclude-pattern>/wp-includes/compat-utf8\.php</exclude-pattern>
279                <exclude-pattern>/wp-includes/class-wp-block-processor\.php</exclude-pattern>
280        </rule>
281
282        <!-- Exclude sample config from modernization to prevent breaking CI workflows based on WP-CLI scaffold.
283                 See: https://core.trac.wordpress.org/ticket/48082#comment:16 -->
284        <rule ref="Modernize.FunctionCalls.Dirname.FileConstant">
285                <exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
286        </rule>
287
288        <rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
289                <exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
290                <!-- Exclude some old classes that cannot be renamed, as it would break back compat. -->
291                <exclude-pattern>/src/wp-admin/includes/class-wp-filesystem-ftpsockets\.php</exclude-pattern>
292                <exclude-pattern>/src/wp-includes/class-wp-oembed\.php</exclude-pattern>
293                <exclude-pattern>/src/wp-includes/class-wp-oembed-controller\.php</exclude-pattern>
294                <exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
295                <exclude-pattern>/src/wp-includes/class-wp-text-diff-renderer-inline\.php</exclude-pattern>
296        </rule>
297
298        <!-- Exclude some old classes that cannot be renamed, as it would break back compat. -->
299        <rule ref="PEAR.NamingConventions.ValidClassName.StartWithCapital">
300                <exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
301                <exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
302                <exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
303                <exclude-pattern>/src/wp-includes/class-wp-xmlrpc-server\.php</exclude-pattern>
304                <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
305        </rule>
306
307        <!-- Allow the WP DB Class and related tests for usage of direct database access functions. -->
308        <rule ref="WordPress.DB.RestrictedFunctions">
309                <exclude-pattern>/src/wp-includes/class-wpdb\.php</exclude-pattern>
310                <exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
311        </rule>
312
313        <!-- Allow the WP DB related tests for issues with prepared SQL placeholders
314                 (as the handling of those are being tested). -->
315        <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare">
316                <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
317        </rule>
318        <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder">
319                <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
320        </rule>
321        <rule ref="WordPress.DB.PreparedSQLPlaceholders.UnescapedLiteral">
322                <exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
323        </rule>
324        <rule ref="WordPress.DB.PreparedSQL.NotPrepared">
325                <exclude-pattern>/tests/phpunit/tests/admin/includesSchema\.php</exclude-pattern>
326                <exclude-pattern>/tests/phpunit/tests/multisite/site\.php</exclude-pattern>
327        </rule>
328
329        <!-- Exclude the unit tests from the file name rules. -->
330        <rule ref="WordPress.Files.FileName">
331                <exclude-pattern>/tests/phpunit/*</exclude-pattern>
332        </rule>
333
334        <!-- WPCS1620: template.php isn't a template tag file. -->
335        <rule ref="WordPress.Files.FileName.InvalidTemplateTagFileName">
336                <exclude-pattern>/src/wp-includes/template\.php</exclude-pattern>
337        </rule>
338
339        <!-- Exclude some incorrectly named files that won't be renamed. -->
340        <rule ref="WordPress.Files.FileName.InvalidClassFileName">
341                <exclude-pattern>/src/wp-admin/includes/class-wp-list-table-compat\.php</exclude-pattern>
342                <exclude-pattern>/src/wp-includes/class-wp-dependency\.php</exclude-pattern>
343                <exclude-pattern>/src/wp-includes/class-wp-editor\.php</exclude-pattern>
344                <exclude-pattern>/src/wp-content/themes/twentyeleven/inc/widgets\.php</exclude-pattern>
345                <exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/widgets\.php</exclude-pattern>
346                <exclude-pattern>/src/wp-content/themes/twentyfourteen/inc/featured-content\.php</exclude-pattern>
347        </rule>
348
349        <!-- WPCS1621: These files are expected to use _ instead of -. -->
350        <rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
351                <exclude-pattern>/src/_index\.php</exclude-pattern>
352                <exclude-pattern>/src/wp-admin/_index\.php</exclude-pattern>
353                <exclude-pattern>/src/wp-content/themes/twentythirteen/taxonomy-post_format\.php</exclude-pattern>
354                <exclude-pattern>/src/wp-content/themes/twentyfourteen/taxonomy-post_format\.php</exclude-pattern>
355        </rule>
356
357        <!-- Allow the I18n functions file for issues identified by the I18n sniff
358                 (such as calling the low-level translate() function). -->
359        <rule ref="WordPress.WP.I18n">
360                <exclude-pattern>/src/wp-includes/l10n\.php</exclude-pattern>
361                <exclude-pattern>/tests/phpunit/tests/l10n\.php</exclude-pattern>
362                <exclude-pattern>/tests/phpunit/tests/l10n/loadTextdomainJustInTime\.php</exclude-pattern>
363        </rule>
364
365        <!-- Translator comments aren't needed in unit tests. -->
366        <rule ref="WordPress.WP.I18n.MissingTranslatorsComment">
367                <exclude-pattern>/tests/*</exclude-pattern>
368        </rule>
369
370</ruleset>
Note: See TracBrowser for help on using the repository browser.