Fix #19506: Fix @property annotations in yii\console\widgets\Table, yii\di\Container and yii\web\Session

This commit is contained in:
Maksim Spirkov
2025-09-15 21:59:22 +04:00
committed by GitHub
parent 4774464159
commit 04202f04f5
5 changed files with 25 additions and 10 deletions

View File

@ -774,13 +774,22 @@ class PhpDocController extends ConsoleController
$className = $namespace . '\\' . $class['name'];
$gets = $this->match(
'#\* @return (?<type>[\w\\|\\\\\\[\\]]+)(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' .
'[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?<kind>get)(?<name>\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#',
$class['content'], true);
'#\* @return (?<type>[\w\\|\\\\\\[\\]]+)'
. '(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/'
. '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}'
. 'public function (?<kind>get)(?<name>\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#',
$class['content'],
true
);
$sets = $this->match(
'#\* @param (?<type>[\w\\|\\\\\\[\\]]+) \$\w+(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' .
'[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?<kind>set)(?<name>\w+)\(\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#',
$class['content'], true);
'#\* @param (?<type>[\w\\|\\\\\\[\\]]+) \$\w+'
. '(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/'
. '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}'
. 'public function (?<kind>set)(?<name>\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#',
$class['content'],
true
);
$acrs = array_merge($gets, $sets);
$manuallyAddedProperties = self::MANUALLY_ADDED_PROPERTIES[$className] ?? [];

View File

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

View File

@ -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 <pana_1990@hotmail.com>

View File

@ -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 <qiang.xue@gmail.com>
* @since 2.0

View File

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