Re: Interface inheritance

From: Date: Tue, 20 Apr 2004 15:14:54 +0000
Subject: Re: Interface inheritance
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-9425@lists.php.net to get a copy of this message
On 20 Apr 2004 at 17:55, Stanislav Malyshev wrote: > FB>>Impl guarantees that by implementing interface A. > > No. It _says_ it implements interface A, but you couldn't know if it > indeed does, if we allow your model - maybe that "dispatched" function > call doesn't really accept those arguments? interface I { /** Documentation says: $a is an integer, $b is a string */ function doSomething($a, $b); } class C implements I { function doSomething($a, $b) { } } We still can't be sure if C::doSometing() actually accepts an integer and a string. We have to trust C. So we can also trust Impl from the previous example... > FB>>What if Impl::doSomething() would accept exactly two parameters, but > FB>>expects them to be arrays? > > Then how can you say it implements B where object is required? I meant to change Impl to accept arrays and to drop the B implementation. > Since PHP does not dispatch methods by parameters, I don't know if there's > a good way to implement both A and B interfaces except making all > doSomething definitions not accept parameters or give them different > names. Provided that one has access to the interfaces... -- Ferdinand Beyer <fb@fbeyer.com>

« previous php.internals (#9425) next »