1
0
Fork 0

moved short declaration extraction to a separate function

pull/438/head
Ivan Bozhanov 2017-07-15 21:44:49 +03:00
parent 7b54ecd67c
commit 7d64f060e8
1 changed files with 14 additions and 1 deletions

View File

@ -37,6 +37,19 @@ class SignatureHelpProvider
$this->index = $index;
}
/**
* Get the short declaration for a callable (class modifiers, function keyword, etc are stripped)
*
* @param string $declaration
* @return string
*/
protected function getShortDeclaration(string $declaration): string
{
$parts = explode('(', $declaration, 2);
$name = array_reverse(explode(' ', trim($parts[0])))[0];
return $name . '(' . $parts[1];
}
/**
* Returns signature help for a specific cursor position in a document
*
@ -86,7 +99,7 @@ class SignatureHelpProvider
return new SignatureHelp(
[
new SignatureInformation(
trim(str_replace(['public', 'protected', 'private', 'function', 'static'], '', $def->declarationLine)),
$this->getShortDeclaration($def->declarationLine),
$def->documentation,
$def->parameters
)