1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 10:07:52 +01:00

If we do not know, do not assume

This commit is contained in:
Matthew Brown 2016-09-13 17:35:30 -04:00
parent cb09a190ce
commit c1ca6c27d5

View File

@ -1911,10 +1911,7 @@ class StatementsChecker
}
if ($stmt->keyVar) {
$foreach_context->vars_in_scope[$stmt->keyVar->name] = $key_type ?: new Type\Union([
new Type\Atomic('int'),
new Type\Atomic('string')
]);
$foreach_context->vars_in_scope[$stmt->keyVar->name] = $key_type ?: Type::getMixed();
$foreach_context->vars_possibly_in_scope[$stmt->keyVar->name] = true;
$this->registerVariable($stmt->keyVar->name, $stmt->getLine());
}