php.net |  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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ezzatron at gmail dot com
New email:
PHP Version: OS:

 

 [2016-11-07 00:25 UTC] ezzatron at gmail dot com
Description:
------------
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.

See https://3v4l.org/c21Nq

Test script:
---------------
<?php

$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"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-11-07 00:32 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2016-11-07 00:32 UTC] requinix@php.net
The behavior was reverted due to BC concerns.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Oct 12 23:01:27 2024 UTC