Re: New function: spl_object_id() or spl_object_handle()
| From: | Nicolas Grekas | Date: | Tue, 09 Dec 2014 09:31:22 +0000 |
| Subject: | Re: New function: spl_object_id() or spl_object_handle() | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-79492@lists.php.net to get a copy of this message | ||
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