Haehnchen / idea-php-laravel-plugin

Laravel Framework Plugin for PhpStorm / IntelliJ IDEA
MIT License
572 stars 108 forks source link

Please remove autocompletition for container instances #72

Open evgeniy-n opened 8 years ago

evgeniy-n commented 8 years ago

You have "Note You must install and use the Laravel IDE Helper in order for PhpStorm to know how to find the Laravel classes." PhpStorm developers already fix autocompletition for classes and bindings from .phpstorm.meta and "Laravel IDE Helper" make it easy and simple. Your plugin has code to override storm functionality, but it works not perfect. Almost all user-defined bindings don't have autocomplete. You can't suggest all bindings. This laravel stuff can be done in any project file, not only in service providers. Also you track calls to $this->app->singleton however there are a lot of ways to register IoC objects.

https://github.com/Haehnchen/idea-php-laravel-plugin/commit/90fb37c0e4ee6a7af5854a416f125b0b95c213d3 https://github.com/Haehnchen/idea-php-laravel-plugin/commit/d06222eff52e9e6a8cad361b7a9a79a411ab4d01

Just revert this code, or make usage of it configurable via settings menu.

Even regular Laravel stuff works incorrect: This code has autocomplete and works as expected. $this->app->singleton('abc:cart', function(){ return new CartRepository; }); This code dosn't work, but it should. $this->app->singleton('abc:cart', CartRepository::class);

Also. When I try to autocomplete code app('abc:cart')-> with disabled plugin, it works fine, but when plugin enabled IDE say: "Nothing to show", so this plugin overwrite native functionality of PhpStorm.

jonnywilliamson commented 7 years ago

Perhaps this is relative:

https://github.com/barryvdh/laravel-ide-helper/issues/473#issuecomment-290933164

Haehnchen commented 7 years ago

This plugin does not overwrite functionality, if so its more a regression on the old metadata implementation on PhpStorm. I tested it inside PhpStorm 2017.1 and its working as expected: both plugin and .phpstorm.meta are taking into account.

Indeed some service registering pattern are missing. but frequently used first.

$this->app->singleton('abc:cart', CartRepository::class);
$this->app->singleton(CartRepository::class, function() {});
$this->app->bind(CartRepository::class, function() {});