3v4l.org

run code in 300+ PHP versions simultaneously
<?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));
Output for git.master_jit, git.master
array(6) { [0]=> string(2) "B3" [1]=> string(2) "B2" [2]=> string(2) "B1" [3]=> string(2) "A3" [4]=> string(2) "A2" [5]=> string(2) "A1" }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.76 ms | 719 KiB | 4 Q