3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function foo(): Exception { return new Exception('foo'); } } class B extends A { public function foo(): ?Exception { return null; } }
Output for 7.1.25 - 7.1.31, 7.2.0 - 7.2.21, 7.3.0 - 7.3.8
Fatal error: Declaration of B::foo(): ?Exception must be compatible with A::foo(): Exception in /in/i6uls on line 17
Process exited with code 255.

preferences:
169.78 ms | 1395 KiB | 45 Q