Re: Invokation on __toString() for object used as array key
| From: | Patrick Schaaf | Date: | Thu, 25 Sep 2014 05:19:43 +0000 |
| Subject: | Re: Invokation on __toString() for object used as array key | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-77603@lists.php.net to get a copy of this message | ||
Am 24.09.2014 22:01 schrieb "Andrea Faulds" <ajf@ajf.me>:
>
> Now, if we were to add actual object key support, that I might like. But
if we’re going to keep with just integers and strings, I’d much prefer to
just support __toString here. I think users are smart enough to understand
that PHP arrays only have string or int keys, so it casts to a string.
Once you do that - automatically use __toString on objects used as keys,
the way to full object key support in the future, is completely blocked,
because BC.
I'd much more like to see full object key support, with spl_object_hash or
a magic __hash() method only used to determine hash slot position
internally.
best regards
Patrick