3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace App; use ArrayIterator; final class PropertySameNameAsVariable { public ArrayIterator $items; public function run() { $items = ['apple']; return array_merge($this->items, $items); } } $a = new PropertySameNameAsVariable(); $a->items = new ArrayIterator([]); $a->run();
Output for 8.2.35 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28, 8.5.0 - 8.5.13, 8.6.0
Fatal error: Uncaught TypeError: array_merge(): Argument #1 must be of type array, ArrayIterator given in /in/fsFR5:14 Stack trace: #0 /in/fsFR5(14): array_merge(Object(ArrayIterator), Array) #1 /in/fsFR5(20): App\PropertySameNameAsVariable->run() #2 {main} thrown in /in/fsFR5 on line 14
Process exited with code 255.

preferences:
22.78 ms | 1164 KiB | 6 Q