Fix PHPStan errors (#20738)

This commit is contained in:
Maksim Spirkov
2026-02-21 19:40:29 +04:00
committed by GitHub
parent 5c6267702a
commit 28bea42401
7 changed files with 13 additions and 10 deletions

View File

@@ -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

View File

@@ -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;
/**

View File

@@ -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]].

View File

@@ -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)
{

View File

@@ -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:
*
* ```

View File

@@ -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()

View File

@@ -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') {