我有类型提示的问题。我有这样的类(伪代码):
interface iBaseDAO
{
public function __construct(iBaseDataMapper $objDataMapper);
//...
}
interface iBaseDataMapper
{
//...
}
interface iConcreteDataMapper extends iBaseDataMapper
{
//...
}
class ConcreteDAO implements iBaseDAO
{
public function __construct(iConcreteDataMapper $objDataMapper)
{
//...
}
}
我想实现,DAO
只能用某种实例化,DataMapper
但ConcreteDAO
要确保它只能用ConcreteDataMapper
. 因为iConcreteDataMapper
是iBaseDataMapper
我认为它应该工作的孩子,但我收到错误:
Fatal error: Declaration of ConcreteDAO::__construct() must be compatible with iBaseDAO::__construct(iBaseDataMapper $objDataMapper)
为什么我不能使用iConcreteDataMapper
in ConcreteDAO
?感谢您的任何帮助。