shawncplus / phpcomplete.vim

Improved PHP omnicompletion
http://www.vim.org/scripts/script.php?script_id=3171
595 stars 110 forks source link

params not displayed for class methods with return typehints (php7) #101

Closed nclundsten closed 7 years ago

nclundsten commented 7 years ago

without return typehint

public function findMe($a, $b = 'foo') { }

$this->findM \\

result

findMe( f $a, $b = 'foo')

with return typehint

public function findMe($a, $b = 'foo') : string { }

$this->findM \\

expected

findMe( f $a, $b = 'foo')

actual result

findMe( f )

Note: seems to work correctly when just doing:

findM \\

complex857 commented 7 years ago

Yeah, we don't have any PHP 7 support... too bad it fails ungracefully as well. Those typehints could / should be used in every place where we use doclbock @returns now.

complex857 commented 7 years ago

Hi @nclundsten!

Sorry, I know it took me almost a half a year to find the time to sit down and actually do some work, but here it is nonetheless. It should work reasonably well for most cases (hooks into the same place where the docblock @return ...s do).

Give it a spin and let me know if I've missed something.

Bergiu commented 6 years ago

Doesn't work for me.

My ctags --version is:

Universal Ctags 0.0.0(b6031a8), Copyright (C) 2015 Universal Ctags Team
Universal Ctags is derived from Exuberant Ctags.
Exuberant Ctags 5.8, Copyright (C) 1996-2009 Darren Hiebert
  Compiled: Nov 10 2017, 13:00:44
  URL: https://ctags.io/
  Optional compiled features: +wildcards, +regex, +multibyte, +option-directory, +xpath, +json, +interactive, +yaml

And I am generating the tags with ctags -R --fields=afikmsS and this generates for example:

returnBar   fixtures/GetClassName/return_typehinted_functions.php   /^  public function returnBar($a, $b = 'foo') : Bar {$/;"   f   class:FooReturnBars access:public   signature:($a, $b = 'foo')

so ctags seems to work.

Vim looks like this: photo_2017-11-10_14-46-16

To give another example: When I define my interface like this:

    /**
     * Login to webservice and get the token
     *
     * @param string $username   username
     * @param string $password   password
     * @param string $webservice webservice to login
     *
     * @return bool true if login was successful
     */
    public function login(string $username, string $password, string $webservice): bool;

it gives me the autocompletion login()

But when I remove the Typehint:

    /**
     * Login to webservice and get the token
     *
     * @param string $username   username
     * @param string $password   password
     * @param string $webservice webservice to login
     *
     * @return bool true if login was successful
     */
    public function login(string $username, string $password, string $webservice);

It returns the completion login(string $username, string $password, string $webservice), so that I can see the parameters.