From 8b1a8ad7dc3182791b12148bbf3a28c084d0705c Mon Sep 17 00:00:00 2001 From: Inernet User Date: Tue, 8 May 2018 22:24:51 +0300 Subject: [PATCH] Completions toArray() retruns docblock prose for user --- .../WorseClassMemberCompletor.php | 6 ++++-- lib/Core/Suggestion.php | 17 ++++++++++++++--- lib/Core/Suggestions.php | 3 ++- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/Bridge/TolerantParser/WorseReflection/WorseClassMemberCompletor.php b/lib/Bridge/TolerantParser/WorseReflection/WorseClassMemberCompletor.php index c675f0dd..28a39fc7 100644 --- a/lib/Bridge/TolerantParser/WorseReflection/WorseClassMemberCompletor.php +++ b/lib/Bridge/TolerantParser/WorseReflection/WorseClassMemberCompletor.php @@ -129,7 +129,8 @@ private function populateSuggestions(SymbolContext $symbolContext, Type $type, S continue; } $info = $this->formatter->format($method); - $suggestions->add(Suggestion::create('f', $method->name(), $info)); + $prose = $method->docblock()->formatted(); + $suggestions->add(Suggestion::create('f', $method->name(), $info, $prose)); } if ($classReflection instanceof ReflectionClass) { @@ -137,7 +138,8 @@ private function populateSuggestions(SymbolContext $symbolContext, Type $type, S if ($publicOnly && false === $property->visibility()->isPublic()) { continue; } - $suggestions->add(Suggestion::create('m', $property->name(), $this->formatter->format($property))); + $prose = $property->docblock()->formatted(); + $suggestions->add(Suggestion::create('m', $property->name(), $this->formatter->format($property), $prose)); } } diff --git a/lib/Core/Suggestion.php b/lib/Core/Suggestion.php index c0afab41..546d3730 100644 --- a/lib/Core/Suggestion.php +++ b/lib/Core/Suggestion.php @@ -19,16 +19,22 @@ class Suggestion */ private $info; - public function __construct(string $type, string $name, string $info) + /** + * @var string + */ + private $prose; + + public function __construct(string $type, string $name, string $info, string $prose = '') { $this->type = $type; $this->name = $name; $this->info = $info; + $this->prose = $prose; } - public static function create(string $type, string $name, string $info) + public static function create(string $type, string $name, string $info, string $prose = '') { - return new self($type, $name, $info); + return new self($type, $name, $info, $prose); } public function type(): string @@ -45,4 +51,9 @@ public function info(): string { return $this->info; } + + public function prose(): string + { + return $this->prose; + } } diff --git a/lib/Core/Suggestions.php b/lib/Core/Suggestions.php index 1a61651c..37554a7f 100644 --- a/lib/Core/Suggestions.php +++ b/lib/Core/Suggestions.php @@ -41,7 +41,8 @@ public function toArray() return [ 'type' => $suggestion->type(), 'name' => $suggestion->name(), - 'info' => $suggestion->info() + 'info' => $suggestion->info(), + 'prose' => $suggestion->prose(), ]; }, $this->suggestions); }