Stage::add()的声明必须与TherapyElement::add(TherapyElement$TA)兼容


Declaration of Stage::add() must be compatible with TherapyElement::add(TherapyElement $TA)

我有一个抽象类TherapyElement,方法为Crate(TherapyElement$te)。我还有3个扩展TherapyElement的课程(培训、阶段、阶段)。我想下一步实现方法"add()":培训:

public function add(Stage $stage ) {
   ...     
}

阶段:

public function add(Phase $stage ) {
        ...
}

阶段:

public function add(Phase $stage ) {
       .. 
}

但我得到了一个错误:阶段声明::add()必须与TherapyElement::add(TherapyElement$TA)兼容。我想,如果训练、阶段、阶段扩展了TherapyElement,那么它们就是TherapyElement的实例,可以用作参数。

问题是参数名称必须相同。在基本TherapyElement类中,您将参数称为$TA,而在其他类中,则将其称为$stage

将它们全部更改为$TA$stage,而不是交换它们。