|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73470 Regression - ReflectionType::__toString() omits nullable type (?) prefix
Submitted: 2016-11-07 00:25 UTC Modified: 2016-11-07 00:32 UTC
From: ezzatron at gmail dot com Assigned:
Status: Not a bug Package: Reflection related
PHP Version: 7.1.0RC5 OS: N/A
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
14 + 41 = ?
Subscribe to this entry?

 [2016-11-07 00:25 UTC] ezzatron at gmail dot com
When a ReflectionType of a nullable type is obtained, its string representation does not include the question mark (?) prefix. This behavior seems to have changed in 7.1.0RC3.


Test script:

$r = new ReflectionFunction(function (?int $a): ?int {});
var_dump((string) $r->getParameters()[0]->getType());
var_dump((string) $r->getReturnType());

Expected result:
string(4) "?int"
string(4) "?int"

Actual result:
string(3) "int"
string(3) "int"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-07 00:32 UTC]
-Status: Open +Status: Not a bug
 [2016-11-07 00:32 UTC]
The behavior was reverted due to BC concerns.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 22:01:27 2024 UTC