Skip to content

Commit 0a7d646

Browse files
committed
PHPCS: Add new ruleset in the project
1 parent 93f531d commit 0a7d646

File tree

4 files changed

+51
-55
lines changed

4 files changed

+51
-55
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ composer.lock
33
node_modules/
44
vendor/
55
*.log
6+
phpunit.xml
7+
phpcs.xml
8+
.phpcs.xml

composer.json

+1-1
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
"wp-cli/scaffold-command": "^2",
2222
"wp-cli/extension-command": "^2"
2323
},

dist-archive-command.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
return;
55
}
66

7-
$autoload = dirname( __FILE__ ) . '/vendor/autoload.php';
8-
if ( file_exists( $autoload ) ) {
9-
require_once $autoload;
7+
$wpcli_dist_archive_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
8+
if ( file_exists( $wpcli_dist_archive_autoloader ) ) {
9+
require_once $wpcli_dist_archive_autoloader;
1010
}
1111

1212
WP_CLI::add_command( 'dist-archive', 'Dist_Archive_Command' );

phpcs.xml.dist

+44-51
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-dist-archive">
3+
<description>Custom ruleset for WP-CLI dist-archive-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.3-"/>
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\DistArchive"/><!-- Namespaces. -->
49+
<element value="wpcli_dist_archive"/><!-- Global variables and such. -->
50+
</property>
5851
</properties>
59-
<exclude name="WordPress.Files.FileName.NotHyphenatedLowercase" />
6052
</rule>
61-
</ruleset>
53+
54+
</ruleset>

0 commit comments

Comments
 (0)