See also:
http://php.net/manual/en/class.generator.php Generator is not a Haxe Iterable. It can be iterated one time only. Unfortunately Haxe does not know that in PHP generators may have no
return
expression orreturn value
with any type ofvalue
. Usereturn null
or untyped cast to workaround this issue:function generatorWithoutReturn():Generator { php.Syntax.yield(1); return null; } function generatorWithReturn():Generator { php.Syntax.yield(1); return cast "hello"; } var g = generatorWithReturn(); for(i in g) { trace(i); } trace(g.getReturn()); // "hello"