Re: [RFC] Allow object keys in arrays
| From: | Andreas Leathley | Date: | Tue, 12 Jan 2021 17:53:52 +0000 |
| Subject: | Re: [RFC] Allow object keys in arrays | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-112856@lists.php.net to get a copy of this message | ||
On 12.01.21 17:51, Marco Pivetta wrote:
Code written to deal with array in a generic way will no longer work
when
invoked through code paths that produce object keys: this is a general
problem with widening types overall, and is a clear BC break.
If you look at levels of BC break, this is on the very low end in my
opinion. No existing code will break when upgrading to this new PHP
version. Only new code written specifically for that PHP version would
be impacted, and frameworks/libraries could, if necessary, add
additional checks without becoming incompatible with older PHP versions.
It helps that currently array keys can be integers or strings, so if the
key type is important, some checking is already necessary.
Of course tools like Psalm would see a lot of potential issues, but
those would only be potential (with new code using this new feature) and
having static analyzers reduces the impact of such a BC break even more,
as it becomes much easier to spot issues. Might be interesting to change
array key type definitions for a few projects/libraries and see if there
are that many potential issues, and what they look like.