Skip to content
This repository has been archived by the owner on Mar 6, 2022. It is now read-only.

Completions toArray() retruns docblock prose for user #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,17 @@ 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) {
foreach ($classReflection->properties() as $property) {
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));
}
}

Expand Down
17 changes: 14 additions & 3 deletions lib/Core/Suggestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,4 +51,9 @@ public function info(): string
{
return $this->info;
}

public function prose(): string
{
return $this->prose;
}
}
3 changes: 2 additions & 1 deletion lib/Core/Suggestions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down