Skip to content

Commit

Permalink
Update to WPCS v3 (#60)
Browse files Browse the repository at this point in the history
* Update to wp-cli-tests v4 (which requires WPCS v3)

* Fix all autofixable CS issues

* Keep loose comparison

---------

Co-authored-by: Pascal Birchler <[email protected]>
  • Loading branch information
schlessera and swissspidy authored Aug 30, 2023
1 parent ba50c71 commit 7680178
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion role-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Capabilities_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -198,7 +198,7 @@ public function remove( $args ) {

$role_obj->remove_cap( $cap );

$count++;
++$count;
}

$capability = WP_CLI\Utils\pluralize( 'capability', $count );
Expand Down
11 changes: 4 additions & 7 deletions src/Role_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public function delete( $args ) {
} else {
WP_CLI::error( "Role with key '{$role_key}' could not be deleted." );
}

}

/**
Expand Down Expand Up @@ -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 : [];
Expand All @@ -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.' );
}
}

Expand Down

0 comments on commit 7680178

Please sign in to comment.