3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace NS { class C { public $fn; public function __construct() { $this->fn = function (string $arg) { var_dump("fn"); }; } } } namespace { $fn = (new NS\C)->fn; $fn(null); echo "Done\n"; }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught TypeError: NS\C::NS\{closure}(): Argument #1 ($arg) must be of type string, null given, called in /in/TD9s0 on line 17 and defined in /in/TD9s0:8 Stack trace: #0 /in/TD9s0(17): NS\C->NS\{closure}(NULL) #1 {main} thrown in /in/TD9s0 on line 8
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to NS\C::NS\{closure}() must be of the type string, null given, called in /in/TD9s0 on line 17 and defined in /in/TD9s0:8 Stack trace: #0 /in/TD9s0(17): NS\C->NS\{closure}(NULL) #1 {main} thrown in /in/TD9s0 on line 8
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
Catchable fatal error: Argument 1 passed to NS\C::NS\{closure}() must be an instance of NS\string, null given, called in /in/TD9s0 on line 17 and defined in /in/TD9s0 on line 8
Process exited with code 255.

preferences:
266.05 ms | 402 KiB | 376 Q