Re: RFC: Stop to automatically cast numeric-string to int when using them as array-key
| From: | Chase Peeler | Date: | Mon, 03 Jan 2022 16:07:53 +0000 |
| Subject: | Re: RFC: Stop to automatically cast numeric-string to int when using them as array-key | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116777@lists.php.net to get a copy of this message | ||
On Mon, Jan 3, 2022 at 10:48 AM Rowan Tommins <rowan.collins@gmail.com>
wrote:
> On 3 January 2022 15:41:48 GMT, Chase Peeler <chasepeeler@gmail.com>
> wrote:
> >But "001" casted to 1 will then get casted back to "1" not
> >"001".
>
> "001" would not be cast to an integer in this context:
> https://3v4l.org/gGFHJ
>
>
My mistake, I thought it did get casted. Still, I think you add a lot of
complexity because you'll need to keep track of whether or not a key was a
string or not. There is no guarantee that all numeric keys were originally
a string:
[ "1" => "foo", 2 => "bar"]
And, for the record, I am not in favor of the original proposal either. I
think it's way too big of a BC break like others have said.
> Regards,
>
> --
> Rowan Tommins
> [IMSoP]
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
>
>
--
Chase Peeler
chasepeeler@gmail.com