Re: Invokation on __toString() for object used as array key
| From: | Michael Wallner | Date: | Tue, 23 Sep 2014 08:51:13 +0000 |
| Subject: | Re: Invokation on __toString() for object used as array key | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77514@lists.php.net to get a copy of this message | ||
On 2014-09-23 10:04, Nicolai Scheer wrote:
> Hi all,
>
> until 5 minutes ago I thought it would be perfectly legal to use an object
> as an array key, given that its __toString() method is in place.
>
> Seems as if I was wrong.
> I know that array keys are not what is considered "string context"
> internally, at least not directly.
>
> Would it harm in any way to add that feature?
Yes, it was removed intentionally (quite a long time ago), like using
resources as array keys, to avoid hard-to-trace bugs for the user. At
least that's the reasoning I can remember.
--
Regards,
Mike