public static function traitsList($object, $autoload = true)
    {
        $traits = [];

        // Get traits of all parent classes
        do {
            $traits = array_merge(class_uses($object, $autoload), $traits);
        } while ($object = get_parent_class($object));

        // Get traits of all parent traits
        $traitsToSearch = $traits;
        while (!empty($traitsToSearch)) {
            $newTraits = class_uses(array_pop($traitsToSearch), $autoload);
            $traits = array_merge($newTraits, $traits);
            $traitsToSearch = array_merge($newTraits, $traitsToSearch);
        };

        foreach ($traits as $trait => $same) {
            $traits = array_merge(class_uses($trait, $autoload), $traits);
        }

        return $traits;
    }
public static function traitsList($object, $autoload = true)
    {
        $traits = [];

        // Get traits of all parent classes
        do {
            $traits = array_merge(class_uses($object, $autoload), $traits);
        } while ($object = get_parent_class($object));

        // Get traits of all parent traits
        $traitsToSearch = $traits;
        while (!empty($traitsToSearch)) {
            $newTraits = class_uses(array_pop($traitsToSearch), $autoload);
            $traits = array_merge($newTraits, $traits);
            $traitsToSearch = array_merge($newTraits, $traitsToSearch);
        };

        foreach ($traits as $trait => $same) {
            $traits = array_merge(class_uses($trait, $autoload), $traits);
        }

        return $traits;
    }
public static function traitsList ( $ object , $ autoload = true ) { $ traits = [ ] ; // Get traits of all parent classes do { $ traits = array_merge ( class_uses ( $ object , $ autoload ) , $ traits ) ; } while ( $ object = get_parent_class ( $ object ) ) ; // Get traits of all parent traits $ traitsToSearch = $ traits ; while ( ! empty ( $ traitsToSearch ) ) { $ newTraits = class_uses ( array_pop ( $ traitsToSearch ) , $ autoload ) ; $ traits = array_merge ( $ newTraits , $ traits ) ; $ traitsToSearch = array_merge ( $ newTraits , $ traitsToSearch ) ; } ; foreach ( $ traits as $ trait => $ same ) { $ traits = array_merge ( class_uses ( $ trait , $ autoload ) , $ traits ) ; } return $ traits ; }
Get an array with all traits for a given object

@param object $object
@param boolean $autoload
@return array
@since 1.0.17
@see https://www.php.net/manual/en/function.class-uses.php#122427
Get an array with all traits for a given object