From e5a17836c71182763010563c3c9fce2c772a7d14 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 15 Sep 2019 10:32:54 +0000 Subject: [PATCH] Code Modernisation: Introduce the spread operator in `wp-includes/category-template.php`. Rather than relying `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable. Props jrf. See #47678. git-svn-id: https://develop.svn.wordpress.org/trunk@46123 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/category-template.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/wp-includes/category-template.php b/src/wp-includes/category-template.php index e10545c862..56cbdf7b7f 100644 --- a/src/wp-includes/category-template.php +++ b/src/wp-includes/category-template.php @@ -1056,18 +1056,19 @@ function _wp_object_count_sort_cb( $a, $b ) { * * @uses Walker_Category to create HTML list content. * @since 2.1.0 - * @see Walker_Category::walk() for parameters and return description. + * @see Walker::walk() for parameters and return description. + * + * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. * @return string */ -function walk_category_tree() { - $args = func_get_args(); - // the user's options are the third parameter +function walk_category_tree( ...$args ) { + // The user's options are the third parameter. if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) { $walker = new Walker_Category; } else { $walker = $args[2]['walker']; } - return call_user_func_array( array( $walker, 'walk' ), $args ); + return $walker->walk( ...$args ); } /** @@ -1075,18 +1076,19 @@ function walk_category_tree() { * * @uses Walker_CategoryDropdown to create HTML dropdown content. * @since 2.1.0 - * @see Walker_CategoryDropdown::walk() for parameters and return description. + * @see Walker::walk() for parameters and return description. + * + * @param mixed ...$args Elements array, maximum hierarchical depth and optional additional arguments. * @return string */ -function walk_category_dropdown_tree() { - $args = func_get_args(); - // the user's options are the third parameter +function walk_category_dropdown_tree( ...$args ) { + // The user's options are the third parameter. if ( empty( $args[2]['walker'] ) || ! ( $args[2]['walker'] instanceof Walker ) ) { $walker = new Walker_CategoryDropdown; } else { $walker = $args[2]['walker']; } - return call_user_func_array( array( $walker, 'walk' ), $args ); + return $walker->walk( ...$args ); } //