Code Modernization: Rename parameters that use reserved keywords in `wp-includes/functions.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 `$array` parameter to `$input_array` in `wp_recursive_ksort()`.
* Moves the function next to other array-related functions for consistency.

Follow-up to [53129], [54929].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55117


git-svn-id: http://core.svn.wordpress.org/trunk@54650 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2023-01-23 15:54:10 +00:00
parent a864df149a
commit 227ba555ae
2 changed files with 21 additions and 19 deletions

View File

@ -4876,6 +4876,26 @@ function wp_array_slice_assoc( $input_array, $keys ) {
return $slice;
}
/**
* Sorts the keys of an array alphabetically.
*
* The array is passed by reference so it doesn't get returned
* which mimics the behavior of `ksort()`.
*
* @since 6.0.0
*
* @param array $input_array The array to sort, passed by reference.
*/
function wp_recursive_ksort( &$input_array ) {
foreach ( $input_array as &$value ) {
if ( is_array( $value ) ) {
wp_recursive_ksort( $value );
}
}
ksort( $input_array );
}
/**
* Accesses an array in depth based on a path of keys.
*
@ -8429,21 +8449,3 @@ function is_php_version_compatible( $required ) {
function wp_fuzzy_number_match( $expected, $actual, $precision = 1 ) {
return abs( (float) $expected - (float) $actual ) <= $precision;
}
/**
* Sorts the keys of an array alphabetically.
* The array is passed by reference so it doesn't get returned
* which mimics the behavior of ksort.
*
* @since 6.0.0
*
* @param array $array The array to sort, passed by reference.
*/
function wp_recursive_ksort( &$array ) {
foreach ( $array as &$value ) {
if ( is_array( $value ) ) {
wp_recursive_ksort( $value );
}
}
ksort( $array );
}

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55116';
$wp_version = '6.2-alpha-55117';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.