note 71608 added to language.oop5.interfaces

From: Date: Thu, 07 Dec 2006 13:25:52 +0000
Subject: note 71608 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-120376@lists.php.net to get a copy of this message
Note that you can extend interfaces with other interfaces since under-the-hood they are just abstract classes: <?php interface Foo { public function doFoo(); } interface Bar extends Foo { public function doBar(); } class Zip implements Bar { public function doFoo() { echo "Foo"; } public function doBar() { echo "Bar"; } } $zip = new Zip(); $zip->doFoo(); $zip->doBar(); ?> This is quite useful when you're using interfaces for identity more than the rigidity it places upon an API. You can get the same result by implementing multiple interfaces. An example of where I've used this in the past is with EventListener objects ala Java's Swing UI. Some listeners are effectively the same thing but happen at different times therefore we can keep the same API but change the naming for clarity. ---- Server IP: 85.116.0.130 Probable Submitter: 213.205.138.154 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/71608 Del: integrated -- https://master.php.net/note/delete/71608/integrated Del: useless -- https://master.php.net/note/delete/71608/useless Del: bad code -- https://master.php.net/note/delete/71608/bad+code Del: spam -- https://master.php.net/note/delete/71608/spam Del: non-english -- https://master.php.net/note/delete/71608/non-english Del: in docs -- https://master.php.net/note/delete/71608/in+docs Del: other reasons-- https://master.php.net/note/delete/71608 Reject -- https://master.php.net/note/reject/71608 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#120376) next »