Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78958 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 25928 invoked from network); 18 Nov 2014 20:51:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2014 20:51:44 -0000 Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.175 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.213.175 mail-ig0-f175.google.com Received: from [209.85.213.175] ([209.85.213.175:36114] helo=mail-ig0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/63-06737-F51BB645 for ; Tue, 18 Nov 2014 15:51:43 -0500 Received: by mail-ig0-f175.google.com with SMTP id h15so1740100igd.8 for ; Tue, 18 Nov 2014 12:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=dv4v8bRnS06rBqyw85tIkfubz5mIA71SRvPeYs8OqFg=; b=CeIUIW/TvRiAaf6mN5WhyaJnss/4Q2r9UEPyCCCQkT/m/6Q0dUj/zn8s6Tf3guiK7y 1tcETAwC9ZwYGVy2bfoutoiuf35dK+GptltEMYUwM23F3SAUzVkrGuvtPiJ3SdWUrAKK Z0rMF8EH91O3ey5dicdFh+kxjmJ3pfSRznZou17Sh1C74a4SSzS4l5NkMe9i7ld2sSay Ur2IiFyPpYVjhb5jL3yZq8X1tzDnSFiZNUM9RuyR1TZ4k1kFQ9C49il1eS3sgCDfOL8C FjsJaJzWZ+yG/c60Juv8kvIz/33FUlMgX3AKM3n7IDt1PiNmk3pIS9XZBC7CqCvorajR ykfg== X-Received: by 10.50.43.130 with SMTP id w2mr6162331igl.21.1416343900339; Tue, 18 Nov 2014 12:51:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.155.5 with HTTP; Tue, 18 Nov 2014 12:51:20 -0800 (PST) In-Reply-To: References: Date: Tue, 18 Nov 2014 15:51:20 -0500 Message-ID: To: Andrea Faulds Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0103de4e0f74ff05082843b6 Subject: Re: [PHP-DEV] [IDEA] Class modifiers support expansion From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --089e0103de4e0f74ff05082843b6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think parts of this can easily be handled in zend_compile. Other pieces requires runtime introspection that could be done at zend_vm_def. My only concern is how to know what's the active scope (class)... While researching for data flow, I also saw that with the inclusion of AST, some checks currently in zend_inheritance could be moved to zend_compile too. If we can discuss and reach some consensus, I can work (or at least try to) on a patch and propose officially as an RFC. But before doing that, we need to resolve how private/protected should behave. My suggestion could work, but it may not be a sane approach. []s, On Tue, Nov 18, 2014 at 12:58 PM, Andrea Faulds wrote: > > > On 18 Nov 2014, at 17:33, guilhermeblanco@gmail.com wrote: > > > > 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 behav= e: > > > > - 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 > > > > What do you think about it? > > I think it=E2=80=99s a good idea, the problem is defining private and pro= tected. > > 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/ > > > > > --=20 Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --089e0103de4e0f74ff05082843b6--