This commit is contained in:
2020-09-02 15:37:06 +08:00
parent a458400bdd
commit 0098e1bc6f
+16 -4
View File
@@ -130,6 +130,21 @@ class Component extends BaseObject
} }
/**
* @param $name
* @param $value
* @throws Exception
*/
public function __set($name, $value)
{
if (property_exists($this, $name)) {
$this->$name = $value;
} else {
parent::__set($name, $value);
}
}
/** /**
* @param $name * @param $name
* @return mixed * @return mixed
@@ -137,10 +152,7 @@ class Component extends BaseObject
*/ */
public function __get($name) public function __get($name)
{ {
$method = 'get' . ucfirst($name); if (property_exists($this, $name)) {
if (method_exists($this, $method)) {
return $this->$method();
} else if (property_exists($this, $name)) {
return $this->$name ?? null; return $this->$name ?? null;
} else { } else {
return parent::__get($name); return parent::__get($name);