Bug #73470 [Opn->Nab]: Regression - ReflectionType::__toString() omits nullable type (?) prefix
Edit report at https://bugs.php.net/bug.php?id=73470&edit=1
ID: 73470
Updated by: requinix@php.net
Reported by: ezzatron at gmail dot com
Summary: Regression - ReflectionType::__toString() omits
nullable type (?) prefix
-Status: Open
+Status: Not a bug
Type: Bug
Package: Reflection related
Operating System: N/A
PHP Version: 7.1.0RC5
Block user comment: N
Private report: N
New Comment:
The behavior was reverted due to BC concerns.
Previous Comments:
------------------------------------------------------------------------
[2016-11-07 00:25:46] 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"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73470&edit=1
Thread (2 messages)