From 7a9741db468199d3d094ab1a057dec3fdbfa2ec6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Fri, 15 Apr 2022 10:50:15 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@53185 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/list-table.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/includes/list-table.php b/src/wp-admin/includes/list-table.php index fbf248599a..43d00e6958 100644 --- a/src/wp-admin/includes/list-table.php +++ b/src/wp-admin/includes/list-table.php @@ -15,11 +15,11 @@ * * @global string $hook_suffix * - * @param string $class The type of the list table, which is the class name. - * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'. + * @param string $class_name The type of the list table, which is the class name. + * @param array $args Optional. Arguments to pass to the class. Accepts 'screen'. * @return WP_List_Table|false List table object on success, false if the class does not exist. */ -function _get_list_table( $class, $args = array() ) { +function _get_list_table( $class_name, $args = array() ) { $core_classes = array( // Site Admin. 'WP_Posts_List_Table' => 'posts', @@ -45,8 +45,8 @@ function _get_list_table( $class, $args = array() ) { 'WP_Privacy_Data_Removal_Requests_List_Table' => 'privacy-data-removal-requests', ); - if ( isset( $core_classes[ $class ] ) ) { - foreach ( (array) $core_classes[ $class ] as $required ) { + if ( isset( $core_classes[ $class_name ] ) ) { + foreach ( (array) $core_classes[ $class_name ] as $required ) { require_once ABSPATH . 'wp-admin/includes/class-wp-' . $required . '-list-table.php'; } @@ -58,7 +58,7 @@ function _get_list_table( $class, $args = array() ) { $args['screen'] = null; } - return new $class( $args ); + return new $class_name( $args ); } return false;