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.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
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:
134.96 ms | 407 KiB | 5 Q