note 77954 added to language.oop5.interfaces

From: Date: Fri, 21 Sep 2007 10:42:07 +0000
Subject: note 77954 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-130653@lists.php.net to get a copy of this message
If it's not already obvious, it's worth noticing that the parameters in the interface's method declaration do not have to have the same names as those in any of its implementations. More significantly, default argument values may be supplied for interface method parameters, and they have to be if you want to use default argument values in the implemented classes: <?php interface isStuffable { public function getStuffed($ratio=0.5); } class Turkey implements isStuffable { public function getStuffed($stuffing=1) { // .... } } ?> Note that not only do the parameters have different names ($ratio and $stuffing), but their default values are free to be different as well. There doesn't seem to be any purpose to the interface's default argument value except as a dummy placeholder to show that there is a default (a class implementing isStuffable will not be able to implement methods with the signatures getStuffed(), getStuffed($a), or getStuffed($a,$b)). ---- Server IP: 202.89.58.1 Probable Submitter: 202.27.216.35 (proxied: 202.27.216.129) ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/77954 Del: integrated -- https://master.php.net/note/delete/77954/integrated Del: useless -- https://master.php.net/note/delete/77954/useless Del: bad code -- https://master.php.net/note/delete/77954/bad+code Del: spam -- https://master.php.net/note/delete/77954/spam Del: non-english -- https://master.php.net/note/delete/77954/non-english Del: in docs -- https://master.php.net/note/delete/77954/in+docs Del: other reasons-- https://master.php.net/note/delete/77954 Reject -- https://master.php.net/note/reject/77954 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130653) next »