Re: Missing __toString() part

From: Date: Sun, 04 Jun 2006 11:52:41 +0000
Subject: Re: Missing __toString() part
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-23918@lists.php.net to get a copy of this message
Hello, > Hello Rasmus, Andi, > marcus@zaphod /usr/src/PHP_5_2 $ php -r 'var_dump(spl_object_hash(new > stdClass));' string(32) "0bab1548e3b42acbcf1170617b5432ae" > > For PHP 5.2 we could think about adding a hash handler to the object > handler table and provide the above as default implementation. That > hash handler would then be called when an object is being used as an > offset. Maybe later in PHP 6 we can also add an interface that allows > to overload that hash implementation. (If someone really wants that). > Yet anything the user can overload be it an interface or magic > function (e.g. __hashOf) seems to be too much for now. Do you mean to allow object as indices with this default implementation? But this implementataion cannot be overloaded? I fail to see the needs of such things in 5.x (or 6.x even with overload). Adding another magic method __toHash is also not what I would like. Adding a function hash_from_object() or spl_hash_from object() to ease the generations of hashes is indeed a good idea. There is no impact in the objects managements and people are free to use it or not (no magic default behaviors). --Pierre

« previous php.internals (#23918) next »