3v4l.org

run code in 300+ PHP versions simultaneously
<?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; } })
Output for 7.0.0 - 7.0.2
Parse error: syntax error, unexpected end of file in /in/7o4rL on line 34
Process exited with code 255.
Output for 5.5.24 - 5.5.31, 5.6.8 - 5.6.17
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/7o4rL on line 8
Process exited with code 255.

preferences:
179.37 ms | 1395 KiB | 28 Q