note 77951 deleted from language.oop5.interfaces by nlopess

From: Date: Fri, 21 Sep 2007 13:39:52 +0000
Subject: note 77951 deleted from language.oop5.interfaces by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130665@lists.php.net to get a copy of this message
Note Submitter: Hayley Watson ---- 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.

« previous php.notes (#130665) next »