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 they can build their own tools.

In fact, that's what I've done: since Symfony 2.6, you can dump using a
userland function that (IMHO again) is more powerful than var_dump:

http://symfony.com/doc/current/components/var_dumper/introduction.html

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

But I'd prefer replacing this trick by a dedicated function. So, with
Julien Pauli, we worked on such a function. Symfony 2.6 also embeds a PHP
extension that exposes more meta data about variables:
https://github.com/symfony/symfony/tree/2.6/src/Symfony/Component/Debug/Resources/ext

The function implemented in this extension is the root primitive that
enables building a feature-full dumper, without resorting to tricks in PHP.

Any interest in putting this in PHP core? Please feel free to do so, you
have my vote :)

Many thanks,
Nicolas

Reply via email to