From 38a8513cf2a58c9bbc0a48aff5868c919fde6ef7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 8 Oct 2019 17:56:02 +0000 Subject: [PATCH] Code Modernisation: Introduce the spread operator in `Walker::walk()` and `::paged_walk()`. Rather than relying on `func_get_args()` to retrieve arbitrary function arguments, we can now use the spread operator to assign them directly to a variable. This re-applies [45624] and reverts [45640], with a dev note upcoming for plugin authors to maintain backward compatibility with old versions of WordPress. Props jrf. See #47678. Built from https://develop.svn.wordpress.org/trunk@46442 git-svn-id: http://core.svn.wordpress.org/trunk@46240 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-walker.php | 10 +++++----- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-walker.php b/wp-includes/class-wp-walker.php index 50d63b6a99..0a764b9fc8 100644 --- a/wp-includes/class-wp-walker.php +++ b/wp-includes/class-wp-walker.php @@ -180,10 +180,10 @@ class Walker { * * @param array $elements An array of elements. * @param int $max_depth The maximum hierarchical depth. + * @param mixed ...$args Optional additional arguments. * @return string The hierarchical item output. */ - public function walk( $elements, $max_depth ) { - $args = array_slice( func_get_args(), 2 ); + public function walk( $elements, $max_depth, ...$args ) { $output = ''; //invalid parameter or nothing to walk @@ -272,16 +272,16 @@ class Walker { * * @param array $elements * @param int $max_depth The maximum hierarchical depth. - * @param int $page_num The specific page number, beginning with 1. + * @param int $page_num The specific page number, beginning with 1. * @param int $per_page + * @param mixed ...$args Optional additional arguments. * @return string XHTML of the specified page of elements */ - public function paged_walk( $elements, $max_depth, $page_num, $per_page ) { + public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$args ) { if ( empty( $elements ) || $max_depth < -1 ) { return ''; } - $args = array_slice( func_get_args(), 4 ); $output = ''; $parent_field = $this->db_fields['parent']; diff --git a/wp-includes/version.php b/wp-includes/version.php index b955cf31e8..3e285189f4 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-beta2-46441'; +$wp_version = '5.3-beta2-46442'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.