Skip to content

Commit 9bebc4e

Browse files
committed
Simplify and modernize wc_walk_category_dropdown_tree()
This commit replaces calls to call_user_func_array() and func_get_args() with the spread operation. Both to make more explicit that this is a variadic function and to do argument unpacking when calling the walker method.
1 parent 193395d commit 9bebc4e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

includes/wc-term-functions.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,10 @@ function wc_product_dropdown_categories( $args = array() ) {
253253
*
254254
* Previously used by wc_product_dropdown_categories, but wp_dropdown_categories has been fixed in core.
255255
*
256+
* @param mixed ...$args Variable number of parameters to be passed to the walker.
256257
* @return mixed
257258
*/
258-
function wc_walk_category_dropdown_tree() {
259-
$args = func_get_args();
260-
259+
function wc_walk_category_dropdown_tree( ...$args ) {
261260
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) {
262261
include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';
263262
}
@@ -269,7 +268,7 @@ function wc_walk_category_dropdown_tree() {
269268
$walker = $args[2]['walker'];
270269
}
271270

272-
return call_user_func_array( array( &$walker, 'walk' ), $args );
271+
return $walker->walk( ...$args );
273272
}
274273

275274
/**

0 commit comments

Comments
 (0)