Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-12-09 Thread Rowan Collins
On 9 December 2014 16:43:52 GMT, Nicolas Grekas wrote: >Indeed. A non-function version of debug_zval_dump which could do this >on >> any variable would be even better (if I read it right, your function >only >> works on array members?) >> > >Not sure this is required: any variable can be put in

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-12-09 Thread Nicolas Grekas
> t would not be a BC break to completely change the output I agree! This could be as simple as removing the XOR for the first part of the hash string (the first 16 chars) and expose the internal object's handle there. This is already leaked by the output of var_dump so not a pb imho. And BC is

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-12-09 Thread Rowan Collins
Nicolas Grekas wrote on 09/12/2014 14:39: Hi Rowan, In order to get an object's id, I use a trick that works for now: https://github.com/symfony/symfony/blob/2.6/src/Symfony/Component/VarDumper/Cloner/VarCloner.php#L258-L282 This seems like a very elaborate piece of revers

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-12-09 Thread Nicolas Grekas
Hi Rowan, In order to get an object's id, I use a trick that works for now: >> https://github.com/symfony/symfony/blob/2.6/src/Symfony/ >> Component/VarDumper/Cloner/VarCloner.php#L258-L282 >> > > This seems like a very elaborate piece of reverse engineering Right, and I made the claim for this

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-12-09 Thread Rowan Collins
Nicolas Grekas wrote on 09/12/2014 09:31: Hi this is a proposal to add new function to PHP core: spl_object_id() IMHO this is a good idea: currently, var_dump has this super-power (and super-useful) capability of outputting a number that ease recognizing identical objects in dumps. This power s

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-12-09 Thread Nicolas Grekas
Hi this is a proposal to add new function to PHP core: spl_object_id() > IMHO this is a good idea: currently, var_dump has this super-power (and super-useful) capability of outputting a number that ease recognizing identical objects in dumps. This power should be transferred to userland devs so

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-29 Thread Rowan Collins
On 29/11/2014 18:04, Bostjan Skufca wrote: On 29 November 2014 at 00:21, Rowan Collins wrote: On 28/11/2014 01:13, Bostjan Skufca wrote: A function called spl_object_hash() exists, but it returns identical hashes for equal objects. In case it's been lost in the noise, no it doesn't. Ouch. I

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-29 Thread Bostjan Skufca
On 28 November 2014 at 21:06, Patrick Schaaf wrote: > > I really don't get it. What are you trying to do there that you cannot do > with storing the object (reference) itself? I probably provided a poor explanation. All this was meant as a convenience method for quick debugging. I just needed to

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-29 Thread Bostjan Skufca
On 29 November 2014 at 00:21, Rowan Collins wrote: > On 28/11/2014 01:13, Bostjan Skufca wrote: >> >> A function called spl_object_hash() exists, >> but it returns identical hashes for equal objects. > > In case it's been lost in the noise, no it doesn't. Ouch. I am terribly sorry about this mist

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Rowan Collins
On 28/11/2014 01:13, Bostjan Skufca wrote: A function called spl_object_hash() exists, but it returns identical hashes for equal objects. In case it's been lost in the noise, no it doesn't. From http://php.net/spl_object_hash > Return Values > A string that is unique for each currently exist

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Rowan Collins
On 28/11/2014 21:06, Marc Bennewitz wrote: But to have a unique ID for objects sound like a very good idea and would solve the object as array key issue. I'm sure it's not as simple as the function prototype explained in this thread previously. Indeed. Fortunately, we already have one: it's c

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Marc Bennewitz
Am 28.11.2014 um 21:21 schrieb Levi Morrison: Won't `$obj1 === $obj2` work for you ? This works if you have two objects which are easily accessible in the same scope. Not that it can not be done this way, but it may require jumping through hoops to get two object references into the common

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Levi Morrison
>> Won't `$obj1 === $obj2` work for you ? >> > > This works if you have two objects which are easily accessible in the same > scope. > > Not that it can not be done this way, but it may require jumping through > hoops to get two object references into the common scope where you can > compare them

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Patrick Schaaf
Am 28.11.2014 20:23 schrieb "Bostjan Skufca" : > > On 28 November 2014 at 04:10, reeze wrote: > > > Won't `$obj1 === $obj2` work for you ? > Think of it like this: > - in file bootstrap.php I see this object initialized and passed somewhere > - in file view.phtml I receive the object of the same

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Bostjan Skufca
On 28 November 2014 at 07:04, Joe Watkins wrote: > > I don't think so, there is talk of removing object handles in 7. Could you point me to a discussion about this? Tnx. > Even if we intended to keep object handles, this leaks implementation > details that we don't really want

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Bostjan Skufca
On 28 November 2014 at 04:10, reeze wrote: > Won't `$obj1 === $obj2` work for you ? > This works if you have two objects which are easily accessible in the same scope. Not that it can not be done this way, but it may require jumping through hoops to get two object references into the common s

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Ferenc Kovacs
On Fri, Nov 28, 2014 at 5:39 PM, Patrick Schaaf wrote: > > Am 28.11.2014 15:46 schrieb "Ferenc Kovacs" : > > > > from a quick test using spl_object_hash seems to be the slower with big > number of elements in haystack. > > Your test only does the is-it-known test once. For an already-visited-set

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Patrick Schaaf
Am 28.11.2014 15:46 schrieb "Ferenc Kovacs" : > > from a quick test using spl_object_hash seems to be the slower with big number of elements in haystack. Your test only does the is-it-known test once. For an already-visited-set use case the test will run once for each visited element, and will usu

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Ferenc Kovacs
On Fri, Nov 28, 2014 at 3:02 PM, Patrick Schaaf wrote: > On Friday 28 November 2014 14:51:55 Ferenc Kovacs wrote: > > > > > > I also used spl_object_hash() in the past when traversing/custom > > > serializing object structures which can have infinite recursions between > > > objects, but even th

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Rowan Collins
Ferenc Kovacs wrote on 28/11/2014 13:51: On Fri, Nov 28, 2014 at 2:14 PM, Sebastian Krebs wrote: 2014-11-28 2:13 GMT+01:00 Bostjan Skufca : Hello everyone, this is a proposal to add new function to PHP core: spl_object_id() The story: Recently I was debugging some larger librarie

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Patrick Schaaf
On Friday 28 November 2014 14:51:55 Ferenc Kovacs wrote: > > I also used spl_object_hash() in the past when traversing/custom > serializing object structures which can have infinite recursions between > objects, but even that could be simply solved by storing the already > traversed objects in an

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Ferenc Kovacs
On Fri, Nov 28, 2014 at 2:14 PM, Sebastian Krebs wrote: > 2014-11-28 2:13 GMT+01:00 Bostjan Skufca : > > > 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

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-28 Thread Sebastian Krebs
2014-11-28 2:13 GMT+01:00 Bostjan Skufca : > 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_obj

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-27 Thread Joe Watkins
On Fri, 2014-11-28 at 02:13 +0100, Bostjan Skufca wrote: > 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 functio

Re: [PHP-DEV] New function: spl_object_id() or spl_object_handle()

2014-11-27 Thread reeze
Won't `$obj1 === $obj2` work for you ? On 28 November 2014 at 09:13, Bostjan Skufca wrote: > 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