Skip to content

Commit 56176c7

Browse files
committed
PHPCS: change example ruleset to project ruleset for this repo
This basically cleans out the existing example ruleset and replaces it with a ruleset specifically aimed at the code in this repository. The file is completely documented in-line.
1 parent eae383b commit 56176c7

File tree

1 file changed

+64
-47
lines changed

1 file changed

+64
-47
lines changed

phpcs.xml.dist

Lines changed: 64 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,73 @@
11
<?xml version="1.0"?>
2-
<ruleset name="WP-CLI">
3-
<description>Custom ruleset for WP-CLI</description>
2+
<ruleset name="WP-CLI-tests">
3+
<description>Custom ruleset for WP-CLI-tests</description>
44

5-
<!-- For help in understanding this file: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
6-
<!-- For help in using PHPCS: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage -->
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+
-->
712

8-
<!-- What to scan -->
13+
<!-- What to scan. -->
914
<file>.</file>
10-
<!-- Ignoring Files and Folders:
11-
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
12-
<exclude-pattern>*/.git/*</exclude-pattern>
13-
<exclude-pattern>*/ci/*</exclude-pattern>
14-
<exclude-pattern>*/features/*</exclude-pattern>
15-
<exclude-pattern>*/packages/*</exclude-pattern>
16-
<exclude-pattern>*/tests/*</exclude-pattern>
17-
<exclude-pattern>*/utils/*</exclude-pattern>
18-
<exclude-pattern>*/vendor/*</exclude-pattern>
19-
20-
<!-- How to scan -->
21-
<arg value="sp"/> <!-- Show sniff and progress -->
22-
<arg name="colors"/> <!-- Show results with colors -->
23-
<arg name="extensions" value="php"/> <!-- Limit to PHP files -->
24-
25-
<!-- Rules: Check PHP version compatibility - see
26-
https://github.com/PHPCompatibility/PHPCompatibilityWP -->
27-
<rule ref="PHPCompatibilityWP">
28-
<!-- Polyfill package is used so array_column() is available for PHP 5.4- -->
29-
<exclude name="PHPCompatibility.Functions.NewFunctions.array_columnFound"/>
30-
<!-- Both magic quotes directives set in wp-settings-cli.php to provide consistent starting point. -->
31-
<exclude name="PHPCompatibility.IniDirectives.RemovedIniDirectives.magic_quotes_runtimeDeprecatedRemoved"/>
32-
<exclude name="PHPCompatibility.IniDirectives.RemovedIniDirectives.magic_quotes_sybaseDeprecatedRemoved"/>
33-
</rule>
3415

35-
<!-- For help in understanding this testVersion:
36-
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
37-
<config name="testVersion" value="5.3-"/>
38-
39-
<!-- Rules: WordPress Coding Standards - see
40-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
41-
<rule ref="WordPress-Core">
42-
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
43-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />
44-
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase" />
45-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCase" />
46-
</rule>
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 simultanously. -->
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+
33+
<!--
34+
#############################################################################
35+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
36+
#############################################################################
37+
-->
38+
39+
<!-- For help understanding the `testVersion` configuration setting:
40+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
41+
<config name="testVersion" value="5.4-"/>
4742

48-
<!-- For help in understanding these custom sniff properties:
49-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
50-
<rule ref="WordPress.Files.FileName">
43+
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
44+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
45+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
5146
<properties>
52-
<property name="strict_class_file_names" value="false"/>
47+
<property name="prefixes" type="array" extend="true">
48+
<element value="WP_CLI\Tests"/><!-- Namespaces. -->
49+
</property>
5350
</properties>
54-
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
5551
</rule>
56-
</ruleset>
52+
53+
<!--
54+
#############################################################################
55+
SELECTIVE EXCLUSIONS
56+
#############################################################################
57+
-->
58+
59+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
60+
<!-- Naming requirement from Behat, can't be changed to comply. -->
61+
<exclude-pattern>*/features/bootstrap/FeatureContext\.php$</exclude-pattern>
62+
</rule>
63+
64+
<!-- This is a procedural stand-alone file that is never loaded in a WordPress context,
65+
so this file does not have to comply with WP naming conventions. -->
66+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
67+
<exclude-pattern>*/utils/behat-tags\.php$</exclude-pattern>
68+
</rule>
69+
<rule ref="WordPress.WP.GlobalVariablesOverride">
70+
<exclude-pattern>*/utils/behat-tags\.php$</exclude-pattern>
71+
</rule>
72+
73+
</ruleset>

0 commit comments

Comments
 (0)