1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Use better heuristic to determine missing types

This commit is contained in:
Matthew Brown 2019-02-23 11:39:00 -05:00
parent cdae79b9fe
commit fff56f7b26
2 changed files with 13 additions and 4 deletions

View File

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

View File

@ -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',
],
];
}