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

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 [32644], [32664], [32798], [38489], [49183], [49197].

Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737


git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
hellofromTonya 2021-09-07 19:24:53 +00:00
parent 172541c6f1
commit aebe05f6f4
8 changed files with 39 additions and 16 deletions

View File

@ -651,17 +651,18 @@ class WP_Comments_List_Table extends WP_List_Table {
* Generate and display row actions links.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
*
* @global string $comment_status Status for the current listed comments.
*
* @param WP_Comment $comment The comment object.
* @param WP_Comment $item The comment object.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for comments. An empty string
* if the current column is not the primary column,
* or if the current user cannot edit the comment.
*/
protected function handle_row_actions( $comment, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
global $comment_status;
if ( $primary !== $column_name ) {
@ -672,6 +673,8 @@ class WP_Comments_List_Table extends WP_List_Table {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$comment = $item;
$the_comment_status = wp_get_comment_status( $comment );
$out = '';

View File

@ -317,18 +317,21 @@ class WP_Links_List_Table extends WP_List_Table {
* Generates and displays row action links.
*
* @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 Link being acted upon.
* @param object $item Link being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for links, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $link, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$link = $item;
$edit_link = get_edit_bookmark_link( $link );
$actions = array();

View File

@ -827,20 +827,25 @@ class WP_Media_List_Table extends WP_List_Table {
* Generates and displays row action links.
*
* @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 Attachment being acted upon.
* @param WP_Post $item Attachment being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for media attachments, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $post, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
$att_title = _draft_or_post_title();
$actions = $this->_get_row_actions(
$item, // WP_Post object for an attachment.
$att_title
);
return $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
return $this->row_actions( $actions );
}
}

View File

@ -668,18 +668,21 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
* Generates and displays row action links.
*
* @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 Site being acted upon.
* @param array $item Site being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for sites in Multisite, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $blog, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$blog = $item;
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
// Preordered.

View File

@ -499,18 +499,21 @@ class WP_MS_Users_List_Table extends WP_List_Table {
* Generates and displays row action links.
*
* @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 User being acted upon.
* @param WP_User $item User being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for users in Multisite, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $user, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$user = $item;
$super_admins = get_super_admins();
$actions = array();

View File

@ -1402,18 +1402,21 @@ class WP_Posts_List_Table extends WP_List_Table {
* Generates and displays row action links.
*
* @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 Post being acted upon.
* @param WP_Post $item Post being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for posts, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $post, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$post = $item;
$post_type_object = get_post_type_object( $post->post_type );
$can_edit_post = current_user_can( 'edit_post', $post->ID );
$actions = array();

View File

@ -461,18 +461,21 @@ class WP_Terms_List_Table extends WP_List_Table {
* Generates and displays row action links.
*
* @since 4.3.0
* @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
*
* @param WP_Term $tag Tag being acted upon.
* @param WP_Term $item Tag being acted upon.
* @param string $column_name Current column name.
* @param string $primary Primary column name.
* @return string Row actions output for terms, or an empty string
* if the current column is not the primary column.
*/
protected function handle_row_actions( $tag, $column_name, $primary ) {
protected function handle_row_actions( $item, $column_name, $primary ) {
if ( $primary !== $column_name ) {
return '';
}
// Restores the more descriptive, specific name for use within this method.
$tag = $item;
$taxonomy = $this->screen->taxonomy;
$tax = get_taxonomy( $taxonomy );
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];

View File

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