From bcaf9c38b22b1e8a92bf56b09987f0f4f5f186a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Thu, 11 Sep 2025 23:44:38 +0400 Subject: [PATCH 1/3] 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 e655136fe43..7dee5423ed8 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -774,13 +774,22 @@ protected function generateClassPropertyDocs($fileName) $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+ ?= ?[^,]+)*\)#', + $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+ ?= ?[^,]+)*\)#', + $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 75e8e3fdbbf..0819f782b8e 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) 2.0.53 June 27, 2025 diff --git a/framework/console/widgets/Table.php b/framework/console/widgets/Table.php index 2e1dc4622ee..2e4de8f8001 100644 --- a/framework/console/widgets/Table.php +++ b/framework/console/widgets/Table.php @@ -40,7 +40,10 @@ * ], * ]); * + * @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 d0e7575f266..77d456eefa9 100644 --- a/framework/di/Container.php +++ b/framework/di/Container.php @@ -94,9 +94,11 @@ * * 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 3cf0c7730c1..c16bef54aa6 100644 --- a/framework/web/Session.php +++ b/framework/web/Session.php @@ -46,8 +46,8 @@ * 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 From 6d7c8b6a8163df12fba13382ea563c3a5bcf1d6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Fri, 12 Sep 2025 14:22:41 +0400 Subject: [PATCH 2/3] handling return types in setters and getters --- build/controllers/PhpDocController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index 7dee5423ed8..761017e5402 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -777,7 +777,7 @@ protected function generateClassPropertyDocs($fileName) '#\* @return (?[\w\\|\\\\\\[\\]]+)' . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' - . 'public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#', + . 'public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s[\w\\|\\\\\\[\\]]+\s*)?#', $class['content'], true ); @@ -786,7 +786,7 @@ protected function generateClassPropertyDocs($fileName) '#\* @param (?[\w\\|\\\\\\[\\]]+) \$\w+' . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' - . 'public function (?set)(?\w+)\(([\w\\|\\\\\\[\\]]+\s*)*\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#', + . 'public function (?set)(?\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s[\w\\|\\\\\\[\\]]+\s*)?#', $class['content'], true ); From 4e84b0d379ba654823953671554ad6ebee24191a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=20=D0=A1=D0=BF=D0=B8?= =?UTF-8?q?=D1=80=D0=BA=D0=BE=D0=B2?= Date: Fri, 12 Sep 2025 14:24:12 +0400 Subject: [PATCH 3/3] self review --- build/controllers/PhpDocController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/controllers/PhpDocController.php b/build/controllers/PhpDocController.php index 761017e5402..47f71892f72 100644 --- a/build/controllers/PhpDocController.php +++ b/build/controllers/PhpDocController.php @@ -777,7 +777,7 @@ protected function generateClassPropertyDocs($fileName) '#\* @return (?[\w\\|\\\\\\[\\]]+)' . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' - . 'public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s[\w\\|\\\\\\[\\]]+\s*)?#', + . 'public function (?get)(?\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#', $class['content'], true ); @@ -786,7 +786,7 @@ protected function generateClassPropertyDocs($fileName) '#\* @param (?[\w\\|\\\\\\[\\]]+) \$\w+' . '(?: (?(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/' . '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}' - . 'public function (?set)(?\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s[\w\\|\\\\\\[\\]]+\s*)?#', + . 'public function (?set)(?\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#', $class['content'], true );