Julien,

On Fri, Jul 31, 2015 at 10:23 AM, Julien Pauli <jpa...@php.net> 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 not very cool to use later  (why does it even add
> randomness ?).
>
> There has been topics about this subject.
> For example, at http://marc.info/?l=php-internals&m=141814350920452&w=2
>
>
> Beeing able to get the object handle back in PHP userland would ease many
> tools, mainly debug-oriented tools.
> I know PHPUnit, Symfony and many big projects today make use of
> spl_object_hash() to identify objects.
>
> 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 ?
> Why couldn't we help those people by simply adding a new function that does
> the job ?
>
> Thoughts ?
>

I'm not sure about the randomness to the handle, but the hash also
includes the object handler pointer. So without the random, we'd be
leaking information about the memory layout of the application.

And for the record, I am cool with simply exposing the handle.

Anthony

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to