Skip to content

Commit 04202f0

Browse files
authored
Fix #19506: Fix @property annotations in yii\console\widgets\Table, yii\di\Container and yii\web\Session
1 parent 4774464 commit 04202f0

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

build/controllers/PhpDocController.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,22 @@ protected function generateClassPropertyDocs($fileName)
774774
$className = $namespace . '\\' . $class['name'];
775775

776776
$gets = $this->match(
777-
'#\* @return (?<type>[\w\\|\\\\\\[\\]]+)(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' .
778-
'[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?<kind>get)(?<name>\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)#',
779-
$class['content'], true);
777+
'#\* @return (?<type>[\w\\|\\\\\\[\\]]+)'
778+
. '(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/'
779+
. '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}'
780+
. 'public function (?<kind>get)(?<name>\w+)\((?:,? ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#',
781+
$class['content'],
782+
true
783+
);
784+
780785
$sets = $this->match(
781-
'#\* @param (?<type>[\w\\|\\\\\\[\\]]+) \$\w+(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)\*/' .
782-
'[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}public function (?<kind>set)(?<name>\w+)\(\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)#',
783-
$class['content'], true);
786+
'#\* @param (?<type>[\w\\|\\\\\\[\\]]+) \$\w+'
787+
. '(?: (?<comment>(?:(?!\*/|\* @).)+?)(?:(?!\*/).)+|[\s\n]*)((\*\n)|(\*\s.+))*\*/'
788+
. '[\s\n]{2,}(\#\[\\\\*.+\])*[\s\n]{2,}'
789+
. 'public function (?<kind>set)(?<name>\w+)\(([\w\\|\\\\\\[\\]]+\s*)?\$\w+(?:, ?\$\w+ ?= ?[^,]+)*\)(\:\s*[\w\\|\\\\\\[\\]]+)?#',
790+
$class['content'],
791+
true
792+
);
784793

785794
$acrs = array_merge($gets, $sets);
786795
$manuallyAddedProperties = self::MANUALLY_ADDED_PROPERTIES[$className] ?? [];

framework/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Yii Framework 2 Change Log
2828
- Enh #20514: Add `@property` annotations for `yii\console\Controller` (max-s-lab)
2929
- Bug #20515: Fix `@param` annotations in `BetweenColumnsCondition`, `InCondition` and `LikeCondition` (max-s-lab)
3030
- Bug #20516: Fix `@template` annotations in `ActiveRecord` (max-s-lab)
31+
- Bug #19506: Fix `@property` annotations in `yii\console\widgets\Table`, `yii\di\Container` and `yii\web\Session` (max-s-lab)
3132
- Enh #20525: Add `@template` annotations for all actions (max-s-lab)
3233
- Bug #20524: Fix PHPStan/Psalm annotations in `Yii::createObject` (max-s-lab)
3334

framework/console/widgets/Table.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@
4040
* ],
4141
* ]);
4242
*
43+
* @property-write array $chars Table chars.
44+
* @property-write array $headers Table headers.
4345
* @property-write string $listPrefix List prefix.
46+
* @property-write array $rows Table rows.
4447
* @property-write int $screenWidth Screen width.
4548
*
4649
* @author Daniel Gomez Pan <[email protected]>

framework/di/Container.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@
9494
*
9595
* For more details and usage information on Container, see the [guide article on di-containers](guide:concept-di-container).
9696
*
97-
* @property-read array $definitions The list of the object definitions or the loaded shared objects (type or
98-
* ID => definition or instance).
97+
* @property array $definitions The list of the object definitions or the loaded shared objects (type or ID =>
98+
* definition or instance).
9999
* @property-write bool $resolveArrays Whether to attempt to resolve elements in array dependencies.
100+
* @property-write array $singletons Array of singleton definitions. See [[setDefinitions()]] for allowed
101+
* formats of array.
100102
*
101103
* @author Qiang Xue <[email protected]>
102104
* @since 2.0

framework/web/Session.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
* For more details and usage information on Session, see the [guide article on sessions](guide:runtime-sessions-cookies).
4747
*
4848
* @property-read array $allFlashes Flash messages (key => message or key => [message1, message2]).
49-
* @property-read string $cacheLimiter Current cache limiter.
50-
* @property-read array $cookieParams The session cookie parameters.
49+
* @property string $cacheLimiter Current cache limiter.
50+
* @property array $cookieParams The session cookie parameters.
5151
* @property-read int $count The number of session variables.
5252
* @property-write string $flash The key identifying the flash message. Note that flash messages and normal
5353
* session variables share the same name space. If you have a normal session variable using the same name, its

0 commit comments

Comments
 (0)