From e71e4e0ff04f149f204f231835228c86a80a5ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20No=C3=A9=20Gonz=C3=A1lez?= Date: Sat, 10 Nov 2018 17:44:05 +0100 Subject: [PATCH] Trimmed Trailing Whitespace --- .vscode/settings.json | 3 ++- fixtures/completion/public_only.php | 15 +++++++++++++++ src/CompletionProvider.php | 4 ++-- src/Definition.php | 8 ++++---- 4 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 fixtures/completion/public_only.php diff --git a/.vscode/settings.json b/.vscode/settings.json index 38150bd..63af6ee 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "search.exclude": { "**/validation": true, "**/tests/Validation/cases": true - } + }, + "files.trimTrailingWhitespace": true, } diff --git a/fixtures/completion/public_only.php b/fixtures/completion/public_only.php new file mode 100644 index 0000000..aadb96c --- /dev/null +++ b/fixtures/completion/public_only.php @@ -0,0 +1,15 @@ +index->getDefinitions() as $fqn => $def) { foreach ($prefixes as $prefix) { - if (substr($fqn, 0, strlen($prefix)) === $prefix && + if (substr($fqn, 0, strlen($prefix)) === $prefix && $def->isMember && $def->isVisible($prefix, $prefixes[0], $isInMethodDeclaration)) { $list->items[] = CompletionItemFactory::fromDefinition($def); } } } - + } elseif ( ($scoped = $node->parent) instanceof Node\Expression\ScopedPropertyAccessExpression || ($scoped = $node) instanceof Node\Expression\ScopedPropertyAccessExpression diff --git a/src/Definition.php b/src/Definition.php index 39636bb..42329fe 100644 --- a/src/Definition.php +++ b/src/Definition.php @@ -133,17 +133,17 @@ class Definition } } } - + /** * Checks the definition's visibility. * @param string $match Owner of the FQNS * @param string $caller Descendant of the FQNS owner - * @param bool $isInMethodDeclaration checking if the call is from inside a + * @param bool $isInMethodDeclaration checking if the call is from inside a * method * @return bool */ public function isVisible(string $match, string $caller, bool $isInMethodDeclaration): bool - { + { if ($isInMethodDeclaration) { if ($match !== $caller && $this->isPrivate()) { return false; @@ -151,7 +151,7 @@ class Definition } else if ($this->isProtected() || $this->isPrivate()) { return false; } - + return true; }