[IDEA for RFC] class_uses and optionally returning traits for parent classes

From: Date: Wed, 25 Mar 2026 07:37:22 +0000
Subject: [IDEA for RFC] class_uses and optionally returning traits for parent classes
Groups: php.internals 
Request: Send a blank email to internals+get-130443@lists.php.net to get a copy of this message
Good Morning Internals, I am aware that traits in general are a topic where people can have strong opinions, so I wanted to get an idea of initial thoughts on this before deciding if it is worth looking into any further. At the moment, there are three functions in SPL that allow access to what a given class is using in some way: * class_implements * class_parents * class_uses (returns the traits the current class uses) class_uses is unique out of the three in that it only returns traits declared on the current class as opposed to the parent class (and higher in inheritance). While this is documented in the manual, looking at the original bug ticket that introduced class_uses (https://bugs.php.net/bug.php?id=55266) then it isn't documented why it only returns traits on the current class. As far as I can tell from the bug ticket and the code, class_implements was copied for class_uses and while _zend_class_entry->interaces contains all interfaces (including from the parent classes), _zend_class_entry->interaces->trait_names does not. So, in terms of my question; what would be the general thoughts on a new optional argument to class_uses that iterates to each parent class, adding the traits from the parent as well? Thanks, Robert

« previous php.internals (#130443) next »