From 4693de6cfa46c8e41bf01992f757d30426b466ba Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 30 Aug 2023 04:56:56 -0700 Subject: [PATCH 1/4] Update to `wp-cli-tests:^4` --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9c3b2df..541bb05 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "wp-cli/wp-cli": "^2" }, "require-dev": { - "wp-cli/wp-cli-tests": "^3.0.11" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, From 8ab5735a50a37ba349595a352a1bd90712652ec7 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 30 Aug 2023 05:06:43 -0700 Subject: [PATCH 2/4] Add a basic phpcs file --- phpcs.xml.dist | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 phpcs.xml.dist diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..ea0a892 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,55 @@ + + + Custom ruleset for WP-CLI admin-command + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */src/Admin_Command\.php$ + + + From 9dce0de37dd91d44a6abb0b5910e3cf013335ff2 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 30 Aug 2023 05:07:08 -0700 Subject: [PATCH 3/4] Register `composer phpcbf` --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 541bb05..bda1de0 100644 --- a/composer.json +++ b/composer.json @@ -38,6 +38,7 @@ "behat-rerun": "rerun-behat-tests", "lint": "run-linter-tests", "phpcs": "run-phpcs-tests", + "phpcbf": "run-phpcbf-cleanup", "phpunit": "run-php-unit-tests", "prepare-tests": "install-package-tests", "test": [ From 3f592b0a250bb1524f561a4a06613eb758a2edba Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Wed, 30 Aug 2023 05:13:07 -0700 Subject: [PATCH 4/4] Define a function instead of a perceived global variable --- admin-command.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/admin-command.php b/admin-command.php index 25eac29..b96329b 100644 --- a/admin-command.php +++ b/admin-command.php @@ -7,7 +7,7 @@ /** * Open /wp-admin/ in a browser. */ -$wp_admin = function() { +function wp_cli_admin_command() { switch ( strtoupper( substr( PHP_OS, 0, 3 ) ) ) { case 'DAR': $exec = 'open'; @@ -19,5 +19,5 @@ $exec = 'xdg-open'; } passthru( $exec . ' ' . escapeshellarg( admin_url() ) ); -}; -WP_CLI::add_command( 'admin', $wp_admin ); +} +WP_CLI::add_command( 'admin', 'wp_cli_admin_command' );