Make WordPress Core


Ignore:
Timestamp:
09/09/2021 01:02:46 PM (4 years ago)
Author:
hellofromTonya
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-walker-nav-menu.php

    r51779 r51780  
    257257     *
    258258     * @since 3.0.0
     259     * @since 5.9.0 Renamed `$item` to `$data_object` to match parent class for PHP 8 named parameter support.
    259260     *
    260261     * @see Walker::end_el()
    261262     *
    262      * @param string   $output Used to append additional content (passed by reference).
    263      * @param WP_Post  $item   Page data object. Not used.
    264      * @param int      $depth  Depth of page. Not Used.
    265      * @param stdClass $args   An object of wp_nav_menu() arguments.
    266      */
    267     public function end_el( &$output, $item, $depth = 0, $args = null ) {
     263     * @param string   $output      Used to append additional content (passed by reference).
     264     * @param WP_Post  $data_object Menu item data object. Not used.
     265     * @param int      $depth       Depth of page. Not Used.
     266     * @param stdClass $args        An object of wp_nav_menu() arguments.
     267     */
     268    public function end_el( &$output, $data_object, $depth = 0, $args = null ) {
    268269        if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) {
    269270            $t = '';
Note: See TracChangeset for help on using the changeset viewer.