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

    r50978 r51728  
    856856     *
    857857     * @since 4.3.0
    858      *
    859      * @param WP_Theme $theme       The current WP_Theme object.
     858     * @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named param.
     859     *
     860     * @param WP_Theme $item        The current WP_Theme object.
    860861     * @param string   $column_name The current column name.
    861862     */
    862     public function column_default( $theme, $column_name ) {
    863         $stylesheet = $theme->get_stylesheet();
    864 
     863    public function column_default( $item, $column_name ) {
    865864        /**
    866865         * Fires inside each custom column of the Multisite themes list table.
     
    872871         * @param WP_Theme $theme       Current WP_Theme object.
    873872         */
    874         do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme );
     873        do_action(
     874            'manage_themes_custom_column',
     875            $column_name,
     876            $item->get_stylesheet(), // Directory name of the theme.
     877            $item // Theme object.
     878        );
    875879    }
    876880
Note: See TracChangeset for help on using the changeset viewer.