An output of the entire inheritance chain using closures, recursion, and OOPclass ParentClass { public static function getChain() { $chain = null; return $function = function($className='') use (& $chain, & $function) { if (empty($className)) $className = static::class; if (empty($chain)) $chain = $className; $parent = get_parent_class($className); if ($parent !== false) { $chain .= " > {$parent}"; return $function($parent); } return $chain; }; }}class Child extends ParentClass {}class SubChild extends Child {}class Sub2 extends SubChild {}class Sub3 extends Sub2 {}class Sub4 extends Sub3 {}class Sub5 extends Sub4 {}class Sub6 extends Sub5 {}class Sub7 extends Sub6 {}printf("%s\n", Sub7::getChain()());$getChain = Sub7::getChain();printf("%s\n", $getChain('Sub3'));Output is:Sub7 > Sub6 > Sub5 > Sub4 > Sub3 > Sub2 > SubChild > Child > ParentClassSub3 > Sub2 > SubChild > Child > ParentClass