Laravel软件包的VSCode自动完成问题

I've a problem with autocompletion in VSCode: the text editor doesn't show me the suggestions for methods of the external packages.

In this case, i'm trying the Faker package but when I type $faker->addr, I cannot see the method address() in the autocompletion hints.

Do you know how to fix this problem? It's annoying, mostly when you're learning new stuff and the autocompletion helps a lot.

This is an example what I intended.

Faker\Factory::create() looks like this:

/**
 * Create a new generator
 *
 * @param string $locale
 * @return Generator
 */
public static function create($locale = self::DEFAULT_LOCALE)
{
    $generator = new Generator();
    foreach (static::$defaultProviders as $provider) {
        $providerClassName = self::getProviderClassname($provider, $locale);
        $generator->addProvider(new $providerClassName($generator));
    }

    return $generator;
}

That means that, unless you have a really cool static analysis engine, all the editor will see is a Faker\Generator instance. And such class does not have any address() method because it's a magic method.

However, the library uses annotations to describe magic properties:

/**
 * @property string $address
 */

That means that you can sensibly expect to get, at least, such property.

In my experience the PHP Intelephense is slightly smarter than PHP IntelliSense. I can confirm you that, at least in this case, Intelephense actually suggests $faker->address as property, while IntelliSense doesn't.


Out of curiosity, I tried PhpStorm with fzaninotto/faker and it doesn't recognise the magic method either (not at least out of the box)—it does recognise it as magic property though.