3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayMap implements \Iterator { public function __construct(private array $array) { } public function current(): mixed { return current($this->array); } public function next(): void { next($this->array); } public function key(): int|string|null { return key($this->array); } public function valid(): bool { return key($this->array) !== null; } public function rewind(): void { reset($this->array); } } class Aggregate implements \IteratorAggregate { public function __construct(private array $array) { } public function getIterator(): Traversable { return new ArrayMap($this->array); } } class Y { } class Z { } $_1 = new Aggregate([Z::class => Z::class,]); var_dump(1); $_2 = [...iterator_to_array($_1, true)]; var_dump(2); $_3 = [...$_2, Y::class => Z::class]; var_dump(3); $_4 = new Aggregate($_3); var_dump(4); [...$_4]; var_dump(5);
Output for git.master_jit, git.master
int(1) int(2) int(3) int(4) int(5)

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:
27.52 ms | 405 KiB | 5 Q