mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Only check param-out when no exception is thrown
This commit is contained in:
parent
12cd9590c8
commit
c64e879178
@ -479,7 +479,16 @@ abstract class FunctionLikeAnalyzer extends SourceAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
$this->examineParamTypes($statements_analyzer, $context, $codebase);
|
||||
$final_actions = ScopeAnalyzer::getControlActions(
|
||||
$this->function->getStmts() ?: [],
|
||||
null,
|
||||
$codebase->config->exit_functions,
|
||||
$context->break_types
|
||||
);
|
||||
|
||||
if ($final_actions !== [ScopeAnalyzer::ACTION_END]) {
|
||||
$this->examineParamTypes($statements_analyzer, $context, $codebase);
|
||||
}
|
||||
|
||||
foreach ($params as $function_param) {
|
||||
// only complain if there's no type defined by a parent type
|
||||
|
@ -157,6 +157,19 @@ class ReferenceConstraintTest extends TestCase
|
||||
|
||||
addValue($foo["a"]);'
|
||||
],
|
||||
'paramOutArrayDefaultNullWithThrow' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param-out array{errors: int}|null $info
|
||||
*/
|
||||
function idnToAsci(?array &$info = null): void {
|
||||
if (rand(0, 1)) {
|
||||
$info = null;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException();
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user