3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Wagon {} class Train { public function __construct(array $wagons) { $this->wagons = (function (Wagon $wagons) { return $wagons; })(...$wagons); } } var_dump(new Train([new Wagon, new Wagon, new Wagon]));
based on GDahs
Output for 7.0.0 - 7.2.0
object(Train)#1 (1) { ["wagons"]=> object(Wagon)#2 (0) { } }
Output for 5.3.18 - 5.6.28
Parse error: syntax error, unexpected '(' in /in/0dH8X on line 11
Process exited with code 255.