Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79347 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 36245 invoked from network); 1 Dec 2014 18:15:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Dec 2014 18:15:49 -0000 Authentication-Results: pb1.pair.com smtp.mail=php@bof.de; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=php@bof.de; sender-id=pass Received-SPF: pass (pb1.pair.com: domain bof.de designates 80.242.145.70 as permitted sender) X-PHP-List-Original-Sender: php@bof.de X-Host-Fingerprint: 80.242.145.70 mars.intermailgate.com Received: from [80.242.145.70] ([80.242.145.70:41599] helo=mars.intermailgate.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/80-32869-350BC745 for ; Mon, 01 Dec 2014 13:15:48 -0500 Received: (qmail 19169 invoked by uid 1009); 1 Dec 2014 19:15:44 +0100 Received: from 209.85.216.177 by mars (envelope-from , uid 89) with qmail-scanner-1.25-st-qms (clamdscan: 0.96.2/19702. spamassassin: 3.3.1. perlscan: 1.25-st-qms. Clear:RC:1(209.85.216.177):. Processed in 0.270597 secs); 01 Dec 2014 18:15:44 -0000 X-Antivirus-MYDOMAIN-Mail-From: php@bof.de via mars X-Antivirus-MYDOMAIN: 1.25-st-qms (Clear:RC:1(209.85.216.177):. Processed in 0.270597 secs Process 19154) Received: from mail-qc0-f177.google.com (gmail@bof.de@209.85.216.177) by mars.intermailgate.com with RC4-SHA encrypted SMTP; 1 Dec 2014 19:15:43 +0100 Received: by mail-qc0-f177.google.com with SMTP id x3so8046811qcv.36 for ; Mon, 01 Dec 2014 10:15:41 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.224.1.200 with SMTP id 8mr50345505qag.54.1417457741993; Mon, 01 Dec 2014 10:15:41 -0800 (PST) Received: by 10.140.37.41 with HTTP; Mon, 1 Dec 2014 10:15:41 -0800 (PST) Received: by 10.140.37.41 with HTTP; Mon, 1 Dec 2014 10:15:41 -0800 (PST) In-Reply-To: <547C991E.2070700@gmail.com> References: <003c01d00d6e$f4fd77c0$def86740$@tutteli.ch> <868FD3D8-4E80-46F4-872A-125D3FD8F40D@ajf.me> <547C991E.2070700@gmail.com> Date: Mon, 1 Dec 2014 19:15:41 +0100 Message-ID: To: Rowan Collins Cc: internals Content-Type: multipart/alternative; boundary=001a11c2cefe3221c105092b99ee Subject: Re: [PHP-DEV] [RFC] Static classes (Was Abstract final classes) From: php@bof.de (Patrick Schaaf) --001a11c2cefe3221c105092b99ee Content-Type: text/plain; charset=UTF-8 Am 01.12.2014 17:37 schrieb "Rowan Collins" : > > guilhermeblanco@gmail.com wrote on 01/12/2014 15:27: > >> (1) Function/Namespaced function autoloading >> (2) State encapsulation >> (3) Function scoping > I would add (4) static polymorphism, which Late Static Binding explicitly supports. Amen! In several places in our codebase, I make use of per-request constants by having an autoloaded baseclass file which uses class_alias for specialization, like this: // in some/class.inc class some_class__base { ... common methods and default implementation } if (class_exists('some_class_'.SOME_CONSTANT)) { class_alias('some_class', 'some_class_'.SOME_CONSTANT); } else { class_alias('some_class', 'some_class__base'); } // in some/class/special.inc class some_class_special extends some_class_base { .... specialization ... } Calling code simply uses some_class::foo() without caring whether the concrete script run then uses the specialized class, or the base class. > The only thing missing is a standardised, enforced, annotation on the class to declare that you are using this ability and instances will never be created. I that regard, I'm quite happy with private function __construct, where desired. best regards Patrick --001a11c2cefe3221c105092b99ee--