Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13065 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 7976 invoked by uid 1010); 29 Sep 2004 10:03:08 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 7939 invoked from network); 29 Sep 2004 10:03:08 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 29 Sep 2004 10:03:08 -0000 Received: from pd95195c2.dip.t-dialin.net ([217.81.149.194] helo=[192.168.0.36]) by iko.gotobg.net with asmtp (Exim 4.41) id 1CCbIj-0001DA-SQ for internals@lists.php.net; Wed, 29 Sep 2004 13:03:10 +0300 Message-ID: <415A8800.30502@hristov.com> Date: Wed, 29 Sep 2004 12:01:36 +0200 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a4) Gecko/20040918 X-Accept-Language: en-us, en MIME-Version: 1.0 To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Re: declaring classes as static or final From: php@hristov.com (Andrey Hristov) Michael Virnstein 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? > andrey@vivaldi:~> php -r 'final class a{} class b extends a{}' Fatal error: Class b may not inherit from final class (a) in Command line code on line 1 > > 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. > Make the constructor private and the class final. No instance will be available, and no inheritance possible. Methods has to work, and therefore they may not expect to have $this available in them. Andrey