3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass {} interface TestCon { public function testCon(MyClass $object): object; } class TestConImplementation implements TestCon { public function testCon(object $object): object { return $object; } } $test = new TestConImplementation; $object = $test->testCon(new MyClass); var_dump($object);
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
object(MyClass)#2 (0) { }
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Fatal error: Declaration of TestConImplementation::testCon(object $object): object must be compatible with TestCon::testCon(MyClass $object): object in /in/D1KWe on line 11
Process exited with code 255.

preferences:
187.45 ms | 402 KiB | 177 Q