interfaces extending multiple interfaces

php.internals

Hans Lellelid

22 years ago
Is there any way to have an _interface_ implement or extend multiple interfaces? This was working as of PHP5b3, but seems to work no longer as of latest snapshot I downloaded. The only way to do it before was to have an interface implement other interfaces: interface ExtendFileSelector implements Parameterizable, FileSelector { } This was a very useful way to get around a need for multiple inheritance. Obviously an interface that implements other interfaces is kinda weird -- but I was very pleased that it worked. I apolgoize if I've missed a thread where this was discussed. Hans

Andrey Hristov

22 years ago
Hi, Hans Lellelid wrote:
> Is there any way to have an _interface_ implement or extend multiple > interfaces? This was working as of PHP5b3, but seems to work no longer > as of latest snapshot I downloaded. > > The only way to do it before was to have an interface implement other > interfaces: > > interface ExtendFileSelector implements Parameterizable, FileSelector { > } > > This was a very useful way to get around a need for multiple > inheritance. Obviously an interface that implements other interfaces is > kinda weird -- but I was very pleased that it worked.
Yeah, it's like that for about 2 days. Hopefully this will be fixed before RC1 which is scheduled for the end of the month. Sebastian Bergmann already complained :)
> I apolgoize if I've missed a thread where this was discussed.
No, it wasn't. Andrey

Andi Gutmans

22 years ago
Zeev is planning on fixing this. Interfaces should be allowed to extend other interfaces but not to implement them. Andi At 04:16 PM 1/16/2004 -0500, Hans Lellelid wrote:

Sebastian Bergmann

22 years ago
Andi Gutmans wrote:
> Zeev is planning on fixing this.
Cool.
> Interfaces should be allowed to extend other interfaces but not > to implement them.
interface Bar extends Foo {} works already (at least last time I checked). What I need (and meant) is interface Barbara extends Bar, Foo {} Just to make sure :-), Sebastian
-- Sebastian Bergmann http://sebastian-bergmann.de/ http://phpOpenTracker.de/ Das Buch zu PHP 5: http://professionelle-softwareentwicklung-mit-php5.de/

Hans Lellelid

22 years ago
Hi - Sebastian Bergmann wrote:
> Andi Gutmans wrote: > >>Zeev is planning on fixing this. > > > Cool. > >>Interfaces should be allowed to extend other interfaces but not >>to implement them. > > > interface Bar extends Foo {} > > works already (at least last time I checked). What I need (and meant) is > > interface Barbara extends Bar, Foo {} > > Just to make sure :-),
This multiple extension would be very nice. I thought this was going to be fixed for beta4/RC1, but still seems not to be. Is the plan not to implement this feature? As Sebastian points out here (some time ago), perhaps there was some misunderstanding about what the original issue was. Hans

Sebastian Bergmann

22 years ago
Hans Lellelid wrote:
> I thought this was going to be fixed for beta4/RC1, but still seems > not to be.
Works for me: <?php interface Foo { public function doFoo(); } interface Bar { public function doBar(); } interface Barbara extends Foo, Bar {} class BarbaraImpl implements Barbara { public function doFoo() {} public function doBar() {} } ?> Greetings, Sebastian
-- Sebastian Bergmann http://sebastian-bergmann.de/ http://phpOpenTracker.de/ Das Buch zu PHP 5: http://professionelle-softwareentwicklung-mit-php5.de/

Hans Lellelid

22 years ago
Sebastian Bergmann wrote:
> Hans Lellelid wrote: > >>I thought this was going to be fixed for beta4/RC1, but still seems >>not to be. > > > Works for me:
Apologies! -- yes, it does work. I was still doing the old "Foo implements Foo, Bar" which used to work (but never should have). Thanks- Hans