I can’t find anything in the documentation to allow a Class to interrogate the object calling it.
An example of where this would be helpful is when using the magic __get() & __set() overload methods. Say you want to keep your member variables Protected, but you want to avoid having to hard code getters and setters for EVERY variable.
class Test
{
protected $var, $moreVars, $EvenMoreVars....;
public function __set($key, $value)
{
if( /* Check if object attempting to set this variable is my child */)
$this->$key = $value;
else
echo 'You are outside of scope';
}
public function __get($var)
{
if(/* Check if object attempting to get this variable is my child */)
return $this->$var;
else
echo 'You are outside of scope';
}
}