Reflection API and Nullable Types
| From: | Sebastian Bergmann | Date: | Sun, 09 Oct 2016 06:56:01 +0000 |
| Subject: | Reflection API and Nullable Types | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-96297@lists.php.net to get a copy of this message | ||
At some point in time during the development of PHP 7.1 this code
function f(?int $x)
{
}
$f = new ReflectionFunction('f');
var_dump((string) $f->getParameters()[0]->getType());
var_dump($f->getParameters()[0]->getType()->getName());
printed
string(4) "?int"
string(3) "int"
and now it prints
string(4) "int"
string(3) "int"
I know that this issue (or a similar one) was recently discussed but after
reading through that thread I am not 100% sure whether the current
behavior is indeed the intended one.
Thanks!
Sebastian