1
0
Fork 0
pull/416/merge
Jens Hausdorf 2017-11-19 02:26:26 +00:00 committed by GitHub
commit 8459572e74
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

@ -567,6 +567,15 @@ class DefinitionResolver
) {
return $n;
}
// foreach loops
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
@ -597,6 +606,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\Object_(new Fqsen('\\' . $this->getContainingClassFqn($expr)));

View File

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