Re: Interface inheritance
| From: | Stanislav Malyshev | Date: | Tue, 20 Apr 2004 14:38:12 +0000 |
| Subject: | Re: Interface inheritance | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-9419@lists.php.net to get a copy of this message | ||
FB>>interface A {
FB>> public function doSomething($integer1, $integer2);
FB>>}
FB>>
FB>>interface B {
FB>> public function doSomething(MyObject $obj);
FB>>}
FB>>
FB>>class Impl implements A, B
FB>>{
FB>> // "Overloaded" - supports both doSomething() interfaces
FB>> public function doSomething()
FB>> {
FB>> // Use var_args to distinquish the two doSomething()'s
FB>> }
FB>>}
The problem here that you can't know if Impl would actually accept
MyObject or two integers as arguments. So if some method requires object
with interface A and it's passed Impl, it cannot actually be sure it can
use it as an A object.
--
Stanislav Malyshev, Zend Products Engineer
stas@zend.com http://www.zend.com/ +972-3-6139665 ext.115