Skip to content

Commit 52fea16

Browse files
authored
Merge pull request #108 from wp-cli/feature/use-phpcs
Implement CS checking based on the `WP_CLI_CS` ruleset
2 parents 20d8167 + 18f5bd4 commit 52fea16

7 files changed

Lines changed: 338 additions & 215 deletions

File tree

‎.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
@@ -18,7 +18,7 @@
1818
},
1919
"require-dev": {
2020
"wp-cli/scaffold-command": "^1 || ^2",
21-
"wp-cli/wp-cli-tests": "^2.0.7"
21+
"wp-cli/wp-cli-tests": "^2.1"
2222
},
2323
"config": {
2424
"process-timeout": 7200,

‎package-command.php‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
return;
55
}
66

7-
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
8-
if ( file_exists( $autoload ) && ! class_exists( 'Package_Command' ) ) {
9-
require_once $autoload;
7+
$wpcli_package_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
8+
if ( file_exists( $wpcli_package_autoloader ) && ! class_exists( 'Package_Command' ) ) {
9+
require_once $wpcli_package_autoloader;
1010
}
1111
WP_CLI::add_command( 'package', 'Package_Command' );

‎phpcs.xml.dist‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="WP-CLI-package">
3+
<description>Custom ruleset for WP-CLI package-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+
<!-- Ignoring select files/folders.
17+
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-files-and-folders -->
18+
<exclude-pattern>*/src/WP_CLI/JsonManipulator\.php$</exclude-pattern>
19+
<exclude-pattern>*/tests/test-json-manipulator\.php$</exclude-pattern>
20+
21+
<!-- Show progress. -->
22+
<arg value="p"/>
23+
24+
<!-- Strip the filepaths down to the relevant bit. -->
25+
<arg name="basepath" value="./"/>
26+
27+
<!-- Check up to 8 files simultaneously. -->
28+
<arg name="parallel" value="8"/>
29+
30+
<!--
31+
#############################################################################
32+
USE THE WP_CLI_CS RULESET
33+
#############################################################################
34+
-->
35+
36+
<rule ref="WP_CLI_CS"/>
37+
38+
<!--
39+
#############################################################################
40+
PROJECT SPECIFIC CONFIGURATION FOR SNIFFS
41+
#############################################################################
42+
-->
43+
44+
<!-- For help understanding the `testVersion` configuration setting:
45+
https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions -->
46+
<config name="testVersion" value="5.4-"/>
47+
48+
<!-- Verify that everything in the global namespace is either namespaced or prefixed.
49+
See: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#naming-conventions-prefix-everything-in-the-global-namespace -->
50+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
51+
<properties>
52+
<property name="prefixes" type="array">
53+
<element value="WP_CLI\Package"/><!-- Namespaces. -->
54+
<element value="wpcli_package"/><!-- Global variables and such. -->
55+
</property>
56+
</properties>
57+
</rule>
58+
59+
<!-- Exclude existing classes from the prefix rule as it would break BC to prefix them now. -->
60+
<rule ref="WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound">
61+
<exclude-pattern>*/src/Package_Command\.php$</exclude-pattern>
62+
</rule>
63+
64+
</ruleset>

0 commit comments

Comments
 (0)