3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface OldInterface { public function foo(); } interface NewInterface { public function foo(): mixed; } final class MyClass implements OldInterface, NewInterface { public function foo(): mixed { return null; } } $c = new MyClass(); $c->foo();
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Output for 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Return value of MyClass::foo() must be an instance of mixed, null returned in /in/eScGI:13 Stack trace: #0 /in/eScGI(17): MyClass->foo() #1 {main} thrown in /in/eScGI on line 13
Process exited with code 255.

preferences:
124.18 ms | 401 KiB | 117 Q