3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class DEP1{} class DEP2{} class DEP3{} interface A{ function get1(): DEP1; function get2(): DEP2; function get3(): DEP3; } class AImpl implements A{ function __construct(A $DEP){ $this->x = $DEP->get1(); $this->y = $DEP->get2(); $this->z = $DEP->get3(); } function get1(): DEP1{ return $this->x; } function get2(): DEP2{ return $this->y; } function get3(): DEP3{ return $this->z; } } new AImpl(new class() implements A{ function get1(): DEP1{ return new DEP1; } function get2(): DEP2{ return new DEP2; } function get3(): DEP3{ return new DEP3; } });
based on 7o4rL
Output for 7.0.0 - 7.2.0
Output for 5.3.21 - 5.6.21
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/XdBiJ on line 8
Process exited with code 255.