From 088745109f3c614f1473fdf3e770b4c80a7a5475 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 21 Jul 2021 11:46:43 +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 --- Annotation/Loader.php | 16 +++++++--------- Database/Base/BaseActiveRecord.php | 3 +++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Annotation/Loader.php b/Annotation/Loader.php index 3474ff9e..279f13f2 100644 --- a/Annotation/Loader.php +++ b/Annotation/Loader.php @@ -242,10 +242,9 @@ class Loader extends BaseObject } $_method[] = $attribute->newInstance(); } - - static::$_methods[$replace->getName()][$method->getName()] = $_method; - - $_array['methods'][$method->getName()] = $_method; + if (!empty($_method)) { + static::$_methods[$replace->getName()][$method->getName()] = $_method; + } } return $_array; } @@ -268,10 +267,9 @@ class Loader extends BaseObject } $_property[] = $attribute->newInstance(); } - - static::$_property[$replace->getName()][$method->getName()] = $_property; - - $_array['property'][$method->getName()] = $_property; + if (!empty($_property)) { + static::$_property[$replace->getName()][$method->getName()] = $_property; + } } return $_array; } @@ -348,7 +346,7 @@ class Loader extends BaseObject if ($annotations === null) { continue; } - foreach ($annotations['methods'] as $name => $attribute) { + foreach (static::$_methods[$className] as $name => $attribute) { $this->methods($annotations, $attribute, $annotation, $className, $name); } } diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 8b746ad7..acb3c777 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -147,6 +147,9 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess public function init() { $this->container = Snowflake::app(); + + $an = Snowflake::app()->getAnnotation(); + $an->injectProperty($this); }