Skip to content

Commit badbdcb

Browse files
committed
PHPCS: add a ruleset for this project
The file is completely documented in-line.
1 parent beda19d commit badbdcb

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

phpcs.xml.dist

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="WP-CLI-search-replace">
3+
<description>Custom ruleset for WP-CLI search-replace-command</description>
4+
5+
<!--
6+
#############################################################################
7+
COMMAND LINE ARGUMENTS
8+
For help understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
9+
For help using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage
10+
#############################################################################
11+
-->
12+
13+
<!-- What to scan. -->
14+
<file>.</file>
15+
16+
<!-- Show progress. -->
17+
<arg value="p"/>
18+
19+
<!-- Strip the filepaths down to the relevant bit. -->
20+
<arg name="basepath" value="./"/>
21+
22+
<!-- Check up to 8 files simultaneously. -->
23+
<arg name="parallel" value="8"/>
24+
25+
<!--
26+
#############################################################################
27+
USE THE WP_CLI_CS RULESET
28+
#############################################################################
29+
-->
30+
31+
<rule ref="WP_CLI_CS">
32+
<!-- Can't be helped as WP itself uses these functions for the data being adjusted. -->
33+
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_unserialize"/>
34+
<exclude name="WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize"/>
35+
</rule>
36+
37+
<!--
38+
#############################################################################
39+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
40+
#############################################################################
41+
-->
42+
43+
<!-- For help understanding the `testVersion` configuration setting:
44+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
45+
<config name="testVersion" value="5.4-"/>
46+
47+
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
48+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
49+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
50+
<properties>
51+
<property name="prefixes" type="array">
52+
<element value="WP_CLI\Search"/><!-- Namespaces. -->
53+
<element value="wpcli_search"/><!-- Global variables and such. -->
54+
</property>
55+
</properties>
56+
</rule>
57+
58+
<!-- Exclude existing classes and namespaces from the prefix rule as it would break BC to prefix them now. -->
59+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
60+
<exclude-pattern>*/src/Search_Replace_Command\.php$</exclude-pattern>
61+
</rule>
62+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedNamespaceFound">
63+
<exclude-pattern>*/src/WP_CLI/SearchReplacer\.php$</exclude-pattern>
64+
</rule>
65+
66+
<!-- Allow for some MySQL native non-snake-case properties.
67+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#mixed-case-property-name-exceptions
68+
Related: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1623 -->
69+
<rule ref="WordPress.NamingConventions.ValidVariableName">
70+
<properties>
71+
<property name="customPropertiesWhitelist" type="array">
72+
<element value="Key"/>
73+
<element value="Field"/>
74+
<element value="Type"/>
75+
</property>
76+
</properties>
77+
</rule>
78+
79+
</ruleset>

0 commit comments

Comments
 (0)