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

    r50780 r51728  
    621621
    622622    /**
    623      * @param WP_Term $tag         Term object.
     623     * @since 5.9.0 Renamed `$tag` to `$item` to match parent class for PHP 8 named param.
     624     *
     625     * @param WP_Term $item        Term object.
    624626     * @param string  $column_name Name of the column.
    625627     * @return string
    626628     */
    627     public function column_default( $tag, $column_name ) {
     629    public function column_default( $item, $column_name ) {
    628630        /**
    629631         * Filters the displayed columns in the terms list table.
     
    639641         * @since 2.8.0
    640642         *
    641          * @param string $string      Blank string.
     643         * @param string $string      Custom column output. Default empty.
    642644         * @param string $column_name Name of the column.
    643645         * @param int    $term_id     Term ID.
    644646         */
    645         return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
     647        return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id );
    646648    }
    647649
Note: See TracChangeset for help on using the changeset viewer.