Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:79873 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 99888 invoked from network); 23 Dec 2014 00:33:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Dec 2014 00:33:17 -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.177 as permitted sender) X-PHP-List-Original-Sender: guilhermeblanco@gmail.com X-Host-Fingerprint: 209.85.223.177 mail-ie0-f177.google.com Received: from [209.85.223.177] ([209.85.223.177:49397] helo=mail-ie0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8B/D0-28901-C48B8945 for ; Mon, 22 Dec 2014 19:33:17 -0500 Received: by mail-ie0-f177.google.com with SMTP id rd18so5229473iec.36 for ; Mon, 22 Dec 2014 16:33:14 -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=g3qenVOk9CyOgo1RiH/LzWy3i7Yga4vRC/dvXBvIedM=; b=D42VY9PE838hIZfvOIE27raP0uSH6kslgV6pC5IEui73RYgfKukAkCQrnTJrY1btuM wQNWhoFZt7iwZDEt/dorB19BKltTVeKxuQLhIiugvpTneHf6NKuPpCVca+HnPYxbMChd kslPhRUlB4XSu9PCAxKySfpkpdGnp3+qmA3RkM33MduDiSkx/cqOvBp2+19uB4IqTFRO uK80wC8n7cHYNT7+aGxd/C9Icu9/EfnTM2vp5VIV4HDVaYVDs7TNAc758/lkICFqt5xj hBf7WrQACqyW1pKwJ+JAKj4T8oOT9LIX8Zk18bWR2wAzW+CQOvlh5J+mleNF+j/hfMyh LD/Q== X-Received: by 10.42.93.2 with SMTP id v2mr19681116icm.35.1419294794012; Mon, 22 Dec 2014 16:33:14 -0800 (PST) MIME-Version: 1.0 Received: by 10.64.238.75 with HTTP; Mon, 22 Dec 2014 16:32:53 -0800 (PST) Date: Mon, 22 Dec 2014 22:32:53 -0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=90e6ba614e46076efd050ad75222 Subject: [RFC] Package private class From: guilhermeblanco@gmail.com ("guilhermeblanco@gmail.com") --90e6ba614e46076efd050ad75222 Content-Type: text/plain; charset=UTF-8 Hi internals, I finalized a new proposal for PHP. It consists into adding support for package-private classes in the language. A package private class is basically a class that can only be instantiated in its declared namespace. This means that you cannot extend, implement or use a class, interface or trait outside of declared namespace. It can be referenced outside of the package, but instantiation can only be done there. Other languages such as Java and C# consider package-private class as a top-level class without any declared visibility. PHP cannot enforce this as it would be an incredible BC break, but we can reuse an already declared keyword "private" to fit this purpose. A class declared without any visibility modifier is considered "public" and works exactly as it currently does. The same applies to a class written with "public" keyword (ie. public class Foo {}). Most of checks are done at compile time and only instantiation is done at runtime (the only place I found out it could be done). Performance impact seems negligible as only one top condition is added during instantiation bytecode executor. At this stage I want to collect implementation feedback. Explanation is done above and the extensive amount of tests self explains what the entire purpose of this feature is. RFC will be created together with voting once I'm able to gather some considerations. Link to PR: https://github.com/php/php-src/pull/947 Cheers, -- Guilherme Blanco MSN: guilhermeblanco@hotmail.com GTalk: guilhermeblanco Toronto - ON/Canada --90e6ba614e46076efd050ad75222--