Make WordPress Core

Changeset 53185


Ignore:
Timestamp:
04/15/2022 10:50:15 AM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/list-table.php.

While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the $class parameter to $class_name in _get_list_table().

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #55327.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/list-table.php

    r49927 r53185  
    1616 * @global string $hook_suffix
    1717 *
    18  * @param string $class The type of the list table, which is the class name.
    19  * @param array  $args  Optional. Arguments to pass to the class. Accepts 'screen'.
     18 * @param string $class_name The type of the list table, which is the class name.
     19 * @param array  $args       Optional. Arguments to pass to the class. Accepts 'screen'.
    2020 * @return WP_List_Table|false List table object on success, false if the class does not exist.
    2121 */
    22 function _get_list_table( $class, $args = array() ) {
     22function _get_list_table( $class_name, $args = array() ) {
    2323    $core_classes = array(
    2424        // Site Admin.
     
    4646    );
    4747
    48     if ( isset( $core_classes[ $class ] ) ) {
    49         foreach ( (array) $core_classes[ $class ] as $required ) {
     48    if ( isset( $core_classes[ $class_name ] ) ) {
     49        foreach ( (array) $core_classes[ $class_name ] as $required ) {
    5050            require_once ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php';
    5151        }
     
    5959        }
    6060
    61         return new $class( $args );
     61        return new $class_name( $args );
    6262    }
    6363
Note: See TracChangeset for help on using the changeset viewer.