From 6cb916e28d8a9f83c26d4df29c6e17153500d825 Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Sat, 8 Oct 2016 12:51:55 +0200 Subject: [PATCH] Improve inline documentation and code style --- src/PhpDocument.php | 41 ++++++++++++++++++++++++++++++++++++- src/Project.php | 4 ++-- src/Server/TextDocument.php | 3 +++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/PhpDocument.php b/src/PhpDocument.php index b97f6c3..febff0e 100644 --- a/src/PhpDocument.php +++ b/src/PhpDocument.php @@ -11,14 +11,52 @@ use PhpParser\NodeVisitor\NameResolver; class PhpDocument { + /** + * The LanguageClient instance (to report errors etc) + * + * @var LanguageClient + */ private $client; + + /** + * The Project this document belongs to (to register definitions etc) + * + * @var Project + */ private $project; + + /** + * The PHPParser instance + * + * @var Parser + */ private $parser; + /** + * The URI of the document + * + * @var string + */ private $uri; + + /** + * The content of the document + * + * @var string + */ private $content; + + /** + * @var SymbolInformation[] + */ private $symbols = []; + /** + * @param string $uri The URI of the document + * @param Project $project The Project this document belongs to (to register definitions etc) + * @param LanguageClient $client The LanguageClient instance (to report errors etc) + * @param Parser $parser The PHPParser instance + */ public function __construct(string $uri, Project $project, LanguageClient $client, Parser $parser) { $this->uri = $uri; @@ -54,6 +92,7 @@ class PhpDocument * Updates the content on this document. * * @param string $content + * @return void */ public function updateContent(string $content) { @@ -73,7 +112,7 @@ class PhpDocument $errors = []; try { $stmts = $this->parser->parse($this->content); - } catch(\PhpParser\Error $e) { + } catch (\PhpParser\Error $e) { // Lexer can throw errors. e.g for unterminated comments // unfortunately we don't get a location back $errors[] = $e; diff --git a/src/Project.php b/src/Project.php index 5063215..adf37f6 100644 --- a/src/Project.php +++ b/src/Project.php @@ -13,7 +13,7 @@ class Project * An associative array [string => PhpDocument] * that maps URIs to loaded PhpDocuments * - * @var array + * @var PhpDocument[] */ private $documents; @@ -63,7 +63,7 @@ class Project public function findSymbols(string $query) { $queryResult = []; - foreach($this->documents as $uri => $document) { + foreach ($this->documents as $uri => $document) { $queryResult = array_merge($queryResult, $document->findSymbols($query)); } return $queryResult; diff --git a/src/Server/TextDocument.php b/src/Server/TextDocument.php index ba7f482..a6541c1 100644 --- a/src/Server/TextDocument.php +++ b/src/Server/TextDocument.php @@ -28,6 +28,9 @@ class TextDocument */ private $client; + /** + * @var Project + */ private $project; public function __construct(Project $project, LanguageClient $client)