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

时间:2015-02-16 23:31:45

标签: php laravel eloquent phpstorm

我正在使用phpstorm 8.0.3(2月12日构建)来构建Laravel 4.2应用程序。我也在使用Barry Heuvel的_ide_helper

在声明与Eloquent方法同名的方法时出错。为了更清楚,这里有一些示例代码:

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!";
    }
}

在此代码中,item->update([...突出显示为红色,并显示错误消息必需参数$ second缺失... 如果我使用“转到声明”那段代码而不是去Eloquent的 update 方法的声明,它转到了在顶层声明的那个。

是否有其他人收到此错误?你找到了修复方法吗?我不确定它是PhpStorm,我的代码还是ide_helper的问题......

谢谢!

修改

由于LazyOne的评论,我认为我找到了问题的根源。 在 findOrFail 的声明中,PHPDoc读取:@return \Illuminate\Support\Collection|static。当更改为“@return \ Illuminate \ Support \ Collection \ static”或者只是没有静态时,不会显示错误。是PHPStorm还是正确读取文档字符串还是格式不正确?

0 个答案:

没有答案