From 42babfa0fdd517cd8bdd66528b3c9027d6d14a29 Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Wed, 30 Aug 2023 17:27:57 +0200 Subject: [PATCH] Update to WPCS v3 (#80) * Update to wp-cli-tests v4 (which requires WPCS v3) * Fix all autofixable CS issues * Rename parameter --------- Co-authored-by: Pascal Birchler --- composer.json | 2 +- router.php | 28 ++++++++++++++-------------- server-command.php | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/composer.json b/composer.json index 0312a14..885f0eb 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "wp-cli/entity-command": "^2", - "wp-cli/wp-cli-tests": "^3.1" + "wp-cli/wp-cli-tests": "^4" }, "config": { "process-timeout": 7200, diff --git a/router.php b/router.php index 86b2f3a..8c6daa9 100644 --- a/router.php +++ b/router.php @@ -27,28 +27,28 @@ function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 * * We duplicate it because WordPress is not loaded yet. */ -function _wp_filter_build_unique_id( $tag, $function, $priority ) { +function _wp_filter_build_unique_id( $tag, $callback, $priority ) { global $wp_filter; static $filter_id_count = 0; - if ( is_string( $function ) ) { - return $function; + if ( is_string( $callback ) ) { + return $callback; } - if ( is_object( $function ) ) { + if ( is_object( $callback ) ) { // Closures are currently implemented as objects - $function = array( $function, '' ); + $callback = array( $callback, '' ); } else { - $function = (array) $function; + $callback = (array) $callback; } - if ( is_object( $function[0] ) ) { + if ( is_object( $callback[0] ) ) { // Object Class Calling if ( function_exists( 'spl_object_hash' ) ) { - return spl_object_hash( $function[0] ) . $function[1]; + return spl_object_hash( $callback[0] ) . $callback[1]; } else { - $obj_idx = get_class( $function[0] ) . $function[1]; - if ( ! isset( $function[0]->wp_filter_id ) ) { + $obj_idx = get_class( $callback[0] ) . $callback[1]; + if ( ! isset( $callback[0]->wp_filter_id ) ) { if ( false === $priority ) { return false; } @@ -56,17 +56,17 @@ function _wp_filter_build_unique_id( $tag, $function, $priority ) { ? count( (array) $wp_filter[ $tag ][ $priority ] ) : $filter_id_count; - $function[0]->wp_filter_id = $filter_id_count; + $callback[0]->wp_filter_id = $filter_id_count; ++$filter_id_count; } else { - $obj_idx .= $function[0]->wp_filter_id; + $obj_idx .= $callback[0]->wp_filter_id; } return $obj_idx; } - } elseif ( is_string( $function[0] ) ) { + } elseif ( is_string( $callback[0] ) ) { // Static Calling - return $function[0] . '::' . $function[1]; + return $callback[0] . '::' . $callback[1]; } } diff --git a/server-command.php b/server-command.php index d1f5d56..6a0b018 100644 --- a/server-command.php +++ b/server-command.php @@ -4,7 +4,7 @@ return; } -$wpcli_server_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php'; +$wpcli_server_autoloader = __DIR__ . '/vendor/autoload.php'; if ( file_exists( $wpcli_server_autoloader ) ) { require_once $wpcli_server_autoloader; } @@ -13,7 +13,7 @@ 'server', 'Server_Command', array( - 'before_invoke' => function() { + 'before_invoke' => function () { $min_version = '5.4'; if ( version_compare( PHP_VERSION, $min_version, '<' ) ) { WP_CLI::error( "The `wp server` command requires PHP {$min_version} or newer." );