mirror of
https://github.com/yiisoft/yii2.git
synced 2025-12-12 09:20:57 +08:00
Add missing generics in yii\validators and yii\log namespaces (#20644)
This commit is contained in:
@@ -13,7 +13,9 @@ use yii\base\InvalidConfigException;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\helpers\StringHelper;
|
||||
use yii\helpers\VarDumper;
|
||||
use yii\web\IdentityInterface;
|
||||
use yii\web\Request;
|
||||
use yii\web\User;
|
||||
|
||||
/**
|
||||
* Target is the base class for all log target classes.
|
||||
@@ -344,7 +346,10 @@ abstract class Target extends Component
|
||||
$request = Yii::$app->getRequest();
|
||||
$ip = $request instanceof Request ? $request->getUserIP() : '-';
|
||||
|
||||
/** @var \yii\web\User $user */
|
||||
/**
|
||||
* @var User $user
|
||||
* @phpstan-var User<IdentityInterface>
|
||||
*/
|
||||
$user = Yii::$app->has('user', true) ? Yii::$app->get('user') : null;
|
||||
if ($user && ($identity = $user->getIdentity(false))) {
|
||||
$userID = $identity->getId();
|
||||
|
||||
@@ -116,13 +116,17 @@ class ExistValidator extends Validator
|
||||
|
||||
/**
|
||||
* Validates existence of the current attribute based on relation name
|
||||
* @param \yii\db\ActiveRecord $model the data model to be validated
|
||||
* @param ActiveRecord $model the data model to be validated
|
||||
* @param string $attribute the name of the attribute to be validated.
|
||||
*/
|
||||
private function checkTargetRelationExistence($model, $attribute)
|
||||
{
|
||||
$exists = false;
|
||||
/** @var ActiveQuery $relationQuery */
|
||||
|
||||
/**
|
||||
* @var ActiveQuery $relationQuery
|
||||
* @phpstan-var ActiveQuery<ActiveRecord>
|
||||
*/
|
||||
$relationQuery = $model->{'get' . ucfirst($this->targetRelation)}();
|
||||
|
||||
if ($this->filter instanceof \Closure) {
|
||||
@@ -316,6 +320,8 @@ class ExistValidator extends Validator
|
||||
* @param array $conditions array of condition, keys to be modified
|
||||
* @param string|null $alias set empty string for no apply alias. Set null for apply primary table alias
|
||||
* @return array
|
||||
*
|
||||
* @phpstan-param ActiveQuery<ActiveRecord> $query
|
||||
*/
|
||||
private function applyTableAlias($query, $conditions, $alias = null)
|
||||
{
|
||||
|
||||
@@ -241,6 +241,8 @@ class UniqueValidator extends Validator
|
||||
* @param array $conditions conditions, compatible with [[\yii\db\Query::where()|Query::where()]] key-value format
|
||||
*
|
||||
* @return ActiveQueryInterface|ActiveQuery
|
||||
*
|
||||
* @phpstan-return ActiveQueryInterface|ActiveQuery<ActiveRecord>
|
||||
*/
|
||||
private function prepareQuery($targetClass, $conditions)
|
||||
{
|
||||
@@ -319,6 +321,8 @@ class UniqueValidator extends Validator
|
||||
* @param array $conditions array of condition, keys to be modified
|
||||
* @param string|null $alias set empty string for no apply alias. Set null for apply primary table alias
|
||||
* @return array
|
||||
*
|
||||
* @phpstan-param ActiveQuery<ActiveRecord> $query
|
||||
*/
|
||||
private function applyTableAlias($query, $conditions, $alias = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user