I really like to write this question because I'm a kind, “scientific guy,” and, well, I always find what I was looking for ... But this one bothers me very much, and I can’t find the answer anywhere ... So , here it is:
As the title says, I need to get the method name with the final class and namespace as a string. I mean something like this: "System\Language\Text::loadLanguageCache"
. As you know, you can get the class name (with a full namespace) by typing, i.e.: Text::class
, and it returns "System\Language\Text"
, but is there any way to get this for the method? Something like: Text::loadLanguageCache::function
to get the string "System\Language\Text::loadLanguageCache"
:?
Edit:
I think I should explain this further ... I know about the magic constant __METHOD__
, but the problem is that it works inside the called method, and I need it "outside the method". Take this as an example:
function someFunction()
{ return __METHOD__; }
Everything is fine with this if I call the function that I get (let it be assumed that the method is in the class System\Helpers
) - "System\Helpers::someFunction"
. But I want this:
function someFunction()
{
function otherFunction()
{
$thatFunctionName = Helpers::someFunction::method
$thatClassName = Helpers::class;
}
Hope this eased my question a bit :)
source
share