As a good practice, should ALL my overloaded __get functions look like this example from https://www.php.net/manual/en/language.oop5.overloading.php#object.isset and include the debugging code?
public function __get($name)
{
echo "Getting '$name'\n";
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
}
/*question specific code from here on*/
$trace = debug_backtrace();
trigger_error(
'Undefined property via __get(): ' . $name .
' in ' . $trace[0]['file'] .
' on line ' . $trace[0]['line'],
E_USER_NOTICE);
return null;
}
It seems like it could end up being a lot of duplicate code if included in every class I overload.