In PHP, how do I map traits with SPL?

PHP, SPL, traits, ReflectionTrait
An example demonstrating how to map traits using SPL in PHP.
<?php trait ExampleTrait { public function hello() { return "Hello from ExampleTrait!"; } } class ExampleClass { use ExampleTrait; } // Using SPL Reflection to map the trait $reflectionClass = new ReflectionClass('ExampleClass'); $traits = $reflectionClass->getTraits(); foreach ($traits as $trait) { echo "Trait: " . $trait->getName() . "\n"; } // Instantiate the class and call the method $example = new ExampleClass(); echo $example->hello(); // Output: "Hello from ExampleTrait!" ?>

PHP SPL traits ReflectionTrait