From 486daf639a8fbb83d6d667cf527225154df6d8bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 4 Mar 2021 14:34:21 +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 --- Database/ActiveRecord.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/Database/ActiveRecord.php b/Database/ActiveRecord.php index af509d2c..8f6d4f16 100644 --- a/Database/ActiveRecord.php +++ b/Database/ActiveRecord.php @@ -239,32 +239,25 @@ class ActiveRecord extends BaseActiveRecord } /** - * @param $data + * @param $method * @return mixed * @throws Exception */ - private function resolveObject($data): mixed + private function resolveObject($method): mixed { - if (is_numeric($data) || !is_string($data)) { - return $data; - } - if (!method_exists($this, $data)) { - return $data; - } - $resolve = $this->{$data}(); + $resolve = $this->$method(); if ($resolve instanceof HasBase) { $resolve = $resolve->get(); } if ($resolve instanceof Collection) { return $resolve->toArray(); - } - if ($resolve instanceof ActiveRecord) { + } else if ($resolve instanceof ActiveRecord) { return $resolve->toArray(); - } - if (is_object($resolve)) { + } else if (is_object($resolve)) { return get_object_vars($resolve); + } else { + return $resolve; } - return $resolve; }