Is there any function in PHP (5.4) to get used traits as array or similar:
class myClass extends movingThings {
use bikes, tanks;
__construct() {
echo 'I\'m using the two traits:' . ????; // bikes, tanks
}
}
Is there any function in PHP (5.4) to get used traits as array or similar:
class myClass extends movingThings {
use bikes, tanks;
__construct() {
echo 'I\'m using the two traits:' . ????; // bikes, tanks
}
}
Short answer: you shouldn't. Traits are almost exactly copy and paste code. You don't NEED to know which traits are used, only on what the traits generate.
Answer I don't want to give: use ReflectionClass::getTraits. I'm not going to elaborate on this one.