Skip to content

Commit 33f18e8

Browse files
authored
Merge pull request #9312 from weirdan/deprecate-functionlikestorage-unused_docblock_params
2 parents 166e678 + 01911a0 commit 33f18e8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ public function analyze(
361361
$context->external_mutation_free = true;
362362
}
363363

364-
if ($storage->unused_docblock_params) {
365-
foreach ($storage->unused_docblock_params as $param_name => $param_location) {
364+
if ($storage->has_undertyped_native_parameters) {
365+
foreach ($storage->unused_docblock_parameters as $param_name => $param_location) {
366366
IssueBuffer::maybeAdd(
367367
new InvalidDocblockParamName(
368368
'Incorrect param name $' . $param_name . ' in docblock for ' . $cased_method_id,

src/Psalm/Internal/PhpVisitor/Reflector/FunctionLikeDocblockScanner.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,12 @@ private static function improveParamsFromDocblock(
908908
);
909909

910910
if ($params_without_docblock_type) {
911+
/** @psalm-suppress DeprecatedProperty remove in Psalm 6 */
911912
$storage->unused_docblock_params = $unused_docblock_params;
912913
}
914+
915+
$storage->has_undertyped_native_parameters = $params_without_docblock_type !== [];
916+
$storage->unused_docblock_parameters = $unused_docblock_params;
913917
}
914918

915919
/**

src/Psalm/Storage/FunctionLikeStorage.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,19 @@ abstract class FunctionLikeStorage implements HasAttributesInterface
172172
public $return_type_description;
173173

174174
/**
175+
* @psalm-suppress PossiblyUnusedProperty
175176
* @var array<string, CodeLocation>|null
177+
* @deprecated will be removed in Psalm 6. use {@see FunctionLikeStorage::$unused_docblock_parameters} instead
176178
*/
177179
public $unused_docblock_params;
178180

181+
/**
182+
* @var array<string, CodeLocation>
183+
*/
184+
public array $unused_docblock_parameters = [];
185+
186+
public bool $has_undertyped_native_parameters = false;
187+
179188
/**
180189
* @var bool
181190
*/

0 commit comments

Comments
 (0)