3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Animal{ abstract public function getSound(): string; } class Cat extends Animal{ public function getSound(): string{ return 'meow'; } } class Goldfish extends Animal{ public function getSound(): never { throw new Exception('Goldfish makes no sound'); } }
Output for 8.1.0 - 8.1.7
Output for 7.4.0 - 7.4.30, 8.0.1 - 8.0.20
Fatal error: Declaration of Goldfish::getSound(): never must be compatible with Animal::getSound(): string in /in/ZRZZE on line 15
Process exited with code 255.

preferences:
156.32 ms | 1399 KiB | 64 Q