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:
@@ -256,15 +256,16 @@ class Walker_Nav_Menu extends Walker {
|
||||
* Ends the element output, if needed.
|
||||
*
|
||||
* @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()
|
||||
*
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Post $item Page data object. Not used.
|
||||
* @param int $depth Depth of page. Not Used.
|
||||
* @param stdClass $args An object of wp_nav_menu() arguments.
|
||||
* @param string $output Used to append additional content (passed by reference).
|
||||
* @param WP_Post $data_object Menu item data object. Not used.
|
||||
* @param int $depth Depth of page. Not Used.
|
||||
* @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 ) {
|
||||
$t = '';
|
||||
$n = '';
|
||||
|
||||
Reference in New Issue
Block a user