diff -r be944660c56a -r 3d72ae0968f4 wp/wp-includes/class-walker-page.php --- a/wp/wp-includes/class-walker-page.php Wed Sep 21 18:19:35 2022 +0200 +++ b/wp/wp-includes/class-walker-page.php Tue Sep 27 16:37:53 2022 +0200 @@ -30,7 +30,7 @@ * Database fields to use. * * @since 2.1.0 - * @var array + * @var string[] * * @see Walker::$db_fields * @todo Decouple this. @@ -93,14 +93,20 @@ * * @see Walker::start_el() * @since 2.1.0 + * @since 5.9.0 Renamed `$page` to `$data_object` and `$current_page` to `$current_object_id` + * to match parent class for PHP 8 named parameter support. * - * @param string $output Used to append additional content. Passed by reference. - * @param WP_Post $page Page data object. - * @param int $depth Optional. Depth of page. Used for padding. Default 0. - * @param array $args Optional. Array of arguments. Default empty array. - * @param int $current_page Optional. Page ID. Default 0. + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $data_object Page data object. + * @param int $depth Optional. Depth of page. Used for padding. Default 0. + * @param array $args Optional. Array of arguments. Default empty array. + * @param int $current_object_id Optional. ID of the current page. Default 0. */ - public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) { + public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) { + // Restores the more descriptive, specific name for use within this method. + $page = $data_object; + $current_page_id = $current_object_id; + if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { $t = "\t"; $n = "\n"; @@ -120,14 +126,14 @@ $css_class[] = 'page_item_has_children'; } - if ( ! empty( $current_page ) ) { - $_current_page = get_post( $current_page ); + if ( ! empty( $current_page_id ) ) { + $_current_page = get_post( $current_page_id ); if ( $_current_page && in_array( $page->ID, $_current_page->ancestors, true ) ) { $css_class[] = 'current_page_ancestor'; } - if ( $page->ID == $current_page ) { + if ( $page->ID == $current_page_id ) { $css_class[] = 'current_page_item'; } elseif ( $_current_page && $page->ID === $_current_page->post_parent ) { $css_class[] = 'current_page_parent'; @@ -143,13 +149,13 @@ * * @see wp_list_pages() * - * @param string[] $css_class An array of CSS classes to be applied to each list item. - * @param WP_Post $page Page data object. - * @param int $depth Depth of page, used for padding. - * @param array $args An array of arguments. - * @param int $current_page ID of the current page. + * @param string[] $css_class An array of CSS classes to be applied to each list item. + * @param WP_Post $page Page data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + * @param int $current_page_id ID of the current page. */ - $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) ); + $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page_id ) ); $css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : ''; if ( '' === $page->post_title ) { @@ -162,7 +168,7 @@ $atts = array(); $atts['href'] = get_permalink( $page->ID ); - $atts['aria-current'] = ( $page->ID == $current_page ) ? 'page' : ''; + $atts['aria-current'] = ( $page->ID == $current_page_id ) ? 'page' : ''; /** * Filters the HTML attributes applied to a page menu item's anchor element. @@ -175,12 +181,12 @@ * @type string $href The href attribute. * @type string $aria-current The aria-current attribute. * } - * @param WP_Post $page Page data object. - * @param int $depth Depth of page, used for padding. - * @param array $args An array of arguments. - * @param int $current_page ID of the current page. + * @param WP_Post $page Page data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + * @param int $current_page_id ID of the current page. */ - $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page ); + $atts = apply_filters( 'page_menu_link_attributes', $atts, $page, $depth, $args, $current_page_id ); $attributes = ''; foreach ( $atts as $attr => $value ) { @@ -216,15 +222,16 @@ * Outputs the end of the current element in the tree. * * @since 2.1.0 + * @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support. * * @see Walker::end_el() * - * @param string $output Used to append additional content. Passed by reference. - * @param WP_Post $page Page data object. Not used. - * @param int $depth Optional. Depth of page. Default 0 (unused). - * @param array $args Optional. Array of arguments. Default empty array. + * @param string $output Used to append additional content. Passed by reference. + * @param WP_Post $data_object Page data object. Not used. + * @param int $depth Optional. Depth of page. Default 0 (unused). + * @param array $args Optional. Array of arguments. Default empty array. */ - public function end_el( &$output, $page, $depth = 0, $args = array() ) { + public function end_el( &$output, $data_object, $depth = 0, $args = array() ) { if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) { $t = "\t"; $n = "\n";