Skip to content

Commit

Permalink
Update to WPCS v3 (#80)
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

* Rename parameter

---------

Co-authored-by: Pascal Birchler <[email protected]>
  • Loading branch information
schlessera and swissspidy authored Aug 30, 2023
1 parent aeffbd1 commit 42babfa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 14 additions & 14 deletions router.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,46 @@ 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;
}
$obj_idx .= isset( $wp_filter[ $tag ][ $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];
}
}

Expand Down
4 changes: 2 additions & 2 deletions server-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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." );
Expand Down

0 comments on commit 42babfa

Please sign in to comment.