Re: toString() and Object #ID

From: Date: Mon, 02 Jul 2007 04:34:05 +0000
Subject: Re: toString() and Object #ID
References: 1 2 3 4 5 6 7 8 9  Groups: php.internals 
Request: Send a blank email to internals+get-30396@lists.php.net to get a copy of this message
Am I right in my guess that there's only a counter for each object type? Still being not really unique this information could be very useful and enough in many situations.
It's more complicated than that. Basically what uniquely identifies the object is the tuple (handlers, ID) - it's more or less by definition since handlers decide what to do with an object based on ID. Now, if we talk about "pure" PHP objects (i.e. made by regular PHP user-defined classes, no tricks) then the handlers would be the same and the ID is unique. However, extensions can produce their own handlers and their own IDs, and they don't even have to adhere to the concept that (class, ID) should uniquely identify the object. I don't know of extension that creates different handler sets for the same class, but there's nothing in the engine preventing anybody from doing that - though I'm not sure it's that good an idea. So (class, ID) would probably work now, but is not guaranteed to work. Just ID would have good chance to break with some extensions. Yes, spl_object_hash uses the correct tuple - (handlers, ID). -- Stanislav Malyshev, Zend Software Architect stas@zend.com http://www.zend.com/ (408)253-8829 MSN: stas@zend.com

« previous php.internals (#30396) next »