The popular stealz solution doesn't handle traits that use other traits. A little bit of recursion can clean the entire thing up a bit and make it more robust.
<?php
public function class_uses_deep( string $class, bool $autoload = true ) : array {
$traits = class_uses($class, $autoload);
if($parent = get_parent_class($class)) {
$traits = array_merge($traits, class_uses_deep($parent, $autoload));
}
foreach( $traits as $trait ) {
$traits = array_merge($traits, class_uses_deep($trait, $autoload));
}
return $traits;
}
?>