Make WordPress Core


Ignore:
Timestamp:
09/02/2021 10:25:58 PM (3 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-ms-users-list-table.php

    r49183 r51728  
    443443     *
    444444     * @since 4.3.0
    445      *
    446      * @param WP_User $user        The current WP_User object.
     445     * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named param.
     446     *
     447     * @param WP_User $item        The current WP_User object.
    447448     * @param string  $column_name The current column name.
    448449     */
    449     public function column_default( $user, $column_name ) {
     450    public function column_default( $item, $column_name ) {
    450451        /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */
    451         echo apply_filters( 'manage_users_custom_column', '', $column_name, $user->ID );
     452        echo apply_filters(
     453            'manage_users_custom_column',
     454            '', // Custom column output. Default empty.
     455            $column_name,
     456            $item->ID // User ID.
     457        );
    452458    }
    453459
Note: See TracChangeset for help on using the changeset viewer.