diff --git a/fixtures/foreach.php b/fixtures/foreach.php new file mode 100644 index 0000000..565490d --- /dev/null +++ b/fixtures/foreach.php @@ -0,0 +1,4 @@ +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))); diff --git a/tests/Server/TextDocument/Definition/ForeachTest.php b/tests/Server/TextDocument/Definition/ForeachTest.php new file mode 100644 index 0000000..6dc2532 --- /dev/null +++ b/tests/Server/TextDocument/Definition/ForeachTest.php @@ -0,0 +1,3 @@ +