note 51961 deleted from language.oop5.abstract by sean

From: Date: Wed, 03 Aug 2005 15:09:12 +0000
Subject: note 51961 deleted from language.oop5.abstract by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-93016@lists.php.net to get a copy of this message
Note Submitter: mweierophinney at gmail dot com ---- If you inherit from an abstract class, any method in the abstract class marked as abstract *must* be implemented by the extending class. For example, in the following abstract class: <?php abstract class AbstractClass { public function setup() {} abstract public function doSomething(); } ?> the method 'doSomething' must be defined in the extending class. Thus, the following does *not* work: <?php class ConcreteClass extends AbstractClass { public function doMyOwnThing() {} } ?> But the following *will*: <?php class ConcreteClass extends AbstractClass { public function doMyOwnThing() {} public function doSomething() {} } ?> The lesson to learn here: if the method is truly optional to the implementation, either do not define it in the abstract class at all, or do not tag it as abstract.

« previous php.notes (#93016) next »