Haehnchen / idea-php-laravel-plugin

Laravel Framework Plugin for PhpStorm / IntelliJ IDEA
MIT License
573 stars 109 forks source link

Support for typehinting var in $var = app(Foo::class); #192

Open stemis opened 6 years ago

stemis commented 6 years ago

Hello,

I was wondering if support for the return of app() can be added. app() can be used for getting an injected model, and it is quite common to use it in situations where dependency injection via controller or constructor is not possible.

I would love to see this autocompleted:

class Foo {
    public function getBar() {
        return 1;
    }
}

$foo = app(Foo::class);
// $foo is not recognized as Foo::class, therefore getBar() is not autocompleted
$foo->getBar();

// Current workaround is adding the following comment:
/** @var Foo $foo */
$foo = app(Foo::class);
$foo->getBar();

Would this be something that can be added?

Thank you

adelf commented 6 years ago

@stemis you can run php artisan ide-helper:meta It will help :)

stemis commented 6 years ago

@adelf That helped, thanks!