子类无法实现父类实现的相同接口是正常行为吗?我有 PHP v5.6
interface blueprint {
public function implement_me();
}
class one implements blueprint {
public function implement_me() {
}
}
class two extends one implements blueprint {
}
//no fatal error triggered for class two
编辑:所以即使我blueprint
在子类中实现了接口two
而没有方法impement_me()
为什么子类不能实现相同的接口父类实现,上面的代码也没有错误或警告?
blueprint
如果我实现了类以外的另一个接口,two
那么它可以工作,我必须blueprint_new
在类中使用方法,two
否则会触发致命错误。这部分按预期工作。
interface blueprint {
public function implement_me();
}
class one implements blueprint {
public function implement_me() {
}
}
interface blueprint_new {
public function todo();
}
class two extends one implements blueprint_new {
}
//this will trigger fatal error.