1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Still look at param defaults even without param types

This commit is contained in:
Brown 2019-06-07 14:24:15 -04:00
parent 3c3c8cd3b9
commit 4660beb28e
2 changed files with 14 additions and 4 deletions

View File

@ -588,10 +588,6 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer implements Statements
];
}
if (!$function_param->type_location || !$function_param->location) {
continue;
}
/**
* @psalm-suppress MixedArrayAccess
*
@ -599,6 +595,14 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer implements Statements
*/
$parser_param = $this->function->getParams()[$offset];
if (!$function_param->type_location || !$function_param->location) {
if ($parser_param->default) {
ExpressionAnalyzer::analyze($statements_analyzer, $parser_param->default, $context);
}
continue;
}
if ($signature_type) {
if (!TypeAnalyzer::isContainedBy(
$codebase,

View File

@ -120,6 +120,12 @@ class IssueSuppressionTest extends TestCase
new C();',
'error_message' => 'UndefinedClass - src' . DIRECTORY_SEPARATOR . 'somefile.php:6:25 - Class or interface C',
],
'missingParamTypeShouldntPreventUndefinedClassError' => [
'<?php
/** @psalm-suppress MissingParamType */
function foo($s = Foo::BAR) : void {}',
'error_message' => 'UndefinedClass',
],
];
}
}