Bishop Bettini wrote on 10/12/2015 14:44:
On Thu, Dec 10, 2015 at 12:02 AM, Dustin Wheeler <mdwhe...@ncsu.edu> wrote:
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.
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]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php