This is important when considering how other Generators work such as JavaScript's an Python's. While PHP's generator has the ->valid() method they don't, or an equivalent. JS uses Iterator protocol which says next() should return an object of
{
done: bool,
value: mixed
}
In which case you can use keys->done to see if the generator can still be iterated.