Re: ReflectionType::__toString() prepending \ to class names
| From: | Nikita Popov | Date: | Mon, 22 Aug 2016 05:33:20 +0000 |
| Subject: | Re: ReflectionType::__toString() prepending \ to class names | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95362@lists.php.net to get a copy of this message | ||
On Sun, Aug 21, 2016 at 10:28 PM, Dan Ackroyd <danack@basereality.com>
wrote:
> On 21 August 2016 at 20:43, Marco Pivetta <ocramius@gmail.com> wrote:
> >
> > Sadly, it won't. Here's an example that shows the BC break in a more
> > explicit way:
> >
> > function foo(Iterator $i = null) {}
> > var_dump((string) (new ReflectionParameter('foo', 0))->getType());
> >
> > This reports
Iterator for PHP 7.0.x,
> > ?\Iterator for 7.1.x.
> > https://3v4l.org/tDkLj
>
>
> Thanks.
>
> I missed that part - I thought this was just about ?types, not things
> that have default of null.
>
> cheers
> Dan
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Hi.
Now that we have made ReflectionType::__toString() be useless and not
represent the type, this method should be deprecated in favor of using
ReflectionNamedType::__toString(), ::allowsNull() and any further
extensions that will be introduced later.
I recommend doing this swiftly so as to ensure that people do not use this
method on PHP 7.1 anymore and thus avoid pain on future upgrades.
Nikita