<?php trait A1 { public $propA1; } trait A2 { use A1; public $propA2; } trait A3 { use A2; public $propA3; } trait B1 { public $propB1; } trait B2 { use B1; public $propB2; } trait B3 { use B2; public $propB3; } class X { use A3; } class Y extends X { use B3; } function getTraits(ReflectionClass $c): array { $t = array_values(array_map(getTraits(...), $c->getTraits())); return array_merge($c->getTraitNames(), ...$t); } $rc = new ReflectionClass('Y'); $traits = []; $c = $rc; while ($c) { $traits[] = getTraits($c); $c = $c->getParentClass(); } var_dump(array_merge(...$traits));
You have javascript disabled. You will not be able to edit any code.