http://www.sitepoint.com/forums/showthread.php?t=342801

From: Date: Thu, 09 Feb 2006 13:40:47 +0000
Subject: http://www.sitepoint.com/forums/showthread.php?t=342801
Groups: php.general 
Request: Send a blank email to php-general+get-230155@lists.php.net to get a copy of this message
hi Jason, you made the following claim on sitepoint (I would have reacted there but couldn't be bother to crteate another website account) - which I think is incorrect: <QUOTE> Nobody has yet brought up the slightly annoying issue that interfaces are actually implmented as abstract classes "under the hood". This means you can't decare two interfaces with an identical method name PHP Code: interface boat { public function drive(); public function float(); } interface car { public function drive(); public function rotateTires(); } class amphibious implements boat, car { public function float() {} public function drive() {} public function rotateTires() {} } </QUOTE> You are correct in that amphibious can't implement both car and boat but you suggest that this is because of a problem with the engine and that it should be fixed. But there is no problem and there is nothing to fix. (regardless of interfaces a class can only implement a method once (we don't have C-like function overloading) and that means you can't implement both interfaces, besides which it makes no sense because if you we're allowed to implement one drive() method to satisfy the 2 drive() interface methods then neither the engine nor your code would know which of the 2 drive() methods was actually bveing implemented (and if that cannot be determined then the whole point of the interface becomes moot) This misconception regarding broken interface functionality seems to seem from content of your example. 'boat' and 'car' are not interfaces in my mind rather I would see them (and 'amphibious') as [abstract] classes and if they were to implement an interface 'vehicle' springs to mind as a candidate. (also boats aren't generally 'driven' ;-) rgds, Jochem

« previous php.general (#230155) next »