下面的接口继承在PHP中是非法的,但我认为它在现实生活中将非常有用。下面的设计是否存在实际的反模式或已记录的问题,PHP正在保护我免受其侵扰?
<?php
/**
* Marker interface
*/
interface IConfig {}
/**
* An api sdk tool
*/
interface IApi
{
public __construct(IConfig $cfg);
}
/**
* Api configuration specific to http
*/
interface IHttpConfig extends IConfig
{
public getSomeNiceHttpSpecificFeature();
}
/**
* Illegal, but would be really nice to have.
* Is this not allowed by design?
*/
interface IHttpApi extends IApi
{
/**
* This constructor must have -exactly- the same
* signature as IApi, even though its first argument
* is a subtype of the parent interface's required
* constructor parameter.
*/
public __construct(IHttpConfig $cfg);
}