Skip to content

Commit a1a26be

Browse files
committed
PHPCS: Add new ruleset to the project
Update .distignore and .gitignore with phpcs/phpunit config files Update wp-cli-tests to 2.1
1 parent 77390d7 commit a1a26be

File tree

4 files changed

+49
-51
lines changed

4 files changed

+49
-51
lines changed

.distignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
.travis.yml
77
behat.yml
88
circle.yml
9+
phpcs.xml.dist
10+
phpunit.xml.dist
911
bin/
1012
features/
1113
utils/

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ vendor/
66
*.tar.gz
77
composer.lock
88
*.log
9+
phpunit.xml
10+
phpcs.xml
11+
.phpcs.xml

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"require-dev": {
1919
"behat/behat": "~2.5",
20-
"wp-cli/wp-cli-tests": "^2"
20+
"wp-cli/wp-cli-tests": "^2.1"
2121
},
2222
"config": {
2323
"platform": {

phpcs.xml.dist

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,54 @@
11
<?xml version="1.0"?>
2-
<ruleset name="WP-CLI">
3-
<description>Custom ruleset for WP-CLI</description>
2+
<ruleset name="WP-CLI-find">
3+
<description>Custom ruleset for WP-CLI find-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>
415

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 -->
16+
<!-- Show progress. -->
17+
<arg value="p"/>
718

8-
<!-- What to scan -->
9-
<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.PHP.NewFunctions.array_columnFound"/>
30-
<!-- Both magic quotes directives set in wp-settings-cli.php to provide consistent starting point. -->
31-
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_runtimeDeprecatedRemoved"/>
32-
<exclude name="PHPCompatibility.PHP.DeprecatedIniDirectives.magic_quotes_sybaseDeprecatedRemoved"/>
33-
</rule>
19+
<!-- Strip the filepaths down to the relevant bit. -->
20+
<arg name="basepath" value="./"/>
3421

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.4-"/>
22+
<!-- Check up to 8 files simultaneously. -->
23+
<arg name="parallel" value="8"/>
3824

39-
<!-- Ignore php_uname mode issue, we're conditionally providing a callback -->
40-
<rule ref="PHPCompatibility.PHP.NewFunctionParameters.php_uname_modeFound">
41-
<exclude-pattern>*/php/commands/src/CLI_Command.php</exclude-pattern>
42-
</rule>
25+
<!--
26+
#############################################################################
27+
USE THE WP_CLI_CS RULESET
28+
#############################################################################
29+
-->
4330

44-
<!-- Rules: WordPress Coding Standards - see
45-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards -->
46-
<rule ref="WordPress-Core">
47-
<exclude name="Squiz.PHP.DisallowMultipleAssignments.Found" />
48-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCaseMemberVar" />
49-
<exclude name="WordPress.NamingConventions.ValidVariableName.MemberNotSnakeCase" />
50-
<exclude name="WordPress.NamingConventions.ValidVariableName.NotSnakeCase" />
51-
</rule>
31+
<rule ref="WP_CLI_CS"/>
32+
33+
<!--
34+
#############################################################################
35+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
36+
#############################################################################
37+
-->
5238

53-
<!-- For help in understanding these custom sniff properties:
54-
https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties -->
55-
<rule ref="WordPress.Files.FileName">
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-"/>
42+
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">
5646
<properties>
57-
<property name="strict_class_file_names" value="false"/>
47+
<property name="prefixes" type="array">
48+
<element value="WP_CLI\Find"/><!-- Namespaces. -->
49+
<element value="wpcli_find"/><!-- Global variables and such. -->
50+
</property>
5851
</properties>
59-
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
6052
</rule>
53+
6154
</ruleset>

0 commit comments

Comments
 (0)