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 diff --git a/composer.json b/composer.json index 2d9406184..1a75b4e0a 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^1.3 || ^2", - "wp-cli/wp-cli-tests": "^2.0.11" + "wp-cli/wp-cli-tests": "^2.1" }, "config": { "process-timeout": 7200, diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 000000000..675ea5f6c --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,66 @@ + + + Custom ruleset for WP-CLI cache-command + + + + + . + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */src/(Cache|Transient)_Command\.php$ + + + diff --git a/src/Cache_Command.php b/src/Cache_Command.php index cca4ec3ae..1b5c8b172 100644 --- a/src/Cache_Command.php +++ b/src/Cache_Command.php @@ -129,7 +129,7 @@ public function decr( $args, $assoc_args ) { */ public function delete( $args, $assoc_args ) { list( $key, $group ) = $args; - $result = wp_cache_delete( $key, $group ); + $result = wp_cache_delete( $key, $group ); if ( false === $result ) { WP_CLI::error( 'The object was not deleted.' ); @@ -188,7 +188,7 @@ public function flush( $args, $assoc_args ) { */ public function get( $args, $assoc_args ) { list( $key, $group ) = $args; - $value = wp_cache_get( $key, $group ); + $value = wp_cache_get( $key, $group ); if ( false === $value ) { WP_CLI::error( "Object with key '$key' and group '$group' not found." ); diff --git a/src/Transient_Command.php b/src/Transient_Command.php index efc13f092..e8bff6881 100644 --- a/src/Transient_Command.php +++ b/src/Transient_Command.php @@ -177,7 +177,7 @@ public function set( $args, $assoc_args ) { * $ wp transient delete --all --network && wp site list --field=url | xargs -n1 -I % wp --url=% transient delete --all */ public function delete( $args, $assoc_args ) { - $key = ( ! empty( $args ) ) ? $args[0] : NULL; + $key = ( ! empty( $args ) ) ? $args[0] : null; $all = Utils\get_flag_value( $assoc_args, 'all' ); $expired = Utils\get_flag_value( $assoc_args, 'expired' ); @@ -201,10 +201,11 @@ public function delete( $args, $assoc_args ) { WP_CLI::success( 'Transient deleted.' ); } else { $func = Utils\get_flag_value( $assoc_args, 'network' ) ? 'get_site_transient' : 'get_transient'; - if ( $func( $key ) ) + if ( $func( $key ) ) { WP_CLI::error( 'Transient was not deleted even though the transient appears to exist.' ); - else + } else { WP_CLI::warning( 'Transient was not deleted; however, the transient does not appear to exist.' ); + } } } @@ -380,6 +381,7 @@ public function list_( $args, $assoc_args ) { $query = "SELECT `option_name` as `name`, `option_value` as `value` FROM {$wpdb->options} {$where}"; } + // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Prepared properly above. $results = $wpdb->get_results( $query ); foreach ( $results as $result ) {