src/mako/syringe/ClassInspector.php
public static function getTraits($class, bool $autoload = true): array
	{
		// Fetch all traits used by a class and its parents

		$traits = [];

		do
		{
			$traits += class_uses($class, $autoload);
		}
		while($class = get_parent_class($class));

		// Find all traits used by the traits

		$search = $traits;

		$searched = [];

		while(!empty($search))
		{
			$trait = array_pop($search);

			if(isset($searched[$trait]))
			{
				continue;
			}

			$traits += $search += class_uses($trait, $autoload);

			$searched[$trait] = $trait;
		}

		// Return complete list of traits used by the class

		return $traits;
	}
public static function getTraits($class, bool $autoload = true): array
	{
		// Fetch all traits used by a class and its parents

		$traits = [];

		do
		{
			$traits += class_uses($class, $autoload);
		}
		while($class = get_parent_class($class));

		// Find all traits used by the traits

		$search = $traits;

		$searched = [];

		while(!empty($search))
		{
			$trait = array_pop($search);

			if(isset($searched[$trait]))
			{
				continue;
			}

			$traits += $search += class_uses($trait, $autoload);

			$searched[$trait] = $trait;
		}

		// Return complete list of traits used by the class

		return $traits;
	}
public static function getTraits ( $ class , bool $ autoload = true ) : array { // Fetch all traits used by a class and its parents $ traits = [ ] ; do { $ traits += class_uses ( $ class , $ autoload ) ; } while ( $ class = get_parent_class ( $ class ) ) ; // Find all traits used by the traits $ search = $ traits ; $ searched = [ ] ; while ( ! empty ( $ search ) ) { $ trait = array_pop ( $ search ) ; if ( isset ( $ searched [ $ trait ] ) ) { continue ; } $ traits += $ search += class_uses ( $ trait , $ autoload ) ; $ searched [ $ trait ] = $ trait ; } // Return complete list of traits used by the class return $ traits ; }
Returns an array of all traits used by a class.

@param  string|object $class    Class name or class instance
@param  bool          $autoload Autoload
@return array
Returns an array of all traits used by a class .