Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78948 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 4681 invoked from network); 18 Nov 2014 17:58:48 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2014 17:58:48 -0000 Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.208 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.208 imap2-3.ox.privateemail.com Received: from [192.64.116.208] ([192.64.116.208:43530] helo=imap2-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/D5-63415-5D88B645 for ; Tue, 18 Nov 2014 12:58:46 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 3DEF88C0080; Tue, 18 Nov 2014 12:58:43 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at imap2.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap2.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ttOootFnvrXL; Tue, 18 Nov 2014 12:58:43 -0500 (EST) Received: from oa-res-27-29.wireless.abdn.ac.uk (oa-res-27-29.wireless.abdn.ac.uk [137.50.27.29]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 6D8A28C007B; Tue, 18 Nov 2014 12:58:42 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) In-Reply-To: Date: Tue, 18 Nov 2014 17:58:40 +0000 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: References: To: "guilhermeblanco@gmail.com" X-Mailer: Apple Mail (2.1993) Subject: Re: [PHP-DEV] [IDEA] Class modifiers support expansion From: ajf@ajf.me (Andrea Faulds) > On 18 Nov 2014, at 17:33, guilhermeblanco@gmail.com wrote: >=20 > Library developers sometimes plan for extensibility of their code, but = not > all pieces are able to be extended and unexpected usage can lead to > unpredictable behavior. > Based on that, I consider it may be a good addition to PHP to add = class > visibility support and enhance existing modifiers' support. I was thinking the very same thing after __construct() came up, but = wasn=E2=80=99t sure how it should work. :) > Now what I mean by class visibility, it requires a better discussion = on how > it could behave, since any other language relies on nested classes to > expose this support. Nevertheless, PHP's lack of Open/Close principle > support could be addressed easily. This is my POV on how it could = behave: >=20 > - private classes: Can only be extended and instantiated inside of the = same > namespace it sits. This is the similar to private-package support in = Java. > - protected classes: I can't determine any similarity to any other = language > in this one, but it could behave somehow like: can be extended and > instantiated anywhere within the root namespace. > - public classes: same as current PHP support >=20 > What do you think about it? I think it=E2=80=99s a good idea, the problem is defining private and = protected. I wonder if this is something autoloaders could handle? private classes = might be visible only within the same file, while protected classes = might be visible only to other files the autoloader can see. -- Andrea Faulds http://ajf.me/