From 011424b54b98c53ae5481c8145a0ec47cedaa0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 23 Apr 2021 10:28:11 +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/Base/AbstractCollection.php | 1 - Database/Base/CollectionIterator.php | 8 +------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Database/Base/AbstractCollection.php b/Database/Base/AbstractCollection.php index ec9fd1ac..e2848206 100644 --- a/Database/Base/AbstractCollection.php +++ b/Database/Base/AbstractCollection.php @@ -111,7 +111,6 @@ abstract class AbstractCollection extends Component implements \IteratorAggregat /** * @return mixed - * @throws ComponentException * @throws Exception */ public function getModel(): ActiveRecord diff --git a/Database/Base/CollectionIterator.php b/Database/Base/CollectionIterator.php index bf4ef5a1..54d4f3d8 100644 --- a/Database/Base/CollectionIterator.php +++ b/Database/Base/CollectionIterator.php @@ -57,13 +57,7 @@ class CollectionIterator extends \ArrayIterator */ protected function newModel($current): ActiveRecord { - /** @var ActiveRecord|string $model */ - $model = $this->model; - if (is_object($model)) { - $model = get_class($model); - } - $model = new $model(); - return $model->setAttributes($current); + return $this->model::populate($current); }