From 7680178016a1811421897aeb9eeae9e81e6893ac Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 18:18:53 +0200 Subject: [PATCH] Update to WPCS v3 (#60) * Update to wp-cli-tests v4 (which requires WPCS v3) * Fix all autofixable CS issues * Keep loose comparison --------- Co-authored-by: Pascal Birchler --- composer.json | 2 +- role-command.php | 2 +- src/Capabilities_Command.php | 4 ++-- src/Role_Command.php | 11 ++++------- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index fb056fca9..479a78f1e 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "wp-cli/wp-cli": "^2.5" }, "require-dev": { - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, diff --git a/role-command.php b/role-command.php index 37f41f0d7..f4bd6411f 100644 --- a/role-command.php +++ b/role-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_role_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_role_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_role_autoloader ) ) { require_once $wpcli_role_autoloader; } diff --git a/src/Capabilities_Command.php b/src/Capabilities_Command.php index c31635960..e27a0cb1d 100644 --- a/src/Capabilities_Command.php +++ b/src/Capabilities_Command.php @@ -156,7 +156,7 @@ public function add( $args, $assoc_args ) { $role_obj->add_cap( $cap, $grant ); - $count++; + ++$count; } $capability = WP_CLI\Utils\pluralize( 'capability', $count ); @@ -198,7 +198,7 @@ public function remove( $args ) { $role_obj->remove_cap( $cap ); - $count++; + ++$count; } $capability = WP_CLI\Utils\pluralize( 'capability', $count ); diff --git a/src/Role_Command.php b/src/Role_Command.php index 9decfd731..55f480e51 100644 --- a/src/Role_Command.php +++ b/src/Role_Command.php @@ -239,7 +239,6 @@ public function delete( $args ) { } else { WP_CLI::error( "Role with key '{$role_key}' could not be deleted." ); } - } /** @@ -370,7 +369,7 @@ public function reset( $args, $assoc_args ) { foreach ( $args as $role_key ) { $after[ $role_key ] = get_role( $role_key ); - // phpcs:ignore WordPress.PHP.StrictComparisons.LooseComparison -- Object instances won't be same, strict check will fail here. + // phpcs:ignore Universal.Operators.StrictComparisons -- Object instances won't be same, strict check will fail here. if ( $after[ $role_key ] != $before[ $role_key ] ) { ++$num_reset; $before_capabilities = isset( $before[ $role_key ] ) ? $before[ $role_key ]->capabilities : []; @@ -392,12 +391,10 @@ public function reset( $args, $assoc_args ) { } else { WP_CLI::success( "{$num_reset} of {$num_to_reset} roles reset." ); } - } else { - if ( 1 === count( $args ) ) { + } elseif ( 1 === count( $args ) ) { WP_CLI::success( 'Role didn\'t need resetting.' ); - } else { - WP_CLI::success( 'No roles needed resetting.' ); - } + } else { + WP_CLI::success( 'No roles needed resetting.' ); } }