Re: Re: Scalar Type Declaration Syntax Weirdness
| From: | Chris Riley | Date: | Tue, 24 Nov 2015 17:29:22 +0000 |
| Subject: | Re: Re: Scalar Type Declaration Syntax Weirdness | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89390@lists.php.net to get a copy of this message | ||
On 24 November 2015 at 17:16, Andrea Faulds <ajf@ajf.me> wrote:
> Hi Stas,
>
> Stanislav Malyshev wrote:
>
>> Hi!
>>
>> <?php
>>>> function a(\int $i) {}
>>>>
>>>> Is it intentional that the \ in front of the "int" is allowed? IMHO,
>>>> this
>>>> confusing notation must not be allowed.
>>>>
>>>
>>> This is weird and I'd consider it a bug. You can't do \array or
>>> \callable, and if I saw \int, I'd think it meant a class of that name
>>> rather than a scalar type.
>>>
>>
>> I would assume \int means class named "int", as opposed to "int" type.
>>
>
> That's also what I'd expect. However, "int" is not allowed as a class name
> in PHP 7. And unfortunately what the code Sebastian posted sctually does is
> act as an integer type hint, not as a class type hint.
>
> Can this be fixed for 7.0.0?
>>>
>>
>> I don't think this would be a good idea. We're in the final stretch of
>> release cycle, and should not do any non-urgent fixes. This does not
>> look urgent. It can wait for 7.0.1.
>>
>
> It can't wait for 7.0.1, because banning this would be a
> backwards-compatibility break with 7.0.0. We have to fix it in 7.0.0 or not
> fix it ever.
>
> Thanks.
>
> --
> Andrea Faulds
> http://ajf.me/
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Could we not just document it as \int is not allowed and throws a fatal
error. Then we'd just be fixing a bug in documented behaviour.
~C