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

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条)

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?