From 1fdcebaeec0cafb06704f64976cf8992e386bc42 Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+mspirkov@users.noreply.github.com> Date: Sun, 2 Nov 2025 11:35:27 +0300 Subject: [PATCH] Fix #20671: Fix PHPDoc annotations in `yii\base`, `yii\console`, `yii\web` and `yii\widgets` namespaces --- framework/CHANGELOG.md | 1 + framework/base/Application.php | 2 +- framework/console/Application.php | 2 +- framework/web/Application.php | 2 +- framework/widgets/BaseListView.php | 4 ++-- framework/widgets/ListView.php | 4 ++-- framework/widgets/MaskedInput.php | 10 +++++----- phpstan-baseline.neon | 2 +- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index 7639b6f8c6..a83603ce0f 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -81,6 +81,7 @@ Yii Framework 2 Change Log - Bug #20665: Fix PHP `8.5` `null` array offset deprecation warnings in `yii\build\controllers\ReleaseController` class (terabytesoftw) - Bug #20658: Add missing generics in `yii\console`, `yii\captcha`, `yii\caching` and `yii\behaviors` namespaces (mspirkov) - Bug #20666: Add missing generics in `yii\base`, `yii\console`, `yii\filters` and `yii\web` namespaces (mspirkov) +- Bug #20671: Fix PHPDoc annotations in `yii\base`, `yii\console`, `yii\web` and `yii\widgets` namespaces (mspirkov) 2.0.53 June 27, 2025 diff --git a/framework/base/Application.php b/framework/base/Application.php index a1ecc3a76d..3f09515002 100644 --- a/framework/base/Application.php +++ b/framework/base/Application.php @@ -113,7 +113,7 @@ abstract class Application extends Module */ public $sourceLanguage = 'en-US'; /** - * @var Controller the currently active controller instance + * @var Controller|null the currently active controller instance */ public $controller; /** diff --git a/framework/console/Application.php b/framework/console/Application.php index a0acad9627..59487d1683 100644 --- a/framework/console/Application.php +++ b/framework/console/Application.php @@ -75,7 +75,7 @@ class Application extends \yii\base\Application */ public $enableCoreCommands = true; /** - * @var Controller the currently active controller instance + * @var Controller|null the currently active controller instance */ public $controller; diff --git a/framework/web/Application.php b/framework/web/Application.php index 2f68ee7d06..2571f34ead 100644 --- a/framework/web/Application.php +++ b/framework/web/Application.php @@ -57,7 +57,7 @@ class Application extends \yii\base\Application */ public $catchAll; /** - * @var Controller the currently active controller instance + * @var Controller|null the currently active controller instance */ public $controller; diff --git a/framework/widgets/BaseListView.php b/framework/widgets/BaseListView.php index be7b7bde78..a015a859f6 100644 --- a/framework/widgets/BaseListView.php +++ b/framework/widgets/BaseListView.php @@ -51,7 +51,7 @@ abstract class BaseListView extends Widget */ public $sorter = []; /** - * @var string the HTML content to be displayed as the summary of the list view. + * @var string|null the HTML content to be displayed as the summary of the list view. * If you do not want to show the summary, you may set it with an empty string. * * The following tokens will be replaced with the corresponding values: @@ -77,7 +77,7 @@ abstract class BaseListView extends Widget */ public $showOnEmpty = false; /** - * @var string|false the HTML content to be displayed when [[dataProvider]] does not have any data. + * @var string|false|null the HTML content to be displayed when [[dataProvider]] does not have any data. * When this is set to `false` no extra HTML content will be generated. * The default value is the text "No results found." which will be translated to the current application language. * @see showOnEmpty diff --git a/framework/widgets/ListView.php b/framework/widgets/ListView.php index a38595a686..52dad52dd9 100644 --- a/framework/widgets/ListView.php +++ b/framework/widgets/ListView.php @@ -75,7 +75,7 @@ class ListView extends BaseListView */ public $options = ['class' => 'list-view']; /** - * @var Closure an anonymous function that is called once BEFORE rendering each data model. + * @var Closure|null an anonymous function that is called once BEFORE rendering each data model. * It should have the following signature: * * ``` @@ -94,7 +94,7 @@ class ListView extends BaseListView */ public $beforeItem; /** - * @var Closure an anonymous function that is called once AFTER rendering each data model. + * @var Closure|null an anonymous function that is called once AFTER rendering each data model. * * It should have the same signature as [[beforeItem]]. * diff --git a/framework/widgets/MaskedInput.php b/framework/widgets/MaskedInput.php index 65aabb24b1..fa8e668ff3 100644 --- a/framework/widgets/MaskedInput.php +++ b/framework/widgets/MaskedInput.php @@ -64,7 +64,7 @@ class MaskedInput extends InputWidget */ public $mask; /** - * @var array custom mask definitions to use. Should be configured as `maskSymbol => settings`, where + * @var array|null custom mask definitions to use. Should be configured as `maskSymbol => settings`, where * * - `maskSymbol` is a string, containing a character to identify your mask definition and * - `settings` is an array, consisting of the following entries: @@ -75,7 +75,7 @@ class MaskedInput extends InputWidget */ public $definitions; /** - * @var array custom aliases to use. Should be configured as `maskAlias => settings`, where + * @var array|null custom aliases to use. Should be configured as `maskAlias => settings`, where * * - `maskAlias` is a string containing a text to identify your mask alias definition (e.g. 'phone') and * - `settings` is an array containing settings for the mask symbol, exactly similar to parameters as passed in [[clientOptions]]. @@ -99,7 +99,7 @@ class MaskedInput extends InputWidget public $type = 'text'; /** - * @var string the hashed variable to store the pluginOptions + * @var string|null the hashed variable to store the pluginOptions */ protected $_hashVar; /** @@ -196,10 +196,10 @@ class MaskedInput extends InputWidget $this->clientOptions['mask'] = $this->mask; } $this->hashPluginOptions($view); - if (!empty($this->definitions) && is_array($this->definitions)) { + if (is_array($this->definitions) && !empty($this->definitions)) { $js .= ucfirst(self::PLUGIN_NAME) . '.extendDefinitions(' . Json::htmlEncode($this->definitions) . ');'; } - if (!empty($this->aliases) && is_array($this->aliases)) { + if (is_array($this->aliases) && !empty($this->aliases)) { $js .= ucfirst(self::PLUGIN_NAME) . '.extendAliases(' . Json::htmlEncode($this->aliases) . ');'; } $id = $this->options['id']; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 34cac67a9c..c79911603b 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -406,6 +406,6 @@ parameters: path: framework/caching/Dependency.php - - message: "#^Property yii\\\\console\\\\Application\\:\\:\\$controller \\(yii\\\\console\\\\Controller\\|yii\\\\web\\\\Controller\\) does not accept yii\\\\base\\\\Controller\\.$#" + message: "#^Property yii\\\\console\\\\Application\\:\\:\\$controller \\(yii\\\\console\\\\Controller\\|yii\\\\web\\\\Controller\\|null\\) does not accept yii\\\\base\\\\Controller\\.$#" count: 1 path: framework/base/Module.php