You miss the point.  The warning that is helpful in debugging, it has
nothing to do with designing things to break, it has to do with
unintentional bugs.  If in 1 case of 1000 in a loop, there is an object
instead of a string used as a key due to a bug (one example: this can
easily happen if you forget to check for a PEAR_Error on return from a
legacy PEAR class), a warning is printed.  With some kind of magic
conversion, this warning will instead translate into a magic conversion
to string, causing unpredictable and very difficult-to-track-down behavior.

Greg

Jasper Bryant-Greene wrote:
> All I've got to say on the matter is that if anyone is relying on that
> kind of behaviour for something serious, then their code deserves to break.
> 
> Jasper
> 
> Richard Lynch wrote:
> 
>>>That *IS* a current behaviour.
>>>
>>>Returns a warning and leaves the array un-modified.
>>>
>>>
>>>On Sun, June 4, 2006 10:59 pm, Robert Amos wrote:
>>>
>>>>As far as I can see, and I'm sure someone will be kind enough to
>>>>correct me
>>>>if I'm wrong, but there is no current behaviour for it, it returns a
>>>>warning.
>>>>
>>>>$a = new stdClass;
>>>>$b[$a] = 0;
>>>>
>>>>Warning: Illegal offset type in t3.php on line 2
>>>>
>>>>And results in an empty array (in this case) so it does nothing.
>>>>
>>>>-bok
>>>>
>>>>On 6/5/06, Richard Lynch <[EMAIL PROTECTED]> wrote:
>>>>
>>>>>On Sat, June 3, 2006 6:42 am, Marcus Boerger wrote:
>>>>>
>>>>>>  the attached patch closes one more __toString() part. It allows
>>>>>>to use objects that define __toString as indexes to arrays. What
>>>>>
>>>>>do
>>>>>
>>>>>>you guys think about this, should we add it or stay with the old
>>>>>>behavior that didn't allow objects as indexes at all.
>>>>>
>>>>>I use objects rarely, and am not sure I care all that much, but...
>>>>>
>>>>>Seems to me that there is a REALLY good chance that there ARE
>>>>>scripts
>>>>>"out there" that rely on current behaviour of:
>>>>>
>>>>>$a = new Foo();
>>>>>$arr[$a] = 42;
>>>>>
>>>>>Never mind that that's a really dumb thing to have -- Somebody is
>>>>>relying on it doing whatever it does...
>>>>>
>>>>>Whether that is erroring out or just turning all objects into ""
>>>>>doesn't matter.  Somebody relies on it doing the same thing it
>>>>>always
>>>>>did.
>>>>>
>>>>>Don't break that, please, in 5.2 -- Do whatever you want in 6.0 on
>>>>>that.
>>>>>
>>>>>This all seems like much ado about nothing to me.  Anybody brainy
>>>>>enough to NEED their objects as array indices can probably manage to
>>>>>write a function to uniquely identify their/all objects.
>>>>>
>>>>>Sorry if my votes aren't fitting into the schema of voting...  I
>>>>>kinda
>>>>>got glassy-eyed with this whole thread, to tell the truth.
>>>>>
>>>>>--
>>>>>Like Music?
>>>>>http://l-i-e.com/artists.htm
>>>>>
>>>>>--
>>>>>PHP Internals - PHP Runtime Development Mailing List
>>>>>To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>>
>>>>--
>>>>Xnyo - http://xnyo.odynia.org/
>>>>
>>>
>>>

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to