|  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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ezzatron at gmail dot com
New email:
PHP Version: OS:


 [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-2023 The PHP Group
All rights reserved.
Last updated: Sat Dec 02 19:01:27 2023 UTC