WordPress.org

Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#53449 new defect (bug)

Child Walker classes change the $args parameter data type and default value signatures for start_el and end_el

Reported by: hellofromTonya Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords: php8
Focuses: Cc:

Description

The following Walker classes have code smells for changing the data type of the $args parameter when extending from the Walker::start_el and end_el:

  • Walker_Nav_Menu
  • Walker_Nav_Menu_Checklist
  • Walker_Nav_Menu_Edit

What is the code smell? The parent defines the $args parameter as an array data type with a default value of an empty array. The child classes change the parameter's data type to stdClass with a default value of null.

These changes need investigation to determine if these changes are needed and why.

Change History (3)

#1 @SergeyBiryukov
3 months ago

  • Component changed from General to Menus

#2 @SergeyBiryukov
3 months ago

Some history here: [13802], [14031], [14248], [19679], [25643], [38559], [45537], [47189].

There appears to be a long-time confusion about the data type of $args in these classes, due to an inconsistency with other walkers which always use it as an array.

#3 @SergeyBiryukov
3 months ago

Related: #18232, #24587, #37136, #37791, #50261.

As noted in comment:1:ticket:50261, the mismatch of the $args parameter between Walker_Nav_Menu and Walker is currently a known long-standing issue that cannot be easily fixed due to backward compatibility problems.

Note: See TracTickets for help on using tickets.