The bug is not in this snippet of code. The problem is with how you call wp_get_nav_menu_array
, wherever that happens. The $current_menu is likely something invalid, so wp_get_nav_menu_items
returns false
, and thus you get the error that you get.
You can see in user contributed notes an example of how to get a valid value for $current_menu https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/#user-contributed-notes