diff --git a/src/ActiveQuery.php b/src/ActiveQuery.php index 4cb8160d7..23ea9ea53 100644 --- a/src/ActiveQuery.php +++ b/src/ActiveQuery.php @@ -107,6 +107,9 @@ class ActiveQuery extends Query implements ActiveQueryInterface private array $joinWith = []; private ActiveRecordInterface|null $arInstance = null; + /** + * @psalm-param class-string $arClass + */ final public function __construct( protected string $arClass, protected ConnectionInterface $db, diff --git a/src/ActiveRecordFactory.php b/src/ActiveRecordFactory.php index 3940fa741..876487e7a 100644 --- a/src/ActiveRecordFactory.php +++ b/src/ActiveRecordFactory.php @@ -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 $arClass + * @psalm-return T */ public function createAR( string $arClass, diff --git a/src/BaseActiveRecord.php b/src/BaseActiveRecord.php index d6cb497e3..c3e2a751a 100644 --- a/src/BaseActiveRecord.php +++ b/src/BaseActiveRecord.php @@ -326,6 +326,8 @@ public function hasAttribute($name): bool * **this** AR class. * * @return ActiveQueryInterface The relational query object. + * + * @psalm-param class-string $class */ public function hasMany(string $class, array $link): ActiveQueryInterface { @@ -362,12 +364,17 @@ public function hasMany(string $class, array $link): ActiveQueryInterface * **this** AR class. * * @return ActiveQueryInterface The relational query object. + * + * @psalm-param class-string $class */ public function hasOne(string $class, array $link): ActiveQueryInterface { return $this->createRelationQuery($class, $link, false); } + /** + * @psalm-param class-string $arClass + */ public function instantiateQuery(string $arClass): ActiveQueryInterface { return new ActiveQuery($arClass, $this->db, $this->arFactory); @@ -1119,6 +1126,8 @@ private function setRelationDependencies( * @param bool $multiple Whether this query represents a relation to more than one record. * * @return ActiveQueryInterface The relational query object. + * + * @psalm-param class-string $arClass * {@see hasOne()} * {@see hasMany()}