3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function getSize(): int { return 2; } } class B extends A { public function getSize(): ?int { return null; } } $b = new B; var_dump($b->getSize());
Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.24, 7.3.0 - 7.3.11
Fatal error: Declaration of B::getSize(): ?int must be compatible with A::getSize(): int in /in/DnSXf on line 13
Process exited with code 255.

preferences:
182.01 ms | 1395 KiB | 53 Q