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

    r51734 r51735  
    869869
    870870    /**
    871      * @param WP_Comment $comment The comment object.
    872      */
    873     public function column_cb( $comment ) {
     871     * @since 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.
     872     *
     873     * @param WP_Comment $item The comment object.
     874     */
     875    public function column_cb( $item ) {
     876        // Restores the more descriptive, specific name for use within this method.
     877        $comment = $item;
     878
    874879        if ( $this->user_can ) {
    875880            ?>
Note: See TracChangeset for help on using the changeset viewer.