3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); namespace App; use Generator; use CachingIterator; $generator = /** * @return Generator<bool, bool> */ static function (): Generator { yield true => true; yield false => false; }; $iterator = new CachingIterator($generator()); foreach ($iterator as $k => $v) { var_dump($k, $v); } foreach ($iterator->getCache() as $k => $v) { var_dump($k, $v); }

preferences:
55.07 ms | 408 KiB | 6 Q