1
0
Fork 0

fix(DefinitionResolver): don't crash if foreach key isn't a variable (#564)

pull/567/head^2 v5.3.2
Phil Nelson 2017-12-25 12:55:48 +11:00 committed by Felix Becker
parent 425b2390b5
commit 1cfba8b6bb
2 changed files with 4 additions and 2 deletions

View File

@ -36,5 +36,5 @@ foreach ($bar->test() as $value) {
$ $
} }
foreach ($unknownArray as $unknown) { foreach ($unknownArray as $member->access => $unknown) {
$unkno $unkno

View File

@ -571,7 +571,9 @@ class DefinitionResolver
// If we get to a ForeachStatement, check the keys and values // If we get to a ForeachStatement, check the keys and values
if ($n instanceof Node\Statement\ForeachStatement) { if ($n instanceof Node\Statement\ForeachStatement) {
if ($n->foreachKey && $n->foreachKey->expression->getName() === $name) { if ($n->foreachKey instanceof Node\Expression\Variable
&& $n->foreachKey->expression->getName() === $name
) {
return $n->foreachKey; return $n->foreachKey;
} }
if ($n->foreachValue if ($n->foreachValue