1
0
Fork 0

start with foreach regocnitian

pull/416/head
jens1o 2017-06-10 14:25:05 +02:00
parent 454e078cd5
commit 893596208e
3 changed files with 17 additions and 0 deletions

4
fixtures/foreach.php Normal file
View File

@ -0,0 +1,4 @@
<?php
foreach([0, 1, 2, 3, 4, 5] as $testValue) {
$testValue;
}

View File

@ -533,6 +533,15 @@ class DefinitionResolver
) {
return $n;
}
// foreach ([0, 1, 2, 3] as $foreachKey => $foreachValue) {}
if ($n instanceof Node\Statement\ForeachStatement) {
if ($n->foreachValue !== null && $n->foreachValue->getText() === $name) {
return $n->foreachValue;
} elseif ($n->foreachKey !== null && $n->foreachKey->getText() === $name) {
return $n->foreachKey;
}
}
}
} while (isset($n) && $n = $n->parent);
// Return null if nothing was found
@ -563,6 +572,7 @@ class DefinitionResolver
// VARIABLE
// $this -> Type\this
// $myVariable -> type of corresponding assignment expression
// $foreachKey -> Register type
if ($expr instanceof Node\Expression\Variable || $expr instanceof Node\UseVariableName) {
if ($expr->getName() === 'this') {
return new Types\This;

View File

@ -0,0 +1,3 @@
<?php
declare(strict_types = 1)
namespace LanguageServer\Tests\Server\TextDocument;