The function name can be easily obtained by the __FUNCTION__ or the __METHOD__
Method 1 (Prints function name):
__FUNCTION__ is used to resolve function name or method name (function in class).
string(3) "foo" string(3) "bar"
Method 2 (Prints function and class name):
string(3) "bar" string(9) "Test::foo"
Note: this code is tested with php7.1