#1099·PHP-Parser

Find a root class of a class

Author: giacomomasseronCreated Aug 7, 2025Updated Aug 7, 2025

Hi,
I need to find the root class of a class.
I tried to use AI, but the code does not work.

class BaseClass {}

class Parent extends BaseClass {}

class Child extends Parent {}

I would need something like:

$root = findRoot('Child'); // It should return "BaseClass"