class_uses_recursive

The class_uses_recursive function returns all traits used by a class, including traits used by all of its parent classes:
<?php $traits = class_uses_recursive(App\Models\User::class);
<?php     public function dispatchNow($command, $handler = null)

    {

        $uses = class_uses_recursive($command);



        if (in_array(InteractsWithQueue::class, $uses) &&

            in_array(Queueable::class, $uses) &&
<?php     {

        parent::__construct();



        if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {

            $this->addTestOptions();

        }
<?php         $info = $this->type;



        if (in_array(CreatesMatchingTest::class, class_uses_recursive($this))) {

            if ($this->handleTestCreation($path)) {

                $info .= ' and test';

            }
<?php     protected function isPrunable($model)

    {

        $uses = class_uses_recursive($model);



        return in_array(Prunable::class, $uses) || in_array(MassPrunable::class, $uses);

    }
<?php         $instance = new $model;



        $count = $instance->prunable()

            ->when(in_array(SoftDeletes::class, class_uses_recursive(get_class($instance))), function ($query) {

                $query->withTrashed();

            })->count();
<?php             return $this->macroCall($method, $parameters);

        }



        if ($method === 'trashed' && in_array(SoftDeletes::class, class_uses_recursive($this->modelName()))) {

            return $this->state([

                $this->newModel()->getDeletedAtColumn() => $parameters[0] ?? Carbon::now()->subDay(),

            ]);
<?php         $total = 0;



        do {

            $total += $count = in_array(SoftDeletes::class, class_uses_recursive(get_class($this)))

                        ? $query->forceDelete()

                        : $query->delete();
<?php         static::$traitInitializers[$class] = [];



        foreach (class_uses_recursive($class) as $trait) {

            $method = 'boot'.class_basename($trait);



            if (method_exists($class, $method) && ! in_array($method, $booted)) {
<?php         $this->load(collect($this->relations)->reject(function ($relation) {

            return $relation instanceof Pivot

                || (is_object($relation) && in_array(AsPivot::class, class_uses_recursive($relation), true));

        })->keys()->all());



        $this->syncOriginal();
<?php         $total = 0;



        $this->prunable()

            ->when(in_array(SoftDeletes::class, class_uses_recursive(get_class($this))), function ($query) {

                $query->withTrashed();

            })->chunkById($chunkSize, function ($models) use (&$total) {

                $models->each->prune();
<?php     {

        $this->pruning();



        return in_array(SoftDeletes::class, class_uses_recursive(get_class($this)))

                ? $this->forceDelete()

                : $this->delete();

    }
<?php             return $table;

        }



        if (in_array(AsPivot::class, class_uses_recursive($model))) {

            $this->using($table);

        }
<?php     public function throughParentSoftDeletes()

    {

        return in_array(SoftDeletes::class, class_uses_recursive($this->throughParent));

    }
<?php             return $this->foreignId($column);

        }



        $modelTraits = class_uses_recursive($model);



        if (in_array(HasUlids::class, $modelTraits, true)) {

            return $this->foreignUlid($column);
<?php             ? $this->container->call([$this, 'run'], $parameters)

            : $this->run(...$parameters);



        $uses = array_flip(class_uses_recursive(static::class));



        if (isset($uses[WithoutModelEvents::class])) {

            $callback = $this->withoutModelEvents($callback);