GetClassTraits::getClassTraits()

Not yet in a tagged release

Description

GetClassTraits::getClassTraits() returns a list of all the traits used by a class or object. The list includes all traits used by parent classes, and by the traits in the list too.

GetClassTraits::getClassTraits() is a deeper-inspecting version of PHP's class_uses().

use GanbaroDigital\MissingBits\TypeInspectors\GetClassTraits;
public array GetClassTraits::getClassTraits(mixed $item);

Parameters

The input parameters are:

Return Value

GetClassTraits::getClassTraits() returns an array.

The resulting list is a complete list of the traits used by $item.

PHP doesn't support using traits in interfaces.

That's why GetClassTraits::getClassTraits() always returns an empty list for an interface.

Throws

GetClassTraits::getClassTraits() does not throw any exceptions.

Works With

GetClassTraits::getClassTraits() is supported on these versions of PHP:

PHP Version Works?
5.5 Yes
5.6 Yes
7.0 Yes
HHVM Yes