Bug #73105 [Opn->Csd]: ReflectionParameter returns nullable type when one is not used
| From: | nikic@php.net | Date: | Sat, 01 Oct 2016 14:39:09 +0000 |
| Subject: | Bug #73105 [Opn->Csd]: ReflectionParameter returns nullable type when one is not used | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204388@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=73105&edit=1
ID: 73105
Updated by: nikic@php.net
Reported by: mail at ciaranmcnulty dot com
Summary: ReflectionParameter returns nullable type when one
is not used
-Status: Open
+Status: Closed
Type: Bug
Package: Class/Object related
Operating System: OSX
PHP Version: 7.1.0RC2
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Resolved by https://github.com/php/php-src/pull/2137.
Previous Comments:
------------------------------------------------------------------------
[2016-09-18 18:02:24] mail at ciaranmcnulty dot com
Thanks for the context, it seems like the conversation ends with opposing views but not much
resolution.
From my perspective, code written under 7.0 that isn't using 7.1 features is no longer behaving
the way it used to.
How can this be correct BC policy?
------------------------------------------------------------------------
[2016-09-18 16:19:45] cmb@php.net
Related discussion: <http://marc.info/?t=147145076000010&r=1&w=2>.
------------------------------------------------------------------------
[2016-09-18 12:08:04] mail at ciaranmcnulty dot com
Description:
------------
Reflection normalises typehints on parameters with defaults of null to be Nullable typehints.
This is a change of behaviour and caused issues in Prophecy (Mocking library) and probably other
tools that lean on reflection. It's not appropriate for a minor version number.
Test script:
---------------
function foo(Bar $bar = null){}
echo ((new ReflectionFunction('foo'))->getParameters()[0]->getType());
Expected result:
----------------
output 'Bar'
Actual result:
--------------
output '?Bar'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73105&edit=1