What is the purpose of using get_called_class() in PHP and what limitations does it have?

The get_called_class() function in PHP is used to retrieve the name of the class that is calling the method within which it is used. This can be useful for implementing certain design patterns or for debugging purposes. However, one limitation of get_called_class() is that it only returns the name of the class that directly called the method, and not the class where the method is actually defined.

class ParentClass {
    public static function getClassName() {
        return get_called_class();
    }
}

class ChildClass extends ParentClass {
    
}

echo ChildClass::getClassName(); // Output: ChildClass