dongyiluan1718 2017-03-04 21:43
浏览 679
已采纳

PhpStorm无法识别方法

So this has been asked several times but I'm yet to find an answer that works.

I'm using PhpStorm - 2016.3.2 and Laravel 5.4

enter image description here

I have tried using https://github.com/barryvdh/laravel-ide-helper and also the Laravel plugin for PhpStorm.

I tried checking the option "Downgrade severity if_magic methods are present in class" - this didn't work.

The only thing I can do to solve this is to turn the warnings off completely for undefined methods, but turning features like this off defeat the point of using an IDE.

Has anyone found a way to solve this?

Sources:

https://laracasts.com/series/how-to-be-awesome-in-phpstorm/episodes/15

https://laracasts.com/discuss/channels/general-discussion/why-does-phpstorm-not-recognise-all-the-classes?page=1

PhpStorm laravel 5 method not found

https://github.com/barryvdh/laravel-ide-helper

  • 写回答

2条回答 默认 最新

  • drhe80011 2017-03-05 01:51
    关注

    The reason this is happening is because PHPStorm doesn't know what that variable is meant to be (it has nothing to be with Laravel). As far as PHPStorm knows it's just a param for a method.

    As @LazyOne suggested, you can type hint the variable e.g.

    public function scopeIncomplete(Builder $query)
    

    Then at the top of the class just add the following use statement

    use Illuminate\Database\Eloquent\Builder;
    

    Alternatively, if you're using a OS X (I'm not sure of the shortcuts for Windows or Linux) you can move the caret in the Builder reference and then hit alt enter to import the class.

    Hope this helps!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?