3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function foo() { foreach ([] as $foo) { yield $foo; } } $iterator = new AppendIterator(); $iterator->append(foo()); var_dump(iterator_to_array($iterator));
based on NpYef
Output for 7.0.10 - 7.2.0
Fatal error: Uncaught Exception: Cannot traverse an already closed generator in /in/q3I67:9 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/q3I67(9): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/q3I67 on line 9
Process exited with code 255.
Output for 5.5.0 - 5.6.24, 7.0.0 - 7.0.9

Process exited with code 139.
Output for hhvm-3.11.1 - 3.22.0
array(0) { }
Output for 5.6.25 - 5.6.30
Fatal error: Uncaught exception 'Exception' with message 'Cannot traverse an already closed generator' in /in/q3I67:9 Stack trace: #0 [internal function]: AppendIterator->rewind() #1 /in/q3I67(9): iterator_to_array(Object(AppendIterator)) #2 {main} thrown in /in/q3I67 on line 9
Process exited with code 255.