<?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";
}
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.
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.
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.