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 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Deprecated: Creation of dynamic property AImpl::$x is deprecated in /in/XdBiJ on line 15 Deprecated: Creation of dynamic property AImpl::$y is deprecated in /in/XdBiJ on line 16 Deprecated: Creation of dynamic property AImpl::$z is deprecated in /in/XdBiJ on line 17
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/XdBiJ on line 8
Process exited with code 255.

preferences:
240.64 ms | 402 KiB | 331 Q