Add support for PHP 5.5 generator

It may be refactored a bit so that the sorting thing is extracted somewhere.