Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_default()`.
Matches the method signatures of the parent class and each child class. Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match. For readability: - `@since` clearly specifies the original parameter name and its new name as well as why the change happened - in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made. Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757]. Props jrf, hellofromTonya, @sergeybiryukov, @azaozz, @desrosj, @johnbillion See #51553. Built from https://develop.svn.wordpress.org/trunk@51728 git-svn-id: http://core.svn.wordpress.org/trunk@51334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c11fbdc7ae
commit
2c91899724
|
@ -1047,10 +1047,12 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param WP_Comment $comment The comment object.
|
||||
* @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param WP_Comment $item The comment object.
|
||||
* @param string $column_name The custom column's name.
|
||||
*/
|
||||
public function column_default( $comment, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
/**
|
||||
* Fires when the default column output is displayed for a single row.
|
||||
*
|
||||
|
@ -1059,6 +1061,6 @@ class WP_Comments_List_Table extends WP_List_Table {
|
|||
* @param string $column_name The custom column's name.
|
||||
* @param int $comment_id The custom column's unique ID number.
|
||||
*/
|
||||
do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
|
||||
do_action( 'manage_comments_custom_column', $column_name, $item->comment_ID );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -279,11 +279,12 @@ class WP_Links_List_Table extends WP_List_Table {
|
|||
* Handles the default column output.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 5.9.0 Renamed `$link` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param object $link Link object.
|
||||
* @param object $item Link object.
|
||||
* @param string $column_name Current column name.
|
||||
*/
|
||||
public function column_default( $link, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
/**
|
||||
* Fires for each registered custom link column.
|
||||
*
|
||||
|
@ -292,7 +293,7 @@ class WP_Links_List_Table extends WP_List_Table {
|
|||
* @param string $column_name Name of the custom column.
|
||||
* @param int $link_id Link ID.
|
||||
*/
|
||||
do_action( 'manage_link_custom_column', $column_name, $link->link_id );
|
||||
do_action( 'manage_link_custom_column', $column_name, $item->link_id );
|
||||
}
|
||||
|
||||
public function display_rows() {
|
||||
|
|
|
@ -594,11 +594,15 @@ class WP_Media_List_Table extends WP_List_Table {
|
|||
* Handles output for the default column.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param WP_Post $post The current WP_Post object.
|
||||
* @param WP_Post $item The current WP_Post object.
|
||||
* @param string $column_name Current column name.
|
||||
*/
|
||||
public function column_default( $post, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$post = $item;
|
||||
|
||||
if ( 'categories' === $column_name ) {
|
||||
$taxonomy = 'category';
|
||||
} elseif ( 'tags' === $column_name ) {
|
||||
|
|
|
@ -560,11 +560,12 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
* Handles output for the default column.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param array $blog Current site.
|
||||
* @param array $item Current site.
|
||||
* @param string $column_name Current column name.
|
||||
*/
|
||||
public function column_default( $blog, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
/**
|
||||
* Fires for each registered custom column in the Sites list table.
|
||||
*
|
||||
|
@ -573,7 +574,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
* @param string $column_name The name of the column to display.
|
||||
* @param int $blog_id The site ID.
|
||||
*/
|
||||
do_action( 'manage_sites_custom_column', $column_name, $blog['blog_id'] );
|
||||
do_action( 'manage_sites_custom_column', $column_name, $item['blog_id'] );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -855,13 +855,12 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
* Handles default column output.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param WP_Theme $theme The current WP_Theme object.
|
||||
* @param WP_Theme $item The current WP_Theme object.
|
||||
* @param string $column_name The current column name.
|
||||
*/
|
||||
public function column_default( $theme, $column_name ) {
|
||||
$stylesheet = $theme->get_stylesheet();
|
||||
|
||||
public function column_default( $item, $column_name ) {
|
||||
/**
|
||||
* Fires inside each custom column of the Multisite themes list table.
|
||||
*
|
||||
|
@ -871,7 +870,12 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
|
|||
* @param string $stylesheet Directory name of the theme.
|
||||
* @param WP_Theme $theme Current WP_Theme object.
|
||||
*/
|
||||
do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
|
||||
do_action(
|
||||
'manage_themes_custom_column',
|
||||
$column_name,
|
||||
$item->get_stylesheet(), // Directory name of the theme.
|
||||
$item // Theme object.
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -442,13 +442,19 @@ class WP_MS_Users_List_Table extends WP_List_Table {
|
|||
* Handles the default column output.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param WP_User $user The current WP_User object.
|
||||
* @param WP_User $item The current WP_User object.
|
||||
* @param string $column_name The current column name.
|
||||
*/
|
||||
public function column_default( $user, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
/** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
|
||||
echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
|
||||
echo apply_filters(
|
||||
'manage_users_custom_column',
|
||||
'', // Custom column output. Default empty.
|
||||
$column_name,
|
||||
$item->ID // User ID.
|
||||
);
|
||||
}
|
||||
|
||||
public function display_rows() {
|
||||
|
|
|
@ -1235,11 +1235,15 @@ class WP_Posts_List_Table extends WP_List_Table {
|
|||
* Handles the default column output.
|
||||
*
|
||||
* @since 4.3.0
|
||||
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param WP_Post $post The current WP_Post object.
|
||||
* @param WP_Post $item The current WP_Post object.
|
||||
* @param string $column_name The current column name.
|
||||
*/
|
||||
public function column_default( $post, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
// Restores the more descriptive, specific name for use within this method.
|
||||
$post = $item;
|
||||
|
||||
if ( 'categories' === $column_name ) {
|
||||
$taxonomy = 'category';
|
||||
} elseif ( 'tags' === $column_name ) {
|
||||
|
|
|
@ -620,11 +620,13 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param WP_Term $tag Term object.
|
||||
* @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named param.
|
||||
*
|
||||
* @param WP_Term $item Term object.
|
||||
* @param string $column_name Name of the column.
|
||||
* @return string
|
||||
*/
|
||||
public function column_default( $tag, $column_name ) {
|
||||
public function column_default( $item, $column_name ) {
|
||||
/**
|
||||
* Filters the displayed columns in the terms list table.
|
||||
*
|
||||
|
@ -638,11 +640,11 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||
*
|
||||
* @since 2.8.0
|
||||
*
|
||||
* @param string $string Blank string.
|
||||
* @param string $string Custom column output. Default empty.
|
||||
* @param string $column_name Name of the column.
|
||||
* @param int $term_id Term ID.
|
||||
*/
|
||||
return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
|
||||
return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-51727';
|
||||
$wp_version = '5.9-alpha-51728';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue