PHP:我可以获得在我的课程中调用我的方法的行吗?

Say I have MyClass.php

class MyClass
{
    public static function myMethod()
    {
        // Here I want to know the line (and file) where my method has been called
    }
}

And SomeOtherFile.php

// other code ...

MyClass::myMethod();

// other code ...

So, is there a way to get the line from SomeOtherFile, where myMethod() has been called directly in myMethod? I mean, without passing the line as parameter.

debug_backtrace() should do the job:

class MyClass
{
    public static function myMethod()
    {
        var_dump(debug_backtrace());
    }
}