drnrxv9383 2015-02-16 23:31
浏览 162

用Laravel进行phpstorm错误的方法声明

I'm using phpstorm 8.0.3 (build 12 February) to build a Laravel 4.2 application. I'm also using the _ide_helper by Barry Heuvel.

I get an error when declaring a method with the same name as an Eloquent method. To be more clear, here is some example code:

class SomeModel extends Eloquent{}

class OtherClass {

    public function update($first, $second, $third){
        //do some stuff
        return true;
    }

    public function check(){
        $item = SomeModel::findOrFail('1');
        $item->update([
            'name'  =>  'my name',
            'attribute' =>  'some attribute'
        ]);
        return "here's the problem!";
    }
}

In this code item->update([... gets highlighted red with the error message Required Parameter $second missing... and if i use "go to declaration" on that piece of code instead of going to the declaration of the update method of Eloquent it goes to the the one declared on top.

Is anyone else getting this error? Have you found a fix? I'm not sure if its a problem of PhpStorm, my code or the ide_helper...

Thanks!

EDIT

I think I found the origin of the problem thanks to the comment by LazyOne. In the declaration of findOrFail the PHPDoc reads: @return \Illuminate\Support\Collection|static. When changed to `@return \Illuminate\Support\Collection\static' or simply without the static, the error isn't shown. Is PHPStorm nor reading the docstring properly or is the format incorrect?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog