Re: [PHP-DEV] Exposing object handles to userland

2017-07-11 Thread tyson andre
> Just to clarify, that means object ids are still re-used between > objects if one gets destroyed? > The initial bug report was about creating a second function that solves this > problem.  Correct. This is intended to return the object handles. The most recent discussion from 2015 was only a

Re: [PHP-DEV] Exposing object handles to userland

2017-07-11 Thread Benjamin Eberlei
On Tue, Jul 11, 2017 at 12:21 PM, Nikita Popov wrote: > On Tue, Jul 11, 2017 at 11:52 AM, Marco Pivetta > wrote: > > > Asking here, since it's not clear to me: is this a good/fitting > > replacement for `spl_object_hash()`? > > > > On 11 Jul 2017 7:00 AM, "tyson andre" wrote: > > > >> >> How lo

Re: [PHP-DEV] Exposing object handles to userland

2017-07-11 Thread Sara Golemon
On Tue, Jul 4, 2017 at 8:01 PM, tyson andre wrote: > I'm unsure if an RFC is necessary. I have two pending questions. > Unless someone insists upon it, I'll put my release manager hat on and say I'm fine with it just going in without an RFC. -Sara -- PHP Internals - PHP Runtime Development Mail

Re: [PHP-DEV] Exposing object handles to userland

2017-07-11 Thread Nikita Popov
On Tue, Jul 11, 2017 at 11:52 AM, Marco Pivetta wrote: > Asking here, since it's not clear to me: is this a good/fitting > replacement for `spl_object_hash()`? > > On 11 Jul 2017 7:00 AM, "tyson andre" wrote: > >> >> How long should I wait to see if there are objections before creating >> a pull

Re: [PHP-DEV] Exposing object handles to userland

2017-07-11 Thread Marco Pivetta
Asking here, since it's not clear to me: is this a good/fitting replacement for `spl_object_hash()`? On 11 Jul 2017 7:00 AM, "tyson andre" wrote: > >> How long should I wait to see if there are objections before creating a > pull request? > >AFAIK you can create PR any time. > > I created a PR i

Re: [PHP-DEV] Exposing object handles to userland

2017-07-10 Thread tyson andre
>> How long should I wait to see if there are objections before creating a pull >> request? >AFAIK you can create PR any time. I created a PR implementing spl_object_id(object $o) : int several days ago, at https://github.com/php/php-src/pull/2611 -- PHP Internals - PHP Runtime Development Mailin

Re: [PHP-DEV] Exposing object handles to userland

2017-07-05 Thread Michał Brzuchalski
06.07.2017 07:24 "tyson andre" napisał(a): > > Updated https://github.com/TysonAndre/php-src/pull/1 , which is now much shorter. > > In response to Nikita Popov's comments: > > > I'm +1 on the addition and would be fine with including it without RFC, if > > there are no objections on internals. >

Re: [PHP-DEV] Exposing object handles to userland

2017-07-05 Thread tyson andre
Updated https://github.com/TysonAndre/php-src/pull/1 , which is now much shorter. In response to Nikita Popov's comments: > I'm +1 on the addition and would be fine with including it without RFC, if > there are no objections on internals. How long should I wait to see if there are objections be

Re: [PHP-DEV] Exposing object handles to userland

2017-07-05 Thread Stanislav Malyshev
Hi! > On 32-bit zend_long is a signed 32-bit int, so it can theoretically overflow, > while sizeof is same. Well, it's the same issue we having on representing any unsigned values, I guess. Since int<->uint in this case is one-to-one, should be ok to just use the negative nums, if they are used

Re: [PHP-DEV] Exposing object handles to userland

2017-07-05 Thread Stanislav Malyshev
Hi! > No: In PHP 7 this is not possible, which is also why spl_object_hash() no > longer includes the handlers. Ah, I missed that part. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

RE: [PHP-DEV] Exposing object handles to userland

2017-07-05 Thread Anatol Belski
Hi, > -Original Message- > From: Stanislav Malyshev [mailto:smalys...@gmail.com] > Sent: Wednesday, July 5, 2017 5:28 AM > To: tyson andre ; internals@lists.php.net > Subject: Re: [PHP-DEV] Exposing object handles to userland > > Hi! > > > - Can two objec

Re: [PHP-DEV] Exposing object handles to userland

2017-07-05 Thread Nikita Popov
On Wed, Jul 5, 2017 at 2:01 AM, tyson andre wrote: > There was a proposal back in 2015 to implement > a function spl_object_id(object $o) : int`, > which directly returns the object handle > (similar to `spl_object_hash`, but as an integer, not a string). > I'm interested in finishing implementin

Re: [PHP-DEV] Exposing object handles to userland

2017-07-04 Thread Stanislav Malyshev
Hi! > - Can two objects can have the same object id > but different object handlers? > (e.g. iterators of some built in classes?) > I'm not familiar enough with PHP's history to be sure. Yes, if extension using non-standard handlers is in use. > - Can the the largest object handle be large

RE: [PHP-DEV] Exposing object handles to userland

2017-07-04 Thread tyson andre
There was a proposal back in 2015 to implement a function spl_object_id(object $o) : int`, which directly returns the object handle (similar to `spl_object_hash`, but as an integer, not a string). I'm interested in finishing implementing spl_object_id for php 7.2 I already have working code imple

RE: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Anatol Belski
Hi Anthony, > -Original Message- > From: Anthony Ferrara [mailto:ircmax...@gmail.com] > Sent: Monday, August 3, 2015 5:39 PM > To: Anatol Belski > Cc: Nicolas Grekas ; Rowan Collins > ; internals@lists.php.net > Subject: Re: [PHP-DEV] Exposing object handles to use

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Stanislav Malyshev
Hi! > Ehm, you realize that object id is only reset because the old object is > freed? As long as the target object is referenced, nothing will have the same > object id. Yes, but if you use it as some sort of ID - e.g. as in "did I already create a object of class X with parameters stated in c

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Anthony Ferrara
To: Rowan Collins >> Cc: internals@lists.php.net >> Subject: Re: [PHP-DEV] Exposing object handles to userland >> >> > >- more importantly for users, these ids couldn't be compared to >> > >var_dumps'. >> > >> > Why do you need to compa

RE: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Anatol Belski
Hi Nicolas, > -Original Message- > From: nicolas.gre...@gmail.com [mailto:nicolas.gre...@gmail.com] On Behalf > Of Nicolas Grekas > Sent: Monday, August 3, 2015 1:29 PM > To: Rowan Collins > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] Exposing objec

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Alexander Lisachenko
2015-08-03 16:10 GMT+03:00 Etienne Kneuss : > As for PHP, It seems like what people actually want is a unique identifier > for objects (for the lifetime of the request), but they compromise and use > the handle instead as it is available without userland counter. Probable, there is no actual nee

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Etienne Kneuss
On Mon, Aug 3, 2015 at 2:26 PM Alexander Lisachenko wrote: > Hello, internals! > > I like the idea to assign a custom identifier to the object, but why this > should be only in the core? Java has a method 'hashCode' which can be used > to return an unique identifier for specific object. Java's

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Alexander Lisachenko
Hello, internals! I like the idea to assign a custom identifier to the object, but why this should be only in the core? Java has a method 'hashCode' which can be used to return an unique identifier for specific object. So, my suggestion is to add 'Hashable' interface for that into the PHP. Then,

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Rowan Collins
On 3 August 2015 12:28:48 BST, Nicolas Grekas wrote: >Oh, and an other benefit of the handle is that it gives a rough >estimation >of the number of objects created and their instantiation order. When >debugging, any hints count. That is exactly the detail that people don't want to expose, or pro

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Nicolas Grekas
> >- more importantly for users, these ids couldn't be compared to > >var_dumps'. > > Why do you need to compare the output of two dump functions? Just add a > note to the documentation that these are not the same IDs. > That's not a strong feature, but still, it makes the tool a little bit more c

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Lester Caine
On 02/08/15 10:05, Stanislav Malyshev wrote: >> I'd more than happy to have an spl_object_id() function btw! > I wouldn't be very happy, because it is wrong design to base userland > PHP code on a detail of an implementation of the engine. That's why > there was a hash and not direct ID - so that t

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Rowan Collins
On 3 August 2015 11:52:06 BST, Nicolas Grekas wrote: >> So, yes, just to make it more human friendly. In which case, the >actual >> value doesn't matter, and rather than reverse-engineering the hash, >you >> could just make up your own ID: >> >> function my_object_id($obj) { >> static $hash_t

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Nicolas Grekas
> So, yes, just to make it more human friendly. In which case, the actual > value doesn't matter, and rather than reverse-engineering the hash, you > could just make up your own ID: > > function my_object_id($obj) { > static $hash_to_id=[]; > $hash = spl_object_hash($obj); > if ( ! arra

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Rowan Collins
On 3 August 2015 08:20:18 BST, Nicolas Grekas wrote: >2015-08-02 20:03 GMT+02:00 Rowan Collins : > >> On 02/08/2015 18:41, Bob Weinand wrote: >> >>> Some suspicious use of spl_object_hash() out there... > > >> > >https://github.com/symfony/symfony/blob/master/src/Symfony/Compone

