Make WordPress Core


Ignore:
Timestamp:
09/07/2021 06:18:10 PM (3 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

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

    r51734 r51735  
    228228     *
    229229     * @since 4.3.0
    230      *
    231      * @param WP_User $user The current WP_User object.
    232      */
    233     public function column_cb( $user ) {
     230     * @since 5.9.0 Renamed `$user` to `$item` to match parent class for PHP 8 named parameter support.
     231     *
     232     * @param WP_User $item The current WP_User object.
     233     */
     234    public function column_cb( $item ) {
     235        // Restores the more descriptive, specific name for use within this method.
     236        $user = $item;
     237
    234238        if ( is_super_admin( $user->ID ) ) {
    235239            return;
Note: See TracChangeset for help on using the changeset viewer.