PHPStorm 无法识别超过 2 个链式 public 方法
PHPStorm not recognising more than 2 chained public methods
这不会影响代码,但有点烦人。
我的控制器中有这 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()
里面的代码执行没有问题。
我该如何解决?这是一个错误吗?
您可以使用文档块来帮助 PHPStorm 识别 return 值:
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;
}
}
这不会影响代码,但有点烦人。
我的控制器中有这 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()
里面的代码执行没有问题。
我该如何解决?这是一个错误吗?
您可以使用文档块来帮助 PHPStorm 识别 return 值:
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;
}
}