我有两个班,一个是家长班,一个是子班.每当我try 将子类中的方法与父类中的方法链接在一起时,就会出现问题.VS代码报告误报.
class BaseClass
{
protected $agent;
protected $report;
public function __construct()
{
}
public function setAgent($agent) : self
{
$this->agent = $agent;
return $this;
}
public function setReport($report) : self
{
$this->report = $report;
return $this;
}
public function getAgent() : User
{
return $this->agent;
}
public function getReport()
{
return $this->report;
}
}
这是一个 children 班:
class ChildClass extends BaseClass
{
public function __construct()
{
}
public function process(string $status)
{
//some code here
}
}
我是这么说的:
$child = new ChildClass();
$child->setAgent($this->user)
->setReport($this->report)
->process($status);
VS代码报告方法Process()未定义,并用红色下划线.代码在使用和测试中都运行良好.在VS代码中看到红线和误报让我很烦恼.有没有办法在VS代码上解决这个问题?