Re: Invokation on __toString() for object used as array key

From: Date: Wed, 24 Sep 2014 05:57:47 +0000
Subject: Re: Invokation on __toString() for object used as array key
References: 1 2 3 4 5 6 7 8  Groups: php.internals 
Request: Send a blank email to internals+get-77566@lists.php.net to get a copy of this message
On 24/09/14 02:08, Stas Malyshev wrote: > Hi! > >> I do believe that the UString class would benefit from such a change. >> >> Why would it be confusing to implement this? > > For some objects, it may lead to rather strange results - i.e., > Exception has __toString() but probably not very useful one for use as > an array key. So may some other __toString methods. But in general, if > we streamline the conversion rules and set expectations, I don't see why > PHP engine can not check for object's convertor to string and even to > int if string one is not there. Yes, that would hide some errors but > also will enable some capabilities (like much smoother work with objects > that may simulate numbers, akin to GMP). > Well, then let's remove this restriction from resources, too. -- Regards, Mike

« previous php.internals (#77566) next »