From 7d64f060e8d2f050d55a820fe9d9a01c132c32e8 Mon Sep 17 00:00:00 2001 From: Ivan Bozhanov Date: Sat, 15 Jul 2017 21:44:49 +0300 Subject: [PATCH] moved short declaration extraction to a separate function --- src/SignatureHelpProvider.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/SignatureHelpProvider.php b/src/SignatureHelpProvider.php index 84a3010..916d177 100644 --- a/src/SignatureHelpProvider.php +++ b/src/SignatureHelpProvider.php @@ -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 )