Skip to content

Commit

Permalink
Code Modernization: Rename parameters that use reserved keywords in `…
Browse files Browse the repository at this point in the history
…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.
Built from https://develop.svn.wordpress.org/trunk@53003


git-svn-id: http://core.svn.wordpress.org/trunk@52592 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
SergeyBiryukov committed Mar 28, 2022
1 parent c3a76d0 commit 8761c4c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions wp-admin/includes/class-wp-debug-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -1471,20 +1471,20 @@ public static function debug_data() {
}

/**
* Returns the value of a MySQL variable.
* Returns the value of a MySQL system variable.
*
* @since 5.9.0
*
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param string $var Name of the MySQL variable.
* @param string $mysql_var Name of the MySQL system variable.
* @return string|null The variable value on success. Null if the variable does not exist.
*/
public static function get_mysql_var( $var ) {
public static function get_mysql_var( $mysql_var ) {
global $wpdb;

$result = $wpdb->get_row(
$wpdb->prepare( 'SHOW VARIABLES LIKE %s', $var ),
$wpdb->prepare( 'SHOW VARIABLES LIKE %s', $mysql_var ),
ARRAY_A
);

Expand All @@ -1500,11 +1500,11 @@ public static function get_mysql_var( $var ) {
*
* @since 5.2.0
*
* @param array $info_array Information gathered from the `WP_Debug_Data::debug_data` function.
* @param string $type The data type to return, either 'info' or 'debug'.
* @param array $info_array Information gathered from the `WP_Debug_Data::debug_data()` function.
* @param string $data_type The data type to return, either 'info' or 'debug'.
* @return string The formatted data.
*/
public static function format( $info_array, $type ) {
public static function format( $info_array, $data_type ) {
$return = "`\n";

foreach ( $info_array as $section => $details ) {
Expand All @@ -1513,7 +1513,7 @@ public static function format( $info_array, $type ) {
continue;
}

$section_label = 'debug' === $type ? $section : $details['label'];
$section_label = 'debug' === $data_type ? $section : $details['label'];

$return .= sprintf(
"### %s%s ###\n\n",
Expand All @@ -1526,7 +1526,7 @@ public static function format( $info_array, $type ) {
continue;
}

if ( 'debug' === $type && isset( $field['debug'] ) ) {
if ( 'debug' === $data_type && isset( $field['debug'] ) ) {
$debug_data = $field['debug'];
} else {
$debug_data = $field['value'];
Expand All @@ -1547,7 +1547,7 @@ public static function format( $info_array, $type ) {
$value = $debug_data;
}

if ( 'debug' === $type ) {
if ( 'debug' === $data_type ) {
$label = $field_name;
} else {
$label = $field['label'];
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-53002';
$wp_version = '6.0-alpha-53003';

/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
Expand Down

0 comments on commit 8761c4c

Please sign in to comment.