In this latest post to The PHP.cc's blog, Sebastian Bergmann talks about using a new feature in PHP - generators.
A generator is an interruptible function that returns a sequence of values (using the yield keyword) instead of a single value (using the return keyword). Two things happen when the yield statement of a generator function is executed: the argument of the yield statement is yielded and the execution of the generator function is suspended. The execution of the generator function is resumed when the next value is requested.
He starts with a simple example, showing a basic foreach loop calling a generator to produce (yield) an incrementing number each time. He also provides a more "real world" use case - using generators as data providers for PHPUnit tests. His example generates a new "Address" object each time the provider is called with a bit of "randomized" information included.