note 33772 deleted from language.oop by didou

From: Date: Mon, 07 Jul 2003 15:01:39 +0000
Subject: note 33772 deleted from language.oop by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-51635@lists.php.net to get a copy of this message
Note Submitter: barend@maximedia.nl ---- PHP doesn't know abstract classes, it'll always let you instantiate any defined class. Not a critical problem if you (and your staff) are disciplined, but if you want to enforce it, here's a simple way to do so from the constructor: class AbstractClass { ....function AbstractClass() { ........assert( is_subclass_of($this, 'AbstractClass') ); ........// remainder of constructor code ....} } Any subclass of AbstractClass can be instantiated, but trying to instantiate AbstractClass itself results in an assertion failure.

« previous php.notes (#51635) next »