Re: [PHP-DEV] Exposing object handles to userland

2015-08-03 Thread Nicolas Grekas
2015-08-02 20:03 GMT+02:00 Rowan Collins : > On 02/08/2015 18:41, Bob Weinand wrote: > >> Some suspicious use of spl_object_hash() out there... >>> > >>> >> https://github.com/symfony/symfony/blob/master/src/Symfony/Component/VarDumper/Cloner/VarCloner.php >>> > >>> >Not sure what t

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Rowan Collins
On 02/08/2015 18:41, Bob Weinand wrote: Some suspicious use of spl_object_hash() out there... > >>https://github.com/symfony/symfony/blob/master/src/Symfony/Component/VarDumper/Cloner/VarCloner.php > >Not sure what this one does... but calculations with spl_object_hash() >look very suspicious.

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Bob Weinand
> Am 02.08.2015 um 19:09 schrieb Derick Rethans : > > On Fri, 31 Jul 2015, Julien Pauli wrote: > >> Hi people. >> >> I've been pinged many times to add a new spl_object_id() function to PHP, >> that would return the internal object handle of an object. >> >> Today, spl_object_hash() partially

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Bob Weinand
As I describe below, I agree with Nikita on spl_object_id(). > Am 02.08.2015 um 08:52 schrieb Stanislav Malyshev : > > Hi! > > Some suspicious use of spl_object_hash() out there... > >> https://github.com/symfony/symfony/blob/master/src/Symfony/Component/VarDumper/Cloner/VarCloner.php > > Not

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Derick Rethans
On Fri, 31 Jul 2015, Julien Pauli wrote: > Hi people. > > I've been pinged many times to add a new spl_object_id() function to PHP, > that would return the internal object handle of an object. > > Today, spl_object_hash() partially allows that, but adds many randomness to > the result, which is

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Stanislav Malyshev
Hi! > This is already part of the public API: var_dump and debug_zval_dump do > expose object IDs to userland. It's just inefficient to get for more Debug functions are not the part of public API. If you rely on anything var_dump is producing for your code to work, you risk your code being broken

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Nicolas Grekas
Hi Stas, thanks for hooking into this thread However, committing to having specific object ID (e.g. as integer) as > part of public API is pretty big commitment This is already part of the public API: var_dump and debug_zval_dump do expose object IDs to userland. It's just inefficient to get f

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Stanislav Malyshev
Hi! > It would be awesome if this patch could be applied for php 7.0! Please don't. This changes the whole meaning of spl_object_hash, and serves no useful purpose. If you need the id so much, it should be a separate function. I am still against exposing raw IDs, but if the consensus is we need t

Re: [PHP-DEV] Exposing object handles to userland

