idea-php-laravel-plugin icon indicating copy to clipboard operation
idea-php-laravel-plugin copied to clipboard

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

Open stemis opened this issue 5 years ago • 2 comments

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

stemis avatar Jul 10 '18 08:07 stemis

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

adelf avatar Jul 10 '18 12:07 adelf

@adelf That helped, thanks!

stemis avatar Jul 11 '18 09:07 stemis