mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Use better heuristic to determine missing types
This commit is contained in:
parent
cdae79b9fe
commit
fff56f7b26
@ -2405,14 +2405,14 @@ class ReflectorVisitor extends PhpParser\NodeVisitorAbstract implements PhpParse
|
||||
$storage_param->type_location = $code_location;
|
||||
}
|
||||
|
||||
$params_without_type = array_filter(
|
||||
$params_without_docblock_type = array_filter(
|
||||
$storage->params,
|
||||
function (FunctionLikeParameter $p) : bool {
|
||||
return !$p->type || $p->type === $p->signature_type;
|
||||
return !$p->has_docblock_type && (!$p->type || $p->type->hasArray());
|
||||
}
|
||||
);
|
||||
|
||||
if ($params_without_type) {
|
||||
if ($params_without_docblock_type) {
|
||||
foreach ($unused_docblock_params as $param_name => $code_location) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidDocblockParamName(
|
||||
|
@ -885,6 +885,15 @@ class AnnotationTest extends TestCase
|
||||
'MixedAssignment'
|
||||
]
|
||||
],
|
||||
'extraneousDocblockParamName' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param string $foo
|
||||
* @param string[] $bar
|
||||
* @param string[] $barb
|
||||
*/
|
||||
function f(string $foo, array $barb): void {}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -1252,7 +1261,7 @@ class AnnotationTest extends TestCase
|
||||
'<?php
|
||||
/** @param string[] $_bar */
|
||||
function f(array $_barb): void {}',
|
||||
'error_message' => 'InvalidDocblock',
|
||||
'error_message' => 'InvalidDocblockParamName',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user