Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split magical and non-magical implementations #339

Merged
merged 20 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions src/ActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,21 @@
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;

/**
* Active Record class which implements {@see ActiveRecordInterface} and provides additional features like:
*
* - {@see ArrayableInterface}: to convert the object into an array;
* - {@see ArrayAccess}: to access attributes as array elements;
* - {@see IteratorAggregate}: to iterate over attributes;
* - {@see TransactionalInterface}: to handle transactions;
* - {@see MagicPropertiesTrait}: to access attributes as properties;
* - {@see MagicRelationsTrait}: to access relation queries.
*
* @see BaseActiveRecord for more information.
* @see ArrayableInterface to convert the object into an array;
* @see ArrayAccess to access attributes as array elements;
* @see IteratorAggregate to iterate over attributes;
* @see TransactionalInterface to handle transactions;
*
* @template-implements ArrayAccess<string, mixed>
* @template-implements IteratorAggregate<string, mixed>
*
* @see BaseActiveRecord for more information.
*/
class ActiveRecord extends BaseActiveRecord implements
ArrayableInterface,
Expand All @@ -38,7 +34,5 @@ class ActiveRecord extends BaseActiveRecord implements
use ArrayableTrait;
use ArrayAccessTrait;
use ArrayIteratorTrait;
use MagicPropertiesTrait;
use MagicRelationsTrait;
use TransactionalTrait;
}
44 changes: 44 additions & 0 deletions src/MagicActiveRecord.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

declare(strict_types=1);

namespace Yiisoft\ActiveRecord;

use ArrayAccess;
use IteratorAggregate;
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;

/**
* Active Record class which implements {@see ActiveRecordInterface} and provides additional features like:
*
* @see ArrayableInterface to convert the object into an array;
* @see ArrayAccess to access attributes as array elements;
* @see IteratorAggregate to iterate over attributes;
* @see TransactionalInterface to handle transactions;
* @see MagicPropertiesTrait to access attributes as properties;
* @see MagicRelationsTrait to access relation queries.
*
* @template-implements ArrayAccess<string, mixed>
* @template-implements IteratorAggregate<string, mixed>
*
* @see BaseActiveRecord for more information.
*/
class MagicActiveRecord extends BaseActiveRecord implements
samdark marked this conversation as resolved.
Show resolved Hide resolved
ArrayableInterface,
ArrayAccess,
IteratorAggregate,
TransactionalInterface
{
use ArrayableTrait;
use ArrayAccessTrait;
use ArrayIteratorTrait;
use MagicPropertiesTrait;
use MagicRelationsTrait;
use TransactionalTrait;
}
Loading
Loading