[wp-trac] [WordPress Trac] #50261: Walker_Nav_Menu doc block is wrong
WordPress Trac
noreply at wordpress.org
Wed May 27 09:06:16 UTC 2020
#50261: Walker_Nav_Menu doc block is wrong
--------------------------+-----------------------------
Reporter: dingo_d | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version:
Severity: normal | Keywords: needs-patch
Focuses: docs |
--------------------------+-----------------------------
The docblock parameters of class Walker_Nav_Menu
(https://developer.wordpress.org/reference/classes/walker_nav_menu/)
should be compatible with Walker class
(https://developer.wordpress.org/reference/classes/walker/)
For instance, we have in `Walker_Nav_Menu`
{{{#!php
<?php
/**
* Starts the list before the elements are added.
*
* @since 3.0.0
*
* @see Walker::start_lvl()
*
* @param string $output Used to append additional content (passed
by reference).
* @param int $depth Depth of menu item. Used for padding.
* @param stdClass $args An object of wp_nav_menu() arguments.
*/
public function start_lvl( &$output, $depth = 0, $args = null ) {
}}}
Whereas the `Walker` class has
{{{#!php
<?php
/**
* Starts the list before the elements are added.
*
* The $args parameter holds additional values that may be used with
the child
* class methods. This method is called at the start of the output
list.
*
* @since 2.1.0
* @abstract
*
* @param string $output Used to append additional content (passed by
reference).
* @param int $depth Depth of the item.
* @param array $args An array of additional arguments.
*/
public function start_lvl( &$output, $depth = 0, $args = array() ) {}
}}}
Notice the `stdClass` typehint in the `Walker_Nav_Menu` class in the third
argument, that should be `array`.
This inconsistency throws tons of false-positive errors when running
PHPStan analysis.
Other methods should be fixed as well, and any classes that extend the
`Walker` class should be checked.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50261>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list