1
0
Fork 0

fix(DefinitionResolver): fix crash on unknown foreach type (#562)

Fix when unknown type is found in foreach expression
pull/564/head v5.3.1
Phil Nelson 2017-12-24 20:52:49 +11:00 committed by Felix Becker
parent a0caf8d18f
commit 425b2390b5
3 changed files with 19 additions and 0 deletions

View File

@ -35,3 +35,6 @@ foreach ($array3 as $key => $value) {
foreach ($bar->test() as $value) {
$
}
foreach ($unknownArray as $unknown) {
$unkno

View File

@ -1122,6 +1122,7 @@ class DefinitionResolver
if ($collectionType instanceof Types\Array_) {
return $collectionType->getValueType();
}
return new Types\Mixed_();
}
// PROPERTIES, CONSTS, CLASS CONSTS, ASSIGNMENT EXPRESSIONS

View File

@ -691,6 +691,21 @@ class CompletionTest extends TestCase
),
]
],
'foreach unknown type' => [
new Position(39, 10),
[
new CompletionItem(
'$unknown',
CompletionItemKind::VARIABLE,
'mixed',
null,
null,
null,
null,
new TextEdit(new Range(new Position(39, 10), new Position(39, 10)), 'wn')
),
]
],
];
}