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

    r51520 r51728  
    12361236     *
    12371237     * @since 4.3.0
    1238      *
    1239      * @param WP_Post $post        The current WP_Post object.
     1238     * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named param.
     1239     *
     1240     * @param WP_Post $item        The current WP_Post object.
    12401241     * @param string  $column_name The current column name.
    12411242     */
    1242     public function column_default( $post, $column_name ) {
     1243    public function column_default( $item, $column_name ) {
     1244        // Restores the more descriptive, specific name for use within this method.
     1245        $post = $item;
     1246
    12431247        if ( 'categories' === $column_name ) {
    12441248            $taxonomy = 'category';
Note: See TracChangeset for help on using the changeset viewer.