On 20/04/2026 12:32, Claude Pache wrote:
I think that `class_uses()` should never have been implemented, because
it gives a false sense of symmetry with `class_implements()` and
`class_parents()`. Implemented interfaces and parent classes can be used
as types on the corresponding object (and types are inherited), while
used traits cannot. Those are fundamentally different concepts.
I agree
If, for some reason, you want to “cheat” and use traits as if they were
inherited types, you are free to do that, but I don’t think that PHP
should provide a built-in function that goes beyond what traits are
intended for.
That won't even work reliably. You can rename trait methods and override
them with methods with incompatible signatures and do other similar
stuff to make this use case a nightmare.
Therefore this:
>> and then where needed checking for the existence of
>> the trait to tell if the functionality is supported or not (think
>> along the lines of if a trait could implement an interface).
is totally impossible to do. A trait with a method does not guarantee
you that the method is available.
Anton