Re: New function: spl_object_id() or spl_object_handle()

From: Date: Fri, 28 Nov 2014 14:08:18 +0000
Subject: Re: New function: spl_object_id() or spl_object_handle()
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-79278@lists.php.net to get a copy of this message
Ferenc Kovacs wrote on 28/11/2014 13:51:
On Fri, Nov 28, 2014 at 2:14 PM, Sebastian Krebs <krebs.seb@gmail.com> wrote:
2014-11-28 2:13 GMT+01:00 Bostjan Skufca <bostjan@a2o.si>:
Hello everyone, this is a proposal to add new function to PHP core: spl_object_id() The story: ======== Recently I was debugging some larger libraries and sorely missed a
function
that would return an object ID. A function called spl_object_hash()
exists,
but it returns identical hashes for equal objects.
It returns unique IDs for existing objects. A hash is only reused only when the corresponding object was removed by the GC earlier. So actually asking me it makes more sense to "fix" the behaviour of spl_object_hash(),
yeah, the more I think about it the more I feel that the current implementation is just a landmine.
Is there any BC implication of changing the implementation? Or is it just that we don't know what the alternative should be? Looking at the implementation of spl_object_hash() [1] it already uses Z_OBJ_HANDLE_P(obj) as part of the output, so presumably that isn't enough to guarantee uniqueness anyway? (Which then leads to the question of what the advantage of an spl_object_id() function would actually be, if it's *less* unique than spl_object_hash()) [1] http://lxr.php.net/xref/PHP_TRUNK/ext/spl/php_spl.c#756 -- Rowan Collins [IMSoP]

« previous php.internals (#79278) next »