Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89042 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 295 invoked from network); 2 Nov 2015 16:41:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Nov 2015 16:41:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=geolim4@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=geolim4@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.54 as permitted sender) X-PHP-List-Original-Sender: geolim4@gmail.com X-Host-Fingerprint: 74.125.82.54 mail-wm0-f54.google.com Received: from [74.125.82.54] ([74.125.82.54:36180] helo=mail-wm0-f54.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7A/17-42726-B3297365 for ; Mon, 02 Nov 2015 11:41:33 -0500 Received: by wmec75 with SMTP id c75so65485540wme.1 for ; Mon, 02 Nov 2015 08:41:29 -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=sRj0SoJwu7KjqpJmEvwP5NYGek154RfJg6mCAtROJxc=; b=Lyd8QO3IZF8k8Bj7B5BwgRWUokD8Osov4sZ+jMKdYVk6qA8j4JxYD+g811/HO4R5ri 487doka8iDZh+fLLexS4lQhfdSuWJjPK1dPvlfjUrsDD2eNV3cBScqy5CZpzhk7StSmI OSlI6NnPbHrNbeKtJA5tA8u9TNRWa4YWpGuvMLxrbV+YODR67MN/RiEK8AWUx7VHSFE+ ce0hkGCncKHe2Kw+e6ZJqcdtm1P/85CqlmGrq/mJ1UjqXP7YtxLQaVNUTMCDtP4a6x69 lrcL9RKGU89DKeFW/gS+WM6bS07JKxsVWRnSoqH+/CoUD69Xjb7+XFTDg6A7QqddFzWn owiA== X-Received: by 10.28.218.70 with SMTP id r67mr14126986wmg.74.1446482489152; Mon, 02 Nov 2015 08:41:29 -0800 (PST) MIME-Version: 1.0 Received: by 10.28.5.78 with HTTP; Mon, 2 Nov 2015 08:40:59 -0800 (PST) In-Reply-To: References: <5637540E.3070005@php.net> Date: Mon, 2 Nov 2015 17:40:59 +0100 Message-ID: To: "guilhermeblanco@gmail.com" Cc: francois , PHP internals Content-Type: multipart/alternative; boundary=001a1145b934f09c7d05239172b8 Subject: Re: [PHP-DEV] Friend class/function From: geolim4@gmail.com (georges) --001a1145b934f09c7d05239172b8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable =E2=80=8B*One more detail : I wouldn't set the 'friend' information on the = same line as the class declaration.* I agree, it can look horrible to read, and the way to use the "friend" syntax as the way that we currently "use" traits can be an interesting idea= . Geolim4 2015-11-02 15:42 GMT+01:00 guilhermeblanco@gmail.com < guilhermeblanco@gmail.com>: > Hi, > > One thing that should be worth mentioning is that my approach of private > classes is decoupled in 2 parts. > > The first one as the ability to prevent instantiation outside of namespac= e > and sub-namespaces. The second is the ability to access protected members= , > which matches your wish of friend classes nicely. > > However, I could not even tackle the second part without discussing and > agreeing on the first one, so I limited the scope of my wish in order to > simplify overall RFC phase. > > Regards, > On Nov 2, 2015 7:17 AM, "Fran=C3=A7ois Laupretre" wrot= e: > >> Hi Georges, >> >> Le 01/11/2015 17:04, georges a =C3=A9crit : >> >>> =E2=80=8BHi php internals, >>> >>> I recently discovered =E2=80=8Bthe "friendship concept" in c++ and i re= ally love >>> the concept. >>> And i wonder if the php internals would be interested to implements it = in >>> the next 7.x major version. >>> >>> >> You may be interested by an article I wrote some weeks ago about adaptin= g >> the 'friendship' concept to PHP ( >> http://tekwire.net/joomla/projects/ideas/php-friend). IMO, we should >> enable friendship from classes and/or namespaces, with and without >> inheritance, giving four cases : class, class and descendants, namespace= , >> namespace and sub-namespaces. >> >> One more detail : I wouldn't set the 'friend' information on the same >> line as the class declaration. First reason is that it already contains >> 'extends' and 'implements' stances. 2nd reason is that the information i= s >> not required by the compiler to start compiling the class body. So, >> 'friend' lines can be part of the class body. >> >> Use cases go well beyond test classes. There are many cases where you >> need to access methods and/or even whole classes from a set of known >> locations, but don't want to make them public. Today, the only way is to >> use protected access but it implies class inheritance which, often, is n= ot >> an option. An example is symfony using the '@internal' tag to mark >> class/properties/methods which mustn't be accessed from the outside of >> symfony (see >> http://symfony.com/doc/current/contributing/code/bc.html#using-our-class= es). >> Information is better than nothing but a way to enforce access restricti= ons >> would be welcome. >> >> About Guilherme's proposal : it seems fine but, IMHO, the 'friend' >> concept includes it, is easier to implement, and goes much further. >> >> Regards >> >> Fran=C3=A7ois >> >> >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: http://www.php.net/unsub.php >> >> --001a1145b934f09c7d05239172b8--