From 28bea424017bb5f348110da25fccdef66b3f3cd5 Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+mspirkov@users.noreply.github.com> Date: Sat, 21 Feb 2026 19:40:29 +0400 Subject: [PATCH] Fix PHPStan errors (#20738) --- framework/CHANGELOG.md | 3 +++ framework/base/Application.php | 2 +- framework/web/AssetBundle.php | 4 ++-- framework/web/AssetManager.php | 6 +++--- framework/web/MultiFieldSession.php | 2 +- framework/web/User.php | 4 ++-- framework/web/View.php | 2 +- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index fa62f7e957..ad5808a925 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -14,6 +14,9 @@ Yii Framework 2 Change Log - Bug #20733: Replace `$this` with `static` and `covariant static` in generics in PHPStan and PHPDoc annotations (mspirkov) - Bug #20735: Fix `@param` annotations for `$name` in `Request::get()` and `Request::post()` (mspirkov) - Enh #20735: Add conditional types in `@return` annotations in `Request::get()` and `Request::post()` (mspirkov) +- Bug #20738: Fix `@var` annotations for `Application::$requestedParams`, `AssetBundle::$basePath`, `AssetBundle::$baseUrl`, `MultiFieldSession::$writeCallback` (mspirkov) +- Bug #20738: Fix `@return` annotations for `User::getAuthManager()` and `User::getAccessChecker()` (mspirkov) +- Bug #20738: Fix `@param` annotation for `$value` parameter in `AssetManager::setConverter()` (mspirkov) 2.0.54 January 09, 2026 diff --git a/framework/base/Application.php b/framework/base/Application.php index 7204a6edce..cca5123ed1 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -130,7 +130,7 @@ abstract class Application extends Module */ public $requestedAction; /** - * @var array the parameters supplied to the requested action. + * @var array|null the parameters supplied to the requested action. */ public $requestedParams; /** diff --git a/framework/web/AssetBundle.php b/framework/web/AssetBundle.php index 4b1dde0933..2759d7a65b 100644 --- a/framework/web/AssetBundle.php +++ b/framework/web/AssetBundle.php @@ -49,7 +49,7 @@ class AssetBundle extends BaseObject */ public $sourcePath; /** - * @var string the Web-accessible directory that contains the asset files in this bundle. + * @var string|null the Web-accessible directory that contains the asset files in this bundle. * * If [[sourcePath]] is set, this property will be *overwritten* by [[AssetManager]] * when it publishes the asset files from [[sourcePath]]. @@ -58,7 +58,7 @@ class AssetBundle extends BaseObject */ public $basePath; /** - * @var string the base URL for the relative asset files listed in [[js]] and [[css]]. + * @var string|null the base URL for the relative asset files listed in [[js]] and [[css]]. * * If [[sourcePath]] is set, this property will be *overwritten* by [[AssetManager]] * when it publishes the asset files from [[sourcePath]]. diff --git a/framework/web/AssetManager.php b/framework/web/AssetManager.php index 253199532d..d5645f5755 100644 --- a/framework/web/AssetManager.php +++ b/framework/web/AssetManager.php @@ -393,7 +393,7 @@ class AssetManager extends Component } /** - * @var AssetConverterInterface + * @var array|string|AssetConverterInterface|null */ private $_converter; @@ -417,9 +417,9 @@ class AssetManager extends Component /** * Sets the asset converter. - * @param array|AssetConverterInterface $value the asset converter. This can be either + * @param array|string|AssetConverterInterface $value the asset converter. This can be either * an object implementing the [[AssetConverterInterface]], or a configuration - * array that can be used to create the asset converter object. + * array that can be used to create the asset converter object, or a class name. */ public function setConverter($value) { diff --git a/framework/web/MultiFieldSession.php b/framework/web/MultiFieldSession.php index 90d21521ba..b02530c06f 100644 --- a/framework/web/MultiFieldSession.php +++ b/framework/web/MultiFieldSession.php @@ -53,7 +53,7 @@ abstract class MultiFieldSession extends Session */ public $readCallback; /** - * @var callable a callback that will be called during session data writing. + * @var callable|null a callback that will be called during session data writing. * The signature of the callback should be as follows: * * ``` diff --git a/framework/web/User.php b/framework/web/User.php index 637a3c5f91..72f9a1a1d2 100644 --- a/framework/web/User.php +++ b/framework/web/User.php @@ -794,7 +794,7 @@ class User extends Component * * By default this is the `authManager` application component. * You may override this method to return a different auth manager instance if needed. - * @return \yii\rbac\ManagerInterface + * @return \yii\rbac\ManagerInterface|null * @since 2.0.6 * @deprecated since version 2.0.9, to be removed in 2.1. Use [[getAccessChecker()]] instead. */ @@ -805,7 +805,7 @@ class User extends Component /** * Returns the access checker used for checking access. - * @return CheckAccessInterface + * @return CheckAccessInterface|null * @since 2.0.9 */ protected function getAccessChecker() diff --git a/framework/web/View.php b/framework/web/View.php index 6f3d0f5dd7..174e2b5eb8 100644 --- a/framework/web/View.php +++ b/framework/web/View.php @@ -534,7 +534,7 @@ class View extends \yii\base\View $trimmedUrl = ltrim((substr($url, 0, $prefixLength) === $prefix) ? substr($url, $prefixLength) : $url, '/'); $timestamp = @filemtime(Yii::getAlias('@webroot/' . $trimmedUrl, false)); if ($timestamp > 0) { - $url = $timestamp ? "$url?v=$timestamp" : $url; + $url = "$url?v=$timestamp"; } } if ($type === 'js') {