3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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"; }
based on R2S1C
Output for 7.0.0 - 7.2.0
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.6.28
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.