Code Modernization: Fix parameter name mismatches for parent/child classes in WP_List_Table::column_cb().

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@51735


git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-09-07 18:19:56 +00:00
parent 213ce0c7ea
commit 7d6a70107a
9 changed files with 49 additions and 17 deletions

View File

@ -868,9 +868,14 @@ 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 parameter support.
*
* @param WP_Comment $item The comment object.
*/
public function column_cb( $comment ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$comment = $item;
if ( $this->user_can ) {
?>
<label class="screen-reader-text" for="cb-select-<?php echo $comment->comment_ID; ?>"><?php _e( 'Select comment' ); ?></label>

View File

@ -166,10 +166,14 @@ class WP_Links_List_Table extends WP_List_Table {
* Handles the checkbox column output.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$link` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param object $link The current link object.
* @param object $item The current link object.
*/
public function column_cb( $link ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$link = $item;
?>
<label class="screen-reader-text" for="cb-select-<?php echo $link->link_id; ?>">
<?php

View File

@ -387,10 +387,14 @@ class WP_Media_List_Table extends WP_List_Table {
* Handles the checkbox column output.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param WP_Post $post The current WP_Post object.
* @param WP_Post $item The current WP_Post object.
*/
public function column_cb( $post ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$post = $item;
if ( current_user_can( 'edit_post', $post->ID ) ) {
?>
<label class="screen-reader-text" for="cb-select-<?php echo $post->ID; ?>">

View File

@ -396,10 +396,14 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
* Handles the checkbox column output.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$blog` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param array $blog Current site.
* @param array $item Current site.
*/
public function column_cb( $blog ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$blog = $item;
if ( ! is_main_site( $blog['blog_id'] ) ) :
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
?>

View File

@ -505,10 +505,13 @@ class WP_MS_Themes_List_Table extends WP_List_Table {
* Handles the checkbox column output.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param WP_Theme $theme The current WP_Theme object.
* @param WP_Theme $item The current WP_Theme object.
*/
public function column_cb( $theme ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$theme = $item;
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) );
?>
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" />

View File

@ -227,10 +227,14 @@ class WP_MS_Users_List_Table extends WP_List_Table {
* Handles the checkbox column output.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param WP_User $user The current WP_User object.
* @param WP_User $item The current WP_User object.
*/
public function column_cb( $user ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$user = $item;
if ( is_super_admin( $user->ID ) ) {
return;
}

View File

@ -971,10 +971,13 @@ class WP_Posts_List_Table extends WP_List_Table {
* Handles the checkbox column output.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param WP_Post $post The current WP_Post object.
* @param WP_Post $item The current WP_Post object.
*/
public function column_cb( $post ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$post = $item;
$show = current_user_can( 'edit_post', $post->ID );
/**

View File

@ -364,10 +364,15 @@ 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 parameter support.
*
* @param WP_Term $item Term object.
* @return string
*/
public function column_cb( $tag ) {
public function column_cb( $item ) {
// Restores the more descriptive, specific name for use within this method.
$tag = $item;
if ( current_user_can( 'delete_term', $tag->term_id ) ) {
return sprintf(
'<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' .

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.9-alpha-51734';
$wp_version = '5.9-alpha-51735';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.