Wordpress - Error: Declaration of MyClass::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl()

From class Walker_Nav_Menu:

function start_lvl( &$output, $depth = 0, $args = array() )

Your child class must use the same signature: three arguments, the first one passed by reference. Every difference will raise the error you got.

Note that $args defaults to an empty array, but you get an instance of stdClass, not an array. This is WordPress.


From class Walker_Nav_Menu replace this lines

function start_el(&$output, $category, $depth, $args) {

to

function start_el(&$output, $category, $depth = 0, $args = array(), $current_object_id = 0) {

function end_lvl(&$output, $depth, $args) {

to

function end_lvl(&$output, $depth = 0, $args = array()) {

function start_lvl(&$output, $depth, $args) {

to

function start_lvl(&$output, $depth = 0, $args = array()) {

function end_el(&$output, $category, $depth, $args) {

to

function end_el(&$output, $category, $depth = 0, $args = array()) {