wp/wp-includes/class-wp-walker.php
changeset 19 3d72ae0968f4
parent 18 be944660c56a
child 21 48c4eec2b7e6
--- a/wp/wp-includes/class-wp-walker.php	Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/class-wp-walker.php	Tue Sep 27 16:37:53 2022 +0200
@@ -24,12 +24,12 @@
 	 * DB fields to use.
 	 *
 	 * @since 2.1.0
-	 * @var array
+	 * @var string[]
 	 */
 	public $db_fields;
 
 	/**
-	 * Max number of pages walked by the paged walker
+	 * Max number of pages walked by the paged walker.
 	 *
 	 * @since 2.7.0
 	 * @var int
@@ -77,21 +77,22 @@
 	public function end_lvl( &$output, $depth = 0, $args = array() ) {}
 
 	/**
-	 * Start the element output.
+	 * Starts the element output.
 	 *
 	 * The $args parameter holds additional values that may be used with the child
-	 * class methods. Includes the element output also.
+	 * class methods. Also includes the element output.
 	 *
 	 * @since 2.1.0
+	 * @since 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.
 	 * @abstract
 	 *
 	 * @param string $output            Used to append additional content (passed by reference).
-	 * @param object $object            The data object.
+	 * @param object $data_object       The data object.
 	 * @param int    $depth             Depth of the item.
 	 * @param array  $args              An array of additional arguments.
-	 * @param int    $current_object_id ID of the current item.
+	 * @param int    $current_object_id Optional. ID of the current item. Default 0.
 	 */
-	public function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
+	public function start_el( &$output, $data_object, $depth = 0, $args = array(), $current_object_id = 0 ) {}
 
 	/**
 	 * Ends the element output, if needed.
@@ -99,17 +100,18 @@
 	 * The $args parameter holds additional values that may be used with the child class methods.
 	 *
 	 * @since 2.1.0
+	 * @since 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.
 	 * @abstract
 	 *
-	 * @param string $output Used to append additional content (passed by reference).
-	 * @param object $object The data object.
-	 * @param int    $depth  Depth of the item.
-	 * @param array  $args   An array of additional arguments.
+	 * @param string $output      Used to append additional content (passed by reference).
+	 * @param object $data_object The data object.
+	 * @param int    $depth       Depth of the item.
+	 * @param array  $args        An array of additional arguments.
 	 */
-	public function end_el( &$output, $object, $depth = 0, $args = array() ) {}
+	public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {}
 
 	/**
-	 * Traverse elements to create list from elements.
+	 * Traverses elements to create list from elements.
 	 *
 	 * Display one element if the element doesn't have any children otherwise,
 	 * display the element and its children. Will only traverse up to the max
@@ -168,7 +170,7 @@
 	}
 
 	/**
-	 * Display array of elements hierarchically.
+	 * Displays array of elements hierarchically.
 	 *
 	 * Does not assume any existing order of elements.
 	 *
@@ -207,7 +209,7 @@
 		/*
 		 * Need to display in hierarchical order.
 		 * Separate elements into two buckets: top level and children elements.
-		 * Children_elements is two dimensional array, eg.
+		 * Children_elements is two dimensional array. Example:
 		 * Children_elements[10][] contains all sub-elements whose parent is 10.
 		 */
 		$top_level_elements = array();
@@ -261,7 +263,7 @@
 	}
 
 	/**
-	 * paged_walk() - produce a page of nested elements
+	 * Produces a page of nested elements.
 	 *
 	 * Given an array of hierarchical elements, the maximum depth, a specific page number,
 	 * and number of elements per page, this function first determines all top level root elements
@@ -274,12 +276,12 @@
 	 * @since 5.3.0 Formalized the existing `...$args` parameter by adding it
 	 *              to the function signature.
 	 *
-	 * @param array $elements
+	 * @param array $elements  An array of elements.
 	 * @param int   $max_depth The maximum hierarchical depth.
 	 * @param int   $page_num  The specific page number, beginning with 1.
-	 * @param int   $per_page
+	 * @param int   $per_page  Number of elements per page.
 	 * @param mixed ...$args   Optional additional arguments.
-	 * @return string XHTML of the specified page of elements
+	 * @return string XHTML of the specified page of elements.
 	 */
 	public function paged_walk( $elements, $max_depth, $page_num, $per_page, ...$args ) {
 		if ( empty( $elements ) || $max_depth < -1 ) {
@@ -420,20 +422,20 @@
 	}
 
 	/**
-	 * Unset all the children for a given top level element.
+	 * Unsets all the children for a given top level element.
 	 *
 	 * @since 2.7.0
 	 *
-	 * @param object $e
-	 * @param array  $children_elements
+	 * @param object $element           The top level element.
+	 * @param array  $children_elements The children elements.
 	 */
-	public function unset_children( $e, &$children_elements ) {
-		if ( ! $e || ! $children_elements ) {
+	public function unset_children( $element, &$children_elements ) {
+		if ( ! $element || ! $children_elements ) {
 			return;
 		}
 
 		$id_field = $this->db_fields['id'];
-		$id       = $e->$id_field;
+		$id       = $element->$id_field;
 
 		if ( ! empty( $children_elements[ $id ] ) && is_array( $children_elements[ $id ] ) ) {
 			foreach ( (array) $children_elements[ $id ] as $child ) {