May not be exactly what you are after, but you could take a look at the Bootstrap Nav Walker implementation.
In the documentation, there’s also an example for manually calling your own walker class which may be worth a read if you haven’t done so already.
class Walker_Quickstart_Menu extends Walker {
// Tell Walker where to inherit it's parent and id values
var $db_fields = array(
'parent' => 'menu_item_parent',
'id' => 'db_id'
);
/**
* At the start of each element, output a <li> and <a> tag structure.
*
* Note: Menu objects include url and title properties, so we will use those.
*/
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$output .= sprintf( "\n<li><a href="https://wordpress.stackexchange.com/questions/327082/%s"%s>%s</a></li>\n",
$item->url,
( $item->object_id === get_the_ID() ) ? ' class="current"' : '',
$item->title
);
}
}
And then call the walker:
// 1. Fetch the menu (we'll assume it has an id of 2)...
$menu = wp_get_nav_menu_object(2);
// 2. Create an empty $menu_items array
$menu_items = array();
// 3. Get menu objects (this is our tree structure)
if ( $menu && ! is_wp_error($menu) && empty($menu_items) ) {
$menu_items = wp_get_nav_menu_items( $menu );
}
// 4. Create a new instance of our walker...
$walk = new Walker_Quickstart_Menu();
// 5. Walk the tree and render the returned output as a one-dimensional array
print_r( $walk->walk( $menu_items, -1 ) );