mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
Fix #20434: Added PHPStan/Psalm annotations for hasMany
and hasOne
methods
This commit is contained in:
@ -4,6 +4,7 @@ Yii Framework 2 Change Log
|
||||
2.0.54 under development
|
||||
------------------------
|
||||
|
||||
- Enh #20434: Added PHPStan/Psalm annotations for `hasMany` and `hasOne` methods (max-s-lab)
|
||||
- Enh #20433: Added PHPStan/Psalm annotations for some controllers methods: `beforeAction`, `afterAction` and `bindActionParams` (max-s-lab)
|
||||
|
||||
|
||||
|
@ -70,9 +70,6 @@ use yii\helpers\StringHelper;
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||
* @author Carsten Brandt <mail@cebe.cc>
|
||||
* @since 2.0
|
||||
@ -595,6 +592,42 @@ class ActiveRecord extends BaseActiveRecord
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return ActiveQuery
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @phpstan-param class-string<T> $class
|
||||
* @psalm-param class-string<T> $class
|
||||
*
|
||||
* @phpstan-return ActiveQuery<T>
|
||||
* @psalm-return ActiveQuery<T>
|
||||
*/
|
||||
public function hasMany($class, $link)
|
||||
{
|
||||
return parent::hasMany($class, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @return ActiveQuery
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @phpstan-param class-string<T> $class
|
||||
* @psalm-param class-string<T> $class
|
||||
*
|
||||
* @phpstan-return ActiveQuery<T>
|
||||
* @psalm-return ActiveQuery<T>
|
||||
*/
|
||||
public function hasOne($class, $link)
|
||||
{
|
||||
return parent::hasOne($class, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts an ActiveRecord into DB without considering transaction.
|
||||
* @param array|null $attributes list of attributes that need to be saved. Defaults to `null`,
|
||||
|
@ -389,6 +389,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
* 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.
|
||||
*
|
||||
* @phpstan-param class-string $class
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @phpstan-param array<string, string> $link
|
||||
* @psalm-param array<string, string> $link
|
||||
*/
|
||||
public function hasOne($class, $link)
|
||||
{
|
||||
@ -424,6 +430,12 @@ abstract class BaseActiveRecord extends Model implements ActiveRecordInterface
|
||||
* 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.
|
||||
*
|
||||
* @phpstan-param class-string $class
|
||||
* @psalm-param class-string $class
|
||||
*
|
||||
* @phpstan-param array<string, string> $link
|
||||
* @psalm-param array<string, string> $link
|
||||
*/
|
||||
public function hasMany($class, $link)
|
||||
{
|
||||
|
Reference in New Issue
Block a user