3v4l.org

run code in 500+ PHP versions simultaneously
<?php // Why is this allowed ? class MyDateTimeImmutable extends DateTimeImmutable implements DateTimeInterface { public function format(string $format): string { return 'Why is this allowed?'; } } // And why is this disallowed ? // Fatal error: DateTimeInterface can't be implemented by user classes class MyTime implements DateTimeInterface { }
Output for 8.5.9 - 8.5.13, 8.6.0
Fatal error: DateTimeInterface can't be implemented by user classes in /in/AVYra on line 14 Stack trace: #0 {main}
Process exited with code 255.
Output for 8.2.34 - 8.2.36, 8.3.0 - 8.3.37, 8.4.1 - 8.4.28
Fatal error: DateTimeInterface can't be implemented by user classes in /in/AVYra on line 14
Process exited with code 255.

preferences:
16.57 ms | 1167 KiB | 6 Q