From cc8e253fba10fb2867c60e16d68c1bac04aa607c Mon Sep 17 00:00:00 2001 From: Ivan Bozhanov Date: Fri, 7 Jul 2017 12:30:04 +0300 Subject: [PATCH] updated doc blocks --- src/CompletionProvider.php | 5 +++-- src/Definition.php | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/CompletionProvider.php b/src/CompletionProvider.php index 8d0fb92..5762651 100644 --- a/src/CompletionProvider.php +++ b/src/CompletionProvider.php @@ -14,6 +14,7 @@ use LanguageServer\Protocol\{ }; use Microsoft\PhpParser; use Microsoft\PhpParser\Node; +use Generator; class CompletionProvider { @@ -374,9 +375,9 @@ class CompletionProvider * Adds the FQNs of all parent classes to an array of FQNs of classes * * @param string[] $fqns - * @return string[] + * @return Generator */ - private function expandParentFqns(array $fqns) + private function expandParentFqns(array $fqns) : Generator { foreach ($fqns as $fqn) { yield $fqn; diff --git a/src/Definition.php b/src/Definition.php index 514d1c0..6e80240 100644 --- a/src/Definition.php +++ b/src/Definition.php @@ -7,6 +7,7 @@ use LanguageServer\Index\ReadableIndex; use phpDocumentor\Reflection\{Types, Type, Fqsen, TypeResolver}; use LanguageServer\Protocol\SymbolInformation; use Exception; +use Generator; /** * Class used to represent symbols @@ -98,16 +99,18 @@ class Definition public $documentation; /** - * Gets the definitons of all ancestor classes + * Yields the definitons of all ancestor classes (the Definition fqn is yielded as key) * - * @return Definition[] + * @param ReadableIndex $index the index to search for needed definitions + * @param bool $includeSelf should the first yielded value be the current definition itself + * @return Generator */ - public function getAncestorDefinitions(ReadableIndex $index, bool $includeSelf = false) + public function getAncestorDefinitions(ReadableIndex $index, bool $includeSelf = false) : Generator { if ($includeSelf) { yield $this->fqn => $this; } - if (is_array($this->extends)) { + if ($this->extends !== null) { // iterating once, storing the references and iterating again // guarantees that closest definitions are yielded first $definitions = [];