Re: ReflectionType::__toString() prepending \ to class names
| From: | Aaron Piotrowski | Date: | Wed, 17 Aug 2016 16:44:00 +0000 |
| Subject: | Re: ReflectionType::__toString() prepending \ to class names | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-95265@lists.php.net to get a copy of this message | ||
Marco,
> On Aug 17, 2016, at 11:22 AM, Marco Pivetta <ocramius@gmail.com
> <mailto:ocramius@gmail.com>> wrote:
>
> Sorry, I have to object here: this is quite a BC break for Zend\Code, specifically. We will
> have to re-adjust the code generators to adapt to the newly introduced prepended
>
\.
>
> In addition to that, there is no need for \ to be prepended to
> a type string, since inside string scope, we are always dealing with the base namespace.
>
> Seems unnecessary and causes a lot of headaches, instead of actually simplifying things.
>
> Marco Pivetta
>
> http://twitter.com/Ocramius
> <http://twitter.com/Ocramius>
>
> http://ocramius.github.com/
> <http://ocramius.github.com/>
>
Adjustments will be necessary in Zend\Code no matter what because of nullable types. If a type is
nullable, ReflectionType::__toString() will return "?\Type\Name" or without the changes I
committed it would return "?Type\Name".
If you need the type name without the leading ? or \, use ReflectionNamedType::getName().
It would be nice to have no BC breaks, but right now I'm not seeing a way of handling nullable
types in ReflectionType::__toString() without some sort of BC break.
Aaron Piotrowski