Fwd: PHP RFC: Scalar type-hinting with cast
| From: | Andrea Faulds | Date: | Mon, 11 Aug 2014 12:46:26 +0000 |
| Subject: | Fwd: PHP RFC: Scalar type-hinting with cast | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-76426@lists.php.net to get a copy of this message | ||
Begin forwarded message:
> From: Andrea Faulds <ajf@ajf.me>
> Subject: Re: PHP RFC: Scalar type-hinting with cast
> Date: 11 August 2014 13:46:05 BST
> To: Benjamin Morel <benjamin.morel@gmail.com>
>
>
> On 11 Aug 2014, at 13:41, Benjamin Morel <benjamin.morel@gmail.com> wrote:
>
>> Hi,
>>
>> I’m a strong supporter of this feature request, so first of all thank you for taking over
>> the RFC!
>>
>> I noticed that there is a use-case that is not present in the RFC and should IMO be
>> explicitly documented: the strings of digits with leading zeros.
>>
>> I think these should “pass” when type-hinted as int:
>> “0123” => 123
>> “-0123” => -123
>>
>> Note that the conversion should be done in base 10, not 8 (octal) as this is what the
>> explicit (int) type-casting does:
>> echo 0123; // 83
>> echo (int) “0123”; // 123
>>
>> I hope you can add this to the RFC.
>
> The patch as it stands does support this, and they are base 10. PHP doesn’t consistently deal
> with bases the same as it stands, however. I’d like to fix that at some point.
>
> Also, the RFC is effectively dead at this point. I will retire it once I have a better
> replacement.
>
> --
> Andrea Faulds
> http://ajf.me/
--
Andrea Faulds
http://ajf.me/