/** * Return TRUE if property has public visibility * @return bool * @param $key string **/ protected function visible($key) { if (property_exists($this, $key)) { $ref = new ReflectionProperty(get_class($this), $key); $out = $ref->ispublic(); unset($ref); return $out; } return FALSE; }
/** * Return TRUE if property has public visibility * * @return bool * @param $key string * */ protected function isPublic($key) { if (property_exists($this, $key)) { try { $ref = new \ReflectionProperty(get_class($this), $key); $out = $ref->ispublic(); unset($ref); } catch (\Exception $e) { // property is set but is not defined in the class: makes it a dynamic prop, so it's public $out = true; } return $out; } return false; }