From b11fdcc63d7014d118f2027ac267ec1a9877594d Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 21 May 2024 14:46:59 +0700 Subject: [PATCH 1/2] Rename `ActiveRecord` to `BaseActiveRecord` --- src/{ActiveRecord.php => BaseActiveRecord.php} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/{ActiveRecord.php => BaseActiveRecord.php} (98%) diff --git a/src/ActiveRecord.php b/src/BaseActiveRecord.php similarity index 98% rename from src/ActiveRecord.php rename to src/BaseActiveRecord.php index d282e144d..558640115 100644 --- a/src/ActiveRecord.php +++ b/src/BaseActiveRecord.php @@ -91,7 +91,7 @@ * @template-implements ArrayAccess * @template-implements IteratorAggregate */ -class ActiveRecord extends AbstractActiveRecord implements ArrayableInterface, ArrayAccess, IteratorAggregate, TransactionalInterface +class BaseActiveRecord extends AbstractActiveRecord implements ArrayableInterface, ArrayAccess, IteratorAggregate, TransactionalInterface { use ArrayableTrait; use ArrayAccessTrait; From 4d498e9cee6f8ed112a7410a69f781437b99b64e Mon Sep 17 00:00:00 2001 From: Tigrov Date: Tue, 21 May 2024 15:20:01 +0700 Subject: [PATCH 2/2] Add `ActiveRecord` --- src/ActiveRecord.php | 44 ++++++++++++++++++++++++++++++++++++++++ src/BaseActiveRecord.php | 26 ++---------------------- 2 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 src/ActiveRecord.php diff --git a/src/ActiveRecord.php b/src/ActiveRecord.php new file mode 100644 index 000000000..f2a7f830e --- /dev/null +++ b/src/ActiveRecord.php @@ -0,0 +1,44 @@ + + * @template-implements IteratorAggregate + */ +class ActiveRecord extends BaseActiveRecord implements + ArrayableInterface, + ArrayAccess, + IteratorAggregate, + TransactionalInterface +{ + use ArrayableTrait; + use ArrayAccessTrait; + use ArrayIteratorTrait; + use MagicPropertiesTrait; + use MagicRelationsTrait; + use TransactionalTrait; +} diff --git a/src/BaseActiveRecord.php b/src/BaseActiveRecord.php index 558640115..cf5a64260 100644 --- a/src/BaseActiveRecord.php +++ b/src/BaseActiveRecord.php @@ -4,16 +4,7 @@ namespace Yiisoft\ActiveRecord; -use ArrayAccess; -use IteratorAggregate; use Throwable; -use Yiisoft\ActiveRecord\Trait\ArrayableTrait; -use Yiisoft\ActiveRecord\Trait\ArrayAccessTrait; -use Yiisoft\ActiveRecord\Trait\ArrayIteratorTrait; -use Yiisoft\ActiveRecord\Trait\MagicPropertiesTrait; -use Yiisoft\ActiveRecord\Trait\MagicRelationsTrait; -use Yiisoft\ActiveRecord\Trait\TransactionalTrait; -use Yiisoft\Arrays\ArrayableInterface; use Yiisoft\Db\Exception\Exception; use Yiisoft\Db\Exception\InvalidArgumentException; use Yiisoft\Db\Exception\InvalidConfigException; @@ -30,7 +21,7 @@ use function preg_replace; /** - * ActiveRecord is the base class for classes representing relational data in terms of objects. + * Base Active Record class which implements {@see ActiveRecordInterface} with the minimum set of methods. * * Active Record implements the [Active Record design pattern](https://en.wikipedia.org/wiki/Active_record). * @@ -84,22 +75,9 @@ * * For more details and usage information on ActiveRecord, * {@see the [guide article on ActiveRecord](guide:db-active-record)} - * - * @method ActiveQuery hasMany($class, array $link) {@see BaseActiveRecord::hasMany()} for more info. - * @method ActiveQuery hasOne($class, array $link) {@see BaseActiveRecord::hasOne()} for more info. - * - * @template-implements ArrayAccess - * @template-implements IteratorAggregate */ -class BaseActiveRecord extends AbstractActiveRecord implements ArrayableInterface, ArrayAccess, IteratorAggregate, TransactionalInterface +class BaseActiveRecord extends AbstractActiveRecord { - use ArrayableTrait; - use ArrayAccessTrait; - use ArrayIteratorTrait; - use MagicPropertiesTrait; - use MagicRelationsTrait; - use TransactionalTrait; - public function attributes(): array { return $this->getTableSchema()->getColumnNames();