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

    r50120 r51728  
    280280     *
    281281     * @since 4.3.0
    282      *
    283      * @param object $link        Link object.
     282     * @since 5.9.0 Renamed `$link` to `$item` to match parent class for PHP 8 named param.
     283     *
     284     * @param object $item        Link object.
    284285     * @param string $column_name Current column name.
    285286     */
    286     public function column_default( $link, $column_name ) {
     287    public function column_default( $item, $column_name ) {
    287288        /**
    288289         * Fires for each registered custom link column.
     
    293294         * @param int    $link_id     Link ID.
    294295         */
    295         do_action( 'manage_link_custom_column', $column_name, $link->link_id );
     296        do_action( 'manage_link_custom_column', $column_name, $item->link_id );
    296297    }
    297298
Note: See TracChangeset for help on using the changeset viewer.