From 0098e1bc6f16227be5452178ff22e17133d4a0cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 2 Sep 2020 15:37:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- system/Abstracts/Component.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/system/Abstracts/Component.php b/system/Abstracts/Component.php index 4e72e356..f7d02032 100644 --- a/system/Abstracts/Component.php +++ b/system/Abstracts/Component.php @@ -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);