Re: [RFC] Deprecations for PHP 8.5
| From: | Theodore Brown | Date: | Mon, 07 Jul 2025 19:19:04 +0000 |
| Subject: | Re: [RFC] Deprecations for PHP 8.5 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127950@lists.php.net to get a copy of this message | ||
On Mon, July 7, 2025 at 11:03 Niels Dossche wrote:
>>> There are a few things I will vote no for:
>>>
>>> [...]
>>>
>>> * Deprecate using values of type null and bool as array offsets and when calling
>>> array_key_exists()
>>> Deprecating this would make the language more inconsistent by allowing this on array
>>> offsets but not on the function.
>>
>> I am slightly confused by what you mean by "allowing this on array offsets but not on
>> the function".
>> However, null is not accepted by functions that accept scalar types, and bool would neither
>> if my other RFC is approved.
>> Moreover, a type declaration of int|string accepted Stringable objects, however array
>> offsets do not accept objects at all.
>
> I'll clarify:
> You're allowed to do $array[null], $array[3.14], etc... and the key will coerce.
> I expect array_key_exists() to behave the same way as keys on array accesses do.
I'm confused what you mean as well. The deprecation is for both array offsets and when calling
array_key_exists().
So $array[null] should output a deprecation just like the function, and there isn't any
inconsistency.
Regards,
Theodore Brown