Make WordPress Core

Opened 2 years ago

Last modified 2 years 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's profile hellofromTonya Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Menus Keywords: php8
Focuses: Cc:


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
2 years ago

  • Component changed from General to Menus

#2 @SergeyBiryukov
2 years 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
2 years 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.