|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 01 22:01:28 2024 UTC