ref = & $obj; $this->reader = & $reader; } /** * @param $attribute * @return \stdClass */ public function __get($attribute) { $exploded = explode(".", $attribute); $result = $this->ref; foreach ($exploded as $elem) { if (isset($result->$elem)) { $result = $result->$elem; } else { return null; } } return $result; } }