Code Modernization: Fix reserved keyword and parameter name mismatches for parent/child classes in `Walker::end_el()`.
In the parent class, renames the parameter `$object` to `$data_object`. Why? `object` is a PHP reserved keyword. The parameter name is selected for consistency with `Walker::start_el()`. In each child class: renames the parameter to match the parent's method signature. Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match. Changes for readability: - `@since` clearly specifies the original parameter name and its new name as well as why the change happened. Follow-up to [7737], [8900], [8970], [14248], [16100], [25642], [25644], [37051], [37056]. Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion. See #51553. Built from https://develop.svn.wordpress.org/trunk@51780 git-svn-id: http://core.svn.wordpress.org/trunk@51387 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
7abc752329
commit
a395d4c50e
|
@ -125,13 +125,14 @@ class Walker_Category_Checklist extends Walker {
|
||||||
* @see Walker::end_el()
|
* @see Walker::end_el()
|
||||||
*
|
*
|
||||||
* @since 2.5.1
|
* @since 2.5.1
|
||||||
|
* @since 5.9.0 Renamed `$category` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||||
*
|
*
|
||||||
* @param string $output Used to append additional content (passed by reference).
|
* @param string $output Used to append additional content (passed by reference).
|
||||||
* @param WP_Term $category The current term object.
|
* @param WP_Term $data_object The current term object.
|
||||||
* @param int $depth Depth of the term in reference to parents. Default 0.
|
* @param int $depth Depth of the term in reference to parents. Default 0.
|
||||||
* @param array $args An array of arguments. @see wp_terms_checklist()
|
* @param array $args An array of arguments. @see wp_terms_checklist()
|
||||||
*/
|
*/
|
||||||
public function end_el( &$output, $category, $depth = 0, $args = array() ) {
|
public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
|
||||||
$output .= "</li>\n";
|
$output .= "</li>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,16 +254,17 @@ class Walker_Category extends Walker {
|
||||||
* Ends the element output, if needed.
|
* Ends the element output, if needed.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @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()
|
* @see Walker::end_el()
|
||||||
*
|
*
|
||||||
* @param string $output Used to append additional content (passed by reference).
|
* @param string $output Used to append additional content (passed by reference).
|
||||||
* @param object $page Not used.
|
* @param object $data_object Category data object. Not used.
|
||||||
* @param int $depth Optional. Depth of category. Not used.
|
* @param int $depth Optional. Depth of category. Not used.
|
||||||
* @param array $args Optional. An array of arguments. Only uses 'list' for whether should append
|
* @param array $args Optional. An array of arguments. Only uses 'list' for whether should
|
||||||
* to output. See wp_list_categories(). Default empty array.
|
* append to output. See wp_list_categories(). 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 ( 'list' !== $args['style'] ) {
|
if ( 'list' !== $args['style'] ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,19 +213,25 @@ class Walker_Comment extends Walker {
|
||||||
* Ends the element output, if needed.
|
* Ends the element output, if needed.
|
||||||
*
|
*
|
||||||
* @since 2.7.0
|
* @since 2.7.0
|
||||||
|
* @since 5.9.0 Renamed `$comment` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||||
*
|
*
|
||||||
* @see Walker::end_el()
|
* @see Walker::end_el()
|
||||||
* @see wp_list_comments()
|
* @see wp_list_comments()
|
||||||
*
|
*
|
||||||
* @param string $output Used to append additional content. Passed by reference.
|
* @param string $output Used to append additional content. Passed by reference.
|
||||||
* @param WP_Comment $comment The current comment object. Default current comment.
|
* @param WP_Comment $data_object Comment data object.
|
||||||
* @param int $depth Optional. Depth of the current comment. Default 0.
|
* @param int $depth Optional. Depth of the current comment. Default 0.
|
||||||
* @param array $args Optional. An array of arguments. Default empty array.
|
* @param array $args Optional. An array of arguments. Default empty array.
|
||||||
*/
|
*/
|
||||||
public function end_el( &$output, $comment, $depth = 0, $args = array() ) {
|
public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
|
||||||
if ( ! empty( $args['end-callback'] ) ) {
|
if ( ! empty( $args['end-callback'] ) ) {
|
||||||
ob_start();
|
ob_start();
|
||||||
call_user_func( $args['end-callback'], $comment, $args, $depth );
|
call_user_func(
|
||||||
|
$args['end-callback'],
|
||||||
|
$data_object, // The current comment object.
|
||||||
|
$args,
|
||||||
|
$depth
|
||||||
|
);
|
||||||
$output .= ob_get_clean();
|
$output .= ob_get_clean();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,15 +256,16 @@ class Walker_Nav_Menu extends Walker {
|
||||||
* Ends the element output, if needed.
|
* Ends the element output, if needed.
|
||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
|
* @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
|
||||||
*
|
*
|
||||||
* @see Walker::end_el()
|
* @see Walker::end_el()
|
||||||
*
|
*
|
||||||
* @param string $output Used to append additional content (passed by reference).
|
* @param string $output Used to append additional content (passed by reference).
|
||||||
* @param WP_Post $item Page data object. Not used.
|
* @param WP_Post $data_object Menu item data object. Not used.
|
||||||
* @param int $depth Depth of page. Not Used.
|
* @param int $depth Depth of page. Not Used.
|
||||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||||
*/
|
*/
|
||||||
public function end_el( &$output, $item, $depth = 0, $args = null ) {
|
public function end_el( &$output, $data_object, $depth = 0, $args = null ) {
|
||||||
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
|
if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
|
||||||
$t = '';
|
$t = '';
|
||||||
$n = '';
|
$n = '';
|
||||||
|
|
|
@ -222,15 +222,16 @@ class Walker_Page extends Walker {
|
||||||
* Outputs the end of the current element in the tree.
|
* Outputs the end of the current element in the tree.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @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()
|
* @see Walker::end_el()
|
||||||
*
|
*
|
||||||
* @param string $output Used to append additional content. Passed by reference.
|
* @param string $output Used to append additional content. Passed by reference.
|
||||||
* @param WP_Post $page Page data object. Not used.
|
* @param WP_Post $data_object Page data object. Not used.
|
||||||
* @param int $depth Optional. Depth of page. Default 0 (unused).
|
* @param int $depth Optional. Depth of page. Default 0 (unused).
|
||||||
* @param array $args Optional. Array of arguments. Default empty array.
|
* @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'] ) {
|
if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {
|
||||||
$t = "\t";
|
$t = "\t";
|
||||||
$n = "\n";
|
$n = "\n";
|
||||||
|
|
|
@ -100,14 +100,15 @@ class Walker {
|
||||||
* The $args parameter holds additional values that may be used with the child class methods.
|
* The $args parameter holds additional values that may be used with the child class methods.
|
||||||
*
|
*
|
||||||
* @since 2.1.0
|
* @since 2.1.0
|
||||||
|
* @since 5.9.0 Renamed `$object` (a PHP reserved keyword) to `$data_object` for PHP 8 named parameter support.
|
||||||
* @abstract
|
* @abstract
|
||||||
*
|
*
|
||||||
* @param string $output Used to append additional content (passed by reference).
|
* @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 int $depth Depth of the item.
|
||||||
* @param array $args An array of additional arguments.
|
* @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.
|
* Traverse elements to create list from elements.
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.9-alpha-51779';
|
$wp_version = '5.9-alpha-51780';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue