0

I have an array that has my traits:

$traits = [
  'app\traits\TraitNumOne',
  'app\traits\TraitNumTwo',
];

is there any way to use that traits in my class dinamically?

class MyClass {
use $traits[0],$traits[1]; // something like this :)
}

I haven't any idea to solve this, please help

  • AFAIK the only way is through `eval`. But if you have to use it there's definitely something wrong with your design. – Jared Jan 03 '23 at 13:30
  • Why do you need to do it? If you will explain what you want to do, maybe we can suggest another solution – Aro Jan 03 '23 at 13:49

0 Answers0