Merge bb54cc242b
into 8439da999a
commit
675feef024
|
@ -38,3 +38,10 @@ foreach ($bar->test() as $value) {
|
|||
|
||||
foreach ($unknownArray as $member->access => $unknown) {
|
||||
$unkno
|
||||
}
|
||||
|
||||
foreach ($loop as $loop) {
|
||||
}
|
||||
|
||||
foreach ($loop->getArray() as $loop) {
|
||||
}
|
||||
|
|
|
@ -571,12 +571,27 @@ class DefinitionResolver
|
|||
|
||||
// If we get to a ForeachStatement, check the keys and values
|
||||
if ($n instanceof Node\Statement\ForeachStatement) {
|
||||
if ($n->foreachKey instanceof Node\Expression\Variable
|
||||
// Only check keys and values if we did not get here from the foreach collection, otherwise code like
|
||||
// foreach ($a as $a) will send us in circles
|
||||
$isForeachCollection = false;
|
||||
if ($n->forEachCollectionName) {
|
||||
if ($n->forEachCollectionName === $var) {
|
||||
$isForeachCollection = true;
|
||||
} else {
|
||||
foreach ($n->forEachCollectionName->getDescendantNodes() as $childNode) {
|
||||
if ($childNode === $var) {
|
||||
$isForeachCollection = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$isForeachCollection && $n->foreachKey instanceof Node\Expression\Variable
|
||||
&& $n->foreachKey->expression->getName() === $name
|
||||
) {
|
||||
return $n->foreachKey;
|
||||
}
|
||||
if ($n->foreachValue
|
||||
if (!$isForeachCollection && $n->foreachValue
|
||||
&& $n->foreachValue->expression instanceof Node\Expression\Variable
|
||||
&& $n->foreachValue->expression->getName() === $name
|
||||
) {
|
||||
|
|
Loading…
Reference in New Issue