Bug #73105 [Opn]: ReflectionParameter returns nullable type when one is not used
| From: | mail at ciaranmcnulty dot com | Date: | Sun, 18 Sep 2016 18:02:26 +0000 |
| Subject: | Bug #73105 [Opn]: ReflectionParameter returns nullable type when one is not used | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-204116@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
User updated by: mail at ciaranmcnulty dot com
Reported by: mail at ciaranmcnulty dot com
Summary: ReflectionParameter returns nullable type when one
is not used
Status: Open
Type: Bug
Package: Class/Object related
Operating System: OSX
PHP Version: 7.1.0RC2
Block user comment: N
Private report: N
New Comment:
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?
Previous Comments:
------------------------------------------------------------------------
[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