note 77950 added to language.oop5.interfaces

From: Date: Fri, 21 Sep 2007 05:34:34 +0000
Subject: note 77950 added to language.oop5.interfaces
Groups: php.notes 
Request: Send a blank email to php-notes+get-130649@lists.php.net to get a copy of this message
On an incidental note, it is not necessary for the implementation of an interface method to use the same variable names for its parameters that were used in the interface declaration. More significantly, your interface method declarations can include default argument values. If you do, you must specify their implementations with default arguments, too. Just like the parameter names, the default argument values do not need to be the same. In fact, there doesn't seem to be any functionality to the one in the interface declaration at all beyond the fact that it is there. <?php interface isStuffed { public function getStuff($something=17); } class oof implements isStuffed { public function getStuff($a=42) { return $a; } } $oof = new oof; echo $oof->getStuff(); ?> Implementations that try to declare the method as getStuff(), getStuff($a), or getStuff($a,$b) will all trigger a fatal error. ---- Server IP: 203.89.181.186 Probable Submitter: 60.234.168.92 ---- Manual Page -- http://www.php.net/manual/en/language.oop5.interfaces.php Edit -- https://master.php.net/note/edit/77950 Del: integrated -- https://master.php.net/note/delete/77950/integrated Del: useless -- https://master.php.net/note/delete/77950/useless Del: bad code -- https://master.php.net/note/delete/77950/bad+code Del: spam -- https://master.php.net/note/delete/77950/spam Del: non-english -- https://master.php.net/note/delete/77950/non-english Del: in docs -- https://master.php.net/note/delete/77950/in+docs Del: other reasons-- https://master.php.net/note/delete/77950 Reject -- https://master.php.net/note/reject/77950 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#130649) next »