Skip to content

Commit 81a48c2

Browse files
committed
Coding Standards: Add the phpcs.xml.dist file.
See #41057. git-svn-id: https://develop.svn.wordpress.org/trunk@42346 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 2c325f6 commit 81a48c2

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

phpcs.xml.dist

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="WordPress Coding Standards">
3+
<description>Apply WordPress Coding Standards to all Core files</description>
4+
5+
<rule ref="WordPress-Core"/>
6+
<rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
7+
<rule ref="WordPress.Commenting.DocblockFormat"/>
8+
9+
<arg name="extensions" value="php"/>
10+
11+
<!-- Show sniff codes in all reports -->
12+
<arg value="ps"/>
13+
14+
<file>.</file>
15+
16+
<!-- Directories and third party library exclusions -->
17+
<exclude-pattern>/build/*</exclude-pattern>
18+
<exclude-pattern>/node_modules/*</exclude-pattern>
19+
<exclude-pattern>/vendor/*</exclude-pattern>
20+
21+
<exclude-pattern>/src/wp-admin/includes/class-ftp*</exclude-pattern>
22+
<exclude-pattern>/src/wp-admin/includes/class-pclzip\.php</exclude-pattern>
23+
<exclude-pattern>/src/wp-admin/includes/deprecated\.php</exclude-pattern>
24+
<exclude-pattern>/src/wp-admin/includes/ms-deprecated\.php</exclude-pattern>
25+
26+
<exclude-pattern>/src/wp-includes/atomlib\.php</exclude-pattern>
27+
<exclude-pattern>/src/wp-includes/class-IXR\.php</exclude-pattern>
28+
<exclude-pattern>/src/wp-includes/class-json\.php</exclude-pattern>
29+
<exclude-pattern>/src/wp-includes/class-phpass\.php</exclude-pattern>
30+
<exclude-pattern>/src/wp-includes/class-phpmailer\.php</exclude-pattern>
31+
<exclude-pattern>/src/wp-includes/class-pop3\.php</exclude-pattern>
32+
<exclude-pattern>/src/wp-includes/class-requests\.php</exclude-pattern>
33+
<exclude-pattern>/src/wp-includes/class-simplepie\.php</exclude-pattern>
34+
<exclude-pattern>/src/wp-includes/class-smtp\.php</exclude-pattern>
35+
<exclude-pattern>/src/wp-includes/class-snoopy\.php</exclude-pattern>
36+
<exclude-pattern>/src/wp-includes/deprecated\.php</exclude-pattern>
37+
<exclude-pattern>/src/wp-includes/ms-deprecated\.php</exclude-pattern>
38+
<exclude-pattern>/src/wp-includes/pluggable-deprecated\.php</exclude-pattern>
39+
<exclude-pattern>/src/wp-includes/rss\.php</exclude-pattern>
40+
41+
<exclude-pattern>/src/wp-includes/ID3/*</exclude-pattern>
42+
<exclude-pattern>/src/wp-includes/IXR/*</exclude-pattern>
43+
<exclude-pattern>/src/wp-includes/random_compat/*</exclude-pattern>
44+
<exclude-pattern>/src/wp-includes/Requests/*</exclude-pattern>
45+
<exclude-pattern>/src/wp-includes/SimplePie/*</exclude-pattern>
46+
<exclude-pattern>/src/wp-includes/Text/*</exclude-pattern>
47+
48+
<!-- Test data and fixtures -->
49+
<exclude-pattern>/tests/phpunit/build*</exclude-pattern>
50+
<exclude-pattern>/tests/phpunit/data/*</exclude-pattern>
51+
52+
<exclude-pattern>/tools/*</exclude-pattern>
53+
54+
<!-- Whitelist the WP DB Class and related tests for usage of direct database access functions. -->
55+
<rule ref="WordPress.DB.RestrictedFunctions">
56+
<exclude-pattern>/src/wp-includes/wp-db\.php</exclude-pattern>
57+
<exclude-pattern>/tests/phpunit/tests/db/charset\.php</exclude-pattern>
58+
</rule>
59+
60+
<!-- Whitelist the WP DB related tests for issues with prepared SQL placeholders
61+
(as the handling of those are being tested). -->
62+
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnfinishedPrepare">
63+
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
64+
</rule>
65+
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnsupportedPlaceholder">
66+
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
67+
</rule>
68+
<rule ref="WordPress.DB.PreparedSQLPlaceholders.UnescapedLiteral">
69+
<exclude-pattern>/tests/phpunit/tests/db\.php</exclude-pattern>
70+
</rule>
71+
72+
<rule ref="Generic.Functions.FunctionCallArgumentSpacing">
73+
<exclude-pattern>/wp-config\.php</exclude-pattern>
74+
<exclude-pattern>/wp-config-sample\.php</exclude-pattern>
75+
<exclude-pattern>/wp-tests-config\.php</exclude-pattern>
76+
<exclude-pattern>/wp-tests-config-sample\.php</exclude-pattern>
77+
</rule>
78+
79+
<!-- Whitelist test classes for select sniffs. -->
80+
<rule ref="WordPress.Files.FileName">
81+
<properties>
82+
<property name="custom_test_class_whitelist" type="array" value="WP_UnitTestCase,WP_Ajax_UnitTestCase,WP_Canonical_UnitTestCase,WP_Test_REST_TestCase,WP_Test_REST_Controller_Testcase,WP_Test_REST_Post_Type_Controller_Testcase,WP_XMLRPC_UnitTestCase"/>
83+
</properties>
84+
</rule>
85+
<rule ref="WordPress.Variables.GlobalVariables">
86+
<properties>
87+
<property name="custom_test_class_whitelist" type="array" value="WP_UnitTestCase,WP_Ajax_UnitTestCase,WP_Canonical_UnitTestCase,WP_Test_REST_TestCase,WP_Test_REST_Controller_Testcase,WP_Test_REST_Post_Type_Controller_Testcase,WP_XMLRPC_UnitTestCase"/>
88+
</properties>
89+
</rule>
90+
91+
<!-- Exclude the unit tests from select sniffs. -->
92+
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
93+
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
94+
</rule>
95+
<rule ref="PEAR.NamingConventions.ValidClassName.Invalid">
96+
<exclude-pattern>/tests/phpunit/tests/*</exclude-pattern>
97+
</rule>
98+
99+
</ruleset>

0 commit comments

Comments
 (0)