Re: Class Friendship in PHP
| From: | Rowan Collins | Date: | Thu, 10 Dec 2015 15:25:48 +0000 |
| Subject: | Re: Class Friendship in PHP | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-89793@lists.php.net to get a copy of this message | ||
Bishop Bettini wrote on 10/12/2015 14:44:
On Thu, Dec 10, 2015 at 12:02 AM, Dustin Wheeler <mdwheele@ncsu.edu> wrote:I guess the point is that if package visibility were also implemented, you could simply make the relevant methods public, and the class as a whole private to the namespace. Any public APIs could then be on a public class in the same namespace, e.g in the same way as having methods "public final function foo()" and "protected function do_foo()", you could have "public class Thing" referencing "private class InternalThing". The advantage of friend declarations seems to be precisely that they are *not* making a general declaration of scope, but marking very specific couplings. If a large number of classes need access to something marked private, it's clearly not really private. Regards, -- Rowan Collins [IMSoP]I don't know that I would use friendship as a means to make an entire package (namespace, in PHP's case) aware of a single object.I think it's the other way around: a single object declares its friendship with an entire namespace.