3v4l.org

run code in 300+ PHP versions simultaneously
<?php class FooCls {} function foo(): iterable { yield new FooCls => 1; yield new FooCls => 2; yield new FooCls => 3; yield new FooCls => 4; } $iterator = foo(); assert($iterator instanceof Iterator); var_dump($iterator->key());
Output for 7.3.0 - 7.3.27, 7.4.0 - 7.4.16, 8.0.0 - 8.0.3
object(FooCls)#2 (0) { }