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-terms-list-table.php

    r51734 r51735  
    365365
    366366    /**
    367      * @param WP_Term $tag Term object.
     367     * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named parameter support.
     368     *
     369     * @param WP_Term $item Term object.
    368370     * @return string
    369371     */
    370     public function column_cb( $tag ) {
     372    public function column_cb( $item ) {
     373        // Restores the more descriptive, specific name for use within this method.
     374        $tag = $item;
     375
    371376        if ( current_user_can( 'delete_term', $tag->term_id ) ) {
    372377            return sprintf(
Note: See TracChangeset for help on using the changeset viewer.