Repository navigation
Lots of classes do not allow __debugInfo() overrides to work #16317
Description
Activity
FWIW even when this is fixed, the DOM classes will keep throwing an exception in your test because you're using them in an incorrect way. You should be constructing them via the document and register a custom class via registerNodeClass
FWIW even when this is fixed, the DOM classes will keep throwing an exception in your test because you're using them in an incorrect way. You should be constructing them via the document and register a custom class via registerNodeClass
I realize that I'm not using them the way that the DOM extension expects, but since we aren't actually using them for any DOM-related things, why would these keep throwing exceptions? I would expect that
__debugInfo()when called on a class that defines its own such method would trigger that method, and, if it doesn't includeparent::__debugInfo(), never trigger the base class's handling that would throw exceptions.Right, brainfart, indeed that would work.
Since I don't have the permission to edit labels, this should probably be tagged with the various extensions - I see
6 extensions
Original list had 25 and was wrong
- date
- DOM
- intl
- mysqli
- spl
- xmlreader
Plus:
Zend - built in functions (stdClass), exceptions, generatorsThough for a few of these, fixing the handling in the baseExceptionandErrorclasses might solve all of the extension's classesSince this applies to multiple extensions, maybe a general solution should be made.
Reacted by Daniel ScherzerMaybe something in the handling of class registration that does not copy the parent
get_debug_info, or rather does not call that for non-internal classes that define the method themselves? I can try and take a lookIf we are going with a general solution, we may not want to go with #12534 though
Update: thats what I get for coding late at night - the actual list is only 20 classes, from date, dom, intl, spl, mysqli, and XMLReader. I've updated the list in the task description - its probably a good thing we didn't tag this issue with all of the extensions
- added a commit that references this issue
on Oct 9, 2024 9 remaining items
- added a commit that references this issue
on Oct 13, 2025 - added 3 commits that reference this issue
on Oct 13, 2025
Description
Inspired by #11310, I wrote a quick test script to check if there were other classes where creating a subclass with a
__debugInfo()method did not work. I found a number of such classes (the one seg fault I filed separately at #16316 since that is a bigger issue than the override just not working).I tested against b675db4
I did not test against all extensions, `php -m` output provided
Approach: create a custom subclass with an empty constructor, and a
__debugInfo()method returning['x' => 'y']. Thevar_dump()a new instance of that subclass and check the output.I found 17 classes across the DOM and SimpleXML extension where doing this caused an exception to be thrown relating to invalid state, e.g.
List of the 17 classes
I also found a further 20 classes where the override does not seem to work, across multiple extensions.
List of those classes
You can see the script I used at https://gist.github.com/DanielEScherzer/c979c15b47bc603758c4c38ba25dd510
PHP Version
dev-master
Operating System
No response