Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78947 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99540 invoked from network); 18 Nov 2014 17:33:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Nov 2014 17:33:40 -0000 Authentication-Results: pb1.pair.com smtp.mail=guilhermeblanco@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=guilhermeblanco@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.223.169 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.223.169 mail-ie0-f169.google.com Received: from [209.85.223.169] ([209.85.223.169:65231] helo=mail-ie0-f169.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/C4-63415-3F28B645 for ; Tue, 18 Nov 2014 12:33:39 -0500 Received: by mail-ie0-f169.google.com with SMTP id y20so7793455ier.28 for ; Tue, 18 Nov 2014 09:33:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=r6CbgWrCxgb3qQWejXuTxBGwb4awTQxIqRuTsaRcybk=; b=zFvEA6o7S2MOpcjJPeL4Mw+0WY/rwhLtFZH5jDX1rjhHStWXyPnfq8UdpYudnS9z4W T7wV+ja+ITq7Ky+au8MLEVen3DfwevGqwrOSDItEVIleIKtBI4kkBKaM4j2My5iaLQ6S Lr9CBrDOsONVv3GsExPmzbUKRWPstv+wsrGt/lislkjAul7I9BHerafvkTOuaeXJkhfq OBrBQ6Lpvmcu2lgcX+8ZU/dSa1apCBqO9uou6TSdZfu7g5aluCyew96lK/u1O6K/VSOp BqsZtXMXwGSLdnjwfvMkaWmtVl+UHHPJopzvI/Il+kCoETf4Urk4YYR2a1CAMezqW9HI 8yUg== X-Received: by 10.50.136.134 with SMTP id qa6mr5038928igb.2.1416332016070; Tue, 18 Nov 2014 09:33:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.155.5 with HTTP; Tue, 18 Nov 2014 09:33:15 -0800 (PST) Date: Tue, 18 Nov 2014 12:33:15 -0500 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=089e0141a8dcb3b97f0508257e28 Subject: [IDEA] Class modifiers support expansion From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --089e0141a8dcb3b97f0508257e28 Content-Type: text/plain; charset=UTF-8 Hi internals, 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. First, we should discuss about possible enhancements on current existing class modifiers' support (abstract and final). Currently, just as an example, I can create a trait with abstract methods, but I cannot declare an abstract trait. My proposed enhancements are: - abstract traits: Currently we only add implicit abstract. We should allow explicit declarations too. Nothing to change in the overall support, seems just a scanner inclusion. - final traits: prevent to be composed in other traits - final interfaces: prevent to be extended in other interfaces By adding these minor additions, we may likely simplify the scanner a bit. This would also make easier to support class visibility in the scanner. Unfortunately, PHP does not support nested classes. Personally speaking, I feel that the language can live happy without it, as soon as we can have class visibility support. 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: - 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? Cheers, -- Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --089e0141a8dcb3b97f0508257e28--