Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13069 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14163 invoked by uid 1010); 29 Sep 2004 19:28:54 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 13998 invoked from network); 29 Sep 2004 19:28:52 -0000 Received: from unknown (HELO jan.prima.de) (83.97.50.139) by pb1.pair.com with SMTP; 29 Sep 2004 19:28:52 -0000 Received: from BAUMBART (pD95F83F5.dip.t-dialin.net [::ffff:217.95.131.245]) (IDENT: HydraIRC, AUTH: LOGIN tobi) by jan.prima.de with esmtp; Wed, 29 Sep 2004 19:28:51 +0000 Date: Wed, 29 Sep 2004 21:26:40 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <787970287.20040929212640@marcus-boerger.de> To: Michael Virnstein CC: internals@lists.php.net In-Reply-To: <20040929094434.37880.qmail@pb1.pair.com> References: <20040928124540.618.qmail@pb1.pair.com> <20040928134447.62577.qmail@pb1.pair.com> <1724849455.20040928233204@marcus-boerger.de> <20040929094434.37880.qmail@pb1.pair.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Re: declaring classes as static or final From: helly@php.net (Marcus Boerger) Hello Michael, Wednesday, September 29, 2004, 11:44:04 AM, you wrote: >> > 2. final classes: >> > final classes can't be extended >> >> already supported > Cannot find it in the docs. > http://www.php.net/manual/en/language.oop5.final.php doesn't seem to have > any comments on that. > I'm not at home at the moment, so i couldn't try, but are you really sure > that final CLASSES are supported? > You're not confusing it with final METHODS, right? Nope, i invented both final and abstract for both classes and methods :-) > A good example for a static class imo, would be e.g. PEAR's DB Class. The > DB-Class itself doesn't need to be instantiate, > it simply works as factory and has some functions to check stuff. that'd be > a class that i would define as > "final static class DB {}". The class should not be extended and should not > containt non static methods or attributes. Sure it isn't > a big deal, if ppl are instantiating the DB Class, but it only has static > methods and instantiating it wouldn't make any sense. Ah so it is just a little bit more enforcement then the following: final class DB { // prevent instantiation private function __construct() { exit(0); } // The following is not needed because the constructor cannot be called // private function __clone() { exit(0); } } -- Best regards, Marcus mailto:helly@php.net