Hi internals, I would like to propose exposing a new `__debugType()` magic method. Before going through the RFC process, I’d like to see if it brings some interest.
Implementing this method would allow changing the `get_debug_type()` return value when it is given an instance of the implementing class. The main target is decorators. Currently when a class is decorated, any code calling `get_debug_type()` on an instance of that class gets the decorator FQCN, while in some cases the desired information is the decorated (inner) FQCN. For instance, the Symfony framework decorates a lot of built-in and userland services with “Traceable” classes that are meant to collect debugging information about the inner service e.g. its execution time, return values, or just if it has been called or not when it’s part of a chain. As a result, the code using such service needs to check if the service is decorated via an instanceof check (so it needs to know about the Traceable type) and if it does, it calls a method to access the inner object and use it in exceptions or log messages. Adding such method would allow removing all that boiler. Another target I can think of: inheritance-based proxy classes. What do you think? If this makes sense, I would be happy to work on the implementation myself, eventually with some help from someone already used to php-src’s code. Thank you. Robin Chalas Principal Engineer @Les-Tilleuls.coop 03 66 72 43 94 ro...@les-tilleuls.coop 82 Rue Winston Churchill - 59160 Lomme