3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Test { public function selfRef(Test $other); } class TestImpl implements Test { public function selfRef(Test $other) { echo var_export($other, true) . PHP_EOL; } public function nonContractSelfRef(self $other) { echo var_export($other, true) . PHP_EOL; } } class DerivedTestImpl extends TestImpl { } $a = new TestImpl(); $b = new DerivedTestImpl(); $a->nonContractSelfRef($b);

preferences:
36.48 ms | 402 KiB | 5 Q