gpt4 book ai didi

PHPStorm 无法识别超过 2 个链式公共(public)方法

转载 作者:行者123 更新时间:2023-12-04 18:02:31 25 4
gpt4 key购买 nike

这不会影响代码,但有点烦人。

我的 Controller 中有这 3 个方法:

public function chainOne()
{
return $this;
}

public function chainTwo()
{
return $this;
}

public function chainThree()
{
return $this;
}

一旦到达特定路线,被调用的方法是这样的:
public function indexAction()
{

$this->chainOne()
->chainTwo()
->chainThree();

}

PHPStorm 说 method chainThree() not found in class $this .但是里面的代码 chainThree()正在执行没有问题。

我该如何解决?这是一个错误吗?

最佳答案

你可以使用 docblocks 来帮助 PHPStorm 识别返回值:

public class Foo
{

/**
* @return Foo $this
*/
public function chainOne()
{
return $this;
}

/**
* @return Foo $this
*/
public function chainTwo()
{
return $this;
}

/**
* @return Foo $this
*/
public function chainThree()
{
return $this;
}

}

关于PHPStorm 无法识别超过 2 个链式公共(public)方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32745751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com