3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); /** * @template TKey * @template TValue * @implements IteratorAggregate<TKey, TValue> */ final class RewindableGenerator implements IteratorAggregate { /** * @param callable(): Generator<TKey, TValue> $generatorFunction */ public function __construct(private $generatorFunction) {} public function getIterator(): Traversable { return ($this->generatorFunction)(); } } /** * @return Generator<int, int> */ function thousand(): Generator { for ($i = 0; $i < 1000; ++$i) { yield $i; } } $thousand = new RewindableGenerator(thousand(...)); foreach ($thousand as $i); foreach ($thousand as $i); foreach ($thousand as $i);
Output for git.master_jit, git.master, rfc.property-hooks

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
154.47 ms | 1394 KiB | 10 Q