note 106290 added to language.oop5.interfaces

From: Date: Tue, 25 Oct 2011 16:12:14 +0000
Subject: note 106290 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-184120@lists.php.net to get a copy of this message
The error "Can't inherit abstract function IB::f() (previously declared abstract in IA)" in the following code <?php interface IA { public function f(); } interface IB { public function f(); } class Test implements IA, IB { public function f() { echo "f"; } } $o = new Test(); $o->f(); ?> can be avoided (if appropriate) by adding a ancestor interface to IA and IB, and moving the common method to it: <?php interface IAncestor { public function f(); } interface IA { } interface IB extends IAncestor { } class Test implements IA, IB { public function f() { echo "f"; } } $o = new Test(); $o->f(); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 93.20.210.161 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/106290 Del: integrated -- https://master.php.net/note/delete/106290/integrated Del: useless -- https://master.php.net/note/delete/106290/useless Del: bad code -- https://master.php.net/note/delete/106290/bad+code Del: spam -- https://master.php.net/note/delete/106290/spam Del: non-english -- https://master.php.net/note/delete/106290/non-english Del: in docs -- https://master.php.net/note/delete/106290/in+docs Del: other reasons-- https://master.php.net/note/delete/106290 Reject -- https://master.php.net/note/reject/106290 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184120) next »