3v4l.org

run code in 500+ PHP versions simultaneously
<?php declare(strict_types=1); function acceptsNull(?string $x): void{} function doesNotAcceptNull(string $x): void{} acceptsNull(null); // all ok doesNotAcceptNull(null); // boom!
Output for 8.1.23 - 8.1.34, 8.2.1 - 8.2.32, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
Fatal error: Uncaught TypeError: doesNotAcceptNull(): Argument #1 ($x) must be of type string, null given, called in /in/u5UPN on line 14 and defined in /in/u5UPN:8 Stack trace: #0 /in/u5UPN(14): doesNotAcceptNull(NULL) #1 {main} thrown in /in/u5UPN on line 8
Process exited with code 255.

preferences:
94.74 ms | 920 KiB | 4 Q