2015-08-02 Thread Stanislav Malyshev
Hi! > I'd prefer to add a separate function spl_object_id, which directly returns > the handle. This should supersede spl_object_hash in the long run. Since in PHP 7 there's no longer a possibility of having different object stores, as far as I can see, spl_object_id can identify an object (it wa

Re: [PHP-DEV] Exposing object handles to userland

2015-08-01 Thread Stanislav Malyshev
Hi! Some suspicious use of spl_object_hash() out there... > https://github.com/symfony/symfony/blob/master/src/Symfony/Component/VarDumper/Cloner/VarCloner.php Not sure what this one does... but calculations with spl_object_hash() look very suspicious. > > https://github.com/horde/horde/blob/

Re: [PHP-DEV] Exposing object handles to userland

2015-08-01 Thread Stanislav Malyshev
Hi! > I've been pinged many times to add a new spl_object_id() function to PHP, > that would return the internal object handle of an object. What would be the use of this? > Today, spl_object_hash() partially allows that, but adds many randomness to > the result, which is not very cool to use la

Re: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Nikita Popov
On Fri, Jul 31, 2015 at 4:53 PM, Nicolas Grekas < nicolas.grekas+...@gmail.com> wrote: > > I also know people that print_r($an_object) and parse the output just to >> extract the object handle from there... Crazy isn't it ? >> > > I plead guilty for doing this, but php let me no better choice for

Re: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Anthony Ferrara
Nicolas, On Fri, Jul 31, 2015 at 2:24 PM, Nicolas Grekas wrote: >> Anthony's argument about exposing the mem layout is crucial, though. >> > > Yes it is! > > The patch I attached un-xors only the part for the object's handle. > The memory pointer is kept xored. Just checked the patch, perfect :-

Re: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Nicolas Grekas
> Anthony's argument about exposing the mem layout is crucial, though. > Yes it is! The patch I attached un-xors only the part for the object's handle. The memory pointer is kept xored.

RE: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Anatol Belski
; ; cont...@jubianchi.fr > Subject: Re: [PHP-DEV] Exposing object handles to userland > > > > > Have you checked the impact of changing the existing function? > > > > Yes I did, and this breaks absolutely nothing: the spl_object_hash output has > exactly the same format (o

Re: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Anthony Ferrara
Julien, On Fri, Jul 31, 2015 at 10:23 AM, Julien Pauli wrote: > Hi people. > > I've been pinged many times to add a new spl_object_id() function to PHP, > that would return the internal object handle of an object. > > Today, spl_object_hash() partially allows that, but adds many randomness to >

RE: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Anatol Belski
on test/debug user land tools would give a better sight, so CC’ing. Regards Anatol From: nicolas.gre...@gmail.com [mailto:nicolas.gre...@gmail.com] On Behalf Of Nicolas Grekas Sent: Friday, July 31, 2015 4:53 PM To: Julien Pauli Cc: PHP Internals Subject: Re: [PHP-DEV] E

Re: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Nicolas Grekas
> > Have you checked the impact of changing the existing function? > Yes I did, and this breaks absolutely nothing: the spl_object_hash output has exactly the same format (otherwise it's a bug). > > > > > http

Re: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Nicolas Grekas
> I also know people that print_r($an_object) and parse the output just to > extract the object handle from there... Crazy isn't it ? > I plead guilty for doing this, but php let me no better choice for now ;) The attached patch removes the XOR hashing for the object handle (it's useless, the "se

RE: [PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Anatol Belski
Hi, > -Original Message- > From: julienpa...@gmail.com [mailto:julienpa...@gmail.com] On Behalf Of > Julien Pauli > Sent: Friday, July 31, 2015 4:24 PM > To: PHP Internals > Subject: [PHP-DEV] Exposing object handles to userland > > Hi people. > > I'

[PHP-DEV] Exposing object handles to userland

2015-07-31 Thread Julien Pauli
Hi people. I've been pinged many times to add a new spl_object_id() function to PHP, that would return the internal object handle of an object. Today, spl_object_hash() partially allows that, but adds many randomness to the result, which is not very cool to use later (why does it even add random