Make WordPress Core

Changeset 53003


Ignore:
Timestamp:
03/28/2022 01:22:38 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Code Modernization: Rename parameters that use reserved keywords in wp-admin/includes/class-wp-debug-data.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 $var parameter to $mysql_var in WP_Debug_Data::get_mysql_var().

Additionally, $type is renamed to $data_type in WP_Debug_Data::format() for clarity.

Follow-up to [51522], [52946], [52996], [52997], [52998].

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r52021 r53003  
    14721472
    14731473    /**
    1474      * Returns the value of a MySQL variable.
     1474     * Returns the value of a MySQL system variable.
    14751475     *
    14761476     * @since 5.9.0
     
    14781478     * @global wpdb $wpdb WordPress database abstraction object.
    14791479     *
    1480      * @param string $var Name of the MySQL variable.
     1480     * @param string $mysql_var Name of the MySQL system variable.
    14811481     * @return string|null The variable value on success. Null if the variable does not exist.
    14821482     */
    1483     public static function get_mysql_var( $var ) {
     1483    public static function get_mysql_var( $mysql_var ) {
    14841484        global $wpdb;
    14851485
    14861486        $result = $wpdb->get_row(
    1487             $wpdb->prepare( 'SHOW VARIABLES LIKE %s', $var ),
     1487            $wpdb->prepare( 'SHOW VARIABLES LIKE %s', $mysql_var ),
    14881488            ARRAY_A
    14891489        );
     
    15011501     * @since 5.2.0
    15021502     *
    1503      * @param array  $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
    1504      * @param string $type       The data type to return, either 'info' or 'debug'.
     1503     * @param array  $info_array Information gathered from the `WP_Debug_Data::debug_data()` function.
     1504     * @param string $data_type  The data type to return, either 'info' or 'debug'.
    15051505     * @return string The formatted data.
    15061506     */
    1507     public static function format( $info_array, $type ) {
     1507    public static function format( $info_array, $data_type ) {
    15081508        $return = "`\n";
    15091509
     
    15141514            }
    15151515
    1516             $section_label = 'debug' === $type ? $section : $details['label'];
     1516            $section_label = 'debug' === $data_type ? $section : $details['label'];
    15171517
    15181518            $return .= sprintf(
     
    15271527                }
    15281528
    1529                 if ( 'debug' === $type && isset( $field['debug'] ) ) {
     1529                if ( 'debug' === $data_type && isset( $field['debug'] ) ) {
    15301530                    $debug_data = $field['debug'];
    15311531                } else {
     
    15481548                }
    15491549
    1550                 if ( 'debug' === $type ) {
     1550                if ( 'debug' === $data_type ) {
    15511551                    $label = $field_name;
    15521552                } else {
Note: See TracChangeset for help on using the changeset viewer.