From 0310ca5b920d99a4bfe6cb540df2f43b50afb797 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Apr 2019 18:24:31 +0200 Subject: [PATCH 1/5] Composer: use wp-cli-tests ^2.1 ... as that version contains the new WPCliCS PHPCS standard. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1ab983452..c13526d3b 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "wp-cli/wp-cli": "^2" }, "require-dev": { - "wp-cli/wp-cli-tests": "^2.0.7" + "wp-cli/wp-cli-tests": "^2.1" }, "config": { "process-timeout": 7200, From 7405c5876ca035da074aafe6a655c975716b9c78 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Apr 2019 18:24:43 +0200 Subject: [PATCH 2/5] .gitignore/.distignore: ignore phpcs/phpunit config files * `.distignore`: no need to distribute the phpcs/phpunit config files. * `.gitignore`: Allow devs to overwrite config files for PHPUnit and PHPCS - The `.dist` files should be committed. However, for their personal use, devs can overrule those files with versions without `.dist`. Those personal versions should never be committed. As a side-note: for PHPCS, having a personal version while still using the original `.dist` file is made very easy, as you can just import the `.dist` file as a starting point, like so: ```xml ``` --- .distignore | 2 ++ .gitignore | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.distignore b/.distignore index b964b40c7..95b52fb02 100644 --- a/.distignore +++ b/.distignore @@ -6,6 +6,8 @@ .travis.yml behat.yml circle.yml +phpcs.xml.dist +phpunit.xml.dist bin/ features/ utils/ diff --git a/.gitignore b/.gitignore index ff4941991..bcf211b32 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ vendor/ *.tar.gz composer.lock *.log +phpunit.xml +phpcs.xml +.phpcs.xml From 77f4989de11f2ef9506f55d51aa984ca1c0b1059 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Apr 2019 18:25:28 +0200 Subject: [PATCH 3/5] PHPCS: add a ruleset for this project The file is completely documented in-line. --- phpcs.xml.dist | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 phpcs.xml.dist diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 000000000..043d3ab99 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,62 @@ + + + Custom ruleset for WP-CLI eval-command + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */src/Eval(File)?_Command\.php$ + + + From ab74281a2997e6c3e34f2b048015064c4b214e79 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Apr 2019 18:25:44 +0200 Subject: [PATCH 4/5] CS: rename the $autoload variable --- eval-command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eval-command.php b/eval-command.php index fa3759336..7f607ce5f 100644 --- a/eval-command.php +++ b/eval-command.php @@ -4,9 +4,9 @@ return; } -$autoload = dirname( __FILE__ ) . '/vendor/autoload.php'; -if ( file_exists( $autoload ) ) { - require_once $autoload; +$wpcli_eval_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +if ( file_exists( $wpcli_eval_autoloader ) ) { + require_once $wpcli_eval_autoloader; } WP_CLI::add_command( 'eval', 'Eval_Command' ); From b140e79448c947e48f2378170a203e739c11510d Mon Sep 17 00:00:00 2001 From: jrfnl Date: Sat, 20 Apr 2019 18:26:10 +0200 Subject: [PATCH 5/5] CS: rename a method to not start with an underscore --- src/EvalFile_Command.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EvalFile_Command.php b/src/EvalFile_Command.php index e9b9ec234..07c10c425 100644 --- a/src/EvalFile_Command.php +++ b/src/EvalFile_Command.php @@ -36,10 +36,10 @@ public function __invoke( $args, $assoc_args ) { WP_CLI::get_runner()->load_wordpress(); } - self::_eval( $file, $args ); + self::execute_eval( $file, $args ); } - private static function _eval( $file, $args ) { + private static function execute_eval( $file, $args ) { if ( '-' === $file ) { eval( '?>' . file_get_contents( 'php://stdin' ) ); } else {