From 599cfc7d105d62f0df06dcf22af482600b210c62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 23 Feb 2021 16:20:19 +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/Annotation.php | 2 +- Database/Base/BaseActiveRecord.php | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Annotation/Annotation.php b/Annotation/Annotation.php index eac65313..f6becad3 100644 --- a/Annotation/Annotation.php +++ b/Annotation/Annotation.php @@ -184,7 +184,7 @@ class Annotation extends Component * @param string $property * @return mixed|null */ - public function getPropertyAnnotation($class, $property = ''): ?array + public function getProperty($class, $property = ''): ?array { if (is_object($class)) { $class = get_class($class); diff --git a/Database/Base/BaseActiveRecord.php b/Database/Base/BaseActiveRecord.php index 15607f99..58bacdbe 100644 --- a/Database/Base/BaseActiveRecord.php +++ b/Database/Base/BaseActiveRecord.php @@ -119,9 +119,14 @@ abstract class BaseActiveRecord extends Component implements IOrm, ArrayAccess { $annotation = Snowflake::app()->getAttributes(); - $this->_annotations = $annotation->getMethods(get_called_class()); + $name = static::class; - $lists = $annotation->getPropertyAnnotation(get_called_class()); + $this->_annotations = $annotation->getMethods($name); + + $lists = $annotation->getProperty($name); + if (empty($lists)) { + return; + } foreach ($lists as $name => $list) { $this->{$name} = $list; }