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

Update the comments of the method createQueryTo in ActiveRecordFactory so that the IDE can automatically identify the specific class of ActiveRecord #280

Merged
merged 51 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
12c3300
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
be499a5
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
3988dcc
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
424f841
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
b64dde5
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
0f680fe
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
594a222
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
08711a6
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
cb9db0e
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
044755d
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
fa7c4cb
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 9, 2023
0af5333
Update src/BaseActiveRecord.php
niqingyang Dec 10, 2023
baf1889
Update src/ActiveRecordInterface.php
niqingyang Dec 10, 2023
b479a12
Revert "Update src/ActiveRecordInterface.php"
niqingyang Dec 10, 2023
0af32f1
Revert "Update src/BaseActiveRecord.php"
niqingyang Dec 10, 2023
c84a97d
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 10, 2023
2b82b2b
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 10, 2023
32cc7b4
Update tests/Driver/Oracle/ActiveRecordTest.php
niqingyang Dec 11, 2023
8583269
Update tests/Driver/Pgsql/ActiveRecordTest.php
niqingyang Dec 11, 2023
e299dfa
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 11, 2023
1f86104
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 11, 2023
43f615b
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 11, 2023
418be7d
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 11, 2023
564e019
implement the interface ArrayableInterface for BaseActiveRecord
niqingyang Dec 11, 2023
20e8962
Merge branch 'yiisoft:master' into master
niqingyang Dec 19, 2023
a5ab133
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
ae57733
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
480c0e1
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
5044c91
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
8f360aa
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
0d4ccc0
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
64b5b31
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 19, 2023
d531911
Update src/ActiveRecordFactory.php
niqingyang Dec 27, 2023
c62cd19
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 29, 2023
f488291
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Dec 29, 2023
8430f4a
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Jan 2, 2024
491e8f2
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Jan 2, 2024
6ce2ce3
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Jan 2, 2024
f3158eb
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Jan 2, 2024
7950258
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Jan 2, 2024
919ccb1
Update the comments of the method createQueryTo in ActiveRecordFactor…
niqingyang Jan 2, 2024
2991192
Update src/ActiveQuery.php
niqingyang Jan 3, 2024
ec3a466
Update src/ActiveRecordFactory.php
niqingyang Jan 3, 2024
236c7af
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
15e9484
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
380e4dc
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
80b1a83
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
040a83a
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
ff9f101
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
801b80a
Update src/BaseActiveRecord.php
niqingyang Jan 3, 2024
71b35f2
Apply suggestions from code review
Tigrov Jan 3, 2024
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
9 changes: 9 additions & 0 deletions src/ActiveQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ class ActiveQuery extends Query implements ActiveQueryInterface
private array $joinWith = [];
private ActiveRecordInterface|null $arInstance = null;

/**
* @param class-string $arClass
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
* @param ConnectionInterface $db
* @param ActiveRecordFactory|null $arFactory
* @param string $tableName
*
* @psalm-template T of ActiveRecordInterface
* @psalm-param class-string<T> $arClass
*/
final public function __construct(
protected string $arClass,
protected ConnectionInterface $db,
Expand Down
7 changes: 6 additions & 1 deletion src/ActiveRecordFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct(private Factory $factory)
/**
* Allows you to create an active record instance through the factory.
*
* @param string $arClass active record class.
* @param class-string<T> $arClass active record class.
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
* @param string $tableName The name of the table associated with this ActiveRecord class, if its empty string the
* name will be generated automatically by calling {@see getTableName()} in the active record class.
* @param ConnectionInterface|null $db the database connection used for creating active record instances.
Expand All @@ -29,6 +29,11 @@ public function __construct(private Factory $factory)
* @throws InvalidConfigException
* @throws NotFoundException
* @throws NotInstantiableException
* @return ActiveRecordInterface
*
* @psalm-template T of ActiveRecordInterface
* @psalm-param class-string<T> $arClass
* @psalm-return T
*/
public function createAR(
string $arClass,
Expand Down
22 changes: 19 additions & 3 deletions src/BaseActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,15 @@ public function hasAttribute($name): bool
*
* Call methods declared in {@see ActiveQuery} to further customize the relation.
*
* @param string $class The class name of the related record
* @param class-string<T> $class The class name of the related record
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
* @param array $link The primary-foreign key constraint. The keys of the array refer to the attributes of the
* record associated with the `$class` model, while the values of the array refer to the corresponding attributes in
* **this** AR class.
*
* @return ActiveQueryInterface The relational query object.
*
* @psalm-template T of ActiveRecordInterface
* @psalm-param class-string<T> $arClass
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
*/
public function hasMany(string $class, array $link): ActiveQueryInterface
{
Expand Down Expand Up @@ -356,18 +359,28 @@ public function hasMany(string $class, array $link): ActiveQueryInterface
*
* Call methods declared in {@see ActiveQuery} to further customize the relation.
*
* @param string $class The class name of the related record.
* @param class-string<T> $class The class name of the related record.
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
* @param array $link The primary-foreign key constraint. The keys of the array refer to the attributes of the
* record associated with the `$class` model, while the values of the array refer to the corresponding attributes in
* **this** AR class.
*
* @return ActiveQueryInterface The relational query object.
*
* @psalm-template T of ActiveRecordInterface
* @psalm-param class-string<T> $arClass
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
*/
public function hasOne(string $class, array $link): ActiveQueryInterface
{
return $this->createRelationQuery($class, $link, false);
}

/**
* @param class-string<T> $arClass
* @return ActiveQueryInterface
*
* @psalm-template T of ActiveRecordInterface
* @psalm-param class-string<T> $arClass
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
*/
public function instantiateQuery(string $arClass): ActiveQueryInterface
{
return new ActiveQuery($arClass, $this->db, $this->arFactory);
Expand Down Expand Up @@ -1114,11 +1127,14 @@ private function setRelationDependencies(
/**
* Creates a query instance for `has-one` or `has-many` relation.
*
* @param string $arClass The class name of the related record.
* @param class-string<T> $arClass The class name of the related record.
niqingyang marked this conversation as resolved.
Show resolved Hide resolved
* @param array $link The primary-foreign key constraint.
* @param bool $multiple Whether this query represents a relation to more than one record.
*
* @return ActiveQueryInterface The relational query object.
*
* @psalm-template T of ActiveRecordInterface
* @psalm-param class-string<T> $arClass
niqingyang marked this conversation as resolved.
Show resolved Hide resolved

* {@see hasOne()}
* {@see hasMany()}
Expand Down