3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class struct { private $args; function __construct(array $args) { $this->args = $args; } function __invoke(callable $signature = NULL) : array { if ($signature === NULL) return $this->signature(...array_values($this->args)); return $signature(...array_values($this->args)); } } final class Dinosaur extends struct { function signature(int $legs) : array { return get_defined_vars(); } } $two_legs = function(Dinosaur $dino) : Dinosaur { $trex = $dino(); $trex['legs'] = 2; return new Dinosaur($trex); }; var_dump($two_legs(new Dinosaur([0])));
based on YOWWT
Output for 7.0.0 - 7.3.0alpha1
object(Dinosaur)#3 (1) { ["args":"struct":private]=> array(1) { ["legs"]=> int(2) } }
Output for 5.6.0 - 5.6.29
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/tTRT6 on line 8
Process exited with code 255.