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

    r51734 r51735  
    388388     *
    389389     * @since 4.3.0
    390      *
    391      * @param WP_Post $post The current WP_Post object.
    392      */
    393     public function column_cb( $post ) {
     390     * @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
     391     *
     392     * @param WP_Post $item The current WP_Post object.
     393     */
     394    public function column_cb( $item ) {
     395        // Restores the more descriptive, specific name for use within this method.
     396        $post = $item;
     397
    394398        if ( current_user_can( 'edit_post', $post->ID ) ) {
    395399            ?>
Note: See TracChangeset for help on using the changeset viewer.