Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66263 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43298 invoked from network); 27 Feb 2013 08:40:45 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 27 Feb 2013 08:40:45 -0000 Authentication-Results: pb1.pair.com header.from=krebs.seb@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=krebs.seb@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.178 as permitted sender) X-PHP-List-Original-Sender: krebs.seb@gmail.com X-Host-Fingerprint: 209.85.212.178 mail-wi0-f178.google.com Received: from [209.85.212.178] ([209.85.212.178:60124] helo=mail-wi0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C8/CB-61918-C86CD215 for ; Wed, 27 Feb 2013 03:40:44 -0500 Received: by mail-wi0-f178.google.com with SMTP id hq4so310781wib.11 for ; Wed, 27 Feb 2013 00:40:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Tv2BUbqRRbM5i1Zo3NgqpZOfKOQRFf/zF7hJ9ps8eZg=; b=Cp5u29ciAxsPQWacLz19+9giRZc1W8W3owC3hID6mRfaWS/pdJchWfhR7nJwY+D0Cy qo4Hq96t6ATB/HwFT5DGsmFpN3oFWvdnmUtIv7od1nJ3uQpswmBlKUCa553LX2H1tJEd qCahnf9XDA7lLGfHzVP1ylaNpkpTzcHy6cey6yBp0RFVkdX3BoSXsKPW3MdZ9SMIKShG /ROz8p4a3c8J8HKMx8UaUXl0vcaEYj7tJYtZ4qX0q01TmumaEr+Ul1+Nq9AYids6Qk+1 uvrwoeP/S8+gBZCnA9RizpYBxAAVg4ceTSvDeV0abF5u/0pkvGSZHvUxK2ZQwNzqMLo9 QUvQ== X-Received: by 10.194.110.69 with SMTP id hy5mr2291414wjb.1.1361954440815; Wed, 27 Feb 2013 00:40:40 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.98.197 with HTTP; Wed, 27 Feb 2013 00:40:19 -0800 (PST) In-Reply-To: References: Date: Wed, 27 Feb 2013 09:40:19 +0100 Message-ID: To: Jens Riisom Schultz Cc: "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e010d867aa529a804d6b0ba4e Subject: Re: [PHP-DEV] I would like to write an RFC for the addition of an internal keyword From: krebs.seb@gmail.com (Sebastian Krebs) --089e010d867aa529a804d6b0ba4e Content-Type: text/plain; charset=ISO-8859-1 2013/2/27 Jens Riisom Schultz > Hi, > > I just want to get a feel for whether the following idea would be > instantly rejected (for example I get the feeling that adding keywords is a > big deal): > > Often, when writing frameworks, you need to make public or protected > functionality or classes which should only be called from inside the > framework. You CAN ensure this with a lot of ninja tricks and > debug_backtrace, but it is very cumbersome and often hides your methods and > properties from class signatures. > Just my 2 cent, but whats about just trust other developers, that when they call a method/function marked with @internal they know, what they are doing? > > Therefore I would propose adding a C# style "internal" keyword. ( > http://msdn.microsoft.com/en-us/library/7c5ka91b(v=vs.80).aspx ) > > The idea is, simply, that functions, methods and classes marked as > "internal" would only be accessible from within the namespace in which they > are defined. > I don't think it makes sense for methods as public/protected/private is enough. For know I don't see reasonable use-cases for an additional visibility-modifier for "public as long as in the same namespace", or "namespace-protected" for methods. But maybe it's interesting to extend public/private/protected to classes and functions like protected function anInternalFunction() { /* Restricted to this and subnamespaces */ } private class { /* Restricted to this namespace */ } Worth the mention, that I rarely miss something like this, but at least I can imagine some use-cases. > > For example the following class, "namespace Framework; internal class > Something {}", would only be visible from within the "Framework" namespace. > > I have a hunch that this would be relatively easy to implement. > > If noone objects I would attempt to create a patch and an RFC. > > What do you think? > > > -Jens Riisom Schultz > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > -- github.com/KingCrunch --089e010d867aa529a804d6b0ba4e--