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
This commit is contained in:
Sergey Biryukov 2022-04-15 10:50:15 +00:00
parent 189a047cb8
commit 7a9741db46

View File

@ -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;