3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo implements IteratorAggregate { protected $attributes = []; function __construct(array $arr) { $this->attributes = $arr; } function getIterator(): \Traversable { return new ArrayIterator($this->attributes); } } (new Foo([]))[0];
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Cannot use object of type Foo as array in /in/hIimN:18 Stack trace: #0 {main} thrown in /in/hIimN on line 18
Process exited with code 255.

preferences:
59.91 ms | 992 KiB | 4 Q