3v4l.org

run code in 300+ PHP versions simultaneously
<?php readonly class A implements IteratorAggregate { function __construct(public string $foo = 'bar') {} function getIterator() : Traversable { return new ArrayIterator($this); } } $obj = new A; foreach ($obj as $k => &$v) { $v = 'baz'; } var_dump($obj); // changed a readonly property

preferences:
28.02 ms | 404 KiB | 5 Q