There are a number of predefined interfaces in Hack. I’ve mentioned Awaitable, XHPChild and Continuation already. There are some more that will help your objects work with foreach loops and as iterators. They are all subtypes of the abstract interface Traversable.

There are two interfaces that are more interesting than others. They are Indexish and KeyedIterator. Indexish lets you use your object with bracket syntax. KeyedIterator lets you use the object with the foreach function.

To see the full inheritance tree, check out the Happyr developer blog.