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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51780 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork
2021-09-09 13:02:46 +00:00
parent 47a3b90231
commit e96aa67fe1
6 changed files with 43 additions and 32 deletions
+6 -5
View File
@@ -100,14 +100,15 @@ class Walker {
* 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.