It often happens to me to handle data that can be either an array or a null variable and to feed some foreach with these data.
foreach
$values = get_val
First of all, every variable must be initialized. Always. Casting is not an option. if get_values(); can return different type variable, this value must be checked, of course.