From 7d6a70107af11b8b1da5bcf0ad727977bb084057 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Tue, 7 Sep 2021 18:19:56 +0000 Subject: [PATCH] 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 --- wp-admin/includes/class-wp-comments-list-table.php | 9 +++++++-- wp-admin/includes/class-wp-links-list-table.php | 8 ++++++-- wp-admin/includes/class-wp-media-list-table.php | 8 ++++++-- wp-admin/includes/class-wp-ms-sites-list-table.php | 8 ++++++-- wp-admin/includes/class-wp-ms-themes-list-table.php | 7 +++++-- wp-admin/includes/class-wp-ms-users-list-table.php | 8 ++++++-- wp-admin/includes/class-wp-posts-list-table.php | 7 +++++-- wp-admin/includes/class-wp-terms-list-table.php | 9 +++++++-- wp-includes/version.php | 2 +- 9 files changed, 49 insertions(+), 17 deletions(-) diff --git a/wp-admin/includes/class-wp-comments-list-table.php b/wp-admin/includes/class-wp-comments-list-table.php index c4cc308b3e..4efe76dd41 100644 --- a/wp-admin/includes/class-wp-comments-list-table.php +++ b/wp-admin/includes/class-wp-comments-list-table.php @@ -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 ) { ?> diff --git a/wp-admin/includes/class-wp-links-list-table.php b/wp-admin/includes/class-wp-links-list-table.php index 21d4724e62..8c2d06bb2c 100644 --- a/wp-admin/includes/class-wp-links-list-table.php +++ b/wp-admin/includes/class-wp-links-list-table.php @@ -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; + ?>