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
foreach ($arr ?: [] as $elem) { // Do something }
This doesen't check if it is an array, but skips the loop if the variable is null or an empty array.