>> it isn't documented why it only returns traits on the current class
> The reason is given here: https://bugs.php.net/bug.php?id=61554#1333085728 :
>> Traits are outside the inheritance system: the
>> parent class is effectively defined by the composition of its own
>> methods/properties and any traits it uses, so trait usage is not actually
>> inherited. Furthermore, it doesn't really make sense to reflect trait usage 
>> down
>> the class hierarchy because the same trait may be used more than once within 
>> a
>> class hierarchy.

Thanks Claude, that is useful to note, when I initially looked, I was
looking for `class_uses` in particular as opposed to `getTraits` from
`Reflection`.

I am not sure I agree with the reasoning though. If you are using
`class_uses` in the first place to check for a trait's presence, then
I can't find any difference in use cases for if a trait is defined at
the current level or parent level. Although the trait is not
inherited, the _effect_ of the trait is.

(While you might get differences in behaviour if using multiple traits
and specifying `insteadof` to resolve conflicts, what functions from
the trait that were used/not used are not provided by `class_uses`, so
the same trait being used more than once doesn't affect any changes to
the function other than needing to dedupe the list)

~ Robert

Reply via email to