Make WordPress Core


Ignore:
Timestamp:
09/02/2021 10:25:58 PM (2 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-comments-list-table.php

    r50805 r51728  
    10481048
    10491049    /**
    1050      * @param WP_Comment $comment     The comment object.
     1050     * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named param.
     1051     *
     1052     * @param WP_Comment $item        The comment object.
    10511053     * @param string     $column_name The custom column's name.
    10521054     */
    1053     public function column_default( $comment, $column_name ) {
     1055    public function column_default( $item, $column_name ) {
    10541056        /**
    10551057         * Fires when the default column output is displayed for a single row.
     
    10601062         * @param int    $comment_id  The custom column's unique ID number.
    10611063         */
    1062         do_action( 'manage_comments_custom_column', $column_name, $comment->comment_ID );
     1064        do_action( 'manage_comments_custom_column', $column_name, $item->comment_ID );
    10631065    }
    10641066}
Note: See TracChangeset for help on using the changeset viewer.