1
0
Fork 0

don't crash if foreach key isn't a variable

pull/564/head
Philip Nelson 2017-12-25 11:41:50 +11:00
parent 425b2390b5
commit 2a2143ab03
No known key found for this signature in database
GPG Key ID: 8C8235644C5E2279
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

View File

@ -571,7 +571,9 @@ class DefinitionResolver
// If we get to a ForeachStatement, check the keys and values
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;
}
if ($n->foreachValue