From 04202f04f5e784eda68c94863a3674d080a481cf Mon Sep 17 00:00:00 2001 From: Maksim Spirkov <63721828+max-s-lab@users.noreply.github.com> Date: Mon, 15 Sep 2025 21:59:22 +0400 Subject: [PATCH] Fix #19506: Fix `@property` annotations in `yii\console\widgets\Table`, `yii\di\Container` and `yii\web\Session` --- build/controllers/PhpDocController.php | 21 +++++++++++++++------ framework/CHANGELOG.md | 1 + framework/console/widgets/Table.php | 3 +++ framework/di/Container.php | 6 ++++-- framework/web/Session.php | 4 ++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index e655136fe4..47f71892f7 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -774,13 +774,22 @@ class PhpDocController extends ConsoleController $className = $namespace . '\\' . $class['name']; $gets = $this->match( - '#\* @return (?[\w\\|\\\\\\[\\]]+)(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . - '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#', - $class['content'], true); + '#\* @return (?[\w\\|\\\\\\[\\]]+)' + . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' + . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' + . 'public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#', + $class['content'], + true + ); + $sets = $this->match( - '#\* @param (?[\w\\|\\\\\\[\\]]+) \$\w+(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' . - '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?set)(?\w+)\(\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#', - $class['content'], true); + '#\* @param (?[\w\\|\\\\\\[\\]]+) \$\w+' + . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' + . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' + . 'public function (?set)(?\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#', + $class['content'], + true + ); $acrs = array_merge($gets, $sets); $manuallyAddedProperties = self::MANUALLY_ADDED_PROPERTIES[$className] ?? []; diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index eaa5911b15..fea8357ca9 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -28,6 +28,7 @@ Yii Framework 2 Change Log - Enh #20514: Add `@property` annotations for `yii\console\Controller` (max-s-lab) - Bug #20515: Fix `@param` annotations in `BetweenColumnsCondition`, `InCondition` and `LikeCondition` (max-s-lab) - Bug #20516: Fix `@template` annotations in `ActiveRecord` (max-s-lab) +- Bug #19506: Fix `@property` annotations in `yii\console\widgets\Table`, `yii\di\Container` and `yii\web\Session` (max-s-lab) - Enh #20525: Add `@template` annotations for all actions (max-s-lab) - Bug #20524: Fix PHPStan/Psalm annotations in `Yii::createObject` (max-s-lab) diff --git a/framework/console/widgets/Table.php b/framework/console/widgets/Table.php index 2e1dc4622e..2e4de8f800 100644 --- a/framework/console/widgets/Table.php +++ b/framework/console/widgets/Table.php @@ -40,7 +40,10 @@ use yii\helpers\Console; * ], * ]); * + * @property-write array $chars Table chars. + * @property-write array $headers Table headers. * @property-write string $listPrefix List prefix. + * @property-write array $rows Table rows. * @property-write int $screenWidth Screen width. * * @author Daniel Gomez Pan diff --git a/framework/di/Container.php b/framework/di/Container.php index d0e7575f26..77d456eefa 100644 --- a/framework/di/Container.php +++ b/framework/di/Container.php @@ -94,9 +94,11 @@ use yii\helpers\ArrayHelper; * * For more details and usage information on Container, see the [guide article on di-containers](guide:concept-di-container). * - * @property-read array $definitions The list of the object definitions or the loaded shared objects (type or - * ID => definition or instance). + * @property array $definitions The list of the object definitions or the loaded shared objects (type or ID => + * definition or instance). * @property-write bool $resolveArrays Whether to attempt to resolve elements in array dependencies. + * @property-write array $singletons Array of singleton definitions. See [[setDefinitions()]] for allowed + * formats of array. * * @author Qiang Xue * @since 2.0 diff --git a/framework/web/Session.php b/framework/web/Session.php index 3cf0c7730c..c16bef54aa 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -46,8 +46,8 @@ use yii\base\InvalidConfigException; * For more details and usage information on Session, see the [guide article on sessions](guide:runtime-sessions-cookies). * * @property-read array $allFlashes Flash messages (key => message or key => [message1, message2]). - * @property-read string $cacheLimiter Current cache limiter. - * @property-read array $cookieParams The session cookie parameters. + * @property string $cacheLimiter Current cache limiter. + * @property array $cookieParams The session cookie parameters. * @property-read int $count The number of session variables. * @property-write string $flash The key identifying the flash message. Note that flash messages and normal * session variables share the same name space. If you have a normal session variable using the same name, its