【发布时间】:2019-12-04 01:04:19
【问题描述】:
我正在实现一个Adapter pattern 用于测试目的,我想用两个不同类的方法输入提示适配器的返回,我该如何实现?
class Foo {
public function somethingOnlyFooHave() {};
}
class Adapter {
protected $handler;
public function __construct(object $handler) {
$this->handler = $handler;
}
public function __call($name, ...$args) {
$this->handler->$name($args);
}
public function somethingOnlyTheAdapterHave() {}
}
$foo = new Adapter(new Foo);
// How can I get type-hinting for both the Adapter and Foo?
$foo->somethingOnlyFooHave();
$foo->somethingOnlyTheAdapterHave();
【问题讨论】:
标签: php type-hinting method-call