Is it possible to get the visibility of methods and properties inside a class in php?
I want to be able to do something like this:
function __call($method, $args)
{
if(is_callable(array($this,$method))
{
if(get_visibility(array($this,$method)) == 'private')
//dosomething
elseif(get_visibility(array($this,$method)) == 'protected')
//dosomething
else
//dosomething
}
}
You might want to consider using PHP’s Reflection API for this. However, I should also ask you why you want to do this, because Reflection usually only gets used in situations that are a bit hacky to begin with. It is possible though, so here goes: