3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Blah { function getOne() { return 1;} } abstract class AbstractTest { use Blah; } class Test extends AbstractTest {} function hier($class) { $traits = class_uses($class) ?: []; $parents = class_parents($t) ?: []; foreach ($parents as $parent) { array_merge($traits, hier($parent)); } return $traits; } $t = new Test; echo $t->getOne() . "\n"; var_dump(hier($t));
Output for git.master, git.master_jit, rfc.property-hooks
1 Warning: Undefined variable $t in /in/AAqZK on line 15 Fatal error: Uncaught TypeError: class_parents(): Argument #1 ($object_or_class) must be of type object|string, null given in /in/AAqZK:15 Stack trace: #0 /in/AAqZK(15): class_parents(NULL) #1 /in/AAqZK(29): hier(Object(Test)) #2 {main} thrown in /in/AAqZK on line 15
Process exited with code 255.

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.8 ms | 401 KiB | 8 Q