Make WordPress Core


Ignore:
Timestamp:
09/09/2021 01:02:46 PM (3 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-page.php

    r51779 r51780  
    223223     *
    224224     * @since 2.1.0
     225     * @since 5.9.0 Renamed `$page` to `$data_object` to match parent class for PHP 8 named parameter support.
    225226     *
    226227     * @see Walker::end_el()
    227228     *
    228      * @param string  $output Used to append additional content. Passed by reference.
    229      * @param WP_Post $page  Page data object. Not used.
    230      * @param int     $depth  Optional. Depth of page. Default 0 (unused).
    231      * @param array   $args   Optional. Array of arguments. Default empty array.
    232      */
    233     public function end_el( &$output, $page, $depth = 0, $args = array() ) {
     229     * @param string  $output      Used to append additional content. Passed by reference.
     230     * @param WP_Post $data_object Page data object. Not used.
     231     * @param int     $depth       Optional. Depth of page. Default 0 (unused).
     232     * @param array   $args        Optional. Array of arguments. Default empty array.
     233     */
     234    public function end_el( &$output, $data_object, $depth = 0, $args = array() ) {
    234235        if ( isset( $args['item_spacing'] ) && 'preserve' === $args['item_spacing'] ) {
    235236            $t = "\t";
Note: See TracChangeset for help on using the changeset viewer.