From 61f1bd7af9665658522c6958a0092d8260d8e507 Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+max-s-lab@users.noreply.github.com> Date: Mon, 8 Sep 2025 15:07:30 +0500 Subject: [PATCH] Fix `@var` annotations (#20517) --- framework/db/ActiveQuery.php | 5 ++++- framework/db/ActiveRelationTrait.php | 2 +- framework/requirements/YiiRequirementChecker.php | 4 +--- framework/web/User.php | 5 ++++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/framework/db/ActiveQuery.php b/framework/db/ActiveQuery.php index add0cdb826..1bebd99863 100644 --- a/framework/db/ActiveQuery.php +++ b/framework/db/ActiveQuery.php @@ -266,7 +266,10 @@ class ActiveQuery extends Query implements ActiveQueryInterface private function removeDuplicatedModels($models) { $hash = []; - /** @var ActiveRecord $class */ + /** + * @var ActiveRecord + * @phpstan-var class-string + */ $class = $this->modelClass; $pks = $class::primaryKey(); diff --git a/framework/db/ActiveRelationTrait.php b/framework/db/ActiveRelationTrait.php index bd4899a245..53addd17ef 100644 --- a/framework/db/ActiveRelationTrait.php +++ b/framework/db/ActiveRelationTrait.php @@ -339,7 +339,6 @@ trait ActiveRelationTrait return; } $model = reset($models); - /** @var ActiveQueryInterface|ActiveQuery $relation */ if ($model instanceof ActiveRecordInterface) { $relation = $model->getRelation($name); } else { @@ -348,6 +347,7 @@ trait ActiveRelationTrait $relation = $modelClass::instance()->getRelation($name); } + /** @var ActiveQueryInterface|ActiveQuery $relation */ if ($relation->multiple) { $buckets = $this->buildBuckets($primaryModels, $relation->link, null, null, false); if ($model instanceof ActiveRecordInterface) { diff --git a/framework/requirements/YiiRequirementChecker.php b/framework/requirements/YiiRequirementChecker.php index 7a6a930c8d..a143f47f1e 100644 --- a/framework/requirements/YiiRequirementChecker.php +++ b/framework/requirements/YiiRequirementChecker.php @@ -49,15 +49,13 @@ if (version_compare(PHP_VERSION, '4.3', '<')) { * Note: this class definition does not match ordinary Yii style, because it should match PHP 4.3 * and should not use features from newer PHP versions! * - * @property array|null $result the check results, this property is for internal usage only. - * * @author Paul Klimov * @since 2.0 */ class YiiRequirementChecker { /** - * @var Check result + * @var array|null the check results, this property is for internal usage only. */ public $result; diff --git a/framework/web/User.php b/framework/web/User.php index 6c78c55d20..5a113158ad 100644 --- a/framework/web/User.php +++ b/framework/web/User.php @@ -626,7 +626,10 @@ class User extends Component $data = json_decode($value, true); if (is_array($data) && count($data) == 3) { list($id, $authKey, $duration) = $data; - /** @var IdentityInterface $class */ + /** + * @var IdentityInterface + * @phpstan-var class-string + */ $class = $this->identityClass; $identity = $class::findIdentity($id); if ($identity !== null) {