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
* @return mixed
@@ -137,10 +152,7 @@ class Component extends BaseObject
*/
public function __get($name)
{
$method = 'get' . ucfirst($name);
if (method_exists($this, $method)) {
return $this->$method();
} else if (property_exists($this, $name)) {
if (property_exists($this, $name)) {
return $this->$name ?? null;
} else {
return parent::__get($name);