Re: RFC: Stop to automatically cast numeric-string to int when using them as array-key
| From: | Lynn | Date: | Thu, 30 Dec 2021 17:34:18 +0000 |
| Subject: | Re: RFC: Stop to automatically cast numeric-string to int when using them as array-key | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-116745@lists.php.net to get a copy of this message | ||
On Thu, Dec 30, 2021 at 5:54 PM Vincent Langlet <
mr.vincent.langlet@gmail.com> wrote:
> Would you still consider this as a massive BC break if
> - The type of the key don't change anymore i.e. array_search(0, ['10' =>
> 0]) will be '10' and not 10.
> - $array[10] still return $array[10] ?? $array['10']
> - $array['10'] still return $array['10'] ?? $array[10]
>
> so it still cast the value when accessing to an array key, but when using
> array_keys/array_search/array_flip/... it won't be cast anymore.
>
"Would you still consider this as a massive BC break"
Yes, because
'10' from an array flip is not 10 anymore, which
means
that using any strict comparisons on those values afterwards will fail if
they assumed it was an int.