3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php declare(strict_types=1); class Foo implements IteratorAggregate { public function getIterator() { return function() { yield from ['A', 'B', 'C']; yield from ['D', 'E', 'F']; }; } } print_r(iterator_to_array(new Foo()));
based on H07Ot
Output for 7.0.30 - 7.3.0beta1
Fatal error: Uncaught Exception: Objects returned by Foo::getIterator() must be traversable or implement interface Iterator in /in/fK1Wh:15 Stack trace: #0 /in/fK1Wh(15): iterator_to_array(Object(Foo)) #1 {main} thrown in /in/fK1Wh on line 15
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: Class Foo must implement interface Traversable as part of either Iterator or IteratorAggregate in /in/fK1Wh:-1 Stack trace: #0 /in/fK1Wh(-1): iterator_to_array() #1 {main}
Process exited with code 255.
Output for hhvm-3.21.3
Fatal error: Uncaught Error: Class Foo must implement interface Traversable as part of either Iterator or IteratorAggregate in /in/fK1Wh:15 Stack trace: #0 /in/fK1Wh(15): iterator_to_array() #1 {main}
Process exited with code 255.
Output for hhvm-3.18.5
Fatal error: Uncaught Error: Class Foo must implement interface Traversable as part of either Iterator or IteratorAggregate in /in/fK1Wh:15 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Warning: Unsupported declare 'strict_types' in /in/fK1Wh on line 2 Parse error: syntax error, unexpected ',', expecting ']' in /in/fK1Wh on line 9
Process exited with code 